blob: 7997e13b59a60c306a8b246c5e0f11c1108c0abc [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 Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Kailang Yangdf694da2005-12-05 19:42:22 +0100103 ALC262_AUTO,
104 ALC262_MODEL_LAST /* last tag */
105};
106
Kailang Yanga361d842007-06-05 12:30:55 +0200107/* ALC268 models */
108enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200109 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200110 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200111 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200112 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100113 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100114 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100115#ifdef CONFIG_SND_DEBUG
116 ALC268_TEST,
117#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200118 ALC268_AUTO,
119 ALC268_MODEL_LAST /* last tag */
120};
121
Kailang Yangf6a92242007-12-13 16:52:54 +0100122/* ALC269 models */
123enum {
124 ALC269_BASIC,
125 ALC269_AUTO,
126 ALC269_MODEL_LAST /* last tag */
127};
128
Kailang Yangdf694da2005-12-05 19:42:22 +0100129/* ALC861 models */
130enum {
131 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200132 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100133 ALC861_3ST_DIG,
134 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200135 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200136 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200137 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100138 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100139 ALC861_AUTO,
140 ALC861_MODEL_LAST,
141};
142
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100143/* ALC861-VD models */
144enum {
145 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200146 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147 ALC861VD_3ST,
148 ALC861VD_3ST_DIG,
149 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200150 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200151 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200152 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153 ALC861VD_AUTO,
154 ALC861VD_MODEL_LAST,
155};
156
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200157/* ALC662 models */
158enum {
159 ALC662_3ST_2ch_DIG,
160 ALC662_3ST_6ch_DIG,
161 ALC662_3ST_6ch,
162 ALC662_5ST_DIG,
163 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200164 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100165 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200166 ALC663_ASUS_M51VA,
167 ALC663_ASUS_G71V,
168 ALC663_ASUS_H13,
169 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170 ALC662_AUTO,
171 ALC662_MODEL_LAST,
172};
173
Kailang Yangdf694da2005-12-05 19:42:22 +0100174/* ALC882 models */
175enum {
176 ALC882_3ST_DIG,
177 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200178 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200179 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200180 ALC882_TARGA,
181 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200182 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100183 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200184 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200185 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200186 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100187 ALC882_MODEL_LAST,
188};
189
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200190/* ALC883 models */
191enum {
192 ALC883_3ST_2ch_DIG,
193 ALC883_3ST_6ch_DIG,
194 ALC883_3ST_6ch,
195 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200196 ALC883_TARGA_DIG,
197 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200198 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200199 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200200 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100202 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200203 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200205 ALC888_LENOVO_MS7195_DIG,
206 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200207 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100208 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100209 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100210 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100211 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200212 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200213 ALC883_AUTO,
214 ALC883_MODEL_LAST,
215};
216
Kailang Yangdf694da2005-12-05 19:42:22 +0100217/* for GPIO Poll */
218#define GPIO_MASK 0x03
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220struct alc_spec {
221 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100222 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 unsigned int num_mixers;
224
Kailang Yangdf694da2005-12-05 19:42:22 +0100225 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200226 * don't forget NULL
227 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200228 */
229 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
Takashi Iwai16ded522005-06-10 19:58:24 +0200231 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 struct hda_pcm_stream *stream_analog_playback;
233 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100234 struct hda_pcm_stream *stream_analog_alt_playback;
235 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200237 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 struct hda_pcm_stream *stream_digital_playback;
239 struct hda_pcm_stream *stream_digital_capture;
240
241 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200242 struct hda_multi_out multiout; /* playback set-up
243 * max_channels, dacs must be set
244 * dig_out_nid and hp_nid are optional
245 */
Takashi Iwai63300792008-01-24 15:31:36 +0100246 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248 /* capture */
249 unsigned int num_adc_nids;
250 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100251 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200252 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200255 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 const struct hda_input_mux *input_mux;
257 unsigned int cur_mux[3];
258
259 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100260 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200262 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
264 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100265 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200266
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200267 /* dynamic controls, init_verbs and input_mux */
268 struct auto_pin_cfg autocfg;
269 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100270 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200271 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200272 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100273
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100274 /* hooks */
275 void (*init_hook)(struct hda_codec *codec);
276 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
277
Takashi Iwai834be882006-03-01 14:16:17 +0100278 /* for pin sensing */
279 unsigned int sense_updated: 1;
280 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100281 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200282
Takashi Iwai2134ea42008-01-10 16:53:55 +0100283 /* for virtual master */
284 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200285#ifdef CONFIG_SND_HDA_POWER_SAVE
286 struct hda_loopback_check loopback;
287#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200288
289 /* for PLL fix */
290 hda_nid_t pll_nid;
291 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100292};
293
294/*
295 * configuration template - to be copied to the spec instance
296 */
297struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200298 struct snd_kcontrol_new *mixers[5]; /* should be identical size
299 * with spec
300 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100301 const struct hda_verb *init_verbs[5];
302 unsigned int num_dacs;
303 hda_nid_t *dac_nids;
304 hda_nid_t dig_out_nid; /* optional */
305 hda_nid_t hp_nid; /* optional */
306 unsigned int num_adc_nids;
307 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100308 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100309 hda_nid_t dig_in_nid;
310 unsigned int num_channel_mode;
311 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200312 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100314 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100315 void (*unsol_event)(struct hda_codec *, unsigned int);
316 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200317#ifdef CONFIG_SND_HDA_POWER_SAVE
318 struct hda_amp_list *loopbacks;
319#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320};
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323/*
324 * input MUX handling
325 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200326static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
327 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
329 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
330 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200331 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
332 if (mux_idx >= spec->num_mux_defs)
333 mux_idx = 0;
334 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200337static int alc_mux_enum_get(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);
343
344 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
345 return 0;
346}
347
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200348static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
352 struct alc_spec *spec = codec->spec;
353 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200354 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100355 hda_nid_t nid = spec->capsrc_nids ?
356 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200357 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100358 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359}
360
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200361
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362/*
363 * channel mode setting
364 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200365static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
366 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367{
368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
369 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100370 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
371 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372}
373
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200374static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
375 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
378 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100379 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380 spec->num_channel_mode,
381 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382}
383
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200384static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
385 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386{
387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
388 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200389 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
390 spec->num_channel_mode,
391 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200392 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200393 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
394 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395}
396
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398 * Control the mode of pin widget settings via the mixer. "pc" is used
399 * instead of "%" to avoid consequences of accidently treating the % as
400 * being part of a format specifier. Maximum allowed length of a value is
401 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100402 *
403 * Note: some retasking pin complexes seem to ignore requests for input
404 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
405 * are requested. Therefore order this list so that this behaviour will not
406 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200407 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
408 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200409 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100410static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100411 "Mic 50pc bias", "Mic 80pc bias",
412 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413};
414static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100415 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416};
417/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200418 * in the pin being assumed to be exclusively an input or an output pin. In
419 * addition, "input" pins may or may not process the mic bias option
420 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
421 * accept requests for bias as of chip versions up to March 2006) and/or
422 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200424#define ALC_PIN_DIR_IN 0x00
425#define ALC_PIN_DIR_OUT 0x01
426#define ALC_PIN_DIR_INOUT 0x02
427#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
428#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431 * For each direction the minimum and maximum values are given.
432 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200433static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 { 0, 2 }, /* ALC_PIN_DIR_IN */
435 { 3, 4 }, /* ALC_PIN_DIR_OUT */
436 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200437 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
438 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439};
440#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
441#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
442#define alc_pin_mode_n_items(_dir) \
443 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
444
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448 unsigned int item_num = uinfo->value.enumerated.item;
449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
450
451 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200452 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
454
455 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
456 item_num = alc_pin_mode_min(dir);
457 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200458 return 0;
459}
460
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200463{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100464 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200468 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
470 AC_VERB_GET_PIN_WIDGET_CONTROL,
471 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 /* Find enumerated value for current pinctl setting */
474 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 return 0;
479}
480
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483{
484 signed int change;
485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
486 hda_nid_t nid = kcontrol->private_value & 0xffff;
487 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
488 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200489 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
490 AC_VERB_GET_PIN_WIDGET_CONTROL,
491 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200493 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494 val = alc_pin_mode_min(dir);
495
496 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100497 if (change) {
498 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200499 snd_hda_codec_write_cache(codec, nid, 0,
500 AC_VERB_SET_PIN_WIDGET_CONTROL,
501 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100502
503 /* Also enable the retasking pin's input/output as required
504 * for the requested pin mode. Enum values of 2 or less are
505 * input modes.
506 *
507 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200508 * reduces noise slightly (particularly on input) so we'll
509 * do it. However, having both input and output buffers
510 * enabled simultaneously doesn't seem to be problematic if
511 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100512 */
513 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200514 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
515 HDA_AMP_MUTE, HDA_AMP_MUTE);
516 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
517 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100518 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200519 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
520 HDA_AMP_MUTE, HDA_AMP_MUTE);
521 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
522 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100523 }
524 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200525 return change;
526}
527
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200529 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 .info = alc_pin_mode_info, \
531 .get = alc_pin_mode_get, \
532 .put = alc_pin_mode_put, \
533 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100534
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100535/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
536 * together using a mask with more than one bit set. This control is
537 * currently used only by the ALC260 test model. At this stage they are not
538 * needed for any "production" models.
539 */
540#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200541#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200542
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100545{
546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
547 hda_nid_t nid = kcontrol->private_value & 0xffff;
548 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
549 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550 unsigned int val = snd_hda_codec_read(codec, nid, 0,
551 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100552
553 *valp = (val & mask) != 0;
554 return 0;
555}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100558{
559 signed int change;
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 hda_nid_t nid = kcontrol->private_value & 0xffff;
562 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
563 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
565 AC_VERB_GET_GPIO_DATA,
566 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100567
568 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
570 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100571 gpio_data &= ~mask;
572 else
573 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200574 snd_hda_codec_write_cache(codec, nid, 0,
575 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100576
577 return change;
578}
579#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
580 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
581 .info = alc_gpio_data_info, \
582 .get = alc_gpio_data_get, \
583 .put = alc_gpio_data_put, \
584 .private_value = nid | (mask<<16) }
585#endif /* CONFIG_SND_DEBUG */
586
Jonathan Woithe92621f12006-02-28 11:47:47 +0100587/* A switch control to allow the enabling of the digital IO pins on the
588 * ALC260. This is incredibly simplistic; the intention of this control is
589 * to provide something in the test model allowing digital outputs to be
590 * identified if present. If models are found which can utilise these
591 * outputs a more complete mixer control can be devised for those models if
592 * necessary.
593 */
594#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200595#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200596
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100599{
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 hda_nid_t nid = kcontrol->private_value & 0xffff;
602 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
603 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100605 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100606
607 *valp = (val & mask) != 0;
608 return 0;
609}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200610static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100612{
613 signed int change;
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 hda_nid_t nid = kcontrol->private_value & 0xffff;
616 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
617 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200618 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100619 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200620 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100621
622 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100624 if (val==0)
625 ctrl_data &= ~mask;
626 else
627 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200628 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
629 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100630
631 return change;
632}
633#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
634 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
635 .info = alc_spdif_ctrl_info, \
636 .get = alc_spdif_ctrl_get, \
637 .put = alc_spdif_ctrl_put, \
638 .private_value = nid | (mask<<16) }
639#endif /* CONFIG_SND_DEBUG */
640
Jonathan Woithef8225f62008-01-08 12:16:54 +0100641/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
642 * Again, this is only used in the ALC26x test models to help identify when
643 * the EAPD line must be asserted for features to work.
644 */
645#ifdef CONFIG_SND_DEBUG
646#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
647
648static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
650{
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
652 hda_nid_t nid = kcontrol->private_value & 0xffff;
653 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
654 long *valp = ucontrol->value.integer.value;
655 unsigned int val = snd_hda_codec_read(codec, nid, 0,
656 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
657
658 *valp = (val & mask) != 0;
659 return 0;
660}
661
662static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
664{
665 int change;
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 hda_nid_t nid = kcontrol->private_value & 0xffff;
668 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
669 long val = *ucontrol->value.integer.value;
670 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
671 AC_VERB_GET_EAPD_BTLENABLE,
672 0x00);
673
674 /* Set/unset the masked control bit(s) as needed */
675 change = (!val ? 0 : mask) != (ctrl_data & mask);
676 if (!val)
677 ctrl_data &= ~mask;
678 else
679 ctrl_data |= mask;
680 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
681 ctrl_data);
682
683 return change;
684}
685
686#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
687 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
688 .info = alc_eapd_ctrl_info, \
689 .get = alc_eapd_ctrl_get, \
690 .put = alc_eapd_ctrl_put, \
691 .private_value = nid | (mask<<16) }
692#endif /* CONFIG_SND_DEBUG */
693
Kailang Yangdf694da2005-12-05 19:42:22 +0100694/*
695 * set up from the preset table
696 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static void setup_preset(struct alc_spec *spec,
698 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100699{
700 int i;
701
702 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
703 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
705 i++)
706 spec->init_verbs[spec->num_init_verbs++] =
707 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100708
709 spec->channel_mode = preset->channel_mode;
710 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200711 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100712
713 spec->multiout.max_channels = spec->channel_mode[0].channels;
714
715 spec->multiout.num_dacs = preset->num_dacs;
716 spec->multiout.dac_nids = preset->dac_nids;
717 spec->multiout.dig_out_nid = preset->dig_out_nid;
718 spec->multiout.hp_nid = preset->hp_nid;
719
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200720 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200721 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200722 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100723 spec->input_mux = preset->input_mux;
724
725 spec->num_adc_nids = preset->num_adc_nids;
726 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100727 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100728 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100729
730 spec->unsol_event = preset->unsol_event;
731 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200732#ifdef CONFIG_SND_HDA_POWER_SAVE
733 spec->loopback.amplist = preset->loopbacks;
734#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100735}
736
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200737/* Enable GPIO mask and set output */
738static struct hda_verb alc_gpio1_init_verbs[] = {
739 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
740 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
741 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
742 { }
743};
744
745static struct hda_verb alc_gpio2_init_verbs[] = {
746 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
747 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
748 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
749 { }
750};
751
Kailang Yangbdd148a2007-05-08 15:19:08 +0200752static struct hda_verb alc_gpio3_init_verbs[] = {
753 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
754 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
755 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
756 { }
757};
758
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200759/*
760 * Fix hardware PLL issue
761 * On some codecs, the analog PLL gating control must be off while
762 * the default value is 1.
763 */
764static void alc_fix_pll(struct hda_codec *codec)
765{
766 struct alc_spec *spec = codec->spec;
767 unsigned int val;
768
769 if (!spec->pll_nid)
770 return;
771 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
772 spec->pll_coef_idx);
773 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
774 AC_VERB_GET_PROC_COEF, 0);
775 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
776 spec->pll_coef_idx);
777 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
778 val & ~(1 << spec->pll_coef_bit));
779}
780
781static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
782 unsigned int coef_idx, unsigned int coef_bit)
783{
784 struct alc_spec *spec = codec->spec;
785 spec->pll_nid = nid;
786 spec->pll_coef_idx = coef_idx;
787 spec->pll_coef_bit = coef_bit;
788 alc_fix_pll(codec);
789}
790
Kailang Yangc9b58002007-10-16 14:30:01 +0200791static void alc_sku_automute(struct hda_codec *codec)
792{
793 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200794 unsigned int present;
795 unsigned int hp_nid = spec->autocfg.hp_pins[0];
796 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
797
798 /* need to execute and sync at first */
799 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
800 present = snd_hda_codec_read(codec, hp_nid, 0,
801 AC_VERB_GET_PIN_SENSE, 0);
802 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100803 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
804 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200805}
806
807/* unsolicited event for HP jack sensing */
808static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
809{
810 if (codec->vendor_id == 0x10ec0880)
811 res >>= 28;
812 else
813 res >>= 26;
814 if (res != ALC880_HP_EVENT)
815 return;
816
817 alc_sku_automute(codec);
818}
819
Kailang Yangf9423e72008-05-27 12:32:25 +0200820/* additional initialization for ALC888 variants */
821static void alc888_coef_init(struct hda_codec *codec)
822{
823 unsigned int tmp;
824
825 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
826 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
827 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
828 if ((tmp & 0xf0) == 2)
829 /* alc888S-VC */
830 snd_hda_codec_read(codec, 0x20, 0,
831 AC_VERB_SET_PROC_COEF, 0x830);
832 else
833 /* alc888-VB */
834 snd_hda_codec_read(codec, 0x20, 0,
835 AC_VERB_SET_PROC_COEF, 0x3030);
836}
837
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200838/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
839 * 31 ~ 16 : Manufacture ID
840 * 15 ~ 8 : SKU ID
841 * 7 ~ 0 : Assembly ID
842 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
843 */
844static void alc_subsystem_id(struct hda_codec *codec,
845 unsigned int porta, unsigned int porte,
846 unsigned int portd)
847{
Kailang Yangc9b58002007-10-16 14:30:01 +0200848 unsigned int ass, tmp, i;
849 unsigned nid;
850 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200851
Kailang Yangc9b58002007-10-16 14:30:01 +0200852 ass = codec->subsystem_id & 0xffff;
853 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
854 goto do_sku;
855
856 /*
857 * 31~30 : port conetcivity
858 * 29~21 : reserve
859 * 20 : PCBEEP input
860 * 19~16 : Check sum (15:1)
861 * 15~1 : Custom
862 * 0 : override
863 */
864 nid = 0x1d;
865 if (codec->vendor_id == 0x10ec0260)
866 nid = 0x17;
867 ass = snd_hda_codec_read(codec, nid, 0,
868 AC_VERB_GET_CONFIG_DEFAULT, 0);
869 if (!(ass & 1) && !(ass & 0x100000))
870 return;
871 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200872 return;
873
Kailang Yangc9b58002007-10-16 14:30:01 +0200874 /* check sum */
875 tmp = 0;
876 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100877 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200878 tmp++;
879 }
880 if (((ass >> 16) & 0xf) != tmp)
881 return;
882do_sku:
883 /*
884 * 0 : override
885 * 1 : Swap Jack
886 * 2 : 0 --> Desktop, 1 --> Laptop
887 * 3~5 : External Amplifier control
888 * 7~6 : Reserved
889 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200890 tmp = (ass & 0x38) >> 3; /* external Amp control */
891 switch (tmp) {
892 case 1:
893 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
894 break;
895 case 3:
896 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
897 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200898 case 7:
899 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
900 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200901 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200902 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200903 case 0x10ec0260:
904 snd_hda_codec_write(codec, 0x0f, 0,
905 AC_VERB_SET_EAPD_BTLENABLE, 2);
906 snd_hda_codec_write(codec, 0x10, 0,
907 AC_VERB_SET_EAPD_BTLENABLE, 2);
908 break;
909 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200910 case 0x10ec0267:
911 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200912 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200913 case 0x10ec0660:
914 case 0x10ec0662:
915 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200916 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200917 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200918 snd_hda_codec_write(codec, 0x14, 0,
919 AC_VERB_SET_EAPD_BTLENABLE, 2);
920 snd_hda_codec_write(codec, 0x15, 0,
921 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200923 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200924 switch (codec->vendor_id) {
925 case 0x10ec0260:
926 snd_hda_codec_write(codec, 0x1a, 0,
927 AC_VERB_SET_COEF_INDEX, 7);
928 tmp = snd_hda_codec_read(codec, 0x1a, 0,
929 AC_VERB_GET_PROC_COEF, 0);
930 snd_hda_codec_write(codec, 0x1a, 0,
931 AC_VERB_SET_COEF_INDEX, 7);
932 snd_hda_codec_write(codec, 0x1a, 0,
933 AC_VERB_SET_PROC_COEF,
934 tmp | 0x2010);
935 break;
936 case 0x10ec0262:
937 case 0x10ec0880:
938 case 0x10ec0882:
939 case 0x10ec0883:
940 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200941 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200942 snd_hda_codec_write(codec, 0x20, 0,
943 AC_VERB_SET_COEF_INDEX, 7);
944 tmp = snd_hda_codec_read(codec, 0x20, 0,
945 AC_VERB_GET_PROC_COEF, 0);
946 snd_hda_codec_write(codec, 0x20, 0,
947 AC_VERB_SET_COEF_INDEX, 7);
948 snd_hda_codec_write(codec, 0x20, 0,
949 AC_VERB_SET_PROC_COEF,
950 tmp | 0x2010);
951 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200952 case 0x10ec0888:
953 alc888_coef_init(codec);
954 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 case 0x10ec0267:
956 case 0x10ec0268:
957 snd_hda_codec_write(codec, 0x20, 0,
958 AC_VERB_SET_COEF_INDEX, 7);
959 tmp = snd_hda_codec_read(codec, 0x20, 0,
960 AC_VERB_GET_PROC_COEF, 0);
961 snd_hda_codec_write(codec, 0x20, 0,
962 AC_VERB_SET_COEF_INDEX, 7);
963 snd_hda_codec_write(codec, 0x20, 0,
964 AC_VERB_SET_PROC_COEF,
965 tmp | 0x3000);
966 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200967 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200968 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200969 break;
970 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200971
Kailang Yang8c427222008-01-10 13:03:59 +0100972 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 * when the external headphone out jack is plugged"
974 */
Kailang Yang8c427222008-01-10 13:03:59 +0100975 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200976 return;
977 /*
978 * 10~8 : Jack location
979 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
980 * 14~13: Resvered
981 * 15 : 1 --> enable the function "Mute internal speaker
982 * when the external headphone out jack is plugged"
983 */
984 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100985 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200986 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100987 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200988 else
989 return;
990 }
991
992 if (!spec->autocfg.hp_pins[0]) {
993 tmp = (ass >> 11) & 0x3; /* HP to chassis */
994 if (tmp == 0)
995 spec->autocfg.hp_pins[0] = porta;
996 else if (tmp == 1)
997 spec->autocfg.hp_pins[0] = porte;
998 else if (tmp == 2)
999 spec->autocfg.hp_pins[0] = portd;
1000 else
1001 return;
1002 }
1003
1004 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1005 AC_VERB_SET_UNSOLICITED_ENABLE,
1006 AC_USRSP_EN | ALC880_HP_EVENT);
1007 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001008}
1009
Takashi Iwai41e41f12005-06-08 14:48:49 +02001010/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001011 * Fix-up pin default configurations
1012 */
1013
1014struct alc_pincfg {
1015 hda_nid_t nid;
1016 u32 val;
1017};
1018
1019static void alc_fix_pincfg(struct hda_codec *codec,
1020 const struct snd_pci_quirk *quirk,
1021 const struct alc_pincfg **pinfix)
1022{
1023 const struct alc_pincfg *cfg;
1024
1025 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1026 if (!quirk)
1027 return;
1028
1029 cfg = pinfix[quirk->value];
1030 for (; cfg->nid; cfg++) {
1031 int i;
1032 u32 val = cfg->val;
1033 for (i = 0; i < 4; i++) {
1034 snd_hda_codec_write(codec, cfg->nid, 0,
1035 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1036 val & 0xff);
1037 val >>= 8;
1038 }
1039 }
1040}
1041
1042/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001043 * ALC880 3-stack model
1044 *
1045 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001046 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1047 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 */
1049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001050static hda_nid_t alc880_dac_nids[4] = {
1051 /* front, rear, clfe, rear_surr */
1052 0x02, 0x05, 0x04, 0x03
1053};
1054
1055static hda_nid_t alc880_adc_nids[3] = {
1056 /* ADC0-2 */
1057 0x07, 0x08, 0x09,
1058};
1059
1060/* The datasheet says the node 0x07 is connected from inputs,
1061 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001062 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001064static hda_nid_t alc880_adc_nids_alt[2] = {
1065 /* ADC1-2 */
1066 0x08, 0x09,
1067};
1068
1069#define ALC880_DIGOUT_NID 0x06
1070#define ALC880_DIGIN_NID 0x0a
1071
1072static struct hda_input_mux alc880_capture_source = {
1073 .num_items = 4,
1074 .items = {
1075 { "Mic", 0x0 },
1076 { "Front Mic", 0x3 },
1077 { "Line", 0x2 },
1078 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001080};
1081
1082/* channel source setting (2/6 channel selection for 3-stack) */
1083/* 2ch mode */
1084static struct hda_verb alc880_threestack_ch2_init[] = {
1085 /* set line-in to input, mute it */
1086 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1087 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1088 /* set mic-in to input vref 80%, mute it */
1089 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1090 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 { } /* end */
1092};
1093
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001094/* 6ch mode */
1095static struct hda_verb alc880_threestack_ch6_init[] = {
1096 /* set line-in to output, unmute it */
1097 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1098 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1099 /* set mic-in to output, unmute it */
1100 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1101 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1102 { } /* end */
1103};
1104
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001105static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001106 { 2, alc880_threestack_ch2_init },
1107 { 6, alc880_threestack_ch6_init },
1108};
1109
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001110static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001113 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001114 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001115 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1116 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001117 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1118 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1128 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001130 {
1131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1132 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001133 .info = alc_ch_mode_info,
1134 .get = alc_ch_mode_get,
1135 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001136 },
1137 { } /* end */
1138};
1139
1140/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001141static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001142 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1143 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1147 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1148 {
1149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1150 /* The multiple "Capture Source" controls confuse alsamixer
1151 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001152 */
1153 /* .name = "Capture Source", */
1154 .name = "Input Source",
1155 .count = 3,
1156 .info = alc_mux_enum_info,
1157 .get = alc_mux_enum_get,
1158 .put = alc_mux_enum_put,
1159 },
1160 { } /* end */
1161};
1162
1163/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001164static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001165 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 {
1170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1171 /* The multiple "Capture Source" controls confuse alsamixer
1172 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 */
1174 /* .name = "Capture Source", */
1175 .name = "Input Source",
1176 .count = 2,
1177 .info = alc_mux_enum_info,
1178 .get = alc_mux_enum_get,
1179 .put = alc_mux_enum_put,
1180 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 { } /* end */
1182};
1183
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001184
1185
1186/*
1187 * ALC880 5-stack model
1188 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001189 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1190 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001191 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1192 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1193 */
1194
1195/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001196static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001197 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001198 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 { } /* end */
1200};
1201
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001202/* channel source setting (6/8 channel selection for 5-stack) */
1203/* 6ch mode */
1204static struct hda_verb alc880_fivestack_ch6_init[] = {
1205 /* set line-in to input, mute it */
1206 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1207 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001208 { } /* end */
1209};
1210
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001211/* 8ch mode */
1212static struct hda_verb alc880_fivestack_ch8_init[] = {
1213 /* set line-in to output, unmute it */
1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1216 { } /* end */
1217};
1218
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001219static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220 { 6, alc880_fivestack_ch6_init },
1221 { 8, alc880_fivestack_ch8_init },
1222};
1223
1224
1225/*
1226 * ALC880 6-stack model
1227 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001228 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1229 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001230 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1231 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1232 */
1233
1234static hda_nid_t alc880_6st_dac_nids[4] = {
1235 /* front, rear, clfe, rear_surr */
1236 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001237};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238
1239static struct hda_input_mux alc880_6stack_capture_source = {
1240 .num_items = 4,
1241 .items = {
1242 { "Mic", 0x0 },
1243 { "Front Mic", 0x1 },
1244 { "Line", 0x2 },
1245 { "CD", 0x4 },
1246 },
1247};
1248
1249/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001250static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001251 { 8, NULL },
1252};
1253
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001254static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001256 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001257 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001258 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001259 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1262 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001263 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1267 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1268 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1271 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1272 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1273 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1274 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001275 {
1276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1277 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001278 .info = alc_ch_mode_info,
1279 .get = alc_ch_mode_get,
1280 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001281 },
1282 { } /* end */
1283};
1284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285
1286/*
1287 * ALC880 W810 model
1288 *
1289 * W810 has rear IO for:
1290 * Front (DAC 02)
1291 * Surround (DAC 03)
1292 * Center/LFE (DAC 04)
1293 * Digital out (06)
1294 *
1295 * The system also has a pair of internal speakers, and a headphone jack.
1296 * These are both connected to Line2 on the codec, hence to DAC 02.
1297 *
1298 * There is a variable resistor to control the speaker or headphone
1299 * volume. This is a hardware-only device without a software API.
1300 *
1301 * Plugging headphones in will disable the internal speakers. This is
1302 * implemented in hardware, not via the driver using jack sense. In
1303 * a similar fashion, plugging into the rear socket marked "front" will
1304 * disable both the speakers and headphones.
1305 *
1306 * For input, there's a microphone jack, and an "audio in" jack.
1307 * These may not do anything useful with this driver yet, because I
1308 * haven't setup any initialization verbs for these yet...
1309 */
1310
1311static hda_nid_t alc880_w810_dac_nids[3] = {
1312 /* front, rear/surround, clfe */
1313 0x02, 0x03, 0x04
1314};
1315
1316/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001317static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001318 { 6, NULL }
1319};
1320
1321/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001322static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001325 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001326 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1332 { } /* end */
1333};
1334
1335
1336/*
1337 * Z710V model
1338 *
1339 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001340 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1341 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001342 */
1343
1344static hda_nid_t alc880_z71v_dac_nids[1] = {
1345 0x02
1346};
1347#define ALC880_Z71V_HP_DAC 0x03
1348
1349/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001350static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001351 { 2, NULL }
1352};
1353
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001354static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001355 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001356 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001358 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1363 { } /* end */
1364};
1365
1366
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001367/*
1368 * ALC880 F1734 model
1369 *
1370 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1371 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1372 */
1373
1374static hda_nid_t alc880_f1734_dac_nids[1] = {
1375 0x03
1376};
1377#define ALC880_F1734_HP_DAC 0x02
1378
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001379static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001381 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001382 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1383 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001388 { } /* end */
1389};
1390
Takashi Iwai937b4162008-02-11 14:52:36 +01001391static struct hda_input_mux alc880_f1734_capture_source = {
1392 .num_items = 2,
1393 .items = {
1394 { "Mic", 0x1 },
1395 { "CD", 0x4 },
1396 },
1397};
1398
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001399
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001400/*
1401 * ALC880 ASUS model
1402 *
1403 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1404 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1405 * Mic = 0x18, Line = 0x1a
1406 */
1407
1408#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1409#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1410
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001411static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001414 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001416 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1417 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001418 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1419 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001426 {
1427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1428 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001429 .info = alc_ch_mode_info,
1430 .get = alc_ch_mode_get,
1431 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 },
1433 { } /* end */
1434};
1435
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001436/*
1437 * ALC880 ASUS W1V model
1438 *
1439 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1440 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1441 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1442 */
1443
1444/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001445static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001446 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1447 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 { } /* end */
1449};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001450
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001451/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001452static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001453 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1454 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1455 { } /* end */
1456};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001457
Kailang Yangdf694da2005-12-05 19:42:22 +01001458/* TCL S700 */
1459static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1461 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1464 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1467 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1468 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1469 {
1470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1471 /* The multiple "Capture Source" controls confuse alsamixer
1472 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001473 */
1474 /* .name = "Capture Source", */
1475 .name = "Input Source",
1476 .count = 1,
1477 .info = alc_mux_enum_info,
1478 .get = alc_mux_enum_get,
1479 .put = alc_mux_enum_put,
1480 },
1481 { } /* end */
1482};
1483
Kailang Yangccc656c2006-10-17 12:32:26 +02001484/* Uniwill */
1485static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001486 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1487 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1488 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1489 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001490 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1491 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1493 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1500 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1501 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1502 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1503 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1504 {
1505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1506 .name = "Channel Mode",
1507 .info = alc_ch_mode_info,
1508 .get = alc_ch_mode_get,
1509 .put = alc_ch_mode_put,
1510 },
1511 { } /* end */
1512};
1513
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001514static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1515 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1516 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1518 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1519 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1520 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1521 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1522 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1523 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1524 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1525 { } /* end */
1526};
1527
Kailang Yangccc656c2006-10-17 12:32:26 +02001528static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1530 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1531 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1532 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1535 { } /* end */
1536};
1537
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001539 * virtual master controls
1540 */
1541
1542/*
1543 * slave controls for virtual master
1544 */
1545static const char *alc_slave_vols[] = {
1546 "Front Playback Volume",
1547 "Surround Playback Volume",
1548 "Center Playback Volume",
1549 "LFE Playback Volume",
1550 "Side Playback Volume",
1551 "Headphone Playback Volume",
1552 "Speaker Playback Volume",
1553 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001554 "Line-Out Playback Volume",
1555 NULL,
1556};
1557
1558static const char *alc_slave_sws[] = {
1559 "Front Playback Switch",
1560 "Surround Playback Switch",
1561 "Center Playback Switch",
1562 "LFE Playback Switch",
1563 "Side Playback Switch",
1564 "Headphone Playback Switch",
1565 "Speaker Playback Switch",
1566 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001567 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001568 NULL,
1569};
1570
1571/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001572 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 */
1574static int alc_build_controls(struct hda_codec *codec)
1575{
1576 struct alc_spec *spec = codec->spec;
1577 int err;
1578 int i;
1579
1580 for (i = 0; i < spec->num_mixers; i++) {
1581 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1582 if (err < 0)
1583 return err;
1584 }
1585
1586 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001587 err = snd_hda_create_spdif_out_ctls(codec,
1588 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 if (err < 0)
1590 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001591 err = snd_hda_create_spdif_share_sw(codec,
1592 &spec->multiout);
1593 if (err < 0)
1594 return err;
1595 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 }
1597 if (spec->dig_in_nid) {
1598 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1599 if (err < 0)
1600 return err;
1601 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001602
1603 /* if we have no master control, let's create it */
1604 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001605 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001606 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001607 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001608 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001609 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001610 if (err < 0)
1611 return err;
1612 }
1613 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1614 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1615 NULL, alc_slave_sws);
1616 if (err < 0)
1617 return err;
1618 }
1619
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 return 0;
1621}
1622
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001623
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624/*
1625 * initialize the codec volumes, etc
1626 */
1627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001628/*
1629 * generic initialization of ADC, input mixers and output mixers
1630 */
1631static struct hda_verb alc880_volume_init_verbs[] = {
1632 /*
1633 * Unmute ADC0-2 and set the default input to mic-in
1634 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001635 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001637 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001639 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001642 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1643 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001644 * Note: PASD motherboards uses the Line In 2 as the input for front
1645 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656 /*
1657 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659 /* set vol=0 to output mixers */
1660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1663 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1664 /* set up input amps for analog loopback */
1665 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001668 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001670 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001672 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674
1675 { }
1676};
1677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678/*
1679 * 3-stack pin configuration:
1680 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1681 */
1682static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1683 /*
1684 * preset connection lists of input pins
1685 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1686 */
1687 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1688 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1689 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1690
1691 /*
1692 * Set pin mode and muting
1693 */
1694 /* set front pin widgets 0x14 for output */
1695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1698 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1699 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1700 /* Mic2 (as headphone out) for HP output */
1701 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1702 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 /* Line In pin widget for input */
1704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1706 /* Line2 (as front mic) pin widget for input and vref at 80% */
1707 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1708 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1709 /* CD pin widget for input */
1710 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1711
1712 { }
1713};
1714
1715/*
1716 * 5-stack pin configuration:
1717 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1718 * line-in/side = 0x1a, f-mic = 0x1b
1719 */
1720static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1721 /*
1722 * preset connection lists of input pins
1723 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1724 */
1725 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1726 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1727
1728 /*
1729 * Set pin mode and muting
1730 */
1731 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736 /* unmute pins for output (no gain on this amp) */
1737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1741
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1745 /* Mic2 (as headphone out) for HP output */
1746 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001748 /* Line In pin widget for input */
1749 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1751 /* Line2 (as front mic) pin widget for input and vref at 80% */
1752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1753 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1754 /* CD pin widget for input */
1755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756
1757 { }
1758};
1759
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760/*
1761 * W810 pin configuration:
1762 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1763 */
1764static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765 /* hphone/speaker input selector: front DAC */
1766 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1767
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774
1775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778 { }
1779};
1780
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001781/*
1782 * Z71V pin configuration:
1783 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1784 */
1785static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001790
Takashi Iwai16ded522005-06-10 19:58:24 +02001791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001793 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001794 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001795
1796 { }
1797};
1798
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799/*
1800 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001801 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1802 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803 */
1804static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1805 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1806
Takashi Iwai16ded522005-06-10 19:58:24 +02001807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001813 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1815
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001824 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1825
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001826 { }
1827};
Takashi Iwai16ded522005-06-10 19:58:24 +02001828
Kailang Yangccc656c2006-10-17 12:32:26 +02001829/*
1830 * Uniwill pin configuration:
1831 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1832 * line = 0x1a
1833 */
1834static struct hda_verb alc880_uniwill_init_verbs[] = {
1835 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1836
1837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1851
1852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1856 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1858 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1859 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1861
1862 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1863 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1864
1865 { }
1866};
1867
1868/*
1869* Uniwill P53
1870* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1871 */
1872static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1874
1875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1887
1888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1892 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1894
1895 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1896 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1897
1898 { }
1899};
1900
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001901static struct hda_verb alc880_beep_init_verbs[] = {
1902 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1903 { }
1904};
1905
Kailang Yangccc656c2006-10-17 12:32:26 +02001906/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001907static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001908{
1909 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001910 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001911
1912 present = snd_hda_codec_read(codec, 0x14, 0,
1913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001914 bits = present ? HDA_AMP_MUTE : 0;
1915 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1916 HDA_AMP_MUTE, bits);
1917 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1918 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001919}
1920
1921/* auto-toggle front mic */
1922static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1923{
1924 unsigned int present;
1925 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001926
1927 present = snd_hda_codec_read(codec, 0x18, 0,
1928 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001929 bits = present ? HDA_AMP_MUTE : 0;
1930 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001931}
1932
1933static void alc880_uniwill_automute(struct hda_codec *codec)
1934{
1935 alc880_uniwill_hp_automute(codec);
1936 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001937}
1938
1939static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1940 unsigned int res)
1941{
1942 /* Looks like the unsol event is incompatible with the standard
1943 * definition. 4bit tag is placed at 28 bit!
1944 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001945 switch (res >> 28) {
1946 case ALC880_HP_EVENT:
1947 alc880_uniwill_hp_automute(codec);
1948 break;
1949 case ALC880_MIC_EVENT:
1950 alc880_uniwill_mic_automute(codec);
1951 break;
1952 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001953}
1954
1955static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1956{
1957 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001958 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001959
1960 present = snd_hda_codec_read(codec, 0x14, 0,
1961 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001962 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001963 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001964}
1965
1966static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1967{
1968 unsigned int present;
1969
1970 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001971 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1972 present &= HDA_AMP_VOLMASK;
1973 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1974 HDA_AMP_VOLMASK, present);
1975 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1976 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001977}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001978
Kailang Yangccc656c2006-10-17 12:32:26 +02001979static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1980 unsigned int res)
1981{
1982 /* Looks like the unsol event is incompatible with the standard
1983 * definition. 4bit tag is placed at 28 bit!
1984 */
1985 if ((res >> 28) == ALC880_HP_EVENT)
1986 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001987 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001988 alc880_uniwill_p53_dcvol_automute(codec);
1989}
1990
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001991/*
1992 * F1734 pin configuration:
1993 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1994 */
1995static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01001996 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1998 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1999 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2000 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2001
2002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2003 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006
2007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002009 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002010 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2014 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002016
Takashi Iwai937b4162008-02-11 14:52:36 +01002017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2018 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2019
Takashi Iwai16ded522005-06-10 19:58:24 +02002020 { }
2021};
2022
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002023/*
2024 * ASUS pin configuration:
2025 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2026 */
2027static struct hda_verb alc880_pin_asus_init_verbs[] = {
2028 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2029 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2030 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2031 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2032
2033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2038 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2039 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041
2042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2051
2052 { }
2053};
2054
2055/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002056#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2057#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002058
Kailang Yangdf694da2005-12-05 19:42:22 +01002059/* Clevo m520g init */
2060static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2061 /* headphone output */
2062 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2063 /* line-out */
2064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 /* Line-in */
2067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2068 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 /* CD */
2070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 /* Mic1 (rear panel) */
2073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2075 /* Mic2 (front panel) */
2076 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2077 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 /* headphone */
2079 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 /* change to EAPD mode */
2082 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2083 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2084
2085 { }
2086};
2087
2088static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002089 /* change to EAPD mode */
2090 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2091 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2092
Kailang Yangdf694da2005-12-05 19:42:22 +01002093 /* Headphone output */
2094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2095 /* Front output*/
2096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2097 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2098
2099 /* Line In pin widget for input */
2100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2101 /* CD pin widget for input */
2102 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2103 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2105
2106 /* change to EAPD mode */
2107 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2108 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2109
2110 { }
2111};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002112
2113/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002114 * LG m1 express dual
2115 *
2116 * Pin assignment:
2117 * Rear Line-In/Out (blue): 0x14
2118 * Build-in Mic-In: 0x15
2119 * Speaker-out: 0x17
2120 * HP-Out (green): 0x1b
2121 * Mic-In/Out (red): 0x19
2122 * SPDIF-Out: 0x1e
2123 */
2124
2125/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2126static hda_nid_t alc880_lg_dac_nids[3] = {
2127 0x05, 0x02, 0x03
2128};
2129
2130/* seems analog CD is not working */
2131static struct hda_input_mux alc880_lg_capture_source = {
2132 .num_items = 3,
2133 .items = {
2134 { "Mic", 0x1 },
2135 { "Line", 0x5 },
2136 { "Internal Mic", 0x6 },
2137 },
2138};
2139
2140/* 2,4,6 channel modes */
2141static struct hda_verb alc880_lg_ch2_init[] = {
2142 /* set line-in and mic-in to input */
2143 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2144 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2145 { }
2146};
2147
2148static struct hda_verb alc880_lg_ch4_init[] = {
2149 /* set line-in to out and mic-in to input */
2150 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2151 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2152 { }
2153};
2154
2155static struct hda_verb alc880_lg_ch6_init[] = {
2156 /* set line-in and mic-in to output */
2157 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2158 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2159 { }
2160};
2161
2162static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2163 { 2, alc880_lg_ch2_init },
2164 { 4, alc880_lg_ch4_init },
2165 { 6, alc880_lg_ch6_init },
2166};
2167
2168static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002169 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2170 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002171 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2172 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2173 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2174 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2176 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2181 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2182 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2183 {
2184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2185 .name = "Channel Mode",
2186 .info = alc_ch_mode_info,
2187 .get = alc_ch_mode_get,
2188 .put = alc_ch_mode_put,
2189 },
2190 { } /* end */
2191};
2192
2193static struct hda_verb alc880_lg_init_verbs[] = {
2194 /* set capture source to mic-in */
2195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2198 /* mute all amp mixer inputs */
2199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002202 /* line-in to input */
2203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2205 /* built-in mic */
2206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2208 /* speaker-out */
2209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2210 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2211 /* mic-in to input */
2212 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2213 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2214 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2215 /* HP-out */
2216 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2218 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2219 /* jack sense */
2220 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2221 { }
2222};
2223
2224/* toggle speaker-output according to the hp-jack state */
2225static void alc880_lg_automute(struct hda_codec *codec)
2226{
2227 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002228 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002229
2230 present = snd_hda_codec_read(codec, 0x1b, 0,
2231 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002232 bits = present ? HDA_AMP_MUTE : 0;
2233 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2234 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002235}
2236
2237static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2238{
2239 /* Looks like the unsol event is incompatible with the standard
2240 * definition. 4bit tag is placed at 28 bit!
2241 */
2242 if ((res >> 28) == 0x01)
2243 alc880_lg_automute(codec);
2244}
2245
2246/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002247 * LG LW20
2248 *
2249 * Pin assignment:
2250 * Speaker-out: 0x14
2251 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002252 * Built-in Mic-In: 0x19
2253 * Line-In: 0x1b
2254 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002255 * SPDIF-Out: 0x1e
2256 */
2257
Takashi Iwaid6815182006-03-23 16:06:23 +01002258static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002259 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002260 .items = {
2261 { "Mic", 0x0 },
2262 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002263 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002264 },
2265};
2266
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002267#define alc880_lg_lw_modes alc880_threestack_modes
2268
Takashi Iwaid6815182006-03-23 16:06:23 +01002269static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2273 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2282 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2283 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002284 {
2285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2286 .name = "Channel Mode",
2287 .info = alc_ch_mode_info,
2288 .get = alc_ch_mode_get,
2289 .put = alc_ch_mode_put,
2290 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002291 { } /* end */
2292};
2293
2294static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002295 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2296 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2297 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2298
Takashi Iwaid6815182006-03-23 16:06:23 +01002299 /* set capture source to mic-in */
2300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002304 /* speaker-out */
2305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 /* mic-in to input */
2311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 /* built-in mic */
2314 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 /* jack sense */
2317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2318 { }
2319};
2320
2321/* toggle speaker-output according to the hp-jack state */
2322static void alc880_lg_lw_automute(struct hda_codec *codec)
2323{
2324 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002325 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002326
2327 present = snd_hda_codec_read(codec, 0x1b, 0,
2328 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002329 bits = present ? HDA_AMP_MUTE : 0;
2330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2331 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002332}
2333
2334static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2335{
2336 /* Looks like the unsol event is incompatible with the standard
2337 * definition. 4bit tag is placed at 28 bit!
2338 */
2339 if ((res >> 28) == 0x01)
2340 alc880_lg_lw_automute(codec);
2341}
2342
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002343static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2344 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2345 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2349 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2350 { } /* end */
2351};
2352
2353static struct hda_input_mux alc880_medion_rim_capture_source = {
2354 .num_items = 2,
2355 .items = {
2356 { "Mic", 0x0 },
2357 { "Internal Mic", 0x1 },
2358 },
2359};
2360
2361static struct hda_verb alc880_medion_rim_init_verbs[] = {
2362 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2363
2364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2366
2367 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2370 /* Mic2 (as headphone out) for HP output */
2371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2373 /* Internal Speaker */
2374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2376
2377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2378 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2379
2380 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2381 { }
2382};
2383
2384/* toggle speaker-output according to the hp-jack state */
2385static void alc880_medion_rim_automute(struct hda_codec *codec)
2386{
2387 unsigned int present;
2388 unsigned char bits;
2389
2390 present = snd_hda_codec_read(codec, 0x14, 0,
2391 AC_VERB_GET_PIN_SENSE, 0)
2392 & AC_PINSENSE_PRESENCE;
2393 bits = present ? HDA_AMP_MUTE : 0;
2394 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2395 HDA_AMP_MUTE, bits);
2396 if (present)
2397 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2398 else
2399 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2400}
2401
2402static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2403 unsigned int res)
2404{
2405 /* Looks like the unsol event is incompatible with the standard
2406 * definition. 4bit tag is placed at 28 bit!
2407 */
2408 if ((res >> 28) == ALC880_HP_EVENT)
2409 alc880_medion_rim_automute(codec);
2410}
2411
Takashi Iwaicb53c622007-08-10 17:21:45 +02002412#ifdef CONFIG_SND_HDA_POWER_SAVE
2413static struct hda_amp_list alc880_loopbacks[] = {
2414 { 0x0b, HDA_INPUT, 0 },
2415 { 0x0b, HDA_INPUT, 1 },
2416 { 0x0b, HDA_INPUT, 2 },
2417 { 0x0b, HDA_INPUT, 3 },
2418 { 0x0b, HDA_INPUT, 4 },
2419 { } /* end */
2420};
2421
2422static struct hda_amp_list alc880_lg_loopbacks[] = {
2423 { 0x0b, HDA_INPUT, 1 },
2424 { 0x0b, HDA_INPUT, 6 },
2425 { 0x0b, HDA_INPUT, 7 },
2426 { } /* end */
2427};
2428#endif
2429
Takashi Iwaid6815182006-03-23 16:06:23 +01002430/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002431 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002432 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002433
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434static int alc_init(struct hda_codec *codec)
2435{
2436 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002437 unsigned int i;
2438
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002439 alc_fix_pll(codec);
2440
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002441 for (i = 0; i < spec->num_init_verbs; i++)
2442 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002443
2444 if (spec->init_hook)
2445 spec->init_hook(codec);
2446
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 return 0;
2448}
2449
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002450static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2451{
2452 struct alc_spec *spec = codec->spec;
2453
2454 if (spec->unsol_event)
2455 spec->unsol_event(codec, res);
2456}
2457
Takashi Iwaicb53c622007-08-10 17:21:45 +02002458#ifdef CONFIG_SND_HDA_POWER_SAVE
2459static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2460{
2461 struct alc_spec *spec = codec->spec;
2462 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2463}
2464#endif
2465
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466/*
2467 * Analog playback callbacks
2468 */
2469static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2470 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002471 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472{
2473 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002474 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2475 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476}
2477
2478static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2479 struct hda_codec *codec,
2480 unsigned int stream_tag,
2481 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002482 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483{
2484 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002485 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2486 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487}
2488
2489static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2490 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002491 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492{
2493 struct alc_spec *spec = codec->spec;
2494 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2495}
2496
2497/*
2498 * Digital out
2499 */
2500static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2501 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002502 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503{
2504 struct alc_spec *spec = codec->spec;
2505 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2506}
2507
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002508static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2509 struct hda_codec *codec,
2510 unsigned int stream_tag,
2511 unsigned int format,
2512 struct snd_pcm_substream *substream)
2513{
2514 struct alc_spec *spec = codec->spec;
2515 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2516 stream_tag, format, substream);
2517}
2518
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2520 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002521 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522{
2523 struct alc_spec *spec = codec->spec;
2524 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2525}
2526
2527/*
2528 * Analog capture
2529 */
Takashi Iwai63300792008-01-24 15:31:36 +01002530static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531 struct hda_codec *codec,
2532 unsigned int stream_tag,
2533 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002534 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535{
2536 struct alc_spec *spec = codec->spec;
2537
Takashi Iwai63300792008-01-24 15:31:36 +01002538 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 stream_tag, 0, format);
2540 return 0;
2541}
2542
Takashi Iwai63300792008-01-24 15:31:36 +01002543static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002545 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546{
2547 struct alc_spec *spec = codec->spec;
2548
Takashi Iwai888afa12008-03-18 09:57:50 +01002549 snd_hda_codec_cleanup_stream(codec,
2550 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 return 0;
2552}
2553
2554
2555/*
2556 */
2557static struct hda_pcm_stream alc880_pcm_analog_playback = {
2558 .substreams = 1,
2559 .channels_min = 2,
2560 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002561 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 .ops = {
2563 .open = alc880_playback_pcm_open,
2564 .prepare = alc880_playback_pcm_prepare,
2565 .cleanup = alc880_playback_pcm_cleanup
2566 },
2567};
2568
2569static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002570 .substreams = 1,
2571 .channels_min = 2,
2572 .channels_max = 2,
2573 /* NID is set in alc_build_pcms */
2574};
2575
2576static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2577 .substreams = 1,
2578 .channels_min = 2,
2579 .channels_max = 2,
2580 /* NID is set in alc_build_pcms */
2581};
2582
2583static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2584 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 .channels_min = 2,
2586 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002589 .prepare = alc880_alt_capture_pcm_prepare,
2590 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002591 },
2592};
2593
2594static struct hda_pcm_stream alc880_pcm_digital_playback = {
2595 .substreams = 1,
2596 .channels_min = 2,
2597 .channels_max = 2,
2598 /* NID is set in alc_build_pcms */
2599 .ops = {
2600 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002601 .close = alc880_dig_playback_pcm_close,
2602 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603 },
2604};
2605
2606static struct hda_pcm_stream alc880_pcm_digital_capture = {
2607 .substreams = 1,
2608 .channels_min = 2,
2609 .channels_max = 2,
2610 /* NID is set in alc_build_pcms */
2611};
2612
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002613/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002614static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002615 .substreams = 0,
2616 .channels_min = 0,
2617 .channels_max = 0,
2618};
2619
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620static int alc_build_pcms(struct hda_codec *codec)
2621{
2622 struct alc_spec *spec = codec->spec;
2623 struct hda_pcm *info = spec->pcm_rec;
2624 int i;
2625
2626 codec->num_pcms = 1;
2627 codec->pcm_info = info;
2628
2629 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002630 if (spec->stream_analog_playback) {
2631 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2632 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2633 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2634 }
2635 if (spec->stream_analog_capture) {
2636 snd_assert(spec->adc_nids, return -EINVAL);
2637 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2638 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2639 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640
Takashi Iwai4a471b72005-12-07 13:56:29 +01002641 if (spec->channel_mode) {
2642 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2643 for (i = 0; i < spec->num_channel_mode; i++) {
2644 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2645 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2646 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 }
2648 }
2649
Takashi Iwaie08a0072006-09-07 17:52:14 +02002650 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002652 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002653 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002655 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002656 if (spec->multiout.dig_out_nid &&
2657 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2659 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2660 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002661 if (spec->dig_in_nid &&
2662 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2664 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2665 }
2666 }
2667
Takashi Iwaie08a0072006-09-07 17:52:14 +02002668 /* If the use of more than one ADC is requested for the current
2669 * model, configure a second analog capture-only PCM.
2670 */
2671 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002672 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2673 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002674 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002675 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002676 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002677 if (spec->alt_dac_nid) {
2678 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2679 *spec->stream_analog_alt_playback;
2680 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2681 spec->alt_dac_nid;
2682 } else {
2683 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2684 alc_pcm_null_stream;
2685 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2686 }
2687 if (spec->num_adc_nids > 1) {
2688 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2689 *spec->stream_analog_alt_capture;
2690 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2691 spec->adc_nids[1];
2692 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2693 spec->num_adc_nids - 1;
2694 } else {
2695 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2696 alc_pcm_null_stream;
2697 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002698 }
2699 }
2700
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 return 0;
2702}
2703
2704static void alc_free(struct hda_codec *codec)
2705{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706 struct alc_spec *spec = codec->spec;
2707 unsigned int i;
2708
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002709 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 return;
2711
2712 if (spec->kctl_alloc) {
2713 for (i = 0; i < spec->num_kctl_used; i++)
2714 kfree(spec->kctl_alloc[i].name);
2715 kfree(spec->kctl_alloc);
2716 }
2717 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002718 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719}
2720
2721/*
2722 */
2723static struct hda_codec_ops alc_patch_ops = {
2724 .build_controls = alc_build_controls,
2725 .build_pcms = alc_build_pcms,
2726 .init = alc_init,
2727 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002728 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002729#ifdef CONFIG_SND_HDA_POWER_SAVE
2730 .check_power_status = alc_check_power_status,
2731#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732};
2733
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002734
2735/*
2736 * Test configuration for debugging
2737 *
2738 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2739 * enum controls.
2740 */
2741#ifdef CONFIG_SND_DEBUG
2742static hda_nid_t alc880_test_dac_nids[4] = {
2743 0x02, 0x03, 0x04, 0x05
2744};
2745
2746static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002747 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002748 .items = {
2749 { "In-1", 0x0 },
2750 { "In-2", 0x1 },
2751 { "In-3", 0x2 },
2752 { "In-4", 0x3 },
2753 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002754 { "Front", 0x5 },
2755 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002756 },
2757};
2758
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002759static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002760 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002761 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002762 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002763 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002764};
2765
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002766static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2767 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002768{
2769 static char *texts[] = {
2770 "N/A", "Line Out", "HP Out",
2771 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2772 };
2773 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2774 uinfo->count = 1;
2775 uinfo->value.enumerated.items = 8;
2776 if (uinfo->value.enumerated.item >= 8)
2777 uinfo->value.enumerated.item = 7;
2778 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2779 return 0;
2780}
2781
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002782static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2783 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002784{
2785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2786 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2787 unsigned int pin_ctl, item = 0;
2788
2789 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2790 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2791 if (pin_ctl & AC_PINCTL_OUT_EN) {
2792 if (pin_ctl & AC_PINCTL_HP_EN)
2793 item = 2;
2794 else
2795 item = 1;
2796 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2797 switch (pin_ctl & AC_PINCTL_VREFEN) {
2798 case AC_PINCTL_VREF_HIZ: item = 3; break;
2799 case AC_PINCTL_VREF_50: item = 4; break;
2800 case AC_PINCTL_VREF_GRD: item = 5; break;
2801 case AC_PINCTL_VREF_80: item = 6; break;
2802 case AC_PINCTL_VREF_100: item = 7; break;
2803 }
2804 }
2805 ucontrol->value.enumerated.item[0] = item;
2806 return 0;
2807}
2808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002809static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2810 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002811{
2812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2813 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2814 static unsigned int ctls[] = {
2815 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2816 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2817 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2818 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2819 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2820 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2821 };
2822 unsigned int old_ctl, new_ctl;
2823
2824 old_ctl = snd_hda_codec_read(codec, nid, 0,
2825 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2826 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2827 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002828 int val;
2829 snd_hda_codec_write_cache(codec, nid, 0,
2830 AC_VERB_SET_PIN_WIDGET_CONTROL,
2831 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002832 val = ucontrol->value.enumerated.item[0] >= 3 ?
2833 HDA_AMP_MUTE : 0;
2834 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2835 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002836 return 1;
2837 }
2838 return 0;
2839}
2840
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002841static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2842 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002843{
2844 static char *texts[] = {
2845 "Front", "Surround", "CLFE", "Side"
2846 };
2847 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2848 uinfo->count = 1;
2849 uinfo->value.enumerated.items = 4;
2850 if (uinfo->value.enumerated.item >= 4)
2851 uinfo->value.enumerated.item = 3;
2852 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2853 return 0;
2854}
2855
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002856static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2857 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002858{
2859 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2860 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2861 unsigned int sel;
2862
2863 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2864 ucontrol->value.enumerated.item[0] = sel & 3;
2865 return 0;
2866}
2867
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002868static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2869 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002870{
2871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2872 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2873 unsigned int sel;
2874
2875 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2876 if (ucontrol->value.enumerated.item[0] != sel) {
2877 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002878 snd_hda_codec_write_cache(codec, nid, 0,
2879 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002880 return 1;
2881 }
2882 return 0;
2883}
2884
2885#define PIN_CTL_TEST(xname,nid) { \
2886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2887 .name = xname, \
2888 .info = alc_test_pin_ctl_info, \
2889 .get = alc_test_pin_ctl_get, \
2890 .put = alc_test_pin_ctl_put, \
2891 .private_value = nid \
2892 }
2893
2894#define PIN_SRC_TEST(xname,nid) { \
2895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2896 .name = xname, \
2897 .info = alc_test_pin_src_info, \
2898 .get = alc_test_pin_src_get, \
2899 .put = alc_test_pin_src_put, \
2900 .private_value = nid \
2901 }
2902
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002903static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2905 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2906 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2907 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2909 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2910 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002912 PIN_CTL_TEST("Front Pin Mode", 0x14),
2913 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2914 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2915 PIN_CTL_TEST("Side Pin Mode", 0x17),
2916 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2917 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2918 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2919 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2920 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2921 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2922 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2923 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2924 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2925 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2926 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2927 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2928 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2929 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2930 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2931 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002934 {
2935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2936 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002937 .info = alc_ch_mode_info,
2938 .get = alc_ch_mode_get,
2939 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002940 },
2941 { } /* end */
2942};
2943
2944static struct hda_verb alc880_test_init_verbs[] = {
2945 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002954 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2958 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002959 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2963 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002964 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2968 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002969 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002975 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2979 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002980 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002982 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002986 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002987 /* Analog input/passthru */
2988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002993 { }
2994};
2995#endif
2996
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997/*
2998 */
2999
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003000static const char *alc880_models[ALC880_MODEL_LAST] = {
3001 [ALC880_3ST] = "3stack",
3002 [ALC880_TCL_S700] = "tcl",
3003 [ALC880_3ST_DIG] = "3stack-digout",
3004 [ALC880_CLEVO] = "clevo",
3005 [ALC880_5ST] = "5stack",
3006 [ALC880_5ST_DIG] = "5stack-digout",
3007 [ALC880_W810] = "w810",
3008 [ALC880_Z71V] = "z71v",
3009 [ALC880_6ST] = "6stack",
3010 [ALC880_6ST_DIG] = "6stack-digout",
3011 [ALC880_ASUS] = "asus",
3012 [ALC880_ASUS_W1V] = "asus-w1v",
3013 [ALC880_ASUS_DIG] = "asus-dig",
3014 [ALC880_ASUS_DIG2] = "asus-dig2",
3015 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003016 [ALC880_UNIWILL_P53] = "uniwill-p53",
3017 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003018 [ALC880_F1734] = "F1734",
3019 [ALC880_LG] = "lg",
3020 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003021 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003022#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003023 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003024#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003025 [ALC880_AUTO] = "auto",
3026};
3027
3028static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003029 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003030 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3031 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3032 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3033 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3034 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3035 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3036 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3037 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003038 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3039 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003040 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3041 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3042 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3043 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3044 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3045 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3046 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3047 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3048 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3049 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003050 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003051 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3052 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3053 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003054 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003055 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003056 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3057 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003058 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3059 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003060 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3061 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3062 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3063 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003064 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3065 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003066 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003067 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003068 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003069 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003070 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3071 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003072 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003073 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003074 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003075 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003076 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003077 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003078 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003079 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003080 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3081 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003083 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3084 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3085 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3086 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003087 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3088 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003089 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003090 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3092 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003093 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3094 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3095 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003096 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3097 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3098 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099 {}
3100};
3101
Takashi Iwai16ded522005-06-10 19:58:24 +02003102/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003103 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003104 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003105static struct alc_config_preset alc880_presets[] = {
3106 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003108 .init_verbs = { alc880_volume_init_verbs,
3109 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003110 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003111 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3113 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003114 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003115 .input_mux = &alc880_capture_source,
3116 },
3117 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003119 .init_verbs = { alc880_volume_init_verbs,
3120 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003121 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003122 .dac_nids = alc880_dac_nids,
3123 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3125 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .input_mux = &alc880_capture_source,
3128 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003129 [ALC880_TCL_S700] = {
3130 .mixers = { alc880_tcl_s700_mixer },
3131 .init_verbs = { alc880_volume_init_verbs,
3132 alc880_pin_tcl_S700_init_verbs,
3133 alc880_gpio2_init_verbs },
3134 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3135 .dac_nids = alc880_dac_nids,
3136 .hp_nid = 0x03,
3137 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3138 .channel_mode = alc880_2_jack_modes,
3139 .input_mux = &alc880_capture_source,
3140 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003142 .mixers = { alc880_three_stack_mixer,
3143 alc880_five_stack_mixer},
3144 .init_verbs = { alc880_volume_init_verbs,
3145 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003146 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3147 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003148 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3149 .channel_mode = alc880_fivestack_modes,
3150 .input_mux = &alc880_capture_source,
3151 },
3152 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003153 .mixers = { alc880_three_stack_mixer,
3154 alc880_five_stack_mixer },
3155 .init_verbs = { alc880_volume_init_verbs,
3156 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
3159 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3161 .channel_mode = alc880_fivestack_modes,
3162 .input_mux = &alc880_capture_source,
3163 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003164 [ALC880_6ST] = {
3165 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003166 .init_verbs = { alc880_volume_init_verbs,
3167 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003168 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3169 .dac_nids = alc880_6st_dac_nids,
3170 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3171 .channel_mode = alc880_sixstack_modes,
3172 .input_mux = &alc880_6stack_capture_source,
3173 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003174 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003175 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003176 .init_verbs = { alc880_volume_init_verbs,
3177 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003178 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3179 .dac_nids = alc880_6st_dac_nids,
3180 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003181 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3182 .channel_mode = alc880_sixstack_modes,
3183 .input_mux = &alc880_6stack_capture_source,
3184 },
3185 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003187 .init_verbs = { alc880_volume_init_verbs,
3188 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003189 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003190 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3191 .dac_nids = alc880_w810_dac_nids,
3192 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3194 .channel_mode = alc880_w810_modes,
3195 .input_mux = &alc880_capture_source,
3196 },
3197 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003199 .init_verbs = { alc880_volume_init_verbs,
3200 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003201 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3202 .dac_nids = alc880_z71v_dac_nids,
3203 .dig_out_nid = ALC880_DIGOUT_NID,
3204 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3206 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003207 .input_mux = &alc880_capture_source,
3208 },
3209 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003211 .init_verbs = { alc880_volume_init_verbs,
3212 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3214 .dac_nids = alc880_f1734_dac_nids,
3215 .hp_nid = 0x02,
3216 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3217 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003218 .input_mux = &alc880_f1734_capture_source,
3219 .unsol_event = alc880_uniwill_p53_unsol_event,
3220 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003221 },
3222 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 alc880_gpio1_init_verbs },
3227 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3228 .dac_nids = alc880_asus_dac_nids,
3229 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3230 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003231 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003232 .input_mux = &alc880_capture_source,
3233 },
3234 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003236 .init_verbs = { alc880_volume_init_verbs,
3237 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 alc880_gpio1_init_verbs },
3239 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3240 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3243 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003244 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003245 .input_mux = &alc880_capture_source,
3246 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003247 [ALC880_ASUS_DIG2] = {
3248 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 .init_verbs = { alc880_volume_init_verbs,
3250 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003251 alc880_gpio2_init_verbs }, /* use GPIO2 */
3252 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3253 .dac_nids = alc880_asus_dac_nids,
3254 .dig_out_nid = ALC880_DIGOUT_NID,
3255 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3256 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003257 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003258 .input_mux = &alc880_capture_source,
3259 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262 .init_verbs = { alc880_volume_init_verbs,
3263 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264 alc880_gpio1_init_verbs },
3265 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3266 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3269 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003270 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 .input_mux = &alc880_capture_source,
3272 },
3273 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003274 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003275 .init_verbs = { alc880_volume_init_verbs,
3276 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3278 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003279 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3281 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003282 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003283 .input_mux = &alc880_capture_source,
3284 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003285 [ALC880_UNIWILL] = {
3286 .mixers = { alc880_uniwill_mixer },
3287 .init_verbs = { alc880_volume_init_verbs,
3288 alc880_uniwill_init_verbs },
3289 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3290 .dac_nids = alc880_asus_dac_nids,
3291 .dig_out_nid = ALC880_DIGOUT_NID,
3292 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3293 .channel_mode = alc880_threestack_modes,
3294 .need_dac_fix = 1,
3295 .input_mux = &alc880_capture_source,
3296 .unsol_event = alc880_uniwill_unsol_event,
3297 .init_hook = alc880_uniwill_automute,
3298 },
3299 [ALC880_UNIWILL_P53] = {
3300 .mixers = { alc880_uniwill_p53_mixer },
3301 .init_verbs = { alc880_volume_init_verbs,
3302 alc880_uniwill_p53_init_verbs },
3303 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3304 .dac_nids = alc880_asus_dac_nids,
3305 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003306 .channel_mode = alc880_threestack_modes,
3307 .input_mux = &alc880_capture_source,
3308 .unsol_event = alc880_uniwill_p53_unsol_event,
3309 .init_hook = alc880_uniwill_p53_hp_automute,
3310 },
3311 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003312 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003313 alc880_pcbeep_mixer, },
3314 .init_verbs = { alc880_volume_init_verbs,
3315 alc880_uniwill_p53_init_verbs,
3316 alc880_beep_init_verbs },
3317 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3318 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003319 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003320 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3321 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 .input_mux = &alc880_capture_source,
3323 .unsol_event = alc880_uniwill_p53_unsol_event,
3324 .init_hook = alc880_uniwill_p53_hp_automute,
3325 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003326 [ALC880_CLEVO] = {
3327 .mixers = { alc880_three_stack_mixer },
3328 .init_verbs = { alc880_volume_init_verbs,
3329 alc880_pin_clevo_init_verbs },
3330 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3331 .dac_nids = alc880_dac_nids,
3332 .hp_nid = 0x03,
3333 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3334 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003335 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003336 .input_mux = &alc880_capture_source,
3337 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003338 [ALC880_LG] = {
3339 .mixers = { alc880_lg_mixer },
3340 .init_verbs = { alc880_volume_init_verbs,
3341 alc880_lg_init_verbs },
3342 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3343 .dac_nids = alc880_lg_dac_nids,
3344 .dig_out_nid = ALC880_DIGOUT_NID,
3345 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3346 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003347 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003348 .input_mux = &alc880_lg_capture_source,
3349 .unsol_event = alc880_lg_unsol_event,
3350 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003351#ifdef CONFIG_SND_HDA_POWER_SAVE
3352 .loopbacks = alc880_lg_loopbacks,
3353#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003354 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003355 [ALC880_LG_LW] = {
3356 .mixers = { alc880_lg_lw_mixer },
3357 .init_verbs = { alc880_volume_init_verbs,
3358 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003359 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003360 .dac_nids = alc880_dac_nids,
3361 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003362 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3363 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003364 .input_mux = &alc880_lg_lw_capture_source,
3365 .unsol_event = alc880_lg_lw_unsol_event,
3366 .init_hook = alc880_lg_lw_automute,
3367 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003368 [ALC880_MEDION_RIM] = {
3369 .mixers = { alc880_medion_rim_mixer },
3370 .init_verbs = { alc880_volume_init_verbs,
3371 alc880_medion_rim_init_verbs,
3372 alc_gpio2_init_verbs },
3373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3374 .dac_nids = alc880_dac_nids,
3375 .dig_out_nid = ALC880_DIGOUT_NID,
3376 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3377 .channel_mode = alc880_2_jack_modes,
3378 .input_mux = &alc880_medion_rim_capture_source,
3379 .unsol_event = alc880_medion_rim_unsol_event,
3380 .init_hook = alc880_medion_rim_automute,
3381 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003382#ifdef CONFIG_SND_DEBUG
3383 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 .mixers = { alc880_test_mixer },
3385 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003386 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3387 .dac_nids = alc880_test_dac_nids,
3388 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003389 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3390 .channel_mode = alc880_test_modes,
3391 .input_mux = &alc880_test_capture_source,
3392 },
3393#endif
3394};
3395
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396/*
3397 * Automatic parse of I/O pins from the BIOS configuration
3398 */
3399
3400#define NUM_CONTROL_ALLOC 32
3401#define NUM_VERB_ALLOC 32
3402
3403enum {
3404 ALC_CTL_WIDGET_VOL,
3405 ALC_CTL_WIDGET_MUTE,
3406 ALC_CTL_BIND_MUTE,
3407};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003408static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3410 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003411 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412};
3413
3414/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003415static int add_control(struct alc_spec *spec, int type, const char *name,
3416 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003418 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419
3420 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3421 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3422
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423 /* array + terminator */
3424 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3425 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426 return -ENOMEM;
3427 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003428 memcpy(knew, spec->kctl_alloc,
3429 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 kfree(spec->kctl_alloc);
3431 }
3432 spec->kctl_alloc = knew;
3433 spec->num_kctl_alloc = num;
3434 }
3435
3436 knew = &spec->kctl_alloc[spec->num_kctl_used];
3437 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003438 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003439 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 return -ENOMEM;
3441 knew->private_value = val;
3442 spec->num_kctl_used++;
3443 return 0;
3444}
3445
3446#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3447#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3448#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3449#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3450#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3451#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3452#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3453#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3454#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3455#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3456#define ALC880_PIN_CD_NID 0x1c
3457
3458/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003459static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3460 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461{
3462 hda_nid_t nid;
3463 int assigned[4];
3464 int i, j;
3465
3466 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003467 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468
3469 /* check the pins hardwired to audio widget */
3470 for (i = 0; i < cfg->line_outs; i++) {
3471 nid = cfg->line_out_pins[i];
3472 if (alc880_is_fixed_pin(nid)) {
3473 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003474 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 assigned[idx] = 1;
3476 }
3477 }
3478 /* left pins can be connect to any audio widget */
3479 for (i = 0; i < cfg->line_outs; i++) {
3480 nid = cfg->line_out_pins[i];
3481 if (alc880_is_fixed_pin(nid))
3482 continue;
3483 /* search for an empty channel */
3484 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003485 if (!assigned[j]) {
3486 spec->multiout.dac_nids[i] =
3487 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488 assigned[j] = 1;
3489 break;
3490 }
3491 }
3492 }
3493 spec->multiout.num_dacs = cfg->line_outs;
3494 return 0;
3495}
3496
3497/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003498static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3499 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500{
3501 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003502 static const char *chname[4] = {
3503 "Front", "Surround", NULL /*CLFE*/, "Side"
3504 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 hda_nid_t nid;
3506 int i, err;
3507
3508 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003509 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003510 continue;
3511 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3512 if (i == 2) {
3513 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003514 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3515 "Center Playback Volume",
3516 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3517 HDA_OUTPUT));
3518 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003520 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3521 "LFE Playback Volume",
3522 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3523 HDA_OUTPUT));
3524 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003526 err = add_control(spec, ALC_CTL_BIND_MUTE,
3527 "Center Playback Switch",
3528 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3529 HDA_INPUT));
3530 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003532 err = add_control(spec, ALC_CTL_BIND_MUTE,
3533 "LFE Playback Switch",
3534 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3535 HDA_INPUT));
3536 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003537 return err;
3538 } else {
3539 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003540 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3541 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3542 HDA_OUTPUT));
3543 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 return err;
3545 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003546 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3547 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3548 HDA_INPUT));
3549 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 return err;
3551 }
3552 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003553 return 0;
3554}
3555
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003556/* add playback controls for speaker and HP outputs */
3557static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3558 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559{
3560 hda_nid_t nid;
3561 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003562 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003564 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 return 0;
3566
3567 if (alc880_is_fixed_pin(pin)) {
3568 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003569 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003570 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003572 else
3573 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574 /* control HP volume/switch on the output mixer amp */
3575 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003576 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003577 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3578 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3579 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003581 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003582 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3583 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3584 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 return err;
3586 } else if (alc880_is_multi_pin(pin)) {
3587 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003589 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3591 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 return err;
3594 }
3595 return 0;
3596}
3597
3598/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003599static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3600 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003601 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602{
3603 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003604 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605
3606 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003607 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3608 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3609 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003610 return err;
3611 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003612 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3613 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3614 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003615 return err;
3616 return 0;
3617}
3618
3619/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003620static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3621 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003624 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625
3626 for (i = 0; i < AUTO_PIN_LAST; i++) {
3627 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003628 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003629 err = new_analog_input(spec, cfg->input_pins[i],
3630 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003631 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 if (err < 0)
3633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003634 imux->items[imux->num_items].label =
3635 auto_pin_cfg_labels[i];
3636 imux->items[imux->num_items].index =
3637 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638 imux->num_items++;
3639 }
3640 }
3641 return 0;
3642}
3643
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003644static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3645 unsigned int pin_type)
3646{
3647 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3648 pin_type);
3649 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003650 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3651 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003652}
3653
Kailang Yangdf694da2005-12-05 19:42:22 +01003654static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3655 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656 int dac_idx)
3657{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003658 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659 /* need the manual connection? */
3660 if (alc880_is_multi_pin(nid)) {
3661 struct alc_spec *spec = codec->spec;
3662 int idx = alc880_multi_pin_idx(nid);
3663 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3664 AC_VERB_SET_CONNECT_SEL,
3665 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3666 }
3667}
3668
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003669static int get_pin_type(int line_out_type)
3670{
3671 if (line_out_type == AUTO_PIN_HP_OUT)
3672 return PIN_HP;
3673 else
3674 return PIN_OUT;
3675}
3676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677static void alc880_auto_init_multi_out(struct hda_codec *codec)
3678{
3679 struct alc_spec *spec = codec->spec;
3680 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003681
3682 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003683 for (i = 0; i < spec->autocfg.line_outs; i++) {
3684 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003685 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3686 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003687 }
3688}
3689
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003690static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691{
3692 struct alc_spec *spec = codec->spec;
3693 hda_nid_t pin;
3694
Takashi Iwai82bc9552006-03-21 11:24:42 +01003695 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003696 if (pin) /* connect to front */
3697 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003698 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 if (pin) /* connect to front */
3700 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3701}
3702
3703static void alc880_auto_init_analog_input(struct hda_codec *codec)
3704{
3705 struct alc_spec *spec = codec->spec;
3706 int i;
3707
3708 for (i = 0; i < AUTO_PIN_LAST; i++) {
3709 hda_nid_t nid = spec->autocfg.input_pins[i];
3710 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003711 snd_hda_codec_write(codec, nid, 0,
3712 AC_VERB_SET_PIN_WIDGET_CONTROL,
3713 i <= AUTO_PIN_FRONT_MIC ?
3714 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003716 snd_hda_codec_write(codec, nid, 0,
3717 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003718 AMP_OUT_MUTE);
3719 }
3720 }
3721}
3722
3723/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724/* return 1 if successful, 0 if the proper config is not found,
3725 * or a negative error code
3726 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003727static int alc880_parse_auto_config(struct hda_codec *codec)
3728{
3729 struct alc_spec *spec = codec->spec;
3730 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003731 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003733 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3734 alc880_ignore);
3735 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003738 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003739
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003740 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3741 if (err < 0)
3742 return err;
3743 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3744 if (err < 0)
3745 return err;
3746 err = alc880_auto_create_extra_out(spec,
3747 spec->autocfg.speaker_pins[0],
3748 "Speaker");
3749 if (err < 0)
3750 return err;
3751 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3752 "Headphone");
3753 if (err < 0)
3754 return err;
3755 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3756 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003757 return err;
3758
3759 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3760
3761 if (spec->autocfg.dig_out_pin)
3762 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3763 if (spec->autocfg.dig_in_pin)
3764 spec->dig_in_nid = ALC880_DIGIN_NID;
3765
3766 if (spec->kctl_alloc)
3767 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3768
3769 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3770
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003771 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 spec->input_mux = &spec->private_imux;
3773
3774 return 1;
3775}
3776
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003777/* additional initialization for auto-configuration model */
3778static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003780 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003781 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003782 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003784 if (spec->unsol_event)
3785 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003786}
3787
3788/*
3789 * OK, here we have finally the patch for ALC880
3790 */
3791
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792static int patch_alc880(struct hda_codec *codec)
3793{
3794 struct alc_spec *spec;
3795 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003796 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003797
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003798 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003799 if (spec == NULL)
3800 return -ENOMEM;
3801
3802 codec->spec = spec;
3803
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003804 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3805 alc880_models,
3806 alc880_cfg_tbl);
3807 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003808 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3809 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811 }
3812
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003813 if (board_config == ALC880_AUTO) {
3814 /* automatic parse from the BIOS config */
3815 err = alc880_parse_auto_config(codec);
3816 if (err < 0) {
3817 alc_free(codec);
3818 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003819 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003820 printk(KERN_INFO
3821 "hda_codec: Cannot set up configuration "
3822 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 board_config = ALC880_3ST;
3824 }
3825 }
3826
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 if (board_config != ALC880_AUTO)
3828 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003829
3830 spec->stream_name_analog = "ALC880 Analog";
3831 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3832 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003833 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003834
3835 spec->stream_name_digital = "ALC880 Digital";
3836 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3837 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003839 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003840 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003841 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 /* get type */
3843 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 if (wcap != AC_WID_AUD_IN) {
3845 spec->adc_nids = alc880_adc_nids_alt;
3846 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847 spec->mixers[spec->num_mixers] =
3848 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 spec->num_mixers++;
3850 } else {
3851 spec->adc_nids = alc880_adc_nids;
3852 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3853 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3854 spec->num_mixers++;
3855 }
3856 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857
Takashi Iwai2134ea42008-01-10 16:53:55 +01003858 spec->vmaster_nid = 0x0c;
3859
Linus Torvalds1da177e2005-04-16 15:20:36 -07003860 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003862 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003863#ifdef CONFIG_SND_HDA_POWER_SAVE
3864 if (!spec->loopback.amplist)
3865 spec->loopback.amplist = alc880_loopbacks;
3866#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867
3868 return 0;
3869}
3870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003871
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872/*
3873 * ALC260 support
3874 */
3875
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003876static hda_nid_t alc260_dac_nids[1] = {
3877 /* front */
3878 0x02,
3879};
3880
3881static hda_nid_t alc260_adc_nids[1] = {
3882 /* ADC0 */
3883 0x04,
3884};
3885
Kailang Yangdf694da2005-12-05 19:42:22 +01003886static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003887 /* ADC1 */
3888 0x05,
3889};
3890
Kailang Yangdf694da2005-12-05 19:42:22 +01003891static hda_nid_t alc260_hp_adc_nids[2] = {
3892 /* ADC1, 0 */
3893 0x05, 0x04
3894};
3895
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003896/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3897 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3898 */
3899static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003900 /* ADC0, ADC1 */
3901 0x04, 0x05
3902};
3903
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003904#define ALC260_DIGOUT_NID 0x03
3905#define ALC260_DIGIN_NID 0x06
3906
3907static struct hda_input_mux alc260_capture_source = {
3908 .num_items = 4,
3909 .items = {
3910 { "Mic", 0x0 },
3911 { "Front Mic", 0x1 },
3912 { "Line", 0x2 },
3913 { "CD", 0x4 },
3914 },
3915};
3916
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003917/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003918 * headphone jack and the internal CD lines since these are the only pins at
3919 * which audio can appear. For flexibility, also allow the option of
3920 * recording the mixer output on the second ADC (ADC0 doesn't have a
3921 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003922 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003923static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3924 {
3925 .num_items = 3,
3926 .items = {
3927 { "Mic/Line", 0x0 },
3928 { "CD", 0x4 },
3929 { "Headphone", 0x2 },
3930 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003931 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003932 {
3933 .num_items = 4,
3934 .items = {
3935 { "Mic/Line", 0x0 },
3936 { "CD", 0x4 },
3937 { "Headphone", 0x2 },
3938 { "Mixer", 0x5 },
3939 },
3940 },
3941
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003942};
3943
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003944/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3945 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003946 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003947static struct hda_input_mux alc260_acer_capture_sources[2] = {
3948 {
3949 .num_items = 4,
3950 .items = {
3951 { "Mic", 0x0 },
3952 { "Line", 0x2 },
3953 { "CD", 0x4 },
3954 { "Headphone", 0x5 },
3955 },
3956 },
3957 {
3958 .num_items = 5,
3959 .items = {
3960 { "Mic", 0x0 },
3961 { "Line", 0x2 },
3962 { "CD", 0x4 },
3963 { "Headphone", 0x6 },
3964 { "Mixer", 0x5 },
3965 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003966 },
3967};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968/*
3969 * This is just place-holder, so there's something for alc_build_pcms to look
3970 * at when it calculates the maximum number of channels. ALC260 has no mixer
3971 * element which allows changing the channel mode, so the verb list is
3972 * never used.
3973 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003974static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975 { 2, NULL },
3976};
3977
Kailang Yangdf694da2005-12-05 19:42:22 +01003978
3979/* Mixer combinations
3980 *
3981 * basic: base_output + input + pc_beep + capture
3982 * HP: base_output + input + capture_alt
3983 * HP_3013: hp_3013 + input + capture
3984 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003985 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003986 */
3987
3988static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003989 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003990 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3992 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3993 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3994 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3995 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996};
Kailang Yangdf694da2005-12-05 19:42:22 +01003997
3998static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4000 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4001 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4002 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4004 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007 { } /* end */
4008};
4009
Kailang Yangdf694da2005-12-05 19:42:22 +01004010static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4013 { } /* end */
4014};
4015
Takashi Iwaibec15c32008-01-28 18:16:30 +01004016/* update HP, line and mono out pins according to the master switch */
4017static void alc260_hp_master_update(struct hda_codec *codec,
4018 hda_nid_t hp, hda_nid_t line,
4019 hda_nid_t mono)
4020{
4021 struct alc_spec *spec = codec->spec;
4022 unsigned int val = spec->master_sw ? PIN_HP : 0;
4023 /* change HP and line-out pins */
4024 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4025 val);
4026 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4027 val);
4028 /* mono (speaker) depending on the HP jack sense */
4029 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4030 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4031 val);
4032}
4033
4034static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4035 struct snd_ctl_elem_value *ucontrol)
4036{
4037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4038 struct alc_spec *spec = codec->spec;
4039 *ucontrol->value.integer.value = spec->master_sw;
4040 return 0;
4041}
4042
4043static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4044 struct snd_ctl_elem_value *ucontrol)
4045{
4046 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4047 struct alc_spec *spec = codec->spec;
4048 int val = !!*ucontrol->value.integer.value;
4049 hda_nid_t hp, line, mono;
4050
4051 if (val == spec->master_sw)
4052 return 0;
4053 spec->master_sw = val;
4054 hp = (kcontrol->private_value >> 16) & 0xff;
4055 line = (kcontrol->private_value >> 8) & 0xff;
4056 mono = kcontrol->private_value & 0xff;
4057 alc260_hp_master_update(codec, hp, line, mono);
4058 return 1;
4059}
4060
4061static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4062 {
4063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4064 .name = "Master Playback Switch",
4065 .info = snd_ctl_boolean_mono_info,
4066 .get = alc260_hp_master_sw_get,
4067 .put = alc260_hp_master_sw_put,
4068 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4069 },
4070 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4071 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4073 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4075 HDA_OUTPUT),
4076 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4077 { } /* end */
4078};
4079
4080static struct hda_verb alc260_hp_unsol_verbs[] = {
4081 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4082 {},
4083};
4084
4085static void alc260_hp_automute(struct hda_codec *codec)
4086{
4087 struct alc_spec *spec = codec->spec;
4088 unsigned int present;
4089
4090 present = snd_hda_codec_read(codec, 0x10, 0,
4091 AC_VERB_GET_PIN_SENSE, 0);
4092 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4093 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4094}
4095
4096static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4097{
4098 if ((res >> 26) == ALC880_HP_EVENT)
4099 alc260_hp_automute(codec);
4100}
4101
Kailang Yangdf694da2005-12-05 19:42:22 +01004102static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004103 {
4104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4105 .name = "Master Playback Switch",
4106 .info = snd_ctl_boolean_mono_info,
4107 .get = alc260_hp_master_sw_get,
4108 .put = alc260_hp_master_sw_put,
4109 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4110 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004111 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4112 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4113 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4114 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004117 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4118 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004119 { } /* end */
4120};
4121
Takashi Iwaibec15c32008-01-28 18:16:30 +01004122static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4124 {},
4125};
4126
4127static void alc260_hp_3013_automute(struct hda_codec *codec)
4128{
4129 struct alc_spec *spec = codec->spec;
4130 unsigned int present;
4131
4132 present = snd_hda_codec_read(codec, 0x15, 0,
4133 AC_VERB_GET_PIN_SENSE, 0);
4134 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4135 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4136}
4137
4138static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4139 unsigned int res)
4140{
4141 if ((res >> 26) == ALC880_HP_EVENT)
4142 alc260_hp_3013_automute(codec);
4143}
4144
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004145/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4146 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4147 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004148static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004149 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004150 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004151 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004152 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4153 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4154 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4155 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004156 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004157 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4158 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4160 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004161 { } /* end */
4162};
4163
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004164/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4165 * versions of the ALC260 don't act on requests to enable mic bias from NID
4166 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4167 * datasheet doesn't mention this restriction. At this stage it's not clear
4168 * whether this behaviour is intentional or is a hardware bug in chip
4169 * revisions available in early 2006. Therefore for now allow the
4170 * "Headphone Jack Mode" control to span all choices, but if it turns out
4171 * that the lack of mic bias for this NID is intentional we could change the
4172 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4173 *
4174 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4175 * don't appear to make the mic bias available from the "line" jack, even
4176 * though the NID used for this jack (0x14) can supply it. The theory is
4177 * that perhaps Acer have included blocking capacitors between the ALC260
4178 * and the output jack. If this turns out to be the case for all such
4179 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4180 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004181 *
4182 * The C20x Tablet series have a mono internal speaker which is controlled
4183 * via the chip's Mono sum widget and pin complex, so include the necessary
4184 * controls for such models. On models without a "mono speaker" the control
4185 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004186 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004187static struct snd_kcontrol_new alc260_acer_mixer[] = {
4188 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4189 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004190 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004191 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004192 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004193 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004194 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004195 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4196 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4198 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4199 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4200 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4201 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4202 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4203 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4204 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4205 { } /* end */
4206};
4207
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004208/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4209 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4210 */
4211static struct snd_kcontrol_new alc260_will_mixer[] = {
4212 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4213 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4215 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4216 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4217 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4218 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4219 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4220 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4221 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4222 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4223 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4224 { } /* end */
4225};
4226
4227/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4228 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4229 */
4230static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4231 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4232 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4234 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4235 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4236 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4237 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4238 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4239 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4240 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4241 { } /* end */
4242};
4243
Kailang Yangdf694da2005-12-05 19:42:22 +01004244/* capture mixer elements */
4245static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004246 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4247 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004248 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4249 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004250 {
4251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004252 /* The multiple "Capture Source" controls confuse alsamixer
4253 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004254 */
4255 /* .name = "Capture Source", */
4256 .name = "Input Source",
4257 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004258 .info = alc_mux_enum_info,
4259 .get = alc_mux_enum_get,
4260 .put = alc_mux_enum_put,
4261 },
4262 { } /* end */
4263};
4264
Kailang Yangdf694da2005-12-05 19:42:22 +01004265static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4266 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4267 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4268 {
4269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4270 /* The multiple "Capture Source" controls confuse alsamixer
4271 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004272 */
4273 /* .name = "Capture Source", */
4274 .name = "Input Source",
4275 .count = 1,
4276 .info = alc_mux_enum_info,
4277 .get = alc_mux_enum_get,
4278 .put = alc_mux_enum_put,
4279 },
4280 { } /* end */
4281};
4282
4283/*
4284 * initialization verbs
4285 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286static struct hda_verb alc260_init_verbs[] = {
4287 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004289 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004291 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004292 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004293 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004294 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004295 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004297 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004298 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004299 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004300 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004302 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004304 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4305 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004306 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307 /* set connection select to line in (default select for this ADC) */
4308 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004309 /* mute capture amp left and right */
4310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4311 /* set connection select to line in (default select for this ADC) */
4312 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004313 /* set vol=0 Line-Out mixer amp left and right */
4314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4315 /* unmute pin widget amp left and right (no gain on this amp) */
4316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4317 /* set vol=0 HP mixer amp left and right */
4318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4319 /* unmute pin widget amp left and right (no gain on this amp) */
4320 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4321 /* set vol=0 Mono mixer amp left and right */
4322 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4323 /* unmute pin widget amp left and right (no gain on this amp) */
4324 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4325 /* unmute LINE-2 out pin */
4326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004327 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4328 * Line In 2 = 0x03
4329 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004330 /* mute analog inputs */
4331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004336 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004337 /* mute Front out path */
4338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4340 /* mute Headphone out path */
4341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4343 /* mute Mono out path */
4344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004346 { }
4347};
4348
Takashi Iwai474167d2006-05-17 17:17:43 +02004349#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004350static struct hda_verb alc260_hp_init_verbs[] = {
4351 /* Headphone and output */
4352 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4353 /* mono output */
4354 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4357 /* Mic2 (front panel) pin widget for input and vref at 80% */
4358 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4359 /* Line In pin widget for input */
4360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4361 /* Line-2 pin widget for output */
4362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4363 /* CD pin widget for input */
4364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4365 /* unmute amp left and right */
4366 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4367 /* set connection select to line in (default select for this ADC) */
4368 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4369 /* unmute Line-Out mixer amp left and right (volume = 0) */
4370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4371 /* mute pin widget amp left and right (no gain on this amp) */
4372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4373 /* unmute HP mixer amp left and right (volume = 0) */
4374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4375 /* mute pin widget amp left and right (no gain on this amp) */
4376 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4378 * Line In 2 = 0x03
4379 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004380 /* mute analog inputs */
4381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004386 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4387 /* Unmute Front out path */
4388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4390 /* Unmute Headphone out path */
4391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4393 /* Unmute Mono out path */
4394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4396 { }
4397};
Takashi Iwai474167d2006-05-17 17:17:43 +02004398#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004399
4400static struct hda_verb alc260_hp_3013_init_verbs[] = {
4401 /* Line out and output */
4402 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4403 /* mono output */
4404 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4405 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4407 /* Mic2 (front panel) pin widget for input and vref at 80% */
4408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4409 /* Line In pin widget for input */
4410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4411 /* Headphone pin widget for output */
4412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4413 /* CD pin widget for input */
4414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4415 /* unmute amp left and right */
4416 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4417 /* set connection select to line in (default select for this ADC) */
4418 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4419 /* unmute Line-Out mixer amp left and right (volume = 0) */
4420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4421 /* mute pin widget amp left and right (no gain on this amp) */
4422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4423 /* unmute HP mixer amp left and right (volume = 0) */
4424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4425 /* mute pin widget amp left and right (no gain on this amp) */
4426 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4428 * Line In 2 = 0x03
4429 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004430 /* mute analog inputs */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004436 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4437 /* Unmute Front out path */
4438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4440 /* Unmute Headphone out path */
4441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4443 /* Unmute Mono out path */
4444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4446 { }
4447};
4448
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004449/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004450 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4451 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004452 */
4453static struct hda_verb alc260_fujitsu_init_verbs[] = {
4454 /* Disable all GPIOs */
4455 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4456 /* Internal speaker is connected to headphone pin */
4457 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4458 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004460 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4461 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4462 /* Ensure all other unused pins are disabled and muted. */
4463 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004465 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004466 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004467 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004468 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004471
Jonathan Woithef7ace402006-02-28 11:46:14 +01004472 /* Disable digital (SPDIF) pins */
4473 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4474 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004475
Jonathan Woithef7ace402006-02-28 11:46:14 +01004476 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4477 * when acting as an output.
4478 */
4479 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4480
4481 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004491
Jonathan Woithef7ace402006-02-28 11:46:14 +01004492 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4494 /* Unmute Line1 pin widget output buffer since it starts as an output.
4495 * If the pin mode is changed by the user the pin mode control will
4496 * take care of enabling the pin's input/output buffers as needed.
4497 * Therefore there's no need to enable the input buffer at this
4498 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004499 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004501 /* Unmute input buffer of pin widget used for Line-in (no equiv
4502 * mixer ctrl)
4503 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004504 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004505
Jonathan Woithef7ace402006-02-28 11:46:14 +01004506 /* Mute capture amp left and right */
4507 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4508 /* Set ADC connection select to match default mixer setting - line
4509 * in (on mic1 pin)
4510 */
4511 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004512
Jonathan Woithef7ace402006-02-28 11:46:14 +01004513 /* Do the same for the second ADC: mute capture input amp and
4514 * set ADC connection to line in (on mic1 pin)
4515 */
4516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4517 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004518
Jonathan Woithef7ace402006-02-28 11:46:14 +01004519 /* Mute all inputs to mixer widget (even unconnected ones) */
4520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004528
4529 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004530};
4531
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004532/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4533 * similar laptops (adapted from Fujitsu init verbs).
4534 */
4535static struct hda_verb alc260_acer_init_verbs[] = {
4536 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4537 * the headphone jack. Turn this on and rely on the standard mute
4538 * methods whenever the user wants to turn these outputs off.
4539 */
4540 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4541 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4542 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4543 /* Internal speaker/Headphone jack is connected to Line-out pin */
4544 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4545 /* Internal microphone/Mic jack is connected to Mic1 pin */
4546 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4547 /* Line In jack is connected to Line1 pin */
4548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004549 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4550 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004551 /* Ensure all other unused pins are disabled and muted. */
4552 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004554 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4555 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4558 /* Disable digital (SPDIF) pins */
4559 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4560 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4561
4562 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4563 * bus when acting as outputs.
4564 */
4565 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4566 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4567
4568 /* Start with output sum widgets muted and their output gains at min */
4569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4575 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004579 /* Unmute Line-out pin widget amp left and right
4580 * (no equiv mixer ctrl)
4581 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004582 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004583 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4584 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004585 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4586 * inputs. If the pin mode is changed by the user the pin mode control
4587 * will take care of enabling the pin's input/output buffers as needed.
4588 * Therefore there's no need to enable the input buffer at this
4589 * stage.
4590 */
4591 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4593
4594 /* Mute capture amp left and right */
4595 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4596 /* Set ADC connection select to match default mixer setting - mic
4597 * (on mic1 pin)
4598 */
4599 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4600
4601 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004602 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004603 */
4604 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004605 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004606
4607 /* Mute all inputs to mixer widget (even unconnected ones) */
4608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4616
4617 { }
4618};
4619
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004620static struct hda_verb alc260_will_verbs[] = {
4621 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4622 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4623 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4624 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4625 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4626 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4627 {}
4628};
4629
4630static struct hda_verb alc260_replacer_672v_verbs[] = {
4631 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4632 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4633 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4634
4635 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4636 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4637 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4638
4639 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4640 {}
4641};
4642
4643/* toggle speaker-output according to the hp-jack state */
4644static void alc260_replacer_672v_automute(struct hda_codec *codec)
4645{
4646 unsigned int present;
4647
4648 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4649 present = snd_hda_codec_read(codec, 0x0f, 0,
4650 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4651 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004652 snd_hda_codec_write_cache(codec, 0x01, 0,
4653 AC_VERB_SET_GPIO_DATA, 1);
4654 snd_hda_codec_write_cache(codec, 0x0f, 0,
4655 AC_VERB_SET_PIN_WIDGET_CONTROL,
4656 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004657 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004658 snd_hda_codec_write_cache(codec, 0x01, 0,
4659 AC_VERB_SET_GPIO_DATA, 0);
4660 snd_hda_codec_write_cache(codec, 0x0f, 0,
4661 AC_VERB_SET_PIN_WIDGET_CONTROL,
4662 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004663 }
4664}
4665
4666static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4667 unsigned int res)
4668{
4669 if ((res >> 26) == ALC880_HP_EVENT)
4670 alc260_replacer_672v_automute(codec);
4671}
4672
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004673/* Test configuration for debugging, modelled after the ALC880 test
4674 * configuration.
4675 */
4676#ifdef CONFIG_SND_DEBUG
4677static hda_nid_t alc260_test_dac_nids[1] = {
4678 0x02,
4679};
4680static hda_nid_t alc260_test_adc_nids[2] = {
4681 0x04, 0x05,
4682};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004683/* For testing the ALC260, each input MUX needs its own definition since
4684 * the signal assignments are different. This assumes that the first ADC
4685 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004686 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004687static struct hda_input_mux alc260_test_capture_sources[2] = {
4688 {
4689 .num_items = 7,
4690 .items = {
4691 { "MIC1 pin", 0x0 },
4692 { "MIC2 pin", 0x1 },
4693 { "LINE1 pin", 0x2 },
4694 { "LINE2 pin", 0x3 },
4695 { "CD pin", 0x4 },
4696 { "LINE-OUT pin", 0x5 },
4697 { "HP-OUT pin", 0x6 },
4698 },
4699 },
4700 {
4701 .num_items = 8,
4702 .items = {
4703 { "MIC1 pin", 0x0 },
4704 { "MIC2 pin", 0x1 },
4705 { "LINE1 pin", 0x2 },
4706 { "LINE2 pin", 0x3 },
4707 { "CD pin", 0x4 },
4708 { "Mixer", 0x5 },
4709 { "LINE-OUT pin", 0x6 },
4710 { "HP-OUT pin", 0x7 },
4711 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004712 },
4713};
4714static struct snd_kcontrol_new alc260_test_mixer[] = {
4715 /* Output driver widgets */
4716 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4717 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4718 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4719 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4720 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4721 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4722
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004723 /* Modes for retasking pin widgets
4724 * Note: the ALC260 doesn't seem to act on requests to enable mic
4725 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4726 * mention this restriction. At this stage it's not clear whether
4727 * this behaviour is intentional or is a hardware bug in chip
4728 * revisions available at least up until early 2006. Therefore for
4729 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4730 * choices, but if it turns out that the lack of mic bias for these
4731 * NIDs is intentional we could change their modes from
4732 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4733 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004734 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4735 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4736 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4737 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4738 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4739 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4740
4741 /* Loopback mixer controls */
4742 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4743 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4744 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4745 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4746 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4747 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4748 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4749 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4750 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4751 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4752 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4753 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4754 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4755 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4756 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4757 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004758
4759 /* Controls for GPIO pins, assuming they are configured as outputs */
4760 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4761 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4762 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4763 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4764
Jonathan Woithe92621f12006-02-28 11:47:47 +01004765 /* Switches to allow the digital IO pins to be enabled. The datasheet
4766 * is ambigious as to which NID is which; testing on laptops which
4767 * make this output available should provide clarification.
4768 */
4769 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4770 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4771
Jonathan Woithef8225f62008-01-08 12:16:54 +01004772 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4773 * this output to turn on an external amplifier.
4774 */
4775 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4776 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4777
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004778 { } /* end */
4779};
4780static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004781 /* Enable all GPIOs as outputs with an initial value of 0 */
4782 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4783 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4784 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4785
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004786 /* Enable retasking pins as output, initially without power amp */
4787 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4788 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4791 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4792 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4793
Jonathan Woithe92621f12006-02-28 11:47:47 +01004794 /* Disable digital (SPDIF) pins initially, but users can enable
4795 * them via a mixer switch. In the case of SPDIF-out, this initverb
4796 * payload also sets the generation to 0, output to be in "consumer"
4797 * PCM format, copyright asserted, no pre-emphasis and no validity
4798 * control.
4799 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004800 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4801 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4802
Jonathan Woithef7ace402006-02-28 11:46:14 +01004803 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004804 * OUT1 sum bus when acting as an output.
4805 */
4806 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4807 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4808 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4809 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4810
4811 /* Start with output sum widgets muted and their output gains at min */
4812 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4818 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4819 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4820 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4821
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004822 /* Unmute retasking pin widget output buffers since the default
4823 * state appears to be output. As the pin mode is changed by the
4824 * user the pin mode control will take care of enabling the pin's
4825 * input/output buffers as needed.
4826 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004827 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4831 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4832 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4833 /* Also unmute the mono-out pin widget */
4834 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4835
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004836 /* Mute capture amp left and right */
4837 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004838 /* Set ADC connection select to match default mixer setting (mic1
4839 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004840 */
4841 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4842
4843 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004844 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004845 */
4846 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4847 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4848
4849 /* Mute all inputs to mixer widget (even unconnected ones) */
4850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4858
4859 { }
4860};
4861#endif
4862
Takashi Iwai63300792008-01-24 15:31:36 +01004863#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4864#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004866#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4867#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4868
Kailang Yangdf694da2005-12-05 19:42:22 +01004869/*
4870 * for BIOS auto-configuration
4871 */
4872
4873static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4874 const char *pfx)
4875{
4876 hda_nid_t nid_vol;
4877 unsigned long vol_val, sw_val;
4878 char name[32];
4879 int err;
4880
4881 if (nid >= 0x0f && nid < 0x11) {
4882 nid_vol = nid - 0x7;
4883 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4884 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4885 } else if (nid == 0x11) {
4886 nid_vol = nid - 0x7;
4887 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4888 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4889 } else if (nid >= 0x12 && nid <= 0x15) {
4890 nid_vol = 0x08;
4891 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4892 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4893 } else
4894 return 0; /* N/A */
4895
4896 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004897 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4898 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004899 return err;
4900 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004901 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4902 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004903 return err;
4904 return 1;
4905}
4906
4907/* add playback controls from the parsed DAC table */
4908static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4909 const struct auto_pin_cfg *cfg)
4910{
4911 hda_nid_t nid;
4912 int err;
4913
4914 spec->multiout.num_dacs = 1;
4915 spec->multiout.dac_nids = spec->private_dac_nids;
4916 spec->multiout.dac_nids[0] = 0x02;
4917
4918 nid = cfg->line_out_pins[0];
4919 if (nid) {
4920 err = alc260_add_playback_controls(spec, nid, "Front");
4921 if (err < 0)
4922 return err;
4923 }
4924
Takashi Iwai82bc9552006-03-21 11:24:42 +01004925 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004926 if (nid) {
4927 err = alc260_add_playback_controls(spec, nid, "Speaker");
4928 if (err < 0)
4929 return err;
4930 }
4931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004932 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004933 if (nid) {
4934 err = alc260_add_playback_controls(spec, nid, "Headphone");
4935 if (err < 0)
4936 return err;
4937 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004939}
4940
4941/* create playback/capture controls for input pins */
4942static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4943 const struct auto_pin_cfg *cfg)
4944{
Kailang Yangdf694da2005-12-05 19:42:22 +01004945 struct hda_input_mux *imux = &spec->private_imux;
4946 int i, err, idx;
4947
4948 for (i = 0; i < AUTO_PIN_LAST; i++) {
4949 if (cfg->input_pins[i] >= 0x12) {
4950 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004951 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004952 auto_pin_cfg_labels[i], idx,
4953 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004954 if (err < 0)
4955 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 imux->items[imux->num_items].label =
4957 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004958 imux->items[imux->num_items].index = idx;
4959 imux->num_items++;
4960 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004962 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004963 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004964 auto_pin_cfg_labels[i], idx,
4965 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004966 if (err < 0)
4967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004968 imux->items[imux->num_items].label =
4969 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004970 imux->items[imux->num_items].index = idx;
4971 imux->num_items++;
4972 }
4973 }
4974 return 0;
4975}
4976
4977static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4978 hda_nid_t nid, int pin_type,
4979 int sel_idx)
4980{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004981 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 /* need the manual connection? */
4983 if (nid >= 0x12) {
4984 int idx = nid - 0x12;
4985 snd_hda_codec_write(codec, idx + 0x0b, 0,
4986 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004987 }
4988}
4989
4990static void alc260_auto_init_multi_out(struct hda_codec *codec)
4991{
4992 struct alc_spec *spec = codec->spec;
4993 hda_nid_t nid;
4994
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004995 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004996 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004997 if (nid) {
4998 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4999 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5000 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005001
Takashi Iwai82bc9552006-03-21 11:24:42 +01005002 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005003 if (nid)
5004 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5005
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005006 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005008 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005009}
Kailang Yangdf694da2005-12-05 19:42:22 +01005010
5011#define ALC260_PIN_CD_NID 0x16
5012static void alc260_auto_init_analog_input(struct hda_codec *codec)
5013{
5014 struct alc_spec *spec = codec->spec;
5015 int i;
5016
5017 for (i = 0; i < AUTO_PIN_LAST; i++) {
5018 hda_nid_t nid = spec->autocfg.input_pins[i];
5019 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005020 snd_hda_codec_write(codec, nid, 0,
5021 AC_VERB_SET_PIN_WIDGET_CONTROL,
5022 i <= AUTO_PIN_FRONT_MIC ?
5023 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005024 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005025 snd_hda_codec_write(codec, nid, 0,
5026 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005027 AMP_OUT_MUTE);
5028 }
5029 }
5030}
5031
5032/*
5033 * generic initialization of ADC, input mixers and output mixers
5034 */
5035static struct hda_verb alc260_volume_init_verbs[] = {
5036 /*
5037 * Unmute ADC0-1 and set the default input to mic-in
5038 */
5039 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5040 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5041 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5042 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5043
5044 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5045 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005046 * Note: PASD motherboards uses the Line In 2 as the input for
5047 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 */
5049 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005050 /* mute analog inputs */
5051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005056
5057 /*
5058 * Set up output mixers (0x08 - 0x0a)
5059 */
5060 /* set vol=0 to output mixers */
5061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5064 /* set up input amps for analog loopback */
5065 /* Amp Indices: DAC = 0, mixer = 1 */
5066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5068 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5070 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5072
5073 { }
5074};
5075
5076static int alc260_parse_auto_config(struct hda_codec *codec)
5077{
5078 struct alc_spec *spec = codec->spec;
5079 unsigned int wcap;
5080 int err;
5081 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5082
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005083 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5084 alc260_ignore);
5085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005087 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5088 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005089 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005090 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005091 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005092 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5093 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005094 return err;
5095
5096 spec->multiout.max_channels = 2;
5097
5098 if (spec->autocfg.dig_out_pin)
5099 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5100 if (spec->kctl_alloc)
5101 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5102
5103 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5104
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005105 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005106 spec->input_mux = &spec->private_imux;
5107
5108 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005109 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005110 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005111 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005112 spec->adc_nids = alc260_adc_nids_alt;
5113 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5114 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005115 } else {
5116 spec->adc_nids = alc260_adc_nids;
5117 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5118 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005119 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005120 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005121
5122 return 1;
5123}
5124
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005125/* additional initialization for auto-configuration model */
5126static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005127{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005128 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005129 alc260_auto_init_multi_out(codec);
5130 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005131 if (spec->unsol_event)
5132 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005133}
5134
Takashi Iwaicb53c622007-08-10 17:21:45 +02005135#ifdef CONFIG_SND_HDA_POWER_SAVE
5136static struct hda_amp_list alc260_loopbacks[] = {
5137 { 0x07, HDA_INPUT, 0 },
5138 { 0x07, HDA_INPUT, 1 },
5139 { 0x07, HDA_INPUT, 2 },
5140 { 0x07, HDA_INPUT, 3 },
5141 { 0x07, HDA_INPUT, 4 },
5142 { } /* end */
5143};
5144#endif
5145
Kailang Yangdf694da2005-12-05 19:42:22 +01005146/*
5147 * ALC260 configurations
5148 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005149static const char *alc260_models[ALC260_MODEL_LAST] = {
5150 [ALC260_BASIC] = "basic",
5151 [ALC260_HP] = "hp",
5152 [ALC260_HP_3013] = "hp-3013",
5153 [ALC260_FUJITSU_S702X] = "fujitsu",
5154 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005155 [ALC260_WILL] = "will",
5156 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005157#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005158 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005159#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005160 [ALC260_AUTO] = "auto",
5161};
5162
5163static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005164 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005165 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005166 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005167 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005168 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5169 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5170 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5171 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5172 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5173 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5174 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5175 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5176 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5177 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5178 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5179 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005180 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005181 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005182 {}
5183};
5184
Kailang Yangdf694da2005-12-05 19:42:22 +01005185static struct alc_config_preset alc260_presets[] = {
5186 [ALC260_BASIC] = {
5187 .mixers = { alc260_base_output_mixer,
5188 alc260_input_mixer,
5189 alc260_pc_beep_mixer,
5190 alc260_capture_mixer },
5191 .init_verbs = { alc260_init_verbs },
5192 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5193 .dac_nids = alc260_dac_nids,
5194 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5195 .adc_nids = alc260_adc_nids,
5196 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5197 .channel_mode = alc260_modes,
5198 .input_mux = &alc260_capture_source,
5199 },
5200 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005201 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 alc260_input_mixer,
5203 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005204 .init_verbs = { alc260_init_verbs,
5205 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005206 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5207 .dac_nids = alc260_dac_nids,
5208 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5209 .adc_nids = alc260_hp_adc_nids,
5210 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5211 .channel_mode = alc260_modes,
5212 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005213 .unsol_event = alc260_hp_unsol_event,
5214 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005215 },
5216 [ALC260_HP_3013] = {
5217 .mixers = { alc260_hp_3013_mixer,
5218 alc260_input_mixer,
5219 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005220 .init_verbs = { alc260_hp_3013_init_verbs,
5221 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005222 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5223 .dac_nids = alc260_dac_nids,
5224 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5225 .adc_nids = alc260_hp_adc_nids,
5226 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5227 .channel_mode = alc260_modes,
5228 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005229 .unsol_event = alc260_hp_3013_unsol_event,
5230 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005231 },
5232 [ALC260_FUJITSU_S702X] = {
5233 .mixers = { alc260_fujitsu_mixer,
5234 alc260_capture_mixer },
5235 .init_verbs = { alc260_fujitsu_init_verbs },
5236 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5237 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005238 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5239 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5241 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005242 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5243 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005244 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005245 [ALC260_ACER] = {
5246 .mixers = { alc260_acer_mixer,
5247 alc260_capture_mixer },
5248 .init_verbs = { alc260_acer_init_verbs },
5249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5250 .dac_nids = alc260_dac_nids,
5251 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5252 .adc_nids = alc260_dual_adc_nids,
5253 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5254 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005255 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5256 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005257 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005258 [ALC260_WILL] = {
5259 .mixers = { alc260_will_mixer,
5260 alc260_capture_mixer },
5261 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5262 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5263 .dac_nids = alc260_dac_nids,
5264 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5265 .adc_nids = alc260_adc_nids,
5266 .dig_out_nid = ALC260_DIGOUT_NID,
5267 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5268 .channel_mode = alc260_modes,
5269 .input_mux = &alc260_capture_source,
5270 },
5271 [ALC260_REPLACER_672V] = {
5272 .mixers = { alc260_replacer_672v_mixer,
5273 alc260_capture_mixer },
5274 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5276 .dac_nids = alc260_dac_nids,
5277 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5278 .adc_nids = alc260_adc_nids,
5279 .dig_out_nid = ALC260_DIGOUT_NID,
5280 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5281 .channel_mode = alc260_modes,
5282 .input_mux = &alc260_capture_source,
5283 .unsol_event = alc260_replacer_672v_unsol_event,
5284 .init_hook = alc260_replacer_672v_automute,
5285 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005286#ifdef CONFIG_SND_DEBUG
5287 [ALC260_TEST] = {
5288 .mixers = { alc260_test_mixer,
5289 alc260_capture_mixer },
5290 .init_verbs = { alc260_test_init_verbs },
5291 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5292 .dac_nids = alc260_test_dac_nids,
5293 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5294 .adc_nids = alc260_test_adc_nids,
5295 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5296 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005297 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5298 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005299 },
5300#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005301};
5302
Linus Torvalds1da177e2005-04-16 15:20:36 -07005303static int patch_alc260(struct hda_codec *codec)
5304{
5305 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005307
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005308 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005309 if (spec == NULL)
5310 return -ENOMEM;
5311
5312 codec->spec = spec;
5313
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005314 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5315 alc260_models,
5316 alc260_cfg_tbl);
5317 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005318 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5319 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005320 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005321 }
5322
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 if (board_config == ALC260_AUTO) {
5324 /* automatic parse from the BIOS config */
5325 err = alc260_parse_auto_config(codec);
5326 if (err < 0) {
5327 alc_free(codec);
5328 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005329 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005330 printk(KERN_INFO
5331 "hda_codec: Cannot set up configuration "
5332 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005333 board_config = ALC260_BASIC;
5334 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005335 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336
Kailang Yangdf694da2005-12-05 19:42:22 +01005337 if (board_config != ALC260_AUTO)
5338 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005339
5340 spec->stream_name_analog = "ALC260 Analog";
5341 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5342 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5343
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005344 spec->stream_name_digital = "ALC260 Digital";
5345 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5346 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5347
Takashi Iwai2134ea42008-01-10 16:53:55 +01005348 spec->vmaster_nid = 0x08;
5349
Linus Torvalds1da177e2005-04-16 15:20:36 -07005350 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005352 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005353#ifdef CONFIG_SND_HDA_POWER_SAVE
5354 if (!spec->loopback.amplist)
5355 spec->loopback.amplist = alc260_loopbacks;
5356#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005357
5358 return 0;
5359}
5360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005361
Linus Torvalds1da177e2005-04-16 15:20:36 -07005362/*
5363 * ALC882 support
5364 *
5365 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5366 * configuration. Each pin widget can choose any input DACs and a mixer.
5367 * Each ADC is connected from a mixer of all inputs. This makes possible
5368 * 6-channel independent captures.
5369 *
5370 * In addition, an independent DAC for the multi-playback (not used in this
5371 * driver yet).
5372 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005373#define ALC882_DIGOUT_NID 0x06
5374#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005375
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005376static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005377 { 8, NULL }
5378};
5379
5380static hda_nid_t alc882_dac_nids[4] = {
5381 /* front, rear, clfe, rear_surr */
5382 0x02, 0x03, 0x04, 0x05
5383};
5384
Kailang Yangdf694da2005-12-05 19:42:22 +01005385/* identical with ALC880 */
5386#define alc882_adc_nids alc880_adc_nids
5387#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388
Takashi Iwaie1406342008-02-11 18:32:32 +01005389static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5390static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5391
Linus Torvalds1da177e2005-04-16 15:20:36 -07005392/* input MUX */
5393/* FIXME: should be a matrix-type input source selection */
5394
5395static struct hda_input_mux alc882_capture_source = {
5396 .num_items = 4,
5397 .items = {
5398 { "Mic", 0x0 },
5399 { "Front Mic", 0x1 },
5400 { "Line", 0x2 },
5401 { "CD", 0x4 },
5402 },
5403};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404#define alc882_mux_enum_info alc_mux_enum_info
5405#define alc882_mux_enum_get alc_mux_enum_get
5406
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005407static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5408 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005409{
5410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5411 struct alc_spec *spec = codec->spec;
5412 const struct hda_input_mux *imux = spec->input_mux;
5413 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005414 hda_nid_t nid = spec->capsrc_nids ?
5415 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005416 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5417 unsigned int i, idx;
5418
5419 idx = ucontrol->value.enumerated.item[0];
5420 if (idx >= imux->num_items)
5421 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005422 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005423 return 0;
5424 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005425 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5426 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005427 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005428 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005429 }
5430 *cur_val = idx;
5431 return 1;
5432}
5433
Kailang Yangdf694da2005-12-05 19:42:22 +01005434/*
Kailang Yang272a5272007-05-14 11:00:38 +02005435 * 2ch mode
5436 */
5437static struct hda_verb alc882_3ST_ch2_init[] = {
5438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5440 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5441 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5442 { } /* end */
5443};
5444
5445/*
5446 * 6ch mode
5447 */
5448static struct hda_verb alc882_3ST_ch6_init[] = {
5449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5451 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5452 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5453 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5454 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5455 { } /* end */
5456};
5457
5458static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5459 { 2, alc882_3ST_ch2_init },
5460 { 6, alc882_3ST_ch6_init },
5461};
5462
5463/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005464 * 6ch mode
5465 */
5466static struct hda_verb alc882_sixstack_ch6_init[] = {
5467 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5468 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5469 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5470 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5471 { } /* end */
5472};
5473
5474/*
5475 * 8ch mode
5476 */
5477static struct hda_verb alc882_sixstack_ch8_init[] = {
5478 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5482 { } /* end */
5483};
5484
5485static struct hda_channel_mode alc882_sixstack_modes[2] = {
5486 { 6, alc882_sixstack_ch6_init },
5487 { 8, alc882_sixstack_ch8_init },
5488};
5489
Takashi Iwai87350ad2007-08-16 18:19:38 +02005490/*
5491 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5492 */
5493
5494/*
5495 * 2ch mode
5496 */
5497static struct hda_verb alc885_mbp_ch2_init[] = {
5498 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5499 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5500 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5501 { } /* end */
5502};
5503
5504/*
5505 * 6ch mode
5506 */
5507static struct hda_verb alc885_mbp_ch6_init[] = {
5508 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5509 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5510 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5511 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5513 { } /* end */
5514};
5515
5516static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5517 { 2, alc885_mbp_ch2_init },
5518 { 6, alc885_mbp_ch6_init },
5519};
5520
5521
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5523 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5524 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005525static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005527 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005528 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005529 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005530 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5531 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005532 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5533 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005534 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005535 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5539 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5540 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005542 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005545 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5547 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5548 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005549 { } /* end */
5550};
5551
Takashi Iwai87350ad2007-08-16 18:19:38 +02005552static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5554 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5555 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5556 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5558 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5560 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005561 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5563 { } /* end */
5564};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005565static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5575 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5576 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5577 { } /* end */
5578};
5579
Kailang Yang272a5272007-05-14 11:00:38 +02005580static struct snd_kcontrol_new alc882_targa_mixer[] = {
5581 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5582 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005593 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005594 { } /* end */
5595};
5596
5597/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5598 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5599 */
5600static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5602 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5604 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5609 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5610 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5611 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5612 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005614 { } /* end */
5615};
5616
Takashi Iwai914759b2007-09-06 14:52:04 +02005617static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5619 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5621 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5622 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5626 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5628 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5629 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5630 { } /* end */
5631};
5632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5634 {
5635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5636 .name = "Channel Mode",
5637 .info = alc_ch_mode_info,
5638 .get = alc_ch_mode_get,
5639 .put = alc_ch_mode_put,
5640 },
5641 { } /* end */
5642};
5643
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644static struct hda_verb alc882_init_verbs[] = {
5645 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005649 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005653 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005662 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005665 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005666 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005670 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005671 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005672 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005674 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005675 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005676 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005677 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005678 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5681 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5684 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5687 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005693
5694 /* FIXME: use matrix-type input source selection */
5695 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5696 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005701 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5711 /* ADC1: mute amp left and right */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005713 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005714 /* ADC2: mute amp left and right */
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005717 /* ADC3: mute amp left and right */
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005719 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005720
5721 { }
5722};
5723
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005724static struct hda_verb alc882_eapd_verbs[] = {
5725 /* change to EAPD mode */
5726 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005727 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005728 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005729};
5730
Tobin Davis9102cd12006-12-15 10:02:12 +01005731/* Mac Pro test */
5732static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5734 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5738 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5739 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5740 { } /* end */
5741};
5742
5743static struct hda_verb alc882_macpro_init_verbs[] = {
5744 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5748 /* Front Pin: output 0 (0x0c) */
5749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5751 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5752 /* Front Mic pin: input vref at 80% */
5753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5755 /* Speaker: output */
5756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5759 /* Headphone output (output 0 - 0x0c) */
5760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5762 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5763
5764 /* FIXME: use matrix-type input source selection */
5765 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5766 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5771 /* Input mixer2 */
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5776 /* Input mixer3 */
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5781 /* ADC1: mute amp left and right */
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5784 /* ADC2: mute amp left and right */
5785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5786 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5787 /* ADC3: mute amp left and right */
5788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5789 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5790
5791 { }
5792};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005793
Takashi Iwai87350ad2007-08-16 18:19:38 +02005794/* Macbook Pro rev3 */
5795static struct hda_verb alc885_mbp3_init_verbs[] = {
5796 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5800 /* Rear mixer */
5801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5804 /* Front Pin: output 0 (0x0c) */
5805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5807 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5808 /* HP Pin: output 0 (0x0d) */
5809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5812 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5813 /* Mic (rear) pin: input vref at 80% */
5814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5815 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5816 /* Front Mic pin: input vref at 80% */
5817 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5819 /* Line In pin: use output 1 when in LineOut mode */
5820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5822 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5823
5824 /* FIXME: use matrix-type input source selection */
5825 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5826 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5831 /* Input mixer2 */
5832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5836 /* Input mixer3 */
5837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5841 /* ADC1: mute amp left and right */
5842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5843 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5844 /* ADC2: mute amp left and right */
5845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5847 /* ADC3: mute amp left and right */
5848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5849 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5850
5851 { }
5852};
5853
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005854/* iMac 24 mixer. */
5855static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5856 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5857 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5858 { } /* end */
5859};
5860
5861/* iMac 24 init verbs. */
5862static struct hda_verb alc885_imac24_init_verbs[] = {
5863 /* Internal speakers: output 0 (0x0c) */
5864 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5866 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5867 /* Internal speakers: output 0 (0x0c) */
5868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5870 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5871 /* Headphone: output 0 (0x0c) */
5872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5874 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5876 /* Front Mic: input vref at 80% */
5877 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5878 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5879 { }
5880};
5881
5882/* Toggle speaker-output according to the hp-jack state */
5883static void alc885_imac24_automute(struct hda_codec *codec)
5884{
5885 unsigned int present;
5886
5887 present = snd_hda_codec_read(codec, 0x14, 0,
5888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005889 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5891 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5892 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005893}
5894
5895/* Processes unsolicited events. */
5896static void alc885_imac24_unsol_event(struct hda_codec *codec,
5897 unsigned int res)
5898{
5899 /* Headphone insertion or removal. */
5900 if ((res >> 26) == ALC880_HP_EVENT)
5901 alc885_imac24_automute(codec);
5902}
5903
Takashi Iwai87350ad2007-08-16 18:19:38 +02005904static void alc885_mbp3_automute(struct hda_codec *codec)
5905{
5906 unsigned int present;
5907
5908 present = snd_hda_codec_read(codec, 0x15, 0,
5909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5910 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5911 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5912 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5913 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5914
5915}
5916static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5917 unsigned int res)
5918{
5919 /* Headphone insertion or removal. */
5920 if ((res >> 26) == ALC880_HP_EVENT)
5921 alc885_mbp3_automute(codec);
5922}
5923
5924
Kailang Yang272a5272007-05-14 11:00:38 +02005925static struct hda_verb alc882_targa_verbs[] = {
5926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5928
5929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5931
5932 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5934 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5935
5936 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5937 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5938 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5939 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5940 { } /* end */
5941};
5942
5943/* toggle speaker-output according to the hp-jack state */
5944static void alc882_targa_automute(struct hda_codec *codec)
5945{
5946 unsigned int present;
5947
5948 present = snd_hda_codec_read(codec, 0x14, 0,
5949 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005950 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005952 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5953 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005954}
5955
5956static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5957{
5958 /* Looks like the unsol event is incompatible with the standard
5959 * definition. 4bit tag is placed at 26 bit!
5960 */
5961 if (((res >> 26) == ALC880_HP_EVENT)) {
5962 alc882_targa_automute(codec);
5963 }
5964}
5965
5966static struct hda_verb alc882_asus_a7j_verbs[] = {
5967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5969
5970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5973
5974 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5976 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5977
5978 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5979 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5980 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5981 { } /* end */
5982};
5983
Takashi Iwai914759b2007-09-06 14:52:04 +02005984static struct hda_verb alc882_asus_a7m_verbs[] = {
5985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5987
5988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5991
5992 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5994 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5995
5996 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5997 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5999 { } /* end */
6000};
6001
Tobin Davis9102cd12006-12-15 10:02:12 +01006002static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6003{
6004 unsigned int gpiostate, gpiomask, gpiodir;
6005
6006 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6007 AC_VERB_GET_GPIO_DATA, 0);
6008
6009 if (!muted)
6010 gpiostate |= (1 << pin);
6011 else
6012 gpiostate &= ~(1 << pin);
6013
6014 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6015 AC_VERB_GET_GPIO_MASK, 0);
6016 gpiomask |= (1 << pin);
6017
6018 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6019 AC_VERB_GET_GPIO_DIRECTION, 0);
6020 gpiodir |= (1 << pin);
6021
6022
6023 snd_hda_codec_write(codec, codec->afg, 0,
6024 AC_VERB_SET_GPIO_MASK, gpiomask);
6025 snd_hda_codec_write(codec, codec->afg, 0,
6026 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6027
6028 msleep(1);
6029
6030 snd_hda_codec_write(codec, codec->afg, 0,
6031 AC_VERB_SET_GPIO_DATA, gpiostate);
6032}
6033
Takashi Iwai7debbe52007-08-16 15:01:03 +02006034/* set up GPIO at initialization */
6035static void alc885_macpro_init_hook(struct hda_codec *codec)
6036{
6037 alc882_gpio_mute(codec, 0, 0);
6038 alc882_gpio_mute(codec, 1, 0);
6039}
6040
6041/* set up GPIO and update auto-muting at initialization */
6042static void alc885_imac24_init_hook(struct hda_codec *codec)
6043{
6044 alc885_macpro_init_hook(codec);
6045 alc885_imac24_automute(codec);
6046}
6047
Kailang Yangdf694da2005-12-05 19:42:22 +01006048/*
6049 * generic initialization of ADC, input mixers and output mixers
6050 */
6051static struct hda_verb alc882_auto_init_verbs[] = {
6052 /*
6053 * Unmute ADC0-2 and set the default input to mic-in
6054 */
6055 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6059 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6061
Takashi Iwaicb53c622007-08-10 17:21:45 +02006062 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006064 * Note: PASD motherboards uses the Line In 2 as the input for
6065 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 */
6067 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006073
6074 /*
6075 * Set up output mixers (0x0c - 0x0f)
6076 */
6077 /* set vol=0 to output mixers */
6078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6082 /* set up input amps for analog loopback */
6083 /* Amp Indices: DAC = 0, mixer = 1 */
6084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6092 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6093 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6094
6095 /* FIXME: use matrix-type input source selection */
6096 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6097 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6102 /* Input mixer2 */
6103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6107 /* Input mixer3 */
6108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6112
6113 { }
6114};
6115
6116/* capture mixer elements */
6117static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6122 {
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* The multiple "Capture Source" controls confuse alsamixer
6125 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006126 */
6127 /* .name = "Capture Source", */
6128 .name = "Input Source",
6129 .count = 2,
6130 .info = alc882_mux_enum_info,
6131 .get = alc882_mux_enum_get,
6132 .put = alc882_mux_enum_put,
6133 },
6134 { } /* end */
6135};
6136
6137static struct snd_kcontrol_new alc882_capture_mixer[] = {
6138 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6139 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6140 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6143 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6144 {
6145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6146 /* The multiple "Capture Source" controls confuse alsamixer
6147 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006148 */
6149 /* .name = "Capture Source", */
6150 .name = "Input Source",
6151 .count = 3,
6152 .info = alc882_mux_enum_info,
6153 .get = alc882_mux_enum_get,
6154 .put = alc882_mux_enum_put,
6155 },
6156 { } /* end */
6157};
6158
Takashi Iwaicb53c622007-08-10 17:21:45 +02006159#ifdef CONFIG_SND_HDA_POWER_SAVE
6160#define alc882_loopbacks alc880_loopbacks
6161#endif
6162
Kailang Yangdf694da2005-12-05 19:42:22 +01006163/* pcm configuration: identiacal with ALC880 */
6164#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6165#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6166#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6167#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6168
6169/*
6170 * configuration and preset
6171 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006172static const char *alc882_models[ALC882_MODEL_LAST] = {
6173 [ALC882_3ST_DIG] = "3stack-dig",
6174 [ALC882_6ST_DIG] = "6stack-dig",
6175 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006176 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006177 [ALC882_TARGA] = "targa",
6178 [ALC882_ASUS_A7J] = "asus-a7j",
6179 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006180 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006181 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006182 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006183 [ALC882_AUTO] = "auto",
6184};
6185
6186static struct snd_pci_quirk alc882_cfg_tbl[] = {
6187 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006188 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006189 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006190 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006191 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006192 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006193 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006194 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006195 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006196 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6197 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6198 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006199 {}
6200};
6201
6202static struct alc_config_preset alc882_presets[] = {
6203 [ALC882_3ST_DIG] = {
6204 .mixers = { alc882_base_mixer },
6205 .init_verbs = { alc882_init_verbs },
6206 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6207 .dac_nids = alc882_dac_nids,
6208 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006209 .dig_in_nid = ALC882_DIGIN_NID,
6210 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6211 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006212 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 .input_mux = &alc882_capture_source,
6214 },
6215 [ALC882_6ST_DIG] = {
6216 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6217 .init_verbs = { alc882_init_verbs },
6218 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6219 .dac_nids = alc882_dac_nids,
6220 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 .dig_in_nid = ALC882_DIGIN_NID,
6222 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6223 .channel_mode = alc882_sixstack_modes,
6224 .input_mux = &alc882_capture_source,
6225 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006226 [ALC882_ARIMA] = {
6227 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6228 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6229 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6230 .dac_nids = alc882_dac_nids,
6231 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6232 .channel_mode = alc882_sixstack_modes,
6233 .input_mux = &alc882_capture_source,
6234 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006235 [ALC882_W2JC] = {
6236 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6237 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6238 alc880_gpio1_init_verbs },
6239 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6240 .dac_nids = alc882_dac_nids,
6241 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6242 .channel_mode = alc880_threestack_modes,
6243 .need_dac_fix = 1,
6244 .input_mux = &alc882_capture_source,
6245 .dig_out_nid = ALC882_DIGOUT_NID,
6246 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006247 [ALC885_MBP3] = {
6248 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6249 .init_verbs = { alc885_mbp3_init_verbs,
6250 alc880_gpio1_init_verbs },
6251 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6252 .dac_nids = alc882_dac_nids,
6253 .channel_mode = alc885_mbp_6ch_modes,
6254 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6255 .input_mux = &alc882_capture_source,
6256 .dig_out_nid = ALC882_DIGOUT_NID,
6257 .dig_in_nid = ALC882_DIGIN_NID,
6258 .unsol_event = alc885_mbp3_unsol_event,
6259 .init_hook = alc885_mbp3_automute,
6260 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006261 [ALC885_MACPRO] = {
6262 .mixers = { alc882_macpro_mixer },
6263 .init_verbs = { alc882_macpro_init_verbs },
6264 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6265 .dac_nids = alc882_dac_nids,
6266 .dig_out_nid = ALC882_DIGOUT_NID,
6267 .dig_in_nid = ALC882_DIGIN_NID,
6268 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6269 .channel_mode = alc882_ch_modes,
6270 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006271 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006272 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006273 [ALC885_IMAC24] = {
6274 .mixers = { alc885_imac24_mixer },
6275 .init_verbs = { alc885_imac24_init_verbs },
6276 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6277 .dac_nids = alc882_dac_nids,
6278 .dig_out_nid = ALC882_DIGOUT_NID,
6279 .dig_in_nid = ALC882_DIGIN_NID,
6280 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6281 .channel_mode = alc882_ch_modes,
6282 .input_mux = &alc882_capture_source,
6283 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006284 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006285 },
Kailang Yang272a5272007-05-14 11:00:38 +02006286 [ALC882_TARGA] = {
6287 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6288 alc882_capture_mixer },
6289 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6290 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6291 .dac_nids = alc882_dac_nids,
6292 .dig_out_nid = ALC882_DIGOUT_NID,
6293 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6294 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006295 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006296 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6297 .channel_mode = alc882_3ST_6ch_modes,
6298 .need_dac_fix = 1,
6299 .input_mux = &alc882_capture_source,
6300 .unsol_event = alc882_targa_unsol_event,
6301 .init_hook = alc882_targa_automute,
6302 },
6303 [ALC882_ASUS_A7J] = {
6304 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6305 alc882_capture_mixer },
6306 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6307 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6308 .dac_nids = alc882_dac_nids,
6309 .dig_out_nid = ALC882_DIGOUT_NID,
6310 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6311 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006312 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006313 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6314 .channel_mode = alc882_3ST_6ch_modes,
6315 .need_dac_fix = 1,
6316 .input_mux = &alc882_capture_source,
6317 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006318 [ALC882_ASUS_A7M] = {
6319 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6320 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6321 alc880_gpio1_init_verbs,
6322 alc882_asus_a7m_verbs },
6323 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6324 .dac_nids = alc882_dac_nids,
6325 .dig_out_nid = ALC882_DIGOUT_NID,
6326 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6327 .channel_mode = alc880_threestack_modes,
6328 .need_dac_fix = 1,
6329 .input_mux = &alc882_capture_source,
6330 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006331};
6332
6333
6334/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006335 * Pin config fixes
6336 */
6337enum {
6338 PINFIX_ABIT_AW9D_MAX
6339};
6340
6341static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6342 { 0x15, 0x01080104 }, /* side */
6343 { 0x16, 0x01011012 }, /* rear */
6344 { 0x17, 0x01016011 }, /* clfe */
6345 { }
6346};
6347
6348static const struct alc_pincfg *alc882_pin_fixes[] = {
6349 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6350};
6351
6352static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6353 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6354 {}
6355};
6356
6357/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006358 * BIOS auto configuration
6359 */
6360static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6361 hda_nid_t nid, int pin_type,
6362 int dac_idx)
6363{
6364 /* set as output */
6365 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006366 int idx;
6367
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006368 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6370 idx = 4;
6371 else
6372 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6374
6375}
6376
6377static void alc882_auto_init_multi_out(struct hda_codec *codec)
6378{
6379 struct alc_spec *spec = codec->spec;
6380 int i;
6381
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006382 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006384 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006385 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006387 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006388 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 }
6390}
6391
6392static void alc882_auto_init_hp_out(struct hda_codec *codec)
6393{
6394 struct alc_spec *spec = codec->spec;
6395 hda_nid_t pin;
6396
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006397 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006398 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006399 /* use dac 0 */
6400 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006401 pin = spec->autocfg.speaker_pins[0];
6402 if (pin)
6403 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006404}
6405
6406#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6407#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6408
6409static void alc882_auto_init_analog_input(struct hda_codec *codec)
6410{
6411 struct alc_spec *spec = codec->spec;
6412 int i;
6413
6414 for (i = 0; i < AUTO_PIN_LAST; i++) {
6415 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006416 unsigned int vref;
6417 if (!nid)
6418 continue;
6419 vref = PIN_IN;
6420 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006421 unsigned int pincap;
6422 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6423 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006424 AC_PINCAP_VREF_80)
6425 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006427 snd_hda_codec_write(codec, nid, 0,
6428 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6429 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6430 snd_hda_codec_write(codec, nid, 0,
6431 AC_VERB_SET_AMP_GAIN_MUTE,
6432 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006433 }
6434}
6435
Takashi Iwai776e1842007-08-29 15:07:11 +02006436/* add mic boosts if needed */
6437static int alc_auto_add_mic_boost(struct hda_codec *codec)
6438{
6439 struct alc_spec *spec = codec->spec;
6440 int err;
6441 hda_nid_t nid;
6442
6443 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006444 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006445 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6446 "Mic Boost",
6447 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6448 if (err < 0)
6449 return err;
6450 }
6451 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006452 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006453 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6454 "Front Mic Boost",
6455 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6456 if (err < 0)
6457 return err;
6458 }
6459 return 0;
6460}
6461
Kailang Yangdf694da2005-12-05 19:42:22 +01006462/* almost identical with ALC880 parser... */
6463static int alc882_parse_auto_config(struct hda_codec *codec)
6464{
6465 struct alc_spec *spec = codec->spec;
6466 int err = alc880_parse_auto_config(codec);
6467
6468 if (err < 0)
6469 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006470 else if (!err)
6471 return 0; /* no config found */
6472
6473 err = alc_auto_add_mic_boost(codec);
6474 if (err < 0)
6475 return err;
6476
6477 /* hack - override the init verbs */
6478 spec->init_verbs[0] = alc882_auto_init_verbs;
6479
6480 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006481}
6482
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006483/* additional initialization for auto-configuration model */
6484static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006486 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 alc882_auto_init_multi_out(codec);
6488 alc882_auto_init_hp_out(codec);
6489 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006490 if (spec->unsol_event)
6491 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006492}
6493
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006494static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6495
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496static int patch_alc882(struct hda_codec *codec)
6497{
6498 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006499 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006500
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006501 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502 if (spec == NULL)
6503 return -ENOMEM;
6504
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505 codec->spec = spec;
6506
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006507 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6508 alc882_models,
6509 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006510
Kailang Yangdf694da2005-12-05 19:42:22 +01006511 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006512 /* Pick up systems that don't supply PCI SSID */
6513 switch (codec->subsystem_id) {
6514 case 0x106b0c00: /* Mac Pro */
6515 board_config = ALC885_MACPRO;
6516 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006517 case 0x106b1000: /* iMac 24 */
6518 board_config = ALC885_IMAC24;
6519 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006520 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006521 case 0x106b2c00: /* Macbook Pro rev3 */
6522 board_config = ALC885_MBP3;
6523 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006524 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006525 /* ALC889A is handled better as ALC888-compatible */
6526 if (codec->revision_id == 0x100103) {
6527 alc_free(codec);
6528 return patch_alc883(codec);
6529 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006530 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6531 "trying auto-probe from BIOS...\n");
6532 board_config = ALC882_AUTO;
6533 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006535
Takashi Iwaif95474e2007-07-10 00:47:43 +02006536 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6537
Kailang Yangdf694da2005-12-05 19:42:22 +01006538 if (board_config == ALC882_AUTO) {
6539 /* automatic parse from the BIOS config */
6540 err = alc882_parse_auto_config(codec);
6541 if (err < 0) {
6542 alc_free(codec);
6543 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006544 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006545 printk(KERN_INFO
6546 "hda_codec: Cannot set up configuration "
6547 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006548 board_config = ALC882_3ST_DIG;
6549 }
6550 }
6551
6552 if (board_config != ALC882_AUTO)
6553 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006554
Kailang Yang2f893282008-05-27 12:14:47 +02006555 if (codec->vendor_id == 0x10ec0885) {
6556 spec->stream_name_analog = "ALC885 Analog";
6557 spec->stream_name_digital = "ALC885 Digital";
6558 } else {
6559 spec->stream_name_analog = "ALC882 Analog";
6560 spec->stream_name_digital = "ALC882 Digital";
6561 }
6562
Kailang Yangdf694da2005-12-05 19:42:22 +01006563 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6564 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006565 /* FIXME: setup DAC5 */
6566 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6567 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006568
Kailang Yangdf694da2005-12-05 19:42:22 +01006569 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6570 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006572 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006574 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006575 /* get type */
6576 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006577 if (wcap != AC_WID_AUD_IN) {
6578 spec->adc_nids = alc882_adc_nids_alt;
6579 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006580 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006581 spec->mixers[spec->num_mixers] =
6582 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006583 spec->num_mixers++;
6584 } else {
6585 spec->adc_nids = alc882_adc_nids;
6586 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006587 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6589 spec->num_mixers++;
6590 }
6591 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006592
Takashi Iwai2134ea42008-01-10 16:53:55 +01006593 spec->vmaster_nid = 0x0c;
6594
Linus Torvalds1da177e2005-04-16 15:20:36 -07006595 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006596 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006597 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006598#ifdef CONFIG_SND_HDA_POWER_SAVE
6599 if (!spec->loopback.amplist)
6600 spec->loopback.amplist = alc882_loopbacks;
6601#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006602
6603 return 0;
6604}
6605
6606/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006607 * ALC883 support
6608 *
6609 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6610 * configuration. Each pin widget can choose any input DACs and a mixer.
6611 * Each ADC is connected from a mixer of all inputs. This makes possible
6612 * 6-channel independent captures.
6613 *
6614 * In addition, an independent DAC for the multi-playback (not used in this
6615 * driver yet).
6616 */
6617#define ALC883_DIGOUT_NID 0x06
6618#define ALC883_DIGIN_NID 0x0a
6619
6620static hda_nid_t alc883_dac_nids[4] = {
6621 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006622 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006623};
6624
6625static hda_nid_t alc883_adc_nids[2] = {
6626 /* ADC1-2 */
6627 0x08, 0x09,
6628};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006629
Takashi Iwaie1406342008-02-11 18:32:32 +01006630static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6631
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006632/* input MUX */
6633/* FIXME: should be a matrix-type input source selection */
6634
6635static struct hda_input_mux alc883_capture_source = {
6636 .num_items = 4,
6637 .items = {
6638 { "Mic", 0x0 },
6639 { "Front Mic", 0x1 },
6640 { "Line", 0x2 },
6641 { "CD", 0x4 },
6642 },
6643};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006644
Jiang zhe17bba1b2008-06-04 12:11:07 +02006645static struct hda_input_mux alc883_3stack_6ch_intel = {
6646 .num_items = 4,
6647 .items = {
6648 { "Mic", 0x1 },
6649 { "Front Mic", 0x0 },
6650 { "Line", 0x2 },
6651 { "CD", 0x4 },
6652 },
6653};
6654
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006655static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6656 .num_items = 2,
6657 .items = {
6658 { "Mic", 0x1 },
6659 { "Line", 0x2 },
6660 },
6661};
6662
Kailang Yang272a5272007-05-14 11:00:38 +02006663static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6664 .num_items = 4,
6665 .items = {
6666 { "Mic", 0x0 },
6667 { "iMic", 0x1 },
6668 { "Line", 0x2 },
6669 { "CD", 0x4 },
6670 },
6671};
6672
Jiang zhefb97dc62008-03-06 11:07:11 +01006673static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6674 .num_items = 2,
6675 .items = {
6676 { "Mic", 0x0 },
6677 { "Int Mic", 0x1 },
6678 },
6679};
6680
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006681#define alc883_mux_enum_info alc_mux_enum_info
6682#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006683/* ALC883 has the ALC882-type input selection */
6684#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006685
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006686/*
6687 * 2ch mode
6688 */
6689static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6690 { 2, NULL }
6691};
6692
6693/*
6694 * 2ch mode
6695 */
6696static struct hda_verb alc883_3ST_ch2_init[] = {
6697 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6698 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6701 { } /* end */
6702};
6703
6704/*
Tobin Davisb2011312007-09-17 12:45:11 +02006705 * 4ch mode
6706 */
6707static struct hda_verb alc883_3ST_ch4_init[] = {
6708 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6709 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6714};
6715
6716/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717 * 6ch mode
6718 */
6719static struct hda_verb alc883_3ST_ch6_init[] = {
6720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6722 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6723 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6724 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6725 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6726 { } /* end */
6727};
6728
Tobin Davisb2011312007-09-17 12:45:11 +02006729static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006730 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006731 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006732 { 6, alc883_3ST_ch6_init },
6733};
6734
6735/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006736 * 2ch mode
6737 */
6738static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6739 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6740 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6742 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6743 { } /* end */
6744};
6745
6746/*
6747 * 4ch mode
6748 */
6749static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6750 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6751 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6752 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6753 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6754 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6755 { } /* end */
6756};
6757
6758/*
6759 * 6ch mode
6760 */
6761static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6762 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6763 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6764 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6768 { } /* end */
6769};
6770
6771static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6772 { 2, alc883_3ST_ch2_intel_init },
6773 { 4, alc883_3ST_ch4_intel_init },
6774 { 6, alc883_3ST_ch6_intel_init },
6775};
6776
6777/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006778 * 6ch mode
6779 */
6780static struct hda_verb alc883_sixstack_ch6_init[] = {
6781 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6782 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6783 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6785 { } /* end */
6786};
6787
6788/*
6789 * 8ch mode
6790 */
6791static struct hda_verb alc883_sixstack_ch8_init[] = {
6792 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6793 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6795 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { } /* end */
6797};
6798
6799static struct hda_channel_mode alc883_sixstack_modes[2] = {
6800 { 6, alc883_sixstack_ch6_init },
6801 { 8, alc883_sixstack_ch8_init },
6802};
6803
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006804static struct hda_verb alc883_medion_eapd_verbs[] = {
6805 /* eanable EAPD on medion laptop */
6806 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6807 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6808 { }
6809};
6810
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006811/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6812 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6813 */
6814
6815static struct snd_kcontrol_new alc883_base_mixer[] = {
6816 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6817 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6819 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6822 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6823 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6824 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6825 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6834 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006835 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6837 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6838 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6841 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6843 {
6844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6845 /* .name = "Capture Source", */
6846 .name = "Input Source",
6847 .count = 2,
6848 .info = alc883_mux_enum_info,
6849 .get = alc883_mux_enum_get,
6850 .put = alc883_mux_enum_put,
6851 },
6852 { } /* end */
6853};
6854
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006855static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6858 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6860 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6861 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6870 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6871 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6872 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6873 {
6874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6875 /* .name = "Capture Source", */
6876 .name = "Input Source",
6877 .count = 2,
6878 .info = alc883_mux_enum_info,
6879 .get = alc883_mux_enum_get,
6880 .put = alc883_mux_enum_put,
6881 },
6882 { } /* end */
6883};
6884
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01006885static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01006886 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6887 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6888 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6893 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6894 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6895 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6897 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6899 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6900 {
6901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6902 /* .name = "Capture Source", */
6903 .name = "Input Source",
6904 .count = 2,
6905 .info = alc883_mux_enum_info,
6906 .get = alc883_mux_enum_get,
6907 .put = alc883_mux_enum_put,
6908 },
6909 { } /* end */
6910};
6911
Jiang zhefb97dc62008-03-06 11:07:11 +01006912static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6913 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6914 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6916 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6920 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6921 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6922 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6925 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6926 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6927 {
6928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6929 /* .name = "Capture Source", */
6930 .name = "Input Source",
6931 .count = 2,
6932 .info = alc883_mux_enum_info,
6933 .get = alc883_mux_enum_get,
6934 .put = alc883_mux_enum_put,
6935 },
6936 { } /* end */
6937};
6938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006939static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006948 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6953 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6954 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6955 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6956 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6957 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6958 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6959 {
6960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6961 /* .name = "Capture Source", */
6962 .name = "Input Source",
6963 .count = 2,
6964 .info = alc883_mux_enum_info,
6965 .get = alc883_mux_enum_get,
6966 .put = alc883_mux_enum_put,
6967 },
6968 { } /* end */
6969};
6970
6971static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6984 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006986 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006989 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6991 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6992 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6994 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6995 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6996 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6997 {
6998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6999 /* .name = "Capture Source", */
7000 .name = "Input Source",
7001 .count = 2,
7002 .info = alc883_mux_enum_info,
7003 .get = alc883_mux_enum_get,
7004 .put = alc883_mux_enum_put,
7005 },
7006 { } /* end */
7007};
7008
Jiang zhe17bba1b2008-06-04 12:11:07 +02007009static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7010 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7011 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7013 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7015 HDA_OUTPUT),
7016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7017 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7018 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7030 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7031 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7033 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7034 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7035 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7036 {
7037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7038 /* .name = "Capture Source", */
7039 .name = "Input Source",
7040 .count = 2,
7041 .info = alc883_mux_enum_info,
7042 .get = alc883_mux_enum_get,
7043 .put = alc883_mux_enum_put,
7044 },
7045 { } /* end */
7046};
7047
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007048static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7050 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7055 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
7056 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7058 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007066 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7068 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7069 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7071 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7072
7073 {
7074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7075 /* .name = "Capture Source", */
7076 .name = "Input Source",
7077 .count = 1,
7078 .info = alc883_mux_enum_info,
7079 .get = alc883_mux_enum_get,
7080 .put = alc883_mux_enum_put,
7081 },
7082 { } /* end */
7083};
7084
Kailang Yangccc656c2006-10-17 12:32:26 +02007085static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7090 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7102 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7103 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7104 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7105 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7106 {
7107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7108 /* .name = "Capture Source", */
7109 .name = "Input Source",
7110 .count = 2,
7111 .info = alc883_mux_enum_info,
7112 .get = alc883_mux_enum_get,
7113 .put = alc883_mux_enum_put,
7114 },
7115 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007116};
Kailang Yangccc656c2006-10-17 12:32:26 +02007117
7118static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7121 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007125 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007127 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7128 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7129 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007130 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7131 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7132 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7133 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7134 {
7135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7136 /* .name = "Capture Source", */
7137 .name = "Input Source",
7138 .count = 2,
7139 .info = alc883_mux_enum_info,
7140 .get = alc883_mux_enum_get,
7141 .put = alc883_mux_enum_put,
7142 },
7143 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007144};
Kailang Yangccc656c2006-10-17 12:32:26 +02007145
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007146static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007149 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7150 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007151 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7156 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7157 {
7158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7159 /* .name = "Capture Source", */
7160 .name = "Input Source",
7161 .count = 1,
7162 .info = alc883_mux_enum_info,
7163 .get = alc883_mux_enum_get,
7164 .put = alc883_mux_enum_put,
7165 },
7166 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007167};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007168
Kailang Yang272a5272007-05-14 11:00:38 +02007169static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7170 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7177 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7178 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7180 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7181 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7182 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7183 {
7184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7185 /* .name = "Capture Source", */
7186 .name = "Input Source",
7187 .count = 2,
7188 .info = alc883_mux_enum_info,
7189 .get = alc883_mux_enum_get,
7190 .put = alc883_mux_enum_put,
7191 },
7192 { } /* end */
7193};
7194
7195static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7198 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7199 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7200 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7205 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7206 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7207 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7208 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7209 {
7210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7211 /* .name = "Capture Source", */
7212 .name = "Input Source",
7213 .count = 2,
7214 .info = alc883_mux_enum_info,
7215 .get = alc883_mux_enum_get,
7216 .put = alc883_mux_enum_put,
7217 },
7218 { } /* end */
7219};
7220
Tobin Davis2880a8672007-08-07 11:50:26 +02007221static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007230 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7231 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7233 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7234 {
7235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7236 /* .name = "Capture Source", */
7237 .name = "Input Source",
7238 .count = 2,
7239 .info = alc883_mux_enum_info,
7240 .get = alc883_mux_enum_get,
7241 .put = alc883_mux_enum_put,
7242 },
7243 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007244};
Tobin Davis2880a8672007-08-07 11:50:26 +02007245
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007246static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7247 {
7248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7249 .name = "Channel Mode",
7250 .info = alc_ch_mode_info,
7251 .get = alc_ch_mode_get,
7252 .put = alc_ch_mode_put,
7253 },
7254 { } /* end */
7255};
7256
7257static struct hda_verb alc883_init_verbs[] = {
7258 /* ADC1: mute amp left and right */
7259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7260 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7261 /* ADC2: mute amp left and right */
7262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7264 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7268 /* Rear mixer */
7269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7272 /* CLFE mixer */
7273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7276 /* Side mixer */
7277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7280
Takashi Iwaicb53c622007-08-10 17:21:45 +02007281 /* mute analog input loopbacks */
7282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007287
7288 /* Front Pin: output 0 (0x0c) */
7289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7291 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7292 /* Rear Pin: output 1 (0x0d) */
7293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7296 /* CLFE Pin: output 2 (0x0e) */
7297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7299 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7300 /* Side Pin: output 3 (0x0f) */
7301 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7302 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7303 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7304 /* Mic (rear) pin: input vref at 80% */
7305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7307 /* Front Mic pin: input vref at 80% */
7308 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7310 /* Line In pin: input */
7311 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7313 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7317 /* CD pin widget for input */
7318 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7319
7320 /* FIXME: use matrix-type input source selection */
7321 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7322 /* Input mixer2 */
7323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7327 /* Input mixer3 */
7328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7332 { }
7333};
7334
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007335/* toggle speaker-output according to the hp-jack state */
7336static void alc883_mitac_hp_automute(struct hda_codec *codec)
7337{
7338 unsigned int present;
7339
7340 present = snd_hda_codec_read(codec, 0x15, 0,
7341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7342 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7343 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7344 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7345 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7346}
7347
7348/* auto-toggle front mic */
7349/*
7350static void alc883_mitac_mic_automute(struct hda_codec *codec)
7351{
7352 unsigned int present;
7353 unsigned char bits;
7354
7355 present = snd_hda_codec_read(codec, 0x18, 0,
7356 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7357 bits = present ? HDA_AMP_MUTE : 0;
7358 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7359}
7360*/
7361
7362static void alc883_mitac_automute(struct hda_codec *codec)
7363{
7364 alc883_mitac_hp_automute(codec);
7365 /* alc883_mitac_mic_automute(codec); */
7366}
7367
7368static void alc883_mitac_unsol_event(struct hda_codec *codec,
7369 unsigned int res)
7370{
7371 switch (res >> 26) {
7372 case ALC880_HP_EVENT:
7373 alc883_mitac_hp_automute(codec);
7374 break;
7375 case ALC880_MIC_EVENT:
7376 /* alc883_mitac_mic_automute(codec); */
7377 break;
7378 }
7379}
7380
7381static struct hda_verb alc883_mitac_verbs[] = {
7382 /* HP */
7383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7385 /* Subwoofer */
7386 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7388
7389 /* enable unsolicited event */
7390 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7391 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7392
7393 { } /* end */
7394};
7395
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007396static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007397 /* HP */
7398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7400 /* Int speaker */
7401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7403
7404 /* enable unsolicited event */
7405 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007407
7408 { } /* end */
7409};
7410
Jiang zhefb97dc62008-03-06 11:07:11 +01007411static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7412 /* HP */
7413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7415 /* Subwoofer */
7416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7418
7419 /* enable unsolicited event */
7420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7421
7422 { } /* end */
7423};
7424
Kailang Yangccc656c2006-10-17 12:32:26 +02007425static struct hda_verb alc883_tagra_verbs[] = {
7426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7428
7429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431
7432 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7433 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7434 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7435
7436 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007437 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7438 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7439 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007440
7441 { } /* end */
7442};
7443
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007444static struct hda_verb alc883_lenovo_101e_verbs[] = {
7445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7447 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7448 { } /* end */
7449};
7450
Kailang Yang272a5272007-05-14 11:00:38 +02007451static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7456 { } /* end */
7457};
7458
7459static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7464 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7465 { } /* end */
7466};
7467
Kailang Yang189609a2007-08-20 11:31:23 +02007468static struct hda_verb alc883_haier_w66_verbs[] = {
7469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7471
7472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7473
7474 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7476 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7478 { } /* end */
7479};
7480
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007481static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007482 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007483 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7484 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007485 { }
7486};
7487
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007488static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007489 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7490 { }
7491};
7492
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007493static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007494 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7495 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7496 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7497 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7498 { }
7499};
7500
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007501static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007502 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7503 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7505 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7506 { }
7507};
7508
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007509static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7510 { 2, alc888_3st_hp_2ch_init },
7511 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007512};
7513
Kailang Yang272a5272007-05-14 11:00:38 +02007514/* toggle front-jack and RCA according to the hp-jack state */
7515static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7516{
7517 unsigned int present;
7518
7519 present = snd_hda_codec_read(codec, 0x1b, 0,
7520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007521 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7522 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7523 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7524 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007525}
7526
7527/* toggle RCA according to the front-jack state */
7528static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7529{
7530 unsigned int present;
7531
7532 present = snd_hda_codec_read(codec, 0x14, 0,
7533 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007534 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7535 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007536}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007537
Kailang Yang272a5272007-05-14 11:00:38 +02007538static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7539 unsigned int res)
7540{
7541 if ((res >> 26) == ALC880_HP_EVENT)
7542 alc888_lenovo_ms7195_front_automute(codec);
7543 if ((res >> 26) == ALC880_FRONT_EVENT)
7544 alc888_lenovo_ms7195_rca_automute(codec);
7545}
7546
7547static struct hda_verb alc883_medion_md2_verbs[] = {
7548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7550
7551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7552
7553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7554 { } /* end */
7555};
7556
7557/* toggle speaker-output according to the hp-jack state */
7558static void alc883_medion_md2_automute(struct hda_codec *codec)
7559{
7560 unsigned int present;
7561
7562 present = snd_hda_codec_read(codec, 0x14, 0,
7563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007564 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7565 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007566}
7567
7568static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7569 unsigned int res)
7570{
7571 if ((res >> 26) == ALC880_HP_EVENT)
7572 alc883_medion_md2_automute(codec);
7573}
7574
Kailang Yangccc656c2006-10-17 12:32:26 +02007575/* toggle speaker-output according to the hp-jack state */
7576static void alc883_tagra_automute(struct hda_codec *codec)
7577{
7578 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007579 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007580
7581 present = snd_hda_codec_read(codec, 0x14, 0,
7582 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007583 bits = present ? HDA_AMP_MUTE : 0;
7584 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7585 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007586 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7587 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007588}
7589
7590static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7591{
7592 if ((res >> 26) == ALC880_HP_EVENT)
7593 alc883_tagra_automute(codec);
7594}
7595
Jiang zhe368c7a92008-03-04 11:20:33 +01007596/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007597static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007598{
7599 unsigned int present;
7600 unsigned char bits;
7601
7602 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7603 & AC_PINSENSE_PRESENCE;
7604 bits = present ? HDA_AMP_MUTE : 0;
7605 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7606 HDA_AMP_MUTE, bits);
7607}
7608
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007609static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7610{
7611 unsigned int present;
7612
7613 present = snd_hda_codec_read(codec, 0x18, 0,
7614 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7615 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7616 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7617}
7618
7619static void alc883_clevo_m720_automute(struct hda_codec *codec)
7620{
7621 alc883_clevo_m720_hp_automute(codec);
7622 alc883_clevo_m720_mic_automute(codec);
7623}
7624
7625static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007626 unsigned int res)
7627{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007628 switch (res >> 26) {
7629 case ALC880_HP_EVENT:
7630 alc883_clevo_m720_hp_automute(codec);
7631 break;
7632 case ALC880_MIC_EVENT:
7633 alc883_clevo_m720_mic_automute(codec);
7634 break;
7635 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007636}
7637
Jiang zhefb97dc62008-03-06 11:07:11 +01007638/* toggle speaker-output according to the hp-jack state */
7639static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7640{
7641 unsigned int present;
7642 unsigned char bits;
7643
7644 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7645 & AC_PINSENSE_PRESENCE;
7646 bits = present ? HDA_AMP_MUTE : 0;
7647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7648 HDA_AMP_MUTE, bits);
7649}
7650
7651static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7652 unsigned int res)
7653{
7654 if ((res >> 26) == ALC880_HP_EVENT)
7655 alc883_2ch_fujitsu_pi2515_automute(codec);
7656}
7657
Kailang Yang189609a2007-08-20 11:31:23 +02007658static void alc883_haier_w66_automute(struct hda_codec *codec)
7659{
7660 unsigned int present;
7661 unsigned char bits;
7662
7663 present = snd_hda_codec_read(codec, 0x1b, 0,
7664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7665 bits = present ? 0x80 : 0;
7666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7667 0x80, bits);
7668}
7669
7670static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7671 unsigned int res)
7672{
7673 if ((res >> 26) == ALC880_HP_EVENT)
7674 alc883_haier_w66_automute(codec);
7675}
7676
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007677static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7678{
7679 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007680 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007681
7682 present = snd_hda_codec_read(codec, 0x14, 0,
7683 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007684 bits = present ? HDA_AMP_MUTE : 0;
7685 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7686 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007687}
7688
7689static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7690{
7691 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007692 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007693
7694 present = snd_hda_codec_read(codec, 0x1b, 0,
7695 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007696 bits = present ? HDA_AMP_MUTE : 0;
7697 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7698 HDA_AMP_MUTE, bits);
7699 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7700 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007701}
7702
7703static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7704 unsigned int res)
7705{
7706 if ((res >> 26) == ALC880_HP_EVENT)
7707 alc883_lenovo_101e_all_automute(codec);
7708 if ((res >> 26) == ALC880_FRONT_EVENT)
7709 alc883_lenovo_101e_ispeaker_automute(codec);
7710}
7711
Takashi Iwai676a9b52007-08-16 15:23:35 +02007712/* toggle speaker-output according to the hp-jack state */
7713static void alc883_acer_aspire_automute(struct hda_codec *codec)
7714{
7715 unsigned int present;
7716
7717 present = snd_hda_codec_read(codec, 0x14, 0,
7718 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7720 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7721 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7722 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7723}
7724
7725static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7726 unsigned int res)
7727{
7728 if ((res >> 26) == ALC880_HP_EVENT)
7729 alc883_acer_aspire_automute(codec);
7730}
7731
Kailang Yangd1a991a2007-08-15 16:21:59 +02007732static struct hda_verb alc883_acer_eapd_verbs[] = {
7733 /* HP Pin: output 0 (0x0c) */
7734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7736 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7737 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007741 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7742 /* eanable EAPD on medion laptop */
7743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7744 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007745 /* enable unsolicited event */
7746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007747 { }
7748};
7749
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007750static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7751{
7752 unsigned int present;
7753
7754 present = snd_hda_codec_read(codec, 0x1b, 0,
7755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7756 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7757 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7758 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7759 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7760 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7761 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7762 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7764}
7765
7766static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7767 unsigned int res)
7768{
7769 switch (res >> 26) {
7770 case ALC880_HP_EVENT:
7771 printk("hp_event\n");
7772 alc888_6st_dell_front_automute(codec);
7773 break;
7774 }
7775}
7776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007777/*
7778 * generic initialization of ADC, input mixers and output mixers
7779 */
7780static struct hda_verb alc883_auto_init_verbs[] = {
7781 /*
7782 * Unmute ADC0-2 and set the default input to mic-in
7783 */
7784 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7786 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7788
Takashi Iwaicb53c622007-08-10 17:21:45 +02007789 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007790 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007791 * Note: PASD motherboards uses the Line In 2 as the input for
7792 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007793 */
7794 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007800
7801 /*
7802 * Set up output mixers (0x0c - 0x0f)
7803 */
7804 /* set vol=0 to output mixers */
7805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7808 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7809 /* set up input amps for analog loopback */
7810 /* Amp Indices: DAC = 0, mixer = 1 */
7811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7819 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7820 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7821
7822 /* FIXME: use matrix-type input source selection */
7823 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7824 /* Input mixer1 */
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007828 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7830 /* Input mixer2 */
7831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007834 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007836
7837 { }
7838};
7839
7840/* capture mixer elements */
7841static struct snd_kcontrol_new alc883_capture_mixer[] = {
7842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7846 {
7847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7848 /* The multiple "Capture Source" controls confuse alsamixer
7849 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007850 */
7851 /* .name = "Capture Source", */
7852 .name = "Input Source",
7853 .count = 2,
7854 .info = alc882_mux_enum_info,
7855 .get = alc882_mux_enum_get,
7856 .put = alc882_mux_enum_put,
7857 },
7858 { } /* end */
7859};
7860
Takashi Iwaicb53c622007-08-10 17:21:45 +02007861#ifdef CONFIG_SND_HDA_POWER_SAVE
7862#define alc883_loopbacks alc880_loopbacks
7863#endif
7864
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007865/* pcm configuration: identiacal with ALC880 */
7866#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7867#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007868#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007869#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7870#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7871
7872/*
7873 * configuration and preset
7874 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007875static const char *alc883_models[ALC883_MODEL_LAST] = {
7876 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7877 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7878 [ALC883_3ST_6ch] = "3stack-6ch",
7879 [ALC883_6ST_DIG] = "6stack-dig",
7880 [ALC883_TARGA_DIG] = "targa-dig",
7881 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007882 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02007883 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007884 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007885 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007886 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007887 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007888 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7889 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007890 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007891 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007892 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007893 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007894 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01007895 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02007896 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007897 [ALC883_AUTO] = "auto",
7898};
7899
7900static struct snd_pci_quirk alc883_cfg_tbl[] = {
7901 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007902 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7903 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7904 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7905 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007906 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007907 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007908 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7909 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01007910 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007911 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02007912 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007913 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007914 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7915 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7916 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007917 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007918 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7919 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7920 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02007921 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007922 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007923 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007924 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7925 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7926 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7927 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7928 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7929 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7930 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7931 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7932 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007933 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7934 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007935 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01007936 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007937 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007938 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007939 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007940 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007941 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7942 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007943 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007944 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007945 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007946 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007947 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007948 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007949 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7950 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007951 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007952 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007953 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007954 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7955 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007956 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007957 {}
7958};
7959
7960static struct alc_config_preset alc883_presets[] = {
7961 [ALC883_3ST_2ch_DIG] = {
7962 .mixers = { alc883_3ST_2ch_mixer },
7963 .init_verbs = { alc883_init_verbs },
7964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7965 .dac_nids = alc883_dac_nids,
7966 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967 .dig_in_nid = ALC883_DIGIN_NID,
7968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7969 .channel_mode = alc883_3ST_2ch_modes,
7970 .input_mux = &alc883_capture_source,
7971 },
7972 [ALC883_3ST_6ch_DIG] = {
7973 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7974 .init_verbs = { alc883_init_verbs },
7975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7976 .dac_nids = alc883_dac_nids,
7977 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007978 .dig_in_nid = ALC883_DIGIN_NID,
7979 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7980 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007981 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007982 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007983 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007984 [ALC883_3ST_6ch] = {
7985 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7986 .init_verbs = { alc883_init_verbs },
7987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7988 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007989 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7990 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007991 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007992 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007993 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02007994 [ALC883_3ST_6ch_INTEL] = {
7995 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
7996 .init_verbs = { alc883_init_verbs },
7997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7998 .dac_nids = alc883_dac_nids,
7999 .dig_out_nid = ALC883_DIGOUT_NID,
8000 .dig_in_nid = ALC883_DIGIN_NID,
8001 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8002 .channel_mode = alc883_3ST_6ch_intel_modes,
8003 .need_dac_fix = 1,
8004 .input_mux = &alc883_3stack_6ch_intel,
8005 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008006 [ALC883_6ST_DIG] = {
8007 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8008 .init_verbs = { alc883_init_verbs },
8009 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8010 .dac_nids = alc883_dac_nids,
8011 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008012 .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 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008017 [ALC883_TARGA_DIG] = {
8018 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8019 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8021 .dac_nids = alc883_dac_nids,
8022 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008023 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8024 .channel_mode = alc883_3ST_6ch_modes,
8025 .need_dac_fix = 1,
8026 .input_mux = &alc883_capture_source,
8027 .unsol_event = alc883_tagra_unsol_event,
8028 .init_hook = alc883_tagra_automute,
8029 },
8030 [ALC883_TARGA_2ch_DIG] = {
8031 .mixers = { alc883_tagra_2ch_mixer},
8032 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8034 .dac_nids = alc883_dac_nids,
8035 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008036 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8037 .channel_mode = alc883_3ST_2ch_modes,
8038 .input_mux = &alc883_capture_source,
8039 .unsol_event = alc883_tagra_unsol_event,
8040 .init_hook = alc883_tagra_automute,
8041 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008042 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008043 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008044 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8045 * and the headphone jack. Turn this on and rely on the
8046 * standard mute methods whenever the user wants to turn
8047 * these outputs off.
8048 */
8049 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8050 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8051 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8053 .channel_mode = alc883_3ST_2ch_modes,
8054 .input_mux = &alc883_capture_source,
8055 },
Tobin Davis2880a8672007-08-07 11:50:26 +02008056 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008057 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008058 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02008059 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8060 .dac_nids = alc883_dac_nids,
8061 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02008062 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8063 .channel_mode = alc883_3ST_2ch_modes,
8064 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008065 .unsol_event = alc883_acer_aspire_unsol_event,
8066 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008067 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008068 [ALC883_MEDION] = {
8069 .mixers = { alc883_fivestack_mixer,
8070 alc883_chmode_mixer },
8071 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008072 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8074 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008075 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8076 .channel_mode = alc883_sixstack_modes,
8077 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008078 },
Kailang Yang272a5272007-05-14 11:00:38 +02008079 [ALC883_MEDION_MD2] = {
8080 .mixers = { alc883_medion_md2_mixer},
8081 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8083 .dac_nids = alc883_dac_nids,
8084 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008085 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8086 .channel_mode = alc883_3ST_2ch_modes,
8087 .input_mux = &alc883_capture_source,
8088 .unsol_event = alc883_medion_md2_unsol_event,
8089 .init_hook = alc883_medion_md2_automute,
8090 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008091 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008092 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008093 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8095 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8097 .channel_mode = alc883_3ST_2ch_modes,
8098 .input_mux = &alc883_capture_source,
8099 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008100 [ALC883_CLEVO_M720] = {
8101 .mixers = { alc883_clevo_m720_mixer },
8102 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8104 .dac_nids = alc883_dac_nids,
8105 .dig_out_nid = ALC883_DIGOUT_NID,
8106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8107 .channel_mode = alc883_3ST_2ch_modes,
8108 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008109 .unsol_event = alc883_clevo_m720_unsol_event,
8110 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008111 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008112 [ALC883_LENOVO_101E_2ch] = {
8113 .mixers = { alc883_lenovo_101e_2ch_mixer},
8114 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8116 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008117 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8118 .channel_mode = alc883_3ST_2ch_modes,
8119 .input_mux = &alc883_lenovo_101e_capture_source,
8120 .unsol_event = alc883_lenovo_101e_unsol_event,
8121 .init_hook = alc883_lenovo_101e_all_automute,
8122 },
Kailang Yang272a5272007-05-14 11:00:38 +02008123 [ALC883_LENOVO_NB0763] = {
8124 .mixers = { alc883_lenovo_nb0763_mixer },
8125 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8127 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008128 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8129 .channel_mode = alc883_3ST_2ch_modes,
8130 .need_dac_fix = 1,
8131 .input_mux = &alc883_lenovo_nb0763_capture_source,
8132 .unsol_event = alc883_medion_md2_unsol_event,
8133 .init_hook = alc883_medion_md2_automute,
8134 },
8135 [ALC888_LENOVO_MS7195_DIG] = {
8136 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8137 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8139 .dac_nids = alc883_dac_nids,
8140 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8142 .channel_mode = alc883_3ST_6ch_modes,
8143 .need_dac_fix = 1,
8144 .input_mux = &alc883_capture_source,
8145 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8146 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008147 },
8148 [ALC883_HAIER_W66] = {
8149 .mixers = { alc883_tagra_2ch_mixer},
8150 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8151 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8152 .dac_nids = alc883_dac_nids,
8153 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8155 .channel_mode = alc883_3ST_2ch_modes,
8156 .input_mux = &alc883_capture_source,
8157 .unsol_event = alc883_haier_w66_unsol_event,
8158 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008159 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008160 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008161 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008162 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008163 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8164 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008165 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8166 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008167 .need_dac_fix = 1,
8168 .input_mux = &alc883_capture_source,
8169 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008170 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008171 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008172 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8173 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8174 .dac_nids = alc883_dac_nids,
8175 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008176 .dig_in_nid = ALC883_DIGIN_NID,
8177 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8178 .channel_mode = alc883_sixstack_modes,
8179 .input_mux = &alc883_capture_source,
8180 .unsol_event = alc888_6st_dell_unsol_event,
8181 .init_hook = alc888_6st_dell_front_automute,
8182 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008183 [ALC883_MITAC] = {
8184 .mixers = { alc883_mitac_mixer },
8185 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8187 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008188 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8189 .channel_mode = alc883_3ST_2ch_modes,
8190 .input_mux = &alc883_capture_source,
8191 .unsol_event = alc883_mitac_unsol_event,
8192 .init_hook = alc883_mitac_automute,
8193 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008194 [ALC883_FUJITSU_PI2515] = {
8195 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8196 .init_verbs = { alc883_init_verbs,
8197 alc883_2ch_fujitsu_pi2515_verbs},
8198 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8199 .dac_nids = alc883_dac_nids,
8200 .dig_out_nid = ALC883_DIGOUT_NID,
8201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8202 .channel_mode = alc883_3ST_2ch_modes,
8203 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8204 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8205 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8206 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008207};
8208
8209
8210/*
8211 * BIOS auto configuration
8212 */
8213static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8214 hda_nid_t nid, int pin_type,
8215 int dac_idx)
8216{
8217 /* set as output */
8218 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008219 int idx;
8220
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008221 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008222 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8223 idx = 4;
8224 else
8225 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008226 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8227
8228}
8229
8230static void alc883_auto_init_multi_out(struct hda_codec *codec)
8231{
8232 struct alc_spec *spec = codec->spec;
8233 int i;
8234
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008235 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008236 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008237 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008238 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008239 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008240 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008241 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008242 }
8243}
8244
8245static void alc883_auto_init_hp_out(struct hda_codec *codec)
8246{
8247 struct alc_spec *spec = codec->spec;
8248 hda_nid_t pin;
8249
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008250 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008251 if (pin) /* connect to front */
8252 /* use dac 0 */
8253 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008254 pin = spec->autocfg.speaker_pins[0];
8255 if (pin)
8256 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008257}
8258
8259#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8260#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8261
8262static void alc883_auto_init_analog_input(struct hda_codec *codec)
8263{
8264 struct alc_spec *spec = codec->spec;
8265 int i;
8266
8267 for (i = 0; i < AUTO_PIN_LAST; i++) {
8268 hda_nid_t nid = spec->autocfg.input_pins[i];
8269 if (alc883_is_input_pin(nid)) {
8270 snd_hda_codec_write(codec, nid, 0,
8271 AC_VERB_SET_PIN_WIDGET_CONTROL,
8272 (i <= AUTO_PIN_FRONT_MIC ?
8273 PIN_VREF80 : PIN_IN));
8274 if (nid != ALC883_PIN_CD_NID)
8275 snd_hda_codec_write(codec, nid, 0,
8276 AC_VERB_SET_AMP_GAIN_MUTE,
8277 AMP_OUT_MUTE);
8278 }
8279 }
8280}
8281
8282/* almost identical with ALC880 parser... */
8283static int alc883_parse_auto_config(struct hda_codec *codec)
8284{
8285 struct alc_spec *spec = codec->spec;
8286 int err = alc880_parse_auto_config(codec);
8287
8288 if (err < 0)
8289 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008290 else if (!err)
8291 return 0; /* no config found */
8292
8293 err = alc_auto_add_mic_boost(codec);
8294 if (err < 0)
8295 return err;
8296
8297 /* hack - override the init verbs */
8298 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008299 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8300 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008301
8302 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008303}
8304
8305/* additional initialization for auto-configuration model */
8306static void alc883_auto_init(struct hda_codec *codec)
8307{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008308 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008309 alc883_auto_init_multi_out(codec);
8310 alc883_auto_init_hp_out(codec);
8311 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008312 if (spec->unsol_event)
8313 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008314}
8315
8316static int patch_alc883(struct hda_codec *codec)
8317{
8318 struct alc_spec *spec;
8319 int err, board_config;
8320
8321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8322 if (spec == NULL)
8323 return -ENOMEM;
8324
8325 codec->spec = spec;
8326
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008327 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8328
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008329 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8330 alc883_models,
8331 alc883_cfg_tbl);
8332 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008333 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8334 "trying auto-probe from BIOS...\n");
8335 board_config = ALC883_AUTO;
8336 }
8337
8338 if (board_config == ALC883_AUTO) {
8339 /* automatic parse from the BIOS config */
8340 err = alc883_parse_auto_config(codec);
8341 if (err < 0) {
8342 alc_free(codec);
8343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008344 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008345 printk(KERN_INFO
8346 "hda_codec: Cannot set up configuration "
8347 "from BIOS. Using base mode...\n");
8348 board_config = ALC883_3ST_2ch_DIG;
8349 }
8350 }
8351
8352 if (board_config != ALC883_AUTO)
8353 setup_preset(spec, &alc883_presets[board_config]);
8354
Kailang Yang2f893282008-05-27 12:14:47 +02008355 switch (codec->vendor_id) {
8356 case 0x10ec0888:
8357 spec->stream_name_analog = "ALC888 Analog";
8358 spec->stream_name_digital = "ALC888 Digital";
8359 break;
8360 case 0x10ec0889:
8361 spec->stream_name_analog = "ALC889 Analog";
8362 spec->stream_name_digital = "ALC889 Digital";
8363 break;
8364 default:
8365 spec->stream_name_analog = "ALC883 Analog";
8366 spec->stream_name_digital = "ALC883 Digital";
8367 break;
8368 }
8369
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008370 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8371 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008372 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008374 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8375 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8376
Takashi Iwaie1406342008-02-11 18:32:32 +01008377 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8378 spec->adc_nids = alc883_adc_nids;
8379 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380
Takashi Iwai2134ea42008-01-10 16:53:55 +01008381 spec->vmaster_nid = 0x0c;
8382
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008383 codec->patch_ops = alc_patch_ops;
8384 if (board_config == ALC883_AUTO)
8385 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008386 else if (codec->vendor_id == 0x10ec0888)
8387 spec->init_hook = alc888_coef_init;
8388
Takashi Iwaicb53c622007-08-10 17:21:45 +02008389#ifdef CONFIG_SND_HDA_POWER_SAVE
8390 if (!spec->loopback.amplist)
8391 spec->loopback.amplist = alc883_loopbacks;
8392#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008393
8394 return 0;
8395}
8396
8397/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008398 * ALC262 support
8399 */
8400
8401#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8402#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8403
8404#define alc262_dac_nids alc260_dac_nids
8405#define alc262_adc_nids alc882_adc_nids
8406#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008407#define alc262_capsrc_nids alc882_capsrc_nids
8408#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008409
8410#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008411#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008412
8413static struct snd_kcontrol_new alc262_base_mixer[] = {
8414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8415 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8416 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8417 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008423 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008425 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008426 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008427 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008428 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8429 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8430 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8431 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008432 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008433};
8434
Kailang Yangccc656c2006-10-17 12:32:26 +02008435static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008445 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8446 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008447 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008448 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008449 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008450 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8452 { } /* end */
8453};
8454
Takashi Iwaice875f02008-01-28 18:17:43 +01008455/* update HP, line and mono-out pins according to the master switch */
8456static void alc262_hp_master_update(struct hda_codec *codec)
8457{
8458 struct alc_spec *spec = codec->spec;
8459 int val = spec->master_sw;
8460
8461 /* HP & line-out */
8462 snd_hda_codec_write_cache(codec, 0x1b, 0,
8463 AC_VERB_SET_PIN_WIDGET_CONTROL,
8464 val ? PIN_HP : 0);
8465 snd_hda_codec_write_cache(codec, 0x15, 0,
8466 AC_VERB_SET_PIN_WIDGET_CONTROL,
8467 val ? PIN_HP : 0);
8468 /* mono (speaker) depending on the HP jack sense */
8469 val = val && !spec->jack_present;
8470 snd_hda_codec_write_cache(codec, 0x16, 0,
8471 AC_VERB_SET_PIN_WIDGET_CONTROL,
8472 val ? PIN_OUT : 0);
8473}
8474
8475static void alc262_hp_bpc_automute(struct hda_codec *codec)
8476{
8477 struct alc_spec *spec = codec->spec;
8478 unsigned int presence;
8479 presence = snd_hda_codec_read(codec, 0x1b, 0,
8480 AC_VERB_GET_PIN_SENSE, 0);
8481 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8482 alc262_hp_master_update(codec);
8483}
8484
8485static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8486{
8487 if ((res >> 26) != ALC880_HP_EVENT)
8488 return;
8489 alc262_hp_bpc_automute(codec);
8490}
8491
8492static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8493{
8494 struct alc_spec *spec = codec->spec;
8495 unsigned int presence;
8496 presence = snd_hda_codec_read(codec, 0x15, 0,
8497 AC_VERB_GET_PIN_SENSE, 0);
8498 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8499 alc262_hp_master_update(codec);
8500}
8501
8502static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8503 unsigned int res)
8504{
8505 if ((res >> 26) != ALC880_HP_EVENT)
8506 return;
8507 alc262_hp_wildwest_automute(codec);
8508}
8509
8510static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8511 struct snd_ctl_elem_value *ucontrol)
8512{
8513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8514 struct alc_spec *spec = codec->spec;
8515 *ucontrol->value.integer.value = spec->master_sw;
8516 return 0;
8517}
8518
8519static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8520 struct snd_ctl_elem_value *ucontrol)
8521{
8522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8523 struct alc_spec *spec = codec->spec;
8524 int val = !!*ucontrol->value.integer.value;
8525
8526 if (val == spec->master_sw)
8527 return 0;
8528 spec->master_sw = val;
8529 alc262_hp_master_update(codec);
8530 return 1;
8531}
8532
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008533static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008534 {
8535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8536 .name = "Master Playback Switch",
8537 .info = snd_ctl_boolean_mono_info,
8538 .get = alc262_hp_master_sw_get,
8539 .put = alc262_hp_master_sw_put,
8540 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008541 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8542 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008544 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8545 HDA_OUTPUT),
8546 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8547 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008553 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8556 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8557 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8558 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8559 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8560 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8561 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8562 { } /* end */
8563};
8564
Kailang Yangcd7509a2007-01-26 18:33:17 +01008565static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008566 {
8567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8568 .name = "Master Playback Switch",
8569 .info = snd_ctl_boolean_mono_info,
8570 .get = alc262_hp_master_sw_get,
8571 .put = alc262_hp_master_sw_put,
8572 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008573 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8574 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008577 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8578 HDA_OUTPUT),
8579 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8580 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008583 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008584 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8585 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8588 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8589 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8590 { } /* end */
8591};
8592
8593static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8594 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8595 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008596 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008597 { } /* end */
8598};
8599
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008600/* mute/unmute internal speaker according to the hp jack and mute state */
8601static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8602{
8603 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008604
8605 if (force || !spec->sense_updated) {
8606 unsigned int present;
8607 present = snd_hda_codec_read(codec, 0x15, 0,
8608 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008609 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008610 spec->sense_updated = 1;
8611 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8613 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008614}
8615
8616static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8617 unsigned int res)
8618{
8619 if ((res >> 26) != ALC880_HP_EVENT)
8620 return;
8621 alc262_hp_t5735_automute(codec, 1);
8622}
8623
8624static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8625{
8626 alc262_hp_t5735_automute(codec, 1);
8627}
8628
8629static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8631 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8637 { } /* end */
8638};
8639
8640static struct hda_verb alc262_hp_t5735_verbs[] = {
8641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8643
8644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8645 { }
8646};
8647
Kailang Yang8c427222008-01-10 13:03:59 +01008648static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008649 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008651 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8652 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8655 { } /* end */
8656};
8657
8658static struct hda_verb alc262_hp_rp5700_verbs[] = {
8659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8661 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8664 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8669 {}
8670};
8671
8672static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8673 .num_items = 1,
8674 .items = {
8675 { "Line", 0x1 },
8676 },
8677};
8678
Takashi Iwai0724ea22007-08-23 00:31:43 +02008679/* bind hp and internal speaker mute (with plug check) */
8680static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8681 struct snd_ctl_elem_value *ucontrol)
8682{
8683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8684 long *valp = ucontrol->value.integer.value;
8685 int change;
8686
8687 /* change hp mute */
8688 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8689 HDA_AMP_MUTE,
8690 valp[0] ? 0 : HDA_AMP_MUTE);
8691 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8692 HDA_AMP_MUTE,
8693 valp[1] ? 0 : HDA_AMP_MUTE);
8694 if (change) {
8695 /* change speaker according to HP jack state */
8696 struct alc_spec *spec = codec->spec;
8697 unsigned int mute;
8698 if (spec->jack_present)
8699 mute = HDA_AMP_MUTE;
8700 else
8701 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8702 HDA_OUTPUT, 0);
8703 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8704 HDA_AMP_MUTE, mute);
8705 }
8706 return change;
8707}
Takashi Iwai5b319542007-07-26 11:49:22 +02008708
Kailang Yang272a5272007-05-14 11:00:38 +02008709static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008710 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8711 {
8712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8713 .name = "Master Playback Switch",
8714 .info = snd_hda_mixer_amp_switch_info,
8715 .get = snd_hda_mixer_amp_switch_get,
8716 .put = alc262_sony_master_sw_put,
8717 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8718 },
Kailang Yang272a5272007-05-14 11:00:38 +02008719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8721 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8722 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8723 { } /* end */
8724};
8725
Kailang Yang83c34212007-07-05 11:43:05 +02008726static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8728 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8734 { } /* end */
8735};
Kailang Yang272a5272007-05-14 11:00:38 +02008736
Kailang Yangdf694da2005-12-05 19:42:22 +01008737#define alc262_capture_mixer alc882_capture_mixer
8738#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8739
8740/*
8741 * generic initialization of ADC, input mixers and output mixers
8742 */
8743static struct hda_verb alc262_init_verbs[] = {
8744 /*
8745 * Unmute ADC0-2 and set the default input to mic-in
8746 */
8747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8753
Takashi Iwaicb53c622007-08-10 17:21:45 +02008754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008755 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008756 * Note: PASD motherboards uses the Line In 2 as the input for
8757 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008758 */
8759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008765
8766 /*
8767 * Set up output mixers (0x0c - 0x0e)
8768 */
8769 /* set vol=0 to output mixers */
8770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8773 /* set up input amps for analog loopback */
8774 /* Amp Indices: DAC = 0, mixer = 1 */
8775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8781
8782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8788
8789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8794
8795 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8797
8798 /* FIXME: use matrix-type input source selection */
8799 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8800 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8805 /* Input mixer2 */
8806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8810 /* Input mixer3 */
8811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008815
8816 { }
8817};
8818
Kailang Yangccc656c2006-10-17 12:32:26 +02008819static struct hda_verb alc262_hippo_unsol_verbs[] = {
8820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8822 {}
8823};
8824
8825static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8826 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8829
8830 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8832 {}
8833};
8834
Kailang Yang272a5272007-05-14 11:00:38 +02008835static struct hda_verb alc262_sony_unsol_verbs[] = {
8836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8839
8840 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008842 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008843};
8844
Kailang Yangccc656c2006-10-17 12:32:26 +02008845/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008846static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008847{
8848 struct alc_spec *spec = codec->spec;
8849 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008850 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008851
Takashi Iwai5b319542007-07-26 11:49:22 +02008852 /* need to execute and sync at first */
8853 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8854 present = snd_hda_codec_read(codec, 0x15, 0,
8855 AC_VERB_GET_PIN_SENSE, 0);
8856 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008857 if (spec->jack_present) {
8858 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008859 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8860 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008861 } else {
8862 /* unmute internal speaker if necessary */
8863 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008864 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8865 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008866 }
8867}
8868
8869/* unsolicited event for HP jack sensing */
8870static void alc262_hippo_unsol_event(struct hda_codec *codec,
8871 unsigned int res)
8872{
8873 if ((res >> 26) != ALC880_HP_EVENT)
8874 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008875 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008876}
8877
Takashi Iwai5b319542007-07-26 11:49:22 +02008878static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008879{
Kailang Yangccc656c2006-10-17 12:32:26 +02008880 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008881 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008882
Takashi Iwai5b319542007-07-26 11:49:22 +02008883 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8884 present = snd_hda_codec_read(codec, 0x1b, 0,
8885 AC_VERB_GET_PIN_SENSE, 0);
8886 present = (present & 0x80000000) != 0;
8887 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008888 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008889 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8890 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008891 } else {
8892 /* unmute internal speaker if necessary */
8893 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008894 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8895 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008896 }
8897}
8898
8899/* unsolicited event for HP jack sensing */
8900static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8901 unsigned int res)
8902{
8903 if ((res >> 26) != ALC880_HP_EVENT)
8904 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008905 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008906}
8907
Takashi Iwai834be882006-03-01 14:16:17 +01008908/*
8909 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008910 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8911 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008912 */
8913
8914#define ALC_HP_EVENT 0x37
8915
8916static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01008921 {}
8922};
8923
Jiang zhe0e31daf2008-03-20 12:12:39 +01008924static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8926 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8927 {}
8928};
8929
Takashi Iwai834be882006-03-01 14:16:17 +01008930static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008931 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008932 .items = {
8933 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008934 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008935 { "CD", 0x4 },
8936 },
8937};
8938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008939static struct hda_input_mux alc262_HP_capture_source = {
8940 .num_items = 5,
8941 .items = {
8942 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008943 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008944 { "Line", 0x2 },
8945 { "CD", 0x4 },
8946 { "AUX IN", 0x6 },
8947 },
8948};
8949
zhejiangaccbe492007-08-31 12:36:05 +02008950static struct hda_input_mux alc262_HP_D7000_capture_source = {
8951 .num_items = 4,
8952 .items = {
8953 { "Mic", 0x0 },
8954 { "Front Mic", 0x2 },
8955 { "Line", 0x1 },
8956 { "CD", 0x4 },
8957 },
8958};
8959
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008960/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01008961static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8962{
8963 struct alc_spec *spec = codec->spec;
8964 unsigned int mute;
8965
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008966 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008967 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01008968 /* need to execute and sync at first */
8969 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008970 /* check laptop HP jack */
8971 present = snd_hda_codec_read(codec, 0x14, 0,
8972 AC_VERB_GET_PIN_SENSE, 0);
8973 /* need to execute and sync at first */
8974 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8975 /* check docking HP jack */
8976 present |= snd_hda_codec_read(codec, 0x1b, 0,
8977 AC_VERB_GET_PIN_SENSE, 0);
8978 if (present & AC_PINSENSE_PRESENCE)
8979 spec->jack_present = 1;
8980 else
8981 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01008982 spec->sense_updated = 1;
8983 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008984 /* unmute internal speaker only if both HPs are unplugged and
8985 * master switch is on
8986 */
8987 if (spec->jack_present)
8988 mute = HDA_AMP_MUTE;
8989 else
Takashi Iwai834be882006-03-01 14:16:17 +01008990 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008991 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8992 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008993}
8994
8995/* unsolicited event for HP jack sensing */
8996static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8997 unsigned int res)
8998{
8999 if ((res >> 26) != ALC_HP_EVENT)
9000 return;
9001 alc262_fujitsu_automute(codec, 1);
9002}
9003
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009004static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9005{
9006 alc262_fujitsu_automute(codec, 1);
9007}
9008
Takashi Iwai834be882006-03-01 14:16:17 +01009009/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009010static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9011 .ops = &snd_hda_bind_vol,
9012 .values = {
9013 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9014 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9015 0
9016 },
9017};
Takashi Iwai834be882006-03-01 14:16:17 +01009018
Jiang zhe0e31daf2008-03-20 12:12:39 +01009019/* mute/unmute internal speaker according to the hp jack and mute state */
9020static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9021{
9022 struct alc_spec *spec = codec->spec;
9023 unsigned int mute;
9024
9025 if (force || !spec->sense_updated) {
9026 unsigned int present_int_hp;
9027 /* need to execute and sync at first */
9028 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9029 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9030 AC_VERB_GET_PIN_SENSE, 0);
9031 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9032 spec->sense_updated = 1;
9033 }
9034 if (spec->jack_present) {
9035 /* mute internal speaker */
9036 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9037 HDA_AMP_MUTE, HDA_AMP_MUTE);
9038 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9039 HDA_AMP_MUTE, HDA_AMP_MUTE);
9040 } else {
9041 /* unmute internal speaker if necessary */
9042 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9043 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9044 HDA_AMP_MUTE, mute);
9045 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9046 HDA_AMP_MUTE, mute);
9047 }
9048}
9049
9050/* unsolicited event for HP jack sensing */
9051static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9052 unsigned int res)
9053{
9054 if ((res >> 26) != ALC_HP_EVENT)
9055 return;
9056 alc262_lenovo_3000_automute(codec, 1);
9057}
9058
Takashi Iwai834be882006-03-01 14:16:17 +01009059/* bind hp and internal speaker mute (with plug check) */
9060static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9061 struct snd_ctl_elem_value *ucontrol)
9062{
9063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9064 long *valp = ucontrol->value.integer.value;
9065 int change;
9066
Tony Vroon5d9fab22008-03-14 17:09:18 +01009067 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9068 HDA_AMP_MUTE,
9069 valp ? 0 : HDA_AMP_MUTE);
9070 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9071 HDA_AMP_MUTE,
9072 valp ? 0 : HDA_AMP_MUTE);
9073
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009074 if (change)
9075 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009076 return change;
9077}
9078
9079static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009080 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009081 {
9082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9083 .name = "Master Playback Switch",
9084 .info = snd_hda_mixer_amp_switch_info,
9085 .get = snd_hda_mixer_amp_switch_get,
9086 .put = alc262_fujitsu_master_sw_put,
9087 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9088 },
9089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009091 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9092 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009096 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9097 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9098 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009099 { } /* end */
9100};
9101
Jiang zhe0e31daf2008-03-20 12:12:39 +01009102/* bind hp and internal speaker mute (with plug check) */
9103static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9104 struct snd_ctl_elem_value *ucontrol)
9105{
9106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9107 long *valp = ucontrol->value.integer.value;
9108 int change;
9109
9110 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9111 HDA_AMP_MUTE,
9112 valp ? 0 : HDA_AMP_MUTE);
9113
9114 if (change)
9115 alc262_lenovo_3000_automute(codec, 0);
9116 return change;
9117}
9118
9119static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9120 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9121 {
9122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9123 .name = "Master Playback Switch",
9124 .info = snd_hda_mixer_amp_switch_info,
9125 .get = snd_hda_mixer_amp_switch_get,
9126 .put = alc262_lenovo_3000_master_sw_put,
9127 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9128 },
9129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9134 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9135 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9136 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9137 { } /* end */
9138};
9139
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009140/* additional init verbs for Benq laptops */
9141static struct hda_verb alc262_EAPD_verbs[] = {
9142 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9143 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9144 {}
9145};
9146
Kailang Yang83c34212007-07-05 11:43:05 +02009147static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9148 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9150
9151 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9152 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9153 {}
9154};
9155
Tobin Davisf651b502007-10-26 12:40:47 +02009156/* Samsung Q1 Ultra Vista model setup */
9157static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009158 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9159 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9162 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009163 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009164 { } /* end */
9165};
9166
9167static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009168 /* output mixer */
9169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9172 /* speaker */
9173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9174 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9181 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9182 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9183 /* internal mic */
9184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9186 /* ADC, choose mic */
9187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009197 {}
9198};
9199
Tobin Davisf651b502007-10-26 12:40:47 +02009200/* mute/unmute internal speaker according to the hp jack and mute state */
9201static void alc262_ultra_automute(struct hda_codec *codec)
9202{
9203 struct alc_spec *spec = codec->spec;
9204 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009205
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009206 mute = 0;
9207 /* auto-mute only when HP is used as HP */
9208 if (!spec->cur_mux[0]) {
9209 unsigned int present;
9210 /* need to execute and sync at first */
9211 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9212 present = snd_hda_codec_read(codec, 0x15, 0,
9213 AC_VERB_GET_PIN_SENSE, 0);
9214 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9215 if (spec->jack_present)
9216 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009217 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009218 /* mute/unmute internal speaker */
9219 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9220 HDA_AMP_MUTE, mute);
9221 /* mute/unmute HP */
9222 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9223 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009224}
9225
9226/* unsolicited event for HP jack sensing */
9227static void alc262_ultra_unsol_event(struct hda_codec *codec,
9228 unsigned int res)
9229{
9230 if ((res >> 26) != ALC880_HP_EVENT)
9231 return;
9232 alc262_ultra_automute(codec);
9233}
9234
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009235static struct hda_input_mux alc262_ultra_capture_source = {
9236 .num_items = 2,
9237 .items = {
9238 { "Mic", 0x1 },
9239 { "Headphone", 0x7 },
9240 },
9241};
9242
9243static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9244 struct snd_ctl_elem_value *ucontrol)
9245{
9246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9247 struct alc_spec *spec = codec->spec;
9248 int ret;
9249
9250 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9251 if (!ret)
9252 return 0;
9253 /* reprogram the HP pin as mic or HP according to the input source */
9254 snd_hda_codec_write_cache(codec, 0x15, 0,
9255 AC_VERB_SET_PIN_WIDGET_CONTROL,
9256 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9257 alc262_ultra_automute(codec); /* mute/unmute HP */
9258 return ret;
9259}
9260
9261static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9262 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9263 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9264 {
9265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9266 .name = "Capture Source",
9267 .info = alc882_mux_enum_info,
9268 .get = alc882_mux_enum_get,
9269 .put = alc262_ultra_mux_enum_put,
9270 },
9271 { } /* end */
9272};
9273
Kailang Yangdf694da2005-12-05 19:42:22 +01009274/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009275static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9276 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009277{
9278 hda_nid_t nid;
9279 int err;
9280
9281 spec->multiout.num_dacs = 1; /* only use one dac */
9282 spec->multiout.dac_nids = spec->private_dac_nids;
9283 spec->multiout.dac_nids[0] = 2;
9284
9285 nid = cfg->line_out_pins[0];
9286 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009287 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9288 "Front Playback Volume",
9289 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9290 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009291 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009292 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9293 "Front Playback Switch",
9294 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9295 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009296 return err;
9297 }
9298
Takashi Iwai82bc9552006-03-21 11:24:42 +01009299 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009300 if (nid) {
9301 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9303 "Speaker Playback Volume",
9304 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9305 HDA_OUTPUT));
9306 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009307 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009308 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9309 "Speaker Playback Switch",
9310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9311 HDA_OUTPUT));
9312 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009313 return err;
9314 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009315 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9316 "Speaker Playback Switch",
9317 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9318 HDA_OUTPUT));
9319 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009320 return err;
9321 }
9322 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009323 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009324 if (nid) {
9325 /* spec->multiout.hp_nid = 2; */
9326 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009327 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9328 "Headphone Playback Volume",
9329 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9330 HDA_OUTPUT));
9331 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009332 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009333 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9334 "Headphone Playback Switch",
9335 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9336 HDA_OUTPUT));
9337 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009338 return err;
9339 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009340 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9341 "Headphone Playback Switch",
9342 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9343 HDA_OUTPUT));
9344 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009345 return err;
9346 }
9347 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009348 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009349}
9350
9351/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009352#define alc262_auto_create_analog_input_ctls \
9353 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009354
9355/*
9356 * generic initialization of ADC, input mixers and output mixers
9357 */
9358static struct hda_verb alc262_volume_init_verbs[] = {
9359 /*
9360 * Unmute ADC0-2 and set the default input to mic-in
9361 */
9362 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9364 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9366 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9368
Takashi Iwaicb53c622007-08-10 17:21:45 +02009369 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009370 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009371 * Note: PASD motherboards uses the Line In 2 as the input for
9372 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009373 */
9374 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009380
9381 /*
9382 * Set up output mixers (0x0c - 0x0f)
9383 */
9384 /* set vol=0 to output mixers */
9385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9388
9389 /* set up input amps for analog loopback */
9390 /* Amp Indices: DAC = 0, mixer = 1 */
9391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9397
9398 /* FIXME: use matrix-type input source selection */
9399 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9400 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9405 /* Input mixer2 */
9406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9410 /* Input mixer3 */
9411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9415
9416 { }
9417};
9418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009419static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9420 /*
9421 * Unmute ADC0-2 and set the default input to mic-in
9422 */
9423 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9425 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9427 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9429
Takashi Iwaicb53c622007-08-10 17:21:45 +02009430 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009431 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009432 * Note: PASD motherboards uses the Line In 2 as the input for
9433 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009434 */
9435 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009436 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009443
9444 /*
9445 * Set up output mixers (0x0c - 0x0e)
9446 */
9447 /* set vol=0 to output mixers */
9448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9451
9452 /* set up input amps for analog loopback */
9453 /* Amp Indices: DAC = 0, mixer = 1 */
9454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9460
Takashi Iwaice875f02008-01-28 18:17:43 +01009461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9464
9465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9467
9468 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9470
9471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9476
9477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9478 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9481 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9482 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9483
9484
9485 /* FIXME: use matrix-type input source selection */
9486 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9487 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9488 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9489 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9492 /* Input mixer2 */
9493 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9494 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9497 /* Input mixer3 */
9498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9502
Takashi Iwaice875f02008-01-28 18:17:43 +01009503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9504
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009505 { }
9506};
9507
Kailang Yangcd7509a2007-01-26 18:33:17 +01009508static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9509 /*
9510 * Unmute ADC0-2 and set the default input to mic-in
9511 */
9512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9514 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9518
Takashi Iwaicb53c622007-08-10 17:21:45 +02009519 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009520 * mixer widget
9521 * Note: PASD motherboards uses the Line In 2 as the input for front
9522 * panel mic (mic 2)
9523 */
9524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009533 /*
9534 * Set up output mixers (0x0c - 0x0e)
9535 */
9536 /* set vol=0 to output mixers */
9537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9540
9541 /* set up input amps for analog loopback */
9542 /* Amp Indices: DAC = 0, mixer = 1 */
9543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9549
9550
9551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9557 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9558
9559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9561
9562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9563 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9564
9565 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9568 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9569 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9570 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9571
9572 /* FIXME: use matrix-type input source selection */
9573 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9574 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9580 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9582 /* Input mixer2 */
9583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9584 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9588 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9590 /* Input mixer3 */
9591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9598
Takashi Iwaice875f02008-01-28 18:17:43 +01009599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9600
Kailang Yangcd7509a2007-01-26 18:33:17 +01009601 { }
9602};
9603
Takashi Iwaicb53c622007-08-10 17:21:45 +02009604#ifdef CONFIG_SND_HDA_POWER_SAVE
9605#define alc262_loopbacks alc880_loopbacks
9606#endif
9607
Kailang Yangdf694da2005-12-05 19:42:22 +01009608/* pcm configuration: identiacal with ALC880 */
9609#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9610#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9611#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9612#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9613
9614/*
9615 * BIOS auto configuration
9616 */
9617static int alc262_parse_auto_config(struct hda_codec *codec)
9618{
9619 struct alc_spec *spec = codec->spec;
9620 int err;
9621 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009623 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9624 alc262_ignore);
9625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009626 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009627 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009628 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9630 if (err < 0)
9631 return err;
9632 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9633 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009634 return err;
9635
9636 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9637
9638 if (spec->autocfg.dig_out_pin)
9639 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9640 if (spec->autocfg.dig_in_pin)
9641 spec->dig_in_nid = ALC262_DIGIN_NID;
9642
9643 if (spec->kctl_alloc)
9644 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9645
9646 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009647 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009648 spec->input_mux = &spec->private_imux;
9649
Takashi Iwai776e1842007-08-29 15:07:11 +02009650 err = alc_auto_add_mic_boost(codec);
9651 if (err < 0)
9652 return err;
9653
Kailang Yangdf694da2005-12-05 19:42:22 +01009654 return 1;
9655}
9656
9657#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9658#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9659#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9660
9661
9662/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009663static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009664{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009665 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009666 alc262_auto_init_multi_out(codec);
9667 alc262_auto_init_hp_out(codec);
9668 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009669 if (spec->unsol_event)
9670 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009671}
9672
9673/*
9674 * configuration and preset
9675 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009676static const char *alc262_models[ALC262_MODEL_LAST] = {
9677 [ALC262_BASIC] = "basic",
9678 [ALC262_HIPPO] = "hippo",
9679 [ALC262_HIPPO_1] = "hippo_1",
9680 [ALC262_FUJITSU] = "fujitsu",
9681 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009682 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009683 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009684 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009685 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009686 [ALC262_BENQ_T31] = "benq-t31",
9687 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009688 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009689 [ALC262_LENOVO_3000] = "lenovo-3000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009690 [ALC262_AUTO] = "auto",
9691};
9692
9693static struct snd_pci_quirk alc262_cfg_tbl[] = {
9694 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9695 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009696 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009697 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9698 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009699 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009700 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009701 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009702 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009703 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009704 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009705 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009706 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009707 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009708 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009709 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009710 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009711 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9712 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9713 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009714 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9715 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009716 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009717 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009718 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009719 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9720 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9721 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009722 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009723 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009724 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009725 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009726 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009727 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009728 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009729 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009730 {}
9731};
9732
9733static struct alc_config_preset alc262_presets[] = {
9734 [ALC262_BASIC] = {
9735 .mixers = { alc262_base_mixer },
9736 .init_verbs = { alc262_init_verbs },
9737 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9738 .dac_nids = alc262_dac_nids,
9739 .hp_nid = 0x03,
9740 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9741 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009742 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009743 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009744 [ALC262_HIPPO] = {
9745 .mixers = { alc262_base_mixer },
9746 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9747 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9748 .dac_nids = alc262_dac_nids,
9749 .hp_nid = 0x03,
9750 .dig_out_nid = ALC262_DIGOUT_NID,
9751 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9752 .channel_mode = alc262_modes,
9753 .input_mux = &alc262_capture_source,
9754 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009755 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009756 },
9757 [ALC262_HIPPO_1] = {
9758 .mixers = { alc262_hippo1_mixer },
9759 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9760 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9761 .dac_nids = alc262_dac_nids,
9762 .hp_nid = 0x02,
9763 .dig_out_nid = ALC262_DIGOUT_NID,
9764 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9765 .channel_mode = alc262_modes,
9766 .input_mux = &alc262_capture_source,
9767 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009768 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009769 },
Takashi Iwai834be882006-03-01 14:16:17 +01009770 [ALC262_FUJITSU] = {
9771 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009772 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9773 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009774 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9775 .dac_nids = alc262_dac_nids,
9776 .hp_nid = 0x03,
9777 .dig_out_nid = ALC262_DIGOUT_NID,
9778 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9779 .channel_mode = alc262_modes,
9780 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009781 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009782 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009783 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009784 [ALC262_HP_BPC] = {
9785 .mixers = { alc262_HP_BPC_mixer },
9786 .init_verbs = { alc262_HP_BPC_init_verbs },
9787 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9788 .dac_nids = alc262_dac_nids,
9789 .hp_nid = 0x03,
9790 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9791 .channel_mode = alc262_modes,
9792 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009793 .unsol_event = alc262_hp_bpc_unsol_event,
9794 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009795 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009796 [ALC262_HP_BPC_D7000_WF] = {
9797 .mixers = { alc262_HP_BPC_WildWest_mixer },
9798 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9799 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9800 .dac_nids = alc262_dac_nids,
9801 .hp_nid = 0x03,
9802 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9803 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009804 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009805 .unsol_event = alc262_hp_wildwest_unsol_event,
9806 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009807 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009808 [ALC262_HP_BPC_D7000_WL] = {
9809 .mixers = { alc262_HP_BPC_WildWest_mixer,
9810 alc262_HP_BPC_WildWest_option_mixer },
9811 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9812 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9813 .dac_nids = alc262_dac_nids,
9814 .hp_nid = 0x03,
9815 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9816 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009817 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009818 .unsol_event = alc262_hp_wildwest_unsol_event,
9819 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009820 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009821 [ALC262_HP_TC_T5735] = {
9822 .mixers = { alc262_hp_t5735_mixer },
9823 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9825 .dac_nids = alc262_dac_nids,
9826 .hp_nid = 0x03,
9827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9828 .channel_mode = alc262_modes,
9829 .input_mux = &alc262_capture_source,
9830 .unsol_event = alc262_hp_t5735_unsol_event,
9831 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009832 },
9833 [ALC262_HP_RP5700] = {
9834 .mixers = { alc262_hp_rp5700_mixer },
9835 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9836 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9837 .dac_nids = alc262_dac_nids,
9838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9839 .channel_mode = alc262_modes,
9840 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009841 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009842 [ALC262_BENQ_ED8] = {
9843 .mixers = { alc262_base_mixer },
9844 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9846 .dac_nids = alc262_dac_nids,
9847 .hp_nid = 0x03,
9848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9849 .channel_mode = alc262_modes,
9850 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009851 },
Kailang Yang272a5272007-05-14 11:00:38 +02009852 [ALC262_SONY_ASSAMD] = {
9853 .mixers = { alc262_sony_mixer },
9854 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9855 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9856 .dac_nids = alc262_dac_nids,
9857 .hp_nid = 0x02,
9858 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9859 .channel_mode = alc262_modes,
9860 .input_mux = &alc262_capture_source,
9861 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009862 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009863 },
9864 [ALC262_BENQ_T31] = {
9865 .mixers = { alc262_benq_t31_mixer },
9866 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9867 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9868 .dac_nids = alc262_dac_nids,
9869 .hp_nid = 0x03,
9870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9871 .channel_mode = alc262_modes,
9872 .input_mux = &alc262_capture_source,
9873 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009874 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009875 },
Tobin Davisf651b502007-10-26 12:40:47 +02009876 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009877 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9878 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009879 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9880 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009881 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9882 .channel_mode = alc262_modes,
9883 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009884 .adc_nids = alc262_adc_nids, /* ADC0 */
9885 .capsrc_nids = alc262_capsrc_nids,
9886 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009887 .unsol_event = alc262_ultra_unsol_event,
9888 .init_hook = alc262_ultra_automute,
9889 },
Jiang zhe0e31daf2008-03-20 12:12:39 +01009890 [ALC262_LENOVO_3000] = {
9891 .mixers = { alc262_lenovo_3000_mixer },
9892 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9893 alc262_lenovo_3000_unsol_verbs },
9894 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9895 .dac_nids = alc262_dac_nids,
9896 .hp_nid = 0x03,
9897 .dig_out_nid = ALC262_DIGOUT_NID,
9898 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9899 .channel_mode = alc262_modes,
9900 .input_mux = &alc262_fujitsu_capture_source,
9901 .unsol_event = alc262_lenovo_3000_unsol_event,
9902 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009903};
9904
9905static int patch_alc262(struct hda_codec *codec)
9906{
9907 struct alc_spec *spec;
9908 int board_config;
9909 int err;
9910
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009911 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009912 if (spec == NULL)
9913 return -ENOMEM;
9914
9915 codec->spec = spec;
9916#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009917 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9918 * under-run
9919 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009920 {
9921 int tmp;
9922 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9923 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9924 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9925 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9926 }
9927#endif
9928
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009929 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9930
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009931 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9932 alc262_models,
9933 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009934
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009935 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009936 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9937 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009938 board_config = ALC262_AUTO;
9939 }
9940
9941 if (board_config == ALC262_AUTO) {
9942 /* automatic parse from the BIOS config */
9943 err = alc262_parse_auto_config(codec);
9944 if (err < 0) {
9945 alc_free(codec);
9946 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009947 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009948 printk(KERN_INFO
9949 "hda_codec: Cannot set up configuration "
9950 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009951 board_config = ALC262_BASIC;
9952 }
9953 }
9954
9955 if (board_config != ALC262_AUTO)
9956 setup_preset(spec, &alc262_presets[board_config]);
9957
9958 spec->stream_name_analog = "ALC262 Analog";
9959 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9960 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9961
9962 spec->stream_name_digital = "ALC262 Digital";
9963 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9964 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9965
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009966 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009967 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009968 unsigned int wcap = get_wcaps(codec, 0x07);
9969
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009970 /* get type */
9971 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009972 if (wcap != AC_WID_AUD_IN) {
9973 spec->adc_nids = alc262_adc_nids_alt;
9974 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009975 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009976 spec->mixers[spec->num_mixers] =
9977 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009978 spec->num_mixers++;
9979 } else {
9980 spec->adc_nids = alc262_adc_nids;
9981 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009982 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009983 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9984 spec->num_mixers++;
9985 }
9986 }
9987
Takashi Iwai2134ea42008-01-10 16:53:55 +01009988 spec->vmaster_nid = 0x0c;
9989
Kailang Yangdf694da2005-12-05 19:42:22 +01009990 codec->patch_ops = alc_patch_ops;
9991 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009992 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009993#ifdef CONFIG_SND_HDA_POWER_SAVE
9994 if (!spec->loopback.amplist)
9995 spec->loopback.amplist = alc262_loopbacks;
9996#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009997
Kailang Yangdf694da2005-12-05 19:42:22 +01009998 return 0;
9999}
10000
Kailang Yangdf694da2005-12-05 19:42:22 +010010001/*
Kailang Yanga361d842007-06-05 12:30:55 +020010002 * ALC268 channel source setting (2 channel)
10003 */
10004#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10005#define alc268_modes alc260_modes
10006
10007static hda_nid_t alc268_dac_nids[2] = {
10008 /* front, hp */
10009 0x02, 0x03
10010};
10011
10012static hda_nid_t alc268_adc_nids[2] = {
10013 /* ADC0-1 */
10014 0x08, 0x07
10015};
10016
10017static hda_nid_t alc268_adc_nids_alt[1] = {
10018 /* ADC0 */
10019 0x08
10020};
10021
Takashi Iwaie1406342008-02-11 18:32:32 +010010022static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10023
Kailang Yanga361d842007-06-05 12:30:55 +020010024static struct snd_kcontrol_new alc268_base_mixer[] = {
10025 /* output mixer control */
10026 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10027 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10028 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010030 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10031 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10032 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010033 { }
10034};
10035
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010036/* bind Beep switches of both NID 0x0f and 0x10 */
10037static struct hda_bind_ctls alc268_bind_beep_sw = {
10038 .ops = &snd_hda_bind_sw,
10039 .values = {
10040 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10041 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10042 0
10043 },
10044};
10045
10046static struct snd_kcontrol_new alc268_beep_mixer[] = {
10047 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10048 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10049 { }
10050};
10051
Kailang Yangd1a991a2007-08-15 16:21:59 +020010052static struct hda_verb alc268_eapd_verbs[] = {
10053 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10054 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10055 { }
10056};
10057
Takashi Iwaid2738092007-08-16 14:59:45 +020010058/* Toshiba specific */
10059#define alc268_toshiba_automute alc262_hippo_automute
10060
10061static struct hda_verb alc268_toshiba_verbs[] = {
10062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10063 { } /* end */
10064};
10065
10066/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010067/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010068static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10069 .ops = &snd_hda_bind_vol,
10070 .values = {
10071 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10072 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10073 0
10074 },
10075};
10076
Takashi Iwai889c4392007-08-23 18:56:52 +020010077/* mute/unmute internal speaker according to the hp jack and mute state */
10078static void alc268_acer_automute(struct hda_codec *codec, int force)
10079{
10080 struct alc_spec *spec = codec->spec;
10081 unsigned int mute;
10082
10083 if (force || !spec->sense_updated) {
10084 unsigned int present;
10085 present = snd_hda_codec_read(codec, 0x14, 0,
10086 AC_VERB_GET_PIN_SENSE, 0);
10087 spec->jack_present = (present & 0x80000000) != 0;
10088 spec->sense_updated = 1;
10089 }
10090 if (spec->jack_present)
10091 mute = HDA_AMP_MUTE; /* mute internal speaker */
10092 else /* unmute internal speaker if necessary */
10093 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10094 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10095 HDA_AMP_MUTE, mute);
10096}
10097
10098
10099/* bind hp and internal speaker mute (with plug check) */
10100static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10101 struct snd_ctl_elem_value *ucontrol)
10102{
10103 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10104 long *valp = ucontrol->value.integer.value;
10105 int change;
10106
10107 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10108 HDA_AMP_MUTE,
10109 valp[0] ? 0 : HDA_AMP_MUTE);
10110 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10111 HDA_AMP_MUTE,
10112 valp[1] ? 0 : HDA_AMP_MUTE);
10113 if (change)
10114 alc268_acer_automute(codec, 0);
10115 return change;
10116}
Takashi Iwaid2738092007-08-16 14:59:45 +020010117
10118static struct snd_kcontrol_new alc268_acer_mixer[] = {
10119 /* output mixer control */
10120 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10121 {
10122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10123 .name = "Master Playback Switch",
10124 .info = snd_hda_mixer_amp_switch_info,
10125 .get = snd_hda_mixer_amp_switch_get,
10126 .put = alc268_acer_master_sw_put,
10127 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10128 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10130 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10131 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010132 { }
10133};
10134
10135static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010136 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10137 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10139 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010140 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010142
10143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10144 { }
10145};
10146
10147/* unsolicited event for HP jack sensing */
10148static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10149 unsigned int res)
10150{
Takashi Iwai889c4392007-08-23 18:56:52 +020010151 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010152 return;
10153 alc268_toshiba_automute(codec);
10154}
10155
10156static void alc268_acer_unsol_event(struct hda_codec *codec,
10157 unsigned int res)
10158{
Takashi Iwai889c4392007-08-23 18:56:52 +020010159 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010160 return;
10161 alc268_acer_automute(codec, 1);
10162}
10163
Takashi Iwai889c4392007-08-23 18:56:52 +020010164static void alc268_acer_init_hook(struct hda_codec *codec)
10165{
10166 alc268_acer_automute(codec, 1);
10167}
10168
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010169static struct snd_kcontrol_new alc268_dell_mixer[] = {
10170 /* output mixer control */
10171 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10173 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10175 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10176 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10177 { }
10178};
10179
10180static struct hda_verb alc268_dell_verbs[] = {
10181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10183 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10184 { }
10185};
10186
10187/* mute/unmute internal speaker according to the hp jack and mute state */
10188static void alc268_dell_automute(struct hda_codec *codec)
10189{
10190 unsigned int present;
10191 unsigned int mute;
10192
10193 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10194 if (present & 0x80000000)
10195 mute = HDA_AMP_MUTE;
10196 else
10197 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10198 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10199 HDA_AMP_MUTE, mute);
10200}
10201
10202static void alc268_dell_unsol_event(struct hda_codec *codec,
10203 unsigned int res)
10204{
10205 if ((res >> 26) != ALC880_HP_EVENT)
10206 return;
10207 alc268_dell_automute(codec);
10208}
10209
10210#define alc268_dell_init_hook alc268_dell_automute
10211
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010212static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10213 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10214 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10217 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10218 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10219 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10220 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10221 { }
10222};
10223
10224static struct hda_verb alc267_quanta_il1_verbs[] = {
10225 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10226 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10227 { }
10228};
10229
10230static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10231{
10232 unsigned int present;
10233
10234 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10235 & AC_PINSENSE_PRESENCE;
10236 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10237 present ? 0 : PIN_OUT);
10238}
10239
10240static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10241{
10242 unsigned int present;
10243
10244 present = snd_hda_codec_read(codec, 0x18, 0,
10245 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10246 snd_hda_codec_write(codec, 0x23, 0,
10247 AC_VERB_SET_CONNECT_SEL,
10248 present ? 0x00 : 0x01);
10249}
10250
10251static void alc267_quanta_il1_automute(struct hda_codec *codec)
10252{
10253 alc267_quanta_il1_hp_automute(codec);
10254 alc267_quanta_il1_mic_automute(codec);
10255}
10256
10257static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10258 unsigned int res)
10259{
10260 switch (res >> 26) {
10261 case ALC880_HP_EVENT:
10262 alc267_quanta_il1_hp_automute(codec);
10263 break;
10264 case ALC880_MIC_EVENT:
10265 alc267_quanta_il1_mic_automute(codec);
10266 break;
10267 }
10268}
10269
Kailang Yanga361d842007-06-05 12:30:55 +020010270/*
10271 * generic initialization of ADC, input mixers and output mixers
10272 */
10273static struct hda_verb alc268_base_init_verbs[] = {
10274 /* Unmute DAC0-1 and set vol = 0 */
10275 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10276 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10277 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10278 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10279 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10280 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10281
10282 /*
10283 * Set up output mixers (0x0c - 0x0e)
10284 */
10285 /* set vol=0 to output mixers */
10286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10289 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10290
10291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10292 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10293
10294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10299 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10300 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10301 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10302
10303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10309 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010310
10311 /* set PCBEEP vol = 0, mute connections */
10312 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10314 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010315
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010316 /* Unmute Selector 23h,24h and set the default input to mic-in */
10317
10318 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10320 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010322
Kailang Yanga361d842007-06-05 12:30:55 +020010323 { }
10324};
10325
10326/*
10327 * generic initialization of ADC, input mixers and output mixers
10328 */
10329static struct hda_verb alc268_volume_init_verbs[] = {
10330 /* set output DAC */
10331 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10332 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10333 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10334 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10335
10336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10339 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10340 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10341
10342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10343 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10345 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10347
10348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10349 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10350 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10351 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10352
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010353 /* set PCBEEP vol = 0, mute connections */
10354 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10355 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10356 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010357
10358 { }
10359};
10360
10361#define alc268_mux_enum_info alc_mux_enum_info
10362#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010363#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010364
10365static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10366 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10367 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10368 {
10369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10370 /* The multiple "Capture Source" controls confuse alsamixer
10371 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010372 */
10373 /* .name = "Capture Source", */
10374 .name = "Input Source",
10375 .count = 1,
10376 .info = alc268_mux_enum_info,
10377 .get = alc268_mux_enum_get,
10378 .put = alc268_mux_enum_put,
10379 },
10380 { } /* end */
10381};
10382
10383static struct snd_kcontrol_new alc268_capture_mixer[] = {
10384 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10385 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10386 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10387 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10388 {
10389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10390 /* The multiple "Capture Source" controls confuse alsamixer
10391 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010392 */
10393 /* .name = "Capture Source", */
10394 .name = "Input Source",
10395 .count = 2,
10396 .info = alc268_mux_enum_info,
10397 .get = alc268_mux_enum_get,
10398 .put = alc268_mux_enum_put,
10399 },
10400 { } /* end */
10401};
10402
10403static struct hda_input_mux alc268_capture_source = {
10404 .num_items = 4,
10405 .items = {
10406 { "Mic", 0x0 },
10407 { "Front Mic", 0x1 },
10408 { "Line", 0x2 },
10409 { "CD", 0x3 },
10410 },
10411};
10412
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010413static struct hda_input_mux alc268_acer_capture_source = {
10414 .num_items = 3,
10415 .items = {
10416 { "Mic", 0x0 },
10417 { "Internal Mic", 0x6 },
10418 { "Line", 0x2 },
10419 },
10420};
10421
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010422#ifdef CONFIG_SND_DEBUG
10423static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010424 /* Volume widgets */
10425 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10426 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10427 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10428 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10429 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10430 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10431 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10432 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10433 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10434 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10435 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10436 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10437 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010438 /* The below appears problematic on some hardwares */
10439 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010440 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10441 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10442 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10443 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10444
10445 /* Modes for retasking pin widgets */
10446 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10447 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10448 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10449 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10450
10451 /* Controls for GPIO pins, assuming they are configured as outputs */
10452 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10453 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10454 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10455 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10456
10457 /* Switches to allow the digital SPDIF output pin to be enabled.
10458 * The ALC268 does not have an SPDIF input.
10459 */
10460 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10461
10462 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10463 * this output to turn on an external amplifier.
10464 */
10465 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10466 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10467
10468 { } /* end */
10469};
10470#endif
10471
Kailang Yanga361d842007-06-05 12:30:55 +020010472/* create input playback/capture controls for the given pin */
10473static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10474 const char *ctlname, int idx)
10475{
10476 char name[32];
10477 int err;
10478
10479 sprintf(name, "%s Playback Volume", ctlname);
10480 if (nid == 0x14) {
10481 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10482 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10483 HDA_OUTPUT));
10484 if (err < 0)
10485 return err;
10486 } else if (nid == 0x15) {
10487 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10488 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10489 HDA_OUTPUT));
10490 if (err < 0)
10491 return err;
10492 } else
10493 return -1;
10494 sprintf(name, "%s Playback Switch", ctlname);
10495 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10496 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10497 if (err < 0)
10498 return err;
10499 return 0;
10500}
10501
10502/* add playback controls from the parsed DAC table */
10503static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10504 const struct auto_pin_cfg *cfg)
10505{
10506 hda_nid_t nid;
10507 int err;
10508
10509 spec->multiout.num_dacs = 2; /* only use one dac */
10510 spec->multiout.dac_nids = spec->private_dac_nids;
10511 spec->multiout.dac_nids[0] = 2;
10512 spec->multiout.dac_nids[1] = 3;
10513
10514 nid = cfg->line_out_pins[0];
10515 if (nid)
10516 alc268_new_analog_output(spec, nid, "Front", 0);
10517
10518 nid = cfg->speaker_pins[0];
10519 if (nid == 0x1d) {
10520 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10521 "Speaker Playback Volume",
10522 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10523 if (err < 0)
10524 return err;
10525 }
10526 nid = cfg->hp_pins[0];
10527 if (nid)
10528 alc268_new_analog_output(spec, nid, "Headphone", 0);
10529
10530 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10531 if (nid == 0x16) {
10532 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10533 "Mono Playback Switch",
10534 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10535 if (err < 0)
10536 return err;
10537 }
10538 return 0;
10539}
10540
10541/* create playback/capture controls for input pins */
10542static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10543 const struct auto_pin_cfg *cfg)
10544{
10545 struct hda_input_mux *imux = &spec->private_imux;
10546 int i, idx1;
10547
10548 for (i = 0; i < AUTO_PIN_LAST; i++) {
10549 switch(cfg->input_pins[i]) {
10550 case 0x18:
10551 idx1 = 0; /* Mic 1 */
10552 break;
10553 case 0x19:
10554 idx1 = 1; /* Mic 2 */
10555 break;
10556 case 0x1a:
10557 idx1 = 2; /* Line In */
10558 break;
10559 case 0x1c:
10560 idx1 = 3; /* CD */
10561 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010562 case 0x12:
10563 case 0x13:
10564 idx1 = 6; /* digital mics */
10565 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010566 default:
10567 continue;
10568 }
10569 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10570 imux->items[imux->num_items].index = idx1;
10571 imux->num_items++;
10572 }
10573 return 0;
10574}
10575
10576static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10577{
10578 struct alc_spec *spec = codec->spec;
10579 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10580 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10581 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10582 unsigned int dac_vol1, dac_vol2;
10583
10584 if (speaker_nid) {
10585 snd_hda_codec_write(codec, speaker_nid, 0,
10586 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10587 snd_hda_codec_write(codec, 0x0f, 0,
10588 AC_VERB_SET_AMP_GAIN_MUTE,
10589 AMP_IN_UNMUTE(1));
10590 snd_hda_codec_write(codec, 0x10, 0,
10591 AC_VERB_SET_AMP_GAIN_MUTE,
10592 AMP_IN_UNMUTE(1));
10593 } else {
10594 snd_hda_codec_write(codec, 0x0f, 0,
10595 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10596 snd_hda_codec_write(codec, 0x10, 0,
10597 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10598 }
10599
10600 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10601 if (line_nid == 0x14)
10602 dac_vol2 = AMP_OUT_ZERO;
10603 else if (line_nid == 0x15)
10604 dac_vol1 = AMP_OUT_ZERO;
10605 if (hp_nid == 0x14)
10606 dac_vol2 = AMP_OUT_ZERO;
10607 else if (hp_nid == 0x15)
10608 dac_vol1 = AMP_OUT_ZERO;
10609 if (line_nid != 0x16 || hp_nid != 0x16 ||
10610 spec->autocfg.line_out_pins[1] != 0x16 ||
10611 spec->autocfg.line_out_pins[2] != 0x16)
10612 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10613
10614 snd_hda_codec_write(codec, 0x02, 0,
10615 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10616 snd_hda_codec_write(codec, 0x03, 0,
10617 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10618}
10619
10620/* pcm configuration: identiacal with ALC880 */
10621#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10622#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010623#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010624#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10625
10626/*
10627 * BIOS auto configuration
10628 */
10629static int alc268_parse_auto_config(struct hda_codec *codec)
10630{
10631 struct alc_spec *spec = codec->spec;
10632 int err;
10633 static hda_nid_t alc268_ignore[] = { 0 };
10634
10635 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10636 alc268_ignore);
10637 if (err < 0)
10638 return err;
10639 if (!spec->autocfg.line_outs)
10640 return 0; /* can't find valid BIOS pin config */
10641
10642 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10643 if (err < 0)
10644 return err;
10645 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10646 if (err < 0)
10647 return err;
10648
10649 spec->multiout.max_channels = 2;
10650
10651 /* digital only support output */
10652 if (spec->autocfg.dig_out_pin)
10653 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10654
10655 if (spec->kctl_alloc)
10656 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10657
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010658 if (spec->autocfg.speaker_pins[0] != 0x1d)
10659 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10660
Kailang Yanga361d842007-06-05 12:30:55 +020010661 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10662 spec->num_mux_defs = 1;
10663 spec->input_mux = &spec->private_imux;
10664
Takashi Iwai776e1842007-08-29 15:07:11 +020010665 err = alc_auto_add_mic_boost(codec);
10666 if (err < 0)
10667 return err;
10668
Kailang Yanga361d842007-06-05 12:30:55 +020010669 return 1;
10670}
10671
10672#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10673#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10674#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10675
10676/* init callback for auto-configuration model -- overriding the default init */
10677static void alc268_auto_init(struct hda_codec *codec)
10678{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010679 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010680 alc268_auto_init_multi_out(codec);
10681 alc268_auto_init_hp_out(codec);
10682 alc268_auto_init_mono_speaker_out(codec);
10683 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010684 if (spec->unsol_event)
10685 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010686}
10687
10688/*
10689 * configuration and preset
10690 */
10691static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010692 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010693 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010694 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010695 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010696 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010697 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010698#ifdef CONFIG_SND_DEBUG
10699 [ALC268_TEST] = "test",
10700#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010701 [ALC268_AUTO] = "auto",
10702};
10703
10704static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010705 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010706 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010707 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010708 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010709 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010710 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010711 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010712 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010713 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010714 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010715 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010716 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010717 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010718 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010719 {}
10720};
10721
10722static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010723 [ALC267_QUANTA_IL1] = {
10724 .mixers = { alc267_quanta_il1_mixer },
10725 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10726 alc267_quanta_il1_verbs },
10727 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10728 .dac_nids = alc268_dac_nids,
10729 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10730 .adc_nids = alc268_adc_nids_alt,
10731 .hp_nid = 0x03,
10732 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10733 .channel_mode = alc268_modes,
10734 .input_mux = &alc268_capture_source,
10735 .unsol_event = alc267_quanta_il1_unsol_event,
10736 .init_hook = alc267_quanta_il1_automute,
10737 },
Kailang Yanga361d842007-06-05 12:30:55 +020010738 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010739 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10740 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010741 .init_verbs = { alc268_base_init_verbs },
10742 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10743 .dac_nids = alc268_dac_nids,
10744 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10745 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010746 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010747 .hp_nid = 0x03,
10748 .dig_out_nid = ALC268_DIGOUT_NID,
10749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10750 .channel_mode = alc268_modes,
10751 .input_mux = &alc268_capture_source,
10752 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010753 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010754 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10755 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010756 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10757 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010758 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10759 .dac_nids = alc268_dac_nids,
10760 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10761 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010762 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010763 .hp_nid = 0x03,
10764 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10765 .channel_mode = alc268_modes,
10766 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010767 .unsol_event = alc268_toshiba_unsol_event,
10768 .init_hook = alc268_toshiba_automute,
10769 },
10770 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010771 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10772 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010773 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10774 alc268_acer_verbs },
10775 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10776 .dac_nids = alc268_dac_nids,
10777 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10778 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010779 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010780 .hp_nid = 0x02,
10781 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10782 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010783 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010784 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010785 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010786 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010787 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010788 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010789 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10790 alc268_dell_verbs },
10791 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10792 .dac_nids = alc268_dac_nids,
10793 .hp_nid = 0x02,
10794 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10795 .channel_mode = alc268_modes,
10796 .unsol_event = alc268_dell_unsol_event,
10797 .init_hook = alc268_dell_init_hook,
10798 .input_mux = &alc268_capture_source,
10799 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010800 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010801 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10802 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010803 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10804 alc268_toshiba_verbs },
10805 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10806 .dac_nids = alc268_dac_nids,
10807 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10808 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010809 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010810 .hp_nid = 0x03,
10811 .dig_out_nid = ALC268_DIGOUT_NID,
10812 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10813 .channel_mode = alc268_modes,
10814 .input_mux = &alc268_capture_source,
10815 .unsol_event = alc268_toshiba_unsol_event,
10816 .init_hook = alc268_toshiba_automute
10817 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010818#ifdef CONFIG_SND_DEBUG
10819 [ALC268_TEST] = {
10820 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10821 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10822 alc268_volume_init_verbs },
10823 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10824 .dac_nids = alc268_dac_nids,
10825 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10826 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010827 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010828 .hp_nid = 0x03,
10829 .dig_out_nid = ALC268_DIGOUT_NID,
10830 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10831 .channel_mode = alc268_modes,
10832 .input_mux = &alc268_capture_source,
10833 },
10834#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010835};
10836
10837static int patch_alc268(struct hda_codec *codec)
10838{
10839 struct alc_spec *spec;
10840 int board_config;
10841 int err;
10842
10843 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10844 if (spec == NULL)
10845 return -ENOMEM;
10846
10847 codec->spec = spec;
10848
10849 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10850 alc268_models,
10851 alc268_cfg_tbl);
10852
10853 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10854 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10855 "trying auto-probe from BIOS...\n");
10856 board_config = ALC268_AUTO;
10857 }
10858
10859 if (board_config == ALC268_AUTO) {
10860 /* automatic parse from the BIOS config */
10861 err = alc268_parse_auto_config(codec);
10862 if (err < 0) {
10863 alc_free(codec);
10864 return err;
10865 } else if (!err) {
10866 printk(KERN_INFO
10867 "hda_codec: Cannot set up configuration "
10868 "from BIOS. Using base mode...\n");
10869 board_config = ALC268_3ST;
10870 }
10871 }
10872
10873 if (board_config != ALC268_AUTO)
10874 setup_preset(spec, &alc268_presets[board_config]);
10875
Kailang Yang2f893282008-05-27 12:14:47 +020010876 if (codec->vendor_id == 0x10ec0267) {
10877 spec->stream_name_analog = "ALC267 Analog";
10878 spec->stream_name_digital = "ALC267 Digital";
10879 } else {
10880 spec->stream_name_analog = "ALC268 Analog";
10881 spec->stream_name_digital = "ALC268 Digital";
10882 }
10883
Kailang Yanga361d842007-06-05 12:30:55 +020010884 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10885 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010886 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010887
Kailang Yanga361d842007-06-05 12:30:55 +020010888 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10889
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010890 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10891 /* override the amp caps for beep generator */
10892 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10893 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10894 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10895 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10896 (0 << AC_AMPCAP_MUTE_SHIFT));
10897
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010898 if (!spec->adc_nids && spec->input_mux) {
10899 /* check whether NID 0x07 is valid */
10900 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010901 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010902
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010903 /* get type */
10904 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010905 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010906 spec->adc_nids = alc268_adc_nids_alt;
10907 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10908 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010909 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010910 spec->num_mixers++;
10911 } else {
10912 spec->adc_nids = alc268_adc_nids;
10913 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10914 spec->mixers[spec->num_mixers] =
10915 alc268_capture_mixer;
10916 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010917 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010918 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010919 /* set default input source */
10920 for (i = 0; i < spec->num_adc_nids; i++)
10921 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10922 0, AC_VERB_SET_CONNECT_SEL,
10923 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010924 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010925
10926 spec->vmaster_nid = 0x02;
10927
Kailang Yanga361d842007-06-05 12:30:55 +020010928 codec->patch_ops = alc_patch_ops;
10929 if (board_config == ALC268_AUTO)
10930 spec->init_hook = alc268_auto_init;
10931
10932 return 0;
10933}
10934
10935/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010936 * ALC269 channel source setting (2 channel)
10937 */
10938#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10939
10940#define alc269_dac_nids alc260_dac_nids
10941
10942static hda_nid_t alc269_adc_nids[1] = {
10943 /* ADC1 */
10944 0x07,
10945};
10946
10947#define alc269_modes alc260_modes
10948#define alc269_capture_source alc880_lg_lw_capture_source
10949
10950static struct snd_kcontrol_new alc269_base_mixer[] = {
10951 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10960 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10962 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10963 { } /* end */
10964};
10965
10966/* capture mixer elements */
10967static struct snd_kcontrol_new alc269_capture_mixer[] = {
10968 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10969 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10970 {
10971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10972 /* The multiple "Capture Source" controls confuse alsamixer
10973 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010974 */
10975 /* .name = "Capture Source", */
10976 .name = "Input Source",
10977 .count = 1,
10978 .info = alc_mux_enum_info,
10979 .get = alc_mux_enum_get,
10980 .put = alc_mux_enum_put,
10981 },
10982 { } /* end */
10983};
10984
10985/*
10986 * generic initialization of ADC, input mixers and output mixers
10987 */
10988static struct hda_verb alc269_init_verbs[] = {
10989 /*
10990 * Unmute ADC0 and set the default input to mic-in
10991 */
10992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10993
10994 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10995 * analog-loopback mixer widget
10996 * Note: PASD motherboards uses the Line In 2 as the input for
10997 * front panel mic (mic 2)
10998 */
10999 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11005
11006 /*
11007 * Set up output mixers (0x0c - 0x0e)
11008 */
11009 /* set vol=0 to output mixers */
11010 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11011 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11012
11013 /* set up input amps for analog loopback */
11014 /* Amp Indices: DAC = 0, mixer = 1 */
11015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11020 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11021
11022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11024 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11029
11030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11034 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11035 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11037
11038 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11039 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11040
11041 /* FIXME: use matrix-type input source selection */
11042 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11043 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11048
11049 /* set EAPD */
11050 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11051 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11052 { }
11053};
11054
11055/* add playback controls from the parsed DAC table */
11056static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11057 const struct auto_pin_cfg *cfg)
11058{
11059 hda_nid_t nid;
11060 int err;
11061
11062 spec->multiout.num_dacs = 1; /* only use one dac */
11063 spec->multiout.dac_nids = spec->private_dac_nids;
11064 spec->multiout.dac_nids[0] = 2;
11065
11066 nid = cfg->line_out_pins[0];
11067 if (nid) {
11068 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11069 "Front Playback Volume",
11070 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11071 if (err < 0)
11072 return err;
11073 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11074 "Front Playback Switch",
11075 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11076 if (err < 0)
11077 return err;
11078 }
11079
11080 nid = cfg->speaker_pins[0];
11081 if (nid) {
11082 if (!cfg->line_out_pins[0]) {
11083 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11084 "Speaker Playback Volume",
11085 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11086 HDA_OUTPUT));
11087 if (err < 0)
11088 return err;
11089 }
11090 if (nid == 0x16) {
11091 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11092 "Speaker Playback Switch",
11093 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11094 HDA_OUTPUT));
11095 if (err < 0)
11096 return err;
11097 } else {
11098 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11099 "Speaker Playback Switch",
11100 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11101 HDA_OUTPUT));
11102 if (err < 0)
11103 return err;
11104 }
11105 }
11106 nid = cfg->hp_pins[0];
11107 if (nid) {
11108 /* spec->multiout.hp_nid = 2; */
11109 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11110 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11111 "Headphone Playback Volume",
11112 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11113 HDA_OUTPUT));
11114 if (err < 0)
11115 return err;
11116 }
11117 if (nid == 0x16) {
11118 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11119 "Headphone Playback Switch",
11120 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11121 HDA_OUTPUT));
11122 if (err < 0)
11123 return err;
11124 } else {
11125 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11126 "Headphone Playback Switch",
11127 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11128 HDA_OUTPUT));
11129 if (err < 0)
11130 return err;
11131 }
11132 }
11133 return 0;
11134}
11135
11136#define alc269_auto_create_analog_input_ctls \
11137 alc880_auto_create_analog_input_ctls
11138
11139#ifdef CONFIG_SND_HDA_POWER_SAVE
11140#define alc269_loopbacks alc880_loopbacks
11141#endif
11142
11143/* pcm configuration: identiacal with ALC880 */
11144#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11145#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11146#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11147#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11148
11149/*
11150 * BIOS auto configuration
11151 */
11152static int alc269_parse_auto_config(struct hda_codec *codec)
11153{
11154 struct alc_spec *spec = codec->spec;
11155 int err;
11156 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11157
11158 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11159 alc269_ignore);
11160 if (err < 0)
11161 return err;
11162
11163 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11164 if (err < 0)
11165 return err;
11166 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11167 if (err < 0)
11168 return err;
11169
11170 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11171
11172 if (spec->autocfg.dig_out_pin)
11173 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11174
11175 if (spec->kctl_alloc)
11176 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11177
11178 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11179 spec->num_mux_defs = 1;
11180 spec->input_mux = &spec->private_imux;
11181
11182 err = alc_auto_add_mic_boost(codec);
11183 if (err < 0)
11184 return err;
11185
11186 return 1;
11187}
11188
11189#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11190#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11191#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11192
11193
11194/* init callback for auto-configuration model -- overriding the default init */
11195static void alc269_auto_init(struct hda_codec *codec)
11196{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011197 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011198 alc269_auto_init_multi_out(codec);
11199 alc269_auto_init_hp_out(codec);
11200 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011201 if (spec->unsol_event)
11202 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011203}
11204
11205/*
11206 * configuration and preset
11207 */
11208static const char *alc269_models[ALC269_MODEL_LAST] = {
11209 [ALC269_BASIC] = "basic",
11210};
11211
11212static struct snd_pci_quirk alc269_cfg_tbl[] = {
11213 {}
11214};
11215
11216static struct alc_config_preset alc269_presets[] = {
11217 [ALC269_BASIC] = {
11218 .mixers = { alc269_base_mixer },
11219 .init_verbs = { alc269_init_verbs },
11220 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11221 .dac_nids = alc269_dac_nids,
11222 .hp_nid = 0x03,
11223 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11224 .channel_mode = alc269_modes,
11225 .input_mux = &alc269_capture_source,
11226 },
11227};
11228
11229static int patch_alc269(struct hda_codec *codec)
11230{
11231 struct alc_spec *spec;
11232 int board_config;
11233 int err;
11234
11235 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11236 if (spec == NULL)
11237 return -ENOMEM;
11238
11239 codec->spec = spec;
11240
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011241 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11242
Kailang Yangf6a92242007-12-13 16:52:54 +010011243 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11244 alc269_models,
11245 alc269_cfg_tbl);
11246
11247 if (board_config < 0) {
11248 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11249 "trying auto-probe from BIOS...\n");
11250 board_config = ALC269_AUTO;
11251 }
11252
11253 if (board_config == ALC269_AUTO) {
11254 /* automatic parse from the BIOS config */
11255 err = alc269_parse_auto_config(codec);
11256 if (err < 0) {
11257 alc_free(codec);
11258 return err;
11259 } else if (!err) {
11260 printk(KERN_INFO
11261 "hda_codec: Cannot set up configuration "
11262 "from BIOS. Using base mode...\n");
11263 board_config = ALC269_BASIC;
11264 }
11265 }
11266
11267 if (board_config != ALC269_AUTO)
11268 setup_preset(spec, &alc269_presets[board_config]);
11269
11270 spec->stream_name_analog = "ALC269 Analog";
11271 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11272 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11273
11274 spec->stream_name_digital = "ALC269 Digital";
11275 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11276 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11277
11278 spec->adc_nids = alc269_adc_nids;
11279 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11280 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11281 spec->num_mixers++;
11282
11283 codec->patch_ops = alc_patch_ops;
11284 if (board_config == ALC269_AUTO)
11285 spec->init_hook = alc269_auto_init;
11286#ifdef CONFIG_SND_HDA_POWER_SAVE
11287 if (!spec->loopback.amplist)
11288 spec->loopback.amplist = alc269_loopbacks;
11289#endif
11290
11291 return 0;
11292}
11293
11294/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11296 */
11297
11298/*
11299 * set the path ways for 2 channel output
11300 * need to set the codec line out and mic 1 pin widgets to inputs
11301 */
11302static struct hda_verb alc861_threestack_ch2_init[] = {
11303 /* set pin widget 1Ah (line in) for input */
11304 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011305 /* set pin widget 18h (mic1/2) for input, for mic also enable
11306 * the vref
11307 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011308 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11309
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011310 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11311#if 0
11312 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11313 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11314#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011315 { } /* end */
11316};
11317/*
11318 * 6ch mode
11319 * need to set the codec line out and mic 1 pin widgets to outputs
11320 */
11321static struct hda_verb alc861_threestack_ch6_init[] = {
11322 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11323 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11324 /* set pin widget 18h (mic1) for output (CLFE)*/
11325 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11326
11327 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011328 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011329
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11331#if 0
11332 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11333 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11334#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011335 { } /* end */
11336};
11337
11338static struct hda_channel_mode alc861_threestack_modes[2] = {
11339 { 2, alc861_threestack_ch2_init },
11340 { 6, alc861_threestack_ch6_init },
11341};
Takashi Iwai22309c32006-08-09 16:57:28 +020011342/* Set mic1 as input and unmute the mixer */
11343static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11344 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11346 { } /* end */
11347};
11348/* Set mic1 as output and mute mixer */
11349static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11350 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11351 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11352 { } /* end */
11353};
11354
11355static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11356 { 2, alc861_uniwill_m31_ch2_init },
11357 { 4, alc861_uniwill_m31_ch4_init },
11358};
Kailang Yangdf694da2005-12-05 19:42:22 +010011359
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011360/* Set mic1 and line-in as input and unmute the mixer */
11361static struct hda_verb alc861_asus_ch2_init[] = {
11362 /* set pin widget 1Ah (line in) for input */
11363 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011364 /* set pin widget 18h (mic1/2) for input, for mic also enable
11365 * the vref
11366 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011367 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11368
11369 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11370#if 0
11371 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11372 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11373#endif
11374 { } /* end */
11375};
11376/* Set mic1 nad line-in as output and mute mixer */
11377static struct hda_verb alc861_asus_ch6_init[] = {
11378 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11379 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11380 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11381 /* set pin widget 18h (mic1) for output (CLFE)*/
11382 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11383 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11384 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11385 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11386
11387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11388#if 0
11389 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11390 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11391#endif
11392 { } /* end */
11393};
11394
11395static struct hda_channel_mode alc861_asus_modes[2] = {
11396 { 2, alc861_asus_ch2_init },
11397 { 6, alc861_asus_ch6_init },
11398};
11399
Kailang Yangdf694da2005-12-05 19:42:22 +010011400/* patch-ALC861 */
11401
11402static struct snd_kcontrol_new alc861_base_mixer[] = {
11403 /* output mixer control */
11404 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11405 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11406 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11409
11410 /*Input mixer control */
11411 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11413 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11414 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11415 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11416 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11418 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11420 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011421
Kailang Yangdf694da2005-12-05 19:42:22 +010011422 /* Capture mixer control */
11423 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11424 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11425 {
11426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11427 .name = "Capture Source",
11428 .count = 1,
11429 .info = alc_mux_enum_info,
11430 .get = alc_mux_enum_get,
11431 .put = alc_mux_enum_put,
11432 },
11433 { } /* end */
11434};
11435
11436static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11437 /* output mixer control */
11438 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11439 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11440 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11441 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11442 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11443
11444 /* Input mixer control */
11445 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11446 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11447 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11448 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11449 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11450 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11452 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011455
Kailang Yangdf694da2005-12-05 19:42:22 +010011456 /* Capture mixer control */
11457 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11458 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11459 {
11460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11461 .name = "Capture Source",
11462 .count = 1,
11463 .info = alc_mux_enum_info,
11464 .get = alc_mux_enum_get,
11465 .put = alc_mux_enum_put,
11466 },
11467 {
11468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11469 .name = "Channel Mode",
11470 .info = alc_ch_mode_info,
11471 .get = alc_ch_mode_get,
11472 .put = alc_ch_mode_put,
11473 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11474 },
11475 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011476};
11477
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011478static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011479 /* output mixer control */
11480 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11482 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11483
11484 /*Capture mixer control */
11485 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11486 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11487 {
11488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11489 .name = "Capture Source",
11490 .count = 1,
11491 .info = alc_mux_enum_info,
11492 .get = alc_mux_enum_get,
11493 .put = alc_mux_enum_put,
11494 },
11495
11496 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011497};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011498
Takashi Iwai22309c32006-08-09 16:57:28 +020011499static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11500 /* output mixer control */
11501 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11502 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11503 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11504 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11505 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11506
11507 /* Input mixer control */
11508 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11509 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11510 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11511 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11512 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11513 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11515 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11516 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011518
Takashi Iwai22309c32006-08-09 16:57:28 +020011519 /* Capture mixer control */
11520 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11521 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11522 {
11523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11524 .name = "Capture Source",
11525 .count = 1,
11526 .info = alc_mux_enum_info,
11527 .get = alc_mux_enum_get,
11528 .put = alc_mux_enum_put,
11529 },
11530 {
11531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11532 .name = "Channel Mode",
11533 .info = alc_ch_mode_info,
11534 .get = alc_ch_mode_get,
11535 .put = alc_ch_mode_put,
11536 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11537 },
11538 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011539};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011540
11541static struct snd_kcontrol_new alc861_asus_mixer[] = {
11542 /* output mixer control */
11543 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11545 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11547 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11548
11549 /* Input mixer control */
11550 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11552 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11553 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11554 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11555 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11557 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11560
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011561 /* Capture mixer control */
11562 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11563 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11564 {
11565 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11566 .name = "Capture Source",
11567 .count = 1,
11568 .info = alc_mux_enum_info,
11569 .get = alc_mux_enum_get,
11570 .put = alc_mux_enum_put,
11571 },
11572 {
11573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11574 .name = "Channel Mode",
11575 .info = alc_ch_mode_info,
11576 .get = alc_ch_mode_get,
11577 .put = alc_ch_mode_put,
11578 .private_value = ARRAY_SIZE(alc861_asus_modes),
11579 },
11580 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011581};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011582
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011583/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011584static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011585 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11586 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11587 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11588 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11589 { }
11590};
11591
Kailang Yangdf694da2005-12-05 19:42:22 +010011592/*
11593 * generic initialization of ADC, input mixers and output mixers
11594 */
11595static struct hda_verb alc861_base_init_verbs[] = {
11596 /*
11597 * Unmute ADC0 and set the default input to mic-in
11598 */
11599 /* port-A for surround (rear panel) */
11600 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11601 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11602 /* port-B for mic-in (rear panel) with vref */
11603 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11604 /* port-C for line-in (rear panel) */
11605 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11606 /* port-D for Front */
11607 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11608 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11609 /* port-E for HP out (front panel) */
11610 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11611 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011612 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011613 /* port-F for mic-in (front panel) with vref */
11614 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11615 /* port-G for CLFE (rear panel) */
11616 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11617 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11618 /* port-H for side (rear panel) */
11619 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11620 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11621 /* CD-in */
11622 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11623 /* route front mic to ADC1*/
11624 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11626
11627 /* Unmute DAC0~3 & spdif out*/
11628 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11630 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11631 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11633
11634 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11635 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11636 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11637 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11638 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11639
11640 /* Unmute Stereo Mixer 15 */
11641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011645
11646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11647 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11648 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011654 /* hp used DAC 3 (Front) */
11655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11657
11658 { }
11659};
11660
11661static struct hda_verb alc861_threestack_init_verbs[] = {
11662 /*
11663 * Unmute ADC0 and set the default input to mic-in
11664 */
11665 /* port-A for surround (rear panel) */
11666 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11667 /* port-B for mic-in (rear panel) with vref */
11668 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11669 /* port-C for line-in (rear panel) */
11670 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11671 /* port-D for Front */
11672 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11673 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11674 /* port-E for HP out (front panel) */
11675 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11676 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011677 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011678 /* port-F for mic-in (front panel) with vref */
11679 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11680 /* port-G for CLFE (rear panel) */
11681 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11682 /* port-H for side (rear panel) */
11683 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11684 /* CD-in */
11685 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11686 /* route front mic to ADC1*/
11687 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11688 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11689 /* Unmute DAC0~3 & spdif out*/
11690 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11692 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11693 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11695
11696 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11697 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11698 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11699 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11700 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11701
11702 /* Unmute Stereo Mixer 15 */
11703 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011707
11708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11709 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11710 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11711 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11713 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11715 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011716 /* hp used DAC 3 (Front) */
11717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011718 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11719 { }
11720};
Takashi Iwai22309c32006-08-09 16:57:28 +020011721
11722static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11723 /*
11724 * Unmute ADC0 and set the default input to mic-in
11725 */
11726 /* port-A for surround (rear panel) */
11727 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11728 /* port-B for mic-in (rear panel) with vref */
11729 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11730 /* port-C for line-in (rear panel) */
11731 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11732 /* port-D for Front */
11733 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11734 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11735 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011736 /* this has to be set to VREF80 */
11737 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011738 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011739 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011740 /* port-F for mic-in (front panel) with vref */
11741 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11742 /* port-G for CLFE (rear panel) */
11743 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11744 /* port-H for side (rear panel) */
11745 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11746 /* CD-in */
11747 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11748 /* route front mic to ADC1*/
11749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11751 /* Unmute DAC0~3 & spdif out*/
11752 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11753 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11754 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11755 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11757
11758 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11759 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11760 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11761 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11762 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11763
11764 /* Unmute Stereo Mixer 15 */
11765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011769
11770 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11772 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11773 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011778 /* hp used DAC 3 (Front) */
11779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11781 { }
11782};
11783
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011784static struct hda_verb alc861_asus_init_verbs[] = {
11785 /*
11786 * Unmute ADC0 and set the default input to mic-in
11787 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011788 /* port-A for surround (rear panel)
11789 * according to codec#0 this is the HP jack
11790 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011791 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11792 /* route front PCM to HP */
11793 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11794 /* port-B for mic-in (rear panel) with vref */
11795 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11796 /* port-C for line-in (rear panel) */
11797 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11798 /* port-D for Front */
11799 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11800 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11801 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011802 /* this has to be set to VREF80 */
11803 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011804 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011805 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011806 /* port-F for mic-in (front panel) with vref */
11807 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11808 /* port-G for CLFE (rear panel) */
11809 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11810 /* port-H for side (rear panel) */
11811 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11812 /* CD-in */
11813 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11814 /* route front mic to ADC1*/
11815 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11816 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11817 /* Unmute DAC0~3 & spdif out*/
11818 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11819 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11820 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11821 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11823 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11824 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11825 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11826 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11827 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11828
11829 /* Unmute Stereo Mixer 15 */
11830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11831 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011834
11835 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11838 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011843 /* hp used DAC 3 (Front) */
11844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11846 { }
11847};
11848
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011849/* additional init verbs for ASUS laptops */
11850static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11851 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11853 { }
11854};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011855
Kailang Yangdf694da2005-12-05 19:42:22 +010011856/*
11857 * generic initialization of ADC, input mixers and output mixers
11858 */
11859static struct hda_verb alc861_auto_init_verbs[] = {
11860 /*
11861 * Unmute ADC0 and set the default input to mic-in
11862 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011863 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011864 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11865
11866 /* Unmute DAC0~3 & spdif out*/
11867 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11868 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11869 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11870 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11872
11873 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11874 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11875 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11876 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11877 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11878
11879 /* Unmute Stereo Mixer 15 */
11880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11884
11885 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11893
11894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011900 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11901 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011903 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011904
11905 { }
11906};
11907
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011908static struct hda_verb alc861_toshiba_init_verbs[] = {
11909 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011910
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011911 { }
11912};
11913
11914/* toggle speaker-output according to the hp-jack state */
11915static void alc861_toshiba_automute(struct hda_codec *codec)
11916{
11917 unsigned int present;
11918
11919 present = snd_hda_codec_read(codec, 0x0f, 0,
11920 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011921 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11922 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11923 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11924 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011925}
11926
11927static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11928 unsigned int res)
11929{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011930 if ((res >> 26) == ALC880_HP_EVENT)
11931 alc861_toshiba_automute(codec);
11932}
11933
Kailang Yangdf694da2005-12-05 19:42:22 +010011934/* pcm configuration: identiacal with ALC880 */
11935#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11936#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11937#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11938#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11939
11940
11941#define ALC861_DIGOUT_NID 0x07
11942
11943static struct hda_channel_mode alc861_8ch_modes[1] = {
11944 { 8, NULL }
11945};
11946
11947static hda_nid_t alc861_dac_nids[4] = {
11948 /* front, surround, clfe, side */
11949 0x03, 0x06, 0x05, 0x04
11950};
11951
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011952static hda_nid_t alc660_dac_nids[3] = {
11953 /* front, clfe, surround */
11954 0x03, 0x05, 0x06
11955};
11956
Kailang Yangdf694da2005-12-05 19:42:22 +010011957static hda_nid_t alc861_adc_nids[1] = {
11958 /* ADC0-2 */
11959 0x08,
11960};
11961
11962static struct hda_input_mux alc861_capture_source = {
11963 .num_items = 5,
11964 .items = {
11965 { "Mic", 0x0 },
11966 { "Front Mic", 0x3 },
11967 { "Line", 0x1 },
11968 { "CD", 0x4 },
11969 { "Mixer", 0x5 },
11970 },
11971};
11972
11973/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011974static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11975 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011976{
11977 int i;
11978 hda_nid_t nid;
11979
11980 spec->multiout.dac_nids = spec->private_dac_nids;
11981 for (i = 0; i < cfg->line_outs; i++) {
11982 nid = cfg->line_out_pins[i];
11983 if (nid) {
11984 if (i >= ARRAY_SIZE(alc861_dac_nids))
11985 continue;
11986 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11987 }
11988 }
11989 spec->multiout.num_dacs = cfg->line_outs;
11990 return 0;
11991}
11992
11993/* add playback controls from the parsed DAC table */
11994static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11995 const struct auto_pin_cfg *cfg)
11996{
11997 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011998 static const char *chname[4] = {
11999 "Front", "Surround", NULL /*CLFE*/, "Side"
12000 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012001 hda_nid_t nid;
12002 int i, idx, err;
12003
12004 for (i = 0; i < cfg->line_outs; i++) {
12005 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012006 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012007 continue;
12008 if (nid == 0x05) {
12009 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012010 err = add_control(spec, ALC_CTL_BIND_MUTE,
12011 "Center Playback Switch",
12012 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12013 HDA_OUTPUT));
12014 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012015 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012016 err = add_control(spec, ALC_CTL_BIND_MUTE,
12017 "LFE Playback Switch",
12018 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12019 HDA_OUTPUT));
12020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012021 return err;
12022 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012023 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12024 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012025 if (nid == alc861_dac_nids[idx])
12026 break;
12027 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012028 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12029 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12030 HDA_OUTPUT));
12031 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012032 return err;
12033 }
12034 }
12035 return 0;
12036}
12037
12038static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12039{
12040 int err;
12041 hda_nid_t nid;
12042
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012043 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012044 return 0;
12045
12046 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12047 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012048 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12049 "Headphone Playback Switch",
12050 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12051 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012052 return err;
12053 spec->multiout.hp_nid = nid;
12054 }
12055 return 0;
12056}
12057
12058/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012059static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12060 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012061{
Kailang Yangdf694da2005-12-05 19:42:22 +010012062 struct hda_input_mux *imux = &spec->private_imux;
12063 int i, err, idx, idx1;
12064
12065 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012066 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012067 case 0x0c:
12068 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012069 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012070 break;
12071 case 0x0f:
12072 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012073 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012074 break;
12075 case 0x0d:
12076 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012077 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012078 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012079 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012080 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012081 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012082 break;
12083 case 0x11:
12084 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012085 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012086 break;
12087 default:
12088 continue;
12089 }
12090
Takashi Iwai4a471b72005-12-07 13:56:29 +010012091 err = new_analog_input(spec, cfg->input_pins[i],
12092 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012093 if (err < 0)
12094 return err;
12095
Takashi Iwai4a471b72005-12-07 13:56:29 +010012096 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012097 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012098 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012099 }
12100 return 0;
12101}
12102
12103static struct snd_kcontrol_new alc861_capture_mixer[] = {
12104 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12105 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12106
12107 {
12108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12109 /* The multiple "Capture Source" controls confuse alsamixer
12110 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012111 */
12112 /* .name = "Capture Source", */
12113 .name = "Input Source",
12114 .count = 1,
12115 .info = alc_mux_enum_info,
12116 .get = alc_mux_enum_get,
12117 .put = alc_mux_enum_put,
12118 },
12119 { } /* end */
12120};
12121
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012122static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12123 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012124 int pin_type, int dac_idx)
12125{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12127 pin_type);
12128 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12129 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012130}
12131
12132static void alc861_auto_init_multi_out(struct hda_codec *codec)
12133{
12134 struct alc_spec *spec = codec->spec;
12135 int i;
12136
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012137 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012138 for (i = 0; i < spec->autocfg.line_outs; i++) {
12139 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012140 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012141 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012142 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012143 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012144 }
12145}
12146
12147static void alc861_auto_init_hp_out(struct hda_codec *codec)
12148{
12149 struct alc_spec *spec = codec->spec;
12150 hda_nid_t pin;
12151
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012152 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012153 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012154 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12155 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012156 pin = spec->autocfg.speaker_pins[0];
12157 if (pin)
12158 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012159}
12160
12161static void alc861_auto_init_analog_input(struct hda_codec *codec)
12162{
12163 struct alc_spec *spec = codec->spec;
12164 int i;
12165
12166 for (i = 0; i < AUTO_PIN_LAST; i++) {
12167 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012168 if (nid >= 0x0c && nid <= 0x11) {
12169 snd_hda_codec_write(codec, nid, 0,
12170 AC_VERB_SET_PIN_WIDGET_CONTROL,
12171 i <= AUTO_PIN_FRONT_MIC ?
12172 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012173 }
12174 }
12175}
12176
12177/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012178/* return 1 if successful, 0 if the proper config is not found,
12179 * or a negative error code
12180 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012181static int alc861_parse_auto_config(struct hda_codec *codec)
12182{
12183 struct alc_spec *spec = codec->spec;
12184 int err;
12185 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12186
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012187 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12188 alc861_ignore);
12189 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012190 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012191 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012192 return 0; /* can't find valid BIOS pin config */
12193
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012194 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12195 if (err < 0)
12196 return err;
12197 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12198 if (err < 0)
12199 return err;
12200 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12201 if (err < 0)
12202 return err;
12203 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12204 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012205 return err;
12206
12207 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12208
12209 if (spec->autocfg.dig_out_pin)
12210 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12211
12212 if (spec->kctl_alloc)
12213 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12214
12215 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12216
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012217 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012218 spec->input_mux = &spec->private_imux;
12219
12220 spec->adc_nids = alc861_adc_nids;
12221 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12222 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12223 spec->num_mixers++;
12224
12225 return 1;
12226}
12227
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012228/* additional initialization for auto-configuration model */
12229static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012230{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012231 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 alc861_auto_init_multi_out(codec);
12233 alc861_auto_init_hp_out(codec);
12234 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012235 if (spec->unsol_event)
12236 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012237}
12238
Takashi Iwaicb53c622007-08-10 17:21:45 +020012239#ifdef CONFIG_SND_HDA_POWER_SAVE
12240static struct hda_amp_list alc861_loopbacks[] = {
12241 { 0x15, HDA_INPUT, 0 },
12242 { 0x15, HDA_INPUT, 1 },
12243 { 0x15, HDA_INPUT, 2 },
12244 { 0x15, HDA_INPUT, 3 },
12245 { } /* end */
12246};
12247#endif
12248
Kailang Yangdf694da2005-12-05 19:42:22 +010012249
12250/*
12251 * configuration and preset
12252 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012253static const char *alc861_models[ALC861_MODEL_LAST] = {
12254 [ALC861_3ST] = "3stack",
12255 [ALC660_3ST] = "3stack-660",
12256 [ALC861_3ST_DIG] = "3stack-dig",
12257 [ALC861_6ST_DIG] = "6stack-dig",
12258 [ALC861_UNIWILL_M31] = "uniwill-m31",
12259 [ALC861_TOSHIBA] = "toshiba",
12260 [ALC861_ASUS] = "asus",
12261 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12262 [ALC861_AUTO] = "auto",
12263};
12264
12265static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012266 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012267 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12268 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12269 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012270 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012271 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012272 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012273 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12274 * Any other models that need this preset?
12275 */
12276 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012277 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12278 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012279 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12280 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12281 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12282 /* FIXME: the below seems conflict */
12283 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12284 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12285 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012286 {}
12287};
12288
12289static struct alc_config_preset alc861_presets[] = {
12290 [ALC861_3ST] = {
12291 .mixers = { alc861_3ST_mixer },
12292 .init_verbs = { alc861_threestack_init_verbs },
12293 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12294 .dac_nids = alc861_dac_nids,
12295 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12296 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012297 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012298 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12299 .adc_nids = alc861_adc_nids,
12300 .input_mux = &alc861_capture_source,
12301 },
12302 [ALC861_3ST_DIG] = {
12303 .mixers = { alc861_base_mixer },
12304 .init_verbs = { alc861_threestack_init_verbs },
12305 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12306 .dac_nids = alc861_dac_nids,
12307 .dig_out_nid = ALC861_DIGOUT_NID,
12308 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12309 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012310 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012311 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12312 .adc_nids = alc861_adc_nids,
12313 .input_mux = &alc861_capture_source,
12314 },
12315 [ALC861_6ST_DIG] = {
12316 .mixers = { alc861_base_mixer },
12317 .init_verbs = { alc861_base_init_verbs },
12318 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12319 .dac_nids = alc861_dac_nids,
12320 .dig_out_nid = ALC861_DIGOUT_NID,
12321 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12322 .channel_mode = alc861_8ch_modes,
12323 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12324 .adc_nids = alc861_adc_nids,
12325 .input_mux = &alc861_capture_source,
12326 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012327 [ALC660_3ST] = {
12328 .mixers = { alc861_3ST_mixer },
12329 .init_verbs = { alc861_threestack_init_verbs },
12330 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12331 .dac_nids = alc660_dac_nids,
12332 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12333 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012334 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012335 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12336 .adc_nids = alc861_adc_nids,
12337 .input_mux = &alc861_capture_source,
12338 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012339 [ALC861_UNIWILL_M31] = {
12340 .mixers = { alc861_uniwill_m31_mixer },
12341 .init_verbs = { alc861_uniwill_m31_init_verbs },
12342 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12343 .dac_nids = alc861_dac_nids,
12344 .dig_out_nid = ALC861_DIGOUT_NID,
12345 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12346 .channel_mode = alc861_uniwill_m31_modes,
12347 .need_dac_fix = 1,
12348 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12349 .adc_nids = alc861_adc_nids,
12350 .input_mux = &alc861_capture_source,
12351 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012352 [ALC861_TOSHIBA] = {
12353 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012354 .init_verbs = { alc861_base_init_verbs,
12355 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012356 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12357 .dac_nids = alc861_dac_nids,
12358 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12359 .channel_mode = alc883_3ST_2ch_modes,
12360 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12361 .adc_nids = alc861_adc_nids,
12362 .input_mux = &alc861_capture_source,
12363 .unsol_event = alc861_toshiba_unsol_event,
12364 .init_hook = alc861_toshiba_automute,
12365 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012366 [ALC861_ASUS] = {
12367 .mixers = { alc861_asus_mixer },
12368 .init_verbs = { alc861_asus_init_verbs },
12369 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12370 .dac_nids = alc861_dac_nids,
12371 .dig_out_nid = ALC861_DIGOUT_NID,
12372 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12373 .channel_mode = alc861_asus_modes,
12374 .need_dac_fix = 1,
12375 .hp_nid = 0x06,
12376 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12377 .adc_nids = alc861_adc_nids,
12378 .input_mux = &alc861_capture_source,
12379 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012380 [ALC861_ASUS_LAPTOP] = {
12381 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12382 .init_verbs = { alc861_asus_init_verbs,
12383 alc861_asus_laptop_init_verbs },
12384 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12385 .dac_nids = alc861_dac_nids,
12386 .dig_out_nid = ALC861_DIGOUT_NID,
12387 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12388 .channel_mode = alc883_3ST_2ch_modes,
12389 .need_dac_fix = 1,
12390 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12391 .adc_nids = alc861_adc_nids,
12392 .input_mux = &alc861_capture_source,
12393 },
12394};
Kailang Yangdf694da2005-12-05 19:42:22 +010012395
12396
12397static int patch_alc861(struct hda_codec *codec)
12398{
12399 struct alc_spec *spec;
12400 int board_config;
12401 int err;
12402
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012404 if (spec == NULL)
12405 return -ENOMEM;
12406
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012407 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012408
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012409 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12410 alc861_models,
12411 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012412
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012413 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012414 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12415 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012416 board_config = ALC861_AUTO;
12417 }
12418
12419 if (board_config == ALC861_AUTO) {
12420 /* automatic parse from the BIOS config */
12421 err = alc861_parse_auto_config(codec);
12422 if (err < 0) {
12423 alc_free(codec);
12424 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012425 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012426 printk(KERN_INFO
12427 "hda_codec: Cannot set up configuration "
12428 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012429 board_config = ALC861_3ST_DIG;
12430 }
12431 }
12432
12433 if (board_config != ALC861_AUTO)
12434 setup_preset(spec, &alc861_presets[board_config]);
12435
12436 spec->stream_name_analog = "ALC861 Analog";
12437 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12438 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12439
12440 spec->stream_name_digital = "ALC861 Digital";
12441 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12442 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12443
Takashi Iwai2134ea42008-01-10 16:53:55 +010012444 spec->vmaster_nid = 0x03;
12445
Kailang Yangdf694da2005-12-05 19:42:22 +010012446 codec->patch_ops = alc_patch_ops;
12447 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012448 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012449#ifdef CONFIG_SND_HDA_POWER_SAVE
12450 if (!spec->loopback.amplist)
12451 spec->loopback.amplist = alc861_loopbacks;
12452#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012453
12454 return 0;
12455}
12456
12457/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012458 * ALC861-VD support
12459 *
12460 * Based on ALC882
12461 *
12462 * In addition, an independent DAC
12463 */
12464#define ALC861VD_DIGOUT_NID 0x06
12465
12466static hda_nid_t alc861vd_dac_nids[4] = {
12467 /* front, surr, clfe, side surr */
12468 0x02, 0x03, 0x04, 0x05
12469};
12470
12471/* dac_nids for ALC660vd are in a different order - according to
12472 * Realtek's driver.
12473 * This should probably tesult in a different mixer for 6stack models
12474 * of ALC660vd codecs, but for now there is only 3stack mixer
12475 * - and it is the same as in 861vd.
12476 * adc_nids in ALC660vd are (is) the same as in 861vd
12477 */
12478static hda_nid_t alc660vd_dac_nids[3] = {
12479 /* front, rear, clfe, rear_surr */
12480 0x02, 0x04, 0x03
12481};
12482
12483static hda_nid_t alc861vd_adc_nids[1] = {
12484 /* ADC0 */
12485 0x09,
12486};
12487
Takashi Iwaie1406342008-02-11 18:32:32 +010012488static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12489
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012490/* input MUX */
12491/* FIXME: should be a matrix-type input source selection */
12492static struct hda_input_mux alc861vd_capture_source = {
12493 .num_items = 4,
12494 .items = {
12495 { "Mic", 0x0 },
12496 { "Front Mic", 0x1 },
12497 { "Line", 0x2 },
12498 { "CD", 0x4 },
12499 },
12500};
12501
Kailang Yang272a5272007-05-14 11:00:38 +020012502static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012503 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012504 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012505 { "Ext Mic", 0x0 },
12506 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012507 },
12508};
12509
Kailang Yangd1a991a2007-08-15 16:21:59 +020012510static struct hda_input_mux alc861vd_hp_capture_source = {
12511 .num_items = 2,
12512 .items = {
12513 { "Front Mic", 0x0 },
12514 { "ATAPI Mic", 0x1 },
12515 },
12516};
12517
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012518#define alc861vd_mux_enum_info alc_mux_enum_info
12519#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012520/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12521#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012522
12523/*
12524 * 2ch mode
12525 */
12526static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12527 { 2, NULL }
12528};
12529
12530/*
12531 * 6ch mode
12532 */
12533static struct hda_verb alc861vd_6stack_ch6_init[] = {
12534 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12535 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12536 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12537 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12538 { } /* end */
12539};
12540
12541/*
12542 * 8ch mode
12543 */
12544static struct hda_verb alc861vd_6stack_ch8_init[] = {
12545 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12546 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12547 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12548 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12549 { } /* end */
12550};
12551
12552static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12553 { 6, alc861vd_6stack_ch6_init },
12554 { 8, alc861vd_6stack_ch8_init },
12555};
12556
12557static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12558 {
12559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12560 .name = "Channel Mode",
12561 .info = alc_ch_mode_info,
12562 .get = alc_ch_mode_get,
12563 .put = alc_ch_mode_put,
12564 },
12565 { } /* end */
12566};
12567
12568static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12569 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12570 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12571
12572 {
12573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12574 /* The multiple "Capture Source" controls confuse alsamixer
12575 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012576 */
12577 /* .name = "Capture Source", */
12578 .name = "Input Source",
12579 .count = 1,
12580 .info = alc861vd_mux_enum_info,
12581 .get = alc861vd_mux_enum_get,
12582 .put = alc861vd_mux_enum_put,
12583 },
12584 { } /* end */
12585};
12586
12587/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12588 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12589 */
12590static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12591 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12592 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12593
12594 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12595 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12596
12597 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12598 HDA_OUTPUT),
12599 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12600 HDA_OUTPUT),
12601 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12602 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12603
12604 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12605 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12606
12607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12608
12609 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12612
12613 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12614 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12615 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12616
12617 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12618 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12619
12620 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12621 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12622
12623 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12624 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12625
12626 { } /* end */
12627};
12628
12629static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12630 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12631 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12632
12633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12634
12635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12638
12639 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12640 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12642
12643 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12644 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12645
12646 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12647 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12648
12649 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12650 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12651
12652 { } /* end */
12653};
12654
Kailang Yangbdd148a2007-05-08 15:19:08 +020012655static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12656 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12657 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12658 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12659
12660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12661
12662 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12665
12666 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12667 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12668 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12669
12670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12672
12673 { } /* end */
12674};
12675
Tobin Davisb419f342008-03-07 11:57:51 +010012676/* Pin assignment: Speaker=0x14, HP = 0x15,
12677 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012678 */
12679static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012680 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12681 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12683 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012684 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12685 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12686 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12687 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12688 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12689 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12690 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12691 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012692 { } /* end */
12693};
12694
Kailang Yangd1a991a2007-08-15 16:21:59 +020012695/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12696 * Front Mic=0x18, ATAPI Mic = 0x19,
12697 */
12698static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12699 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12700 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12702 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12703 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12705 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12706 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12707
12708 { } /* end */
12709};
12710
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012711/*
12712 * generic initialization of ADC, input mixers and output mixers
12713 */
12714static struct hda_verb alc861vd_volume_init_verbs[] = {
12715 /*
12716 * Unmute ADC0 and set the default input to mic-in
12717 */
12718 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12720
12721 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12722 * the analog-loopback mixer widget
12723 */
12724 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012730
12731 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012736
12737 /*
12738 * Set up output mixers (0x02 - 0x05)
12739 */
12740 /* set vol=0 to output mixers */
12741 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12742 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12743 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12745
12746 /* set up input amps for analog loopback */
12747 /* Amp Indices: DAC = 0, mixer = 1 */
12748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12750 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12756
12757 { }
12758};
12759
12760/*
12761 * 3-stack pin configuration:
12762 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12763 */
12764static struct hda_verb alc861vd_3stack_init_verbs[] = {
12765 /*
12766 * Set pin mode and muting
12767 */
12768 /* set front pin widgets 0x14 for output */
12769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12772
12773 /* Mic (rear) pin: input vref at 80% */
12774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12776 /* Front Mic pin: input vref at 80% */
12777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12779 /* Line In pin: input */
12780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12782 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12786 /* CD pin widget for input */
12787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12788
12789 { }
12790};
12791
12792/*
12793 * 6-stack pin configuration:
12794 */
12795static struct hda_verb alc861vd_6stack_init_verbs[] = {
12796 /*
12797 * Set pin mode and muting
12798 */
12799 /* set front pin widgets 0x14 for output */
12800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12802 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12803
12804 /* Rear Pin: output 1 (0x0d) */
12805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12807 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12808 /* CLFE Pin: output 2 (0x0e) */
12809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12810 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12811 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12812 /* Side Pin: output 3 (0x0f) */
12813 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12815 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12816
12817 /* Mic (rear) pin: input vref at 80% */
12818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12819 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12820 /* Front Mic pin: input vref at 80% */
12821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12823 /* Line In pin: input */
12824 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12825 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12826 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12829 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12830 /* CD pin widget for input */
12831 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12832
12833 { }
12834};
12835
Kailang Yangbdd148a2007-05-08 15:19:08 +020012836static struct hda_verb alc861vd_eapd_verbs[] = {
12837 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12838 { }
12839};
12840
Kailang Yangf9423e72008-05-27 12:32:25 +020012841static struct hda_verb alc660vd_eapd_verbs[] = {
12842 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12843 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12844 { }
12845};
12846
Kailang Yangbdd148a2007-05-08 15:19:08 +020012847static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12851 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12852 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12853 {}
12854};
12855
12856/* toggle speaker-output according to the hp-jack state */
12857static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12858{
12859 unsigned int present;
12860 unsigned char bits;
12861
12862 present = snd_hda_codec_read(codec, 0x1b, 0,
12863 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012864 bits = present ? HDA_AMP_MUTE : 0;
12865 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12866 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012867}
12868
12869static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12870{
12871 unsigned int present;
12872 unsigned char bits;
12873
12874 present = snd_hda_codec_read(codec, 0x18, 0,
12875 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012876 bits = present ? HDA_AMP_MUTE : 0;
12877 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12878 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012879}
12880
12881static void alc861vd_lenovo_automute(struct hda_codec *codec)
12882{
12883 alc861vd_lenovo_hp_automute(codec);
12884 alc861vd_lenovo_mic_automute(codec);
12885}
12886
12887static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12888 unsigned int res)
12889{
12890 switch (res >> 26) {
12891 case ALC880_HP_EVENT:
12892 alc861vd_lenovo_hp_automute(codec);
12893 break;
12894 case ALC880_MIC_EVENT:
12895 alc861vd_lenovo_mic_automute(codec);
12896 break;
12897 }
12898}
12899
Kailang Yang272a5272007-05-14 11:00:38 +020012900static struct hda_verb alc861vd_dallas_verbs[] = {
12901 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12902 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12903 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12904 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12905
12906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12913 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12914
12915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12921 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12922 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12923
12924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12930 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12931 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12932
12933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12937
12938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12939 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12941
12942 { } /* end */
12943};
12944
12945/* toggle speaker-output according to the hp-jack state */
12946static void alc861vd_dallas_automute(struct hda_codec *codec)
12947{
12948 unsigned int present;
12949
12950 present = snd_hda_codec_read(codec, 0x15, 0,
12951 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012952 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012954}
12955
12956static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12957{
12958 if ((res >> 26) == ALC880_HP_EVENT)
12959 alc861vd_dallas_automute(codec);
12960}
12961
Takashi Iwaicb53c622007-08-10 17:21:45 +020012962#ifdef CONFIG_SND_HDA_POWER_SAVE
12963#define alc861vd_loopbacks alc880_loopbacks
12964#endif
12965
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012966/* pcm configuration: identiacal with ALC880 */
12967#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12968#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12969#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12970#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12971
12972/*
12973 * configuration and preset
12974 */
12975static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12976 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012977 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012978 [ALC861VD_3ST] = "3stack",
12979 [ALC861VD_3ST_DIG] = "3stack-digout",
12980 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012981 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012982 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012983 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012984 [ALC861VD_AUTO] = "auto",
12985};
12986
12987static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012988 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12989 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012990 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012991 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012992 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012993 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012994 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012995 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012996 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012997 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010012998 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012999 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013000 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13001 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013002 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013003 {}
13004};
13005
13006static struct alc_config_preset alc861vd_presets[] = {
13007 [ALC660VD_3ST] = {
13008 .mixers = { alc861vd_3st_mixer },
13009 .init_verbs = { alc861vd_volume_init_verbs,
13010 alc861vd_3stack_init_verbs },
13011 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13012 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013013 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13014 .channel_mode = alc861vd_3stack_2ch_modes,
13015 .input_mux = &alc861vd_capture_source,
13016 },
Mike Crash6963f842007-06-25 12:12:51 +020013017 [ALC660VD_3ST_DIG] = {
13018 .mixers = { alc861vd_3st_mixer },
13019 .init_verbs = { alc861vd_volume_init_verbs,
13020 alc861vd_3stack_init_verbs },
13021 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13022 .dac_nids = alc660vd_dac_nids,
13023 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013024 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13025 .channel_mode = alc861vd_3stack_2ch_modes,
13026 .input_mux = &alc861vd_capture_source,
13027 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013028 [ALC861VD_3ST] = {
13029 .mixers = { alc861vd_3st_mixer },
13030 .init_verbs = { alc861vd_volume_init_verbs,
13031 alc861vd_3stack_init_verbs },
13032 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13033 .dac_nids = alc861vd_dac_nids,
13034 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13035 .channel_mode = alc861vd_3stack_2ch_modes,
13036 .input_mux = &alc861vd_capture_source,
13037 },
13038 [ALC861VD_3ST_DIG] = {
13039 .mixers = { alc861vd_3st_mixer },
13040 .init_verbs = { alc861vd_volume_init_verbs,
13041 alc861vd_3stack_init_verbs },
13042 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13043 .dac_nids = alc861vd_dac_nids,
13044 .dig_out_nid = ALC861VD_DIGOUT_NID,
13045 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13046 .channel_mode = alc861vd_3stack_2ch_modes,
13047 .input_mux = &alc861vd_capture_source,
13048 },
13049 [ALC861VD_6ST_DIG] = {
13050 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13051 .init_verbs = { alc861vd_volume_init_verbs,
13052 alc861vd_6stack_init_verbs },
13053 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13054 .dac_nids = alc861vd_dac_nids,
13055 .dig_out_nid = ALC861VD_DIGOUT_NID,
13056 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13057 .channel_mode = alc861vd_6stack_modes,
13058 .input_mux = &alc861vd_capture_source,
13059 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013060 [ALC861VD_LENOVO] = {
13061 .mixers = { alc861vd_lenovo_mixer },
13062 .init_verbs = { alc861vd_volume_init_verbs,
13063 alc861vd_3stack_init_verbs,
13064 alc861vd_eapd_verbs,
13065 alc861vd_lenovo_unsol_verbs },
13066 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13067 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013068 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13069 .channel_mode = alc861vd_3stack_2ch_modes,
13070 .input_mux = &alc861vd_capture_source,
13071 .unsol_event = alc861vd_lenovo_unsol_event,
13072 .init_hook = alc861vd_lenovo_automute,
13073 },
Kailang Yang272a5272007-05-14 11:00:38 +020013074 [ALC861VD_DALLAS] = {
13075 .mixers = { alc861vd_dallas_mixer },
13076 .init_verbs = { alc861vd_dallas_verbs },
13077 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13078 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013079 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13080 .channel_mode = alc861vd_3stack_2ch_modes,
13081 .input_mux = &alc861vd_dallas_capture_source,
13082 .unsol_event = alc861vd_dallas_unsol_event,
13083 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013084 },
13085 [ALC861VD_HP] = {
13086 .mixers = { alc861vd_hp_mixer },
13087 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13088 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13089 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013090 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013091 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13092 .channel_mode = alc861vd_3stack_2ch_modes,
13093 .input_mux = &alc861vd_hp_capture_source,
13094 .unsol_event = alc861vd_dallas_unsol_event,
13095 .init_hook = alc861vd_dallas_automute,
13096 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013097};
13098
13099/*
13100 * BIOS auto configuration
13101 */
13102static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13103 hda_nid_t nid, int pin_type, int dac_idx)
13104{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013105 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013106}
13107
13108static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13109{
13110 struct alc_spec *spec = codec->spec;
13111 int i;
13112
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013113 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013114 for (i = 0; i <= HDA_SIDE; i++) {
13115 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013116 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013117 if (nid)
13118 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013119 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013120 }
13121}
13122
13123
13124static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13125{
13126 struct alc_spec *spec = codec->spec;
13127 hda_nid_t pin;
13128
13129 pin = spec->autocfg.hp_pins[0];
13130 if (pin) /* connect to front and use dac 0 */
13131 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013132 pin = spec->autocfg.speaker_pins[0];
13133 if (pin)
13134 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013135}
13136
13137#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13138#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13139
13140static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13141{
13142 struct alc_spec *spec = codec->spec;
13143 int i;
13144
13145 for (i = 0; i < AUTO_PIN_LAST; i++) {
13146 hda_nid_t nid = spec->autocfg.input_pins[i];
13147 if (alc861vd_is_input_pin(nid)) {
13148 snd_hda_codec_write(codec, nid, 0,
13149 AC_VERB_SET_PIN_WIDGET_CONTROL,
13150 i <= AUTO_PIN_FRONT_MIC ?
13151 PIN_VREF80 : PIN_IN);
13152 if (nid != ALC861VD_PIN_CD_NID)
13153 snd_hda_codec_write(codec, nid, 0,
13154 AC_VERB_SET_AMP_GAIN_MUTE,
13155 AMP_OUT_MUTE);
13156 }
13157 }
13158}
13159
13160#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13161#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13162
13163/* add playback controls from the parsed DAC table */
13164/* Based on ALC880 version. But ALC861VD has separate,
13165 * different NIDs for mute/unmute switch and volume control */
13166static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13167 const struct auto_pin_cfg *cfg)
13168{
13169 char name[32];
13170 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13171 hda_nid_t nid_v, nid_s;
13172 int i, err;
13173
13174 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013175 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013176 continue;
13177 nid_v = alc861vd_idx_to_mixer_vol(
13178 alc880_dac_to_idx(
13179 spec->multiout.dac_nids[i]));
13180 nid_s = alc861vd_idx_to_mixer_switch(
13181 alc880_dac_to_idx(
13182 spec->multiout.dac_nids[i]));
13183
13184 if (i == 2) {
13185 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013186 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13187 "Center Playback Volume",
13188 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13189 HDA_OUTPUT));
13190 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013191 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013192 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13193 "LFE Playback Volume",
13194 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13195 HDA_OUTPUT));
13196 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013197 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013198 err = add_control(spec, ALC_CTL_BIND_MUTE,
13199 "Center Playback Switch",
13200 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13201 HDA_INPUT));
13202 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013203 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013204 err = add_control(spec, ALC_CTL_BIND_MUTE,
13205 "LFE Playback Switch",
13206 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13207 HDA_INPUT));
13208 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013209 return err;
13210 } else {
13211 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013212 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13213 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13214 HDA_OUTPUT));
13215 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013216 return err;
13217 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013218 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013219 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013220 HDA_INPUT));
13221 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013222 return err;
13223 }
13224 }
13225 return 0;
13226}
13227
13228/* add playback controls for speaker and HP outputs */
13229/* Based on ALC880 version. But ALC861VD has separate,
13230 * different NIDs for mute/unmute switch and volume control */
13231static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13232 hda_nid_t pin, const char *pfx)
13233{
13234 hda_nid_t nid_v, nid_s;
13235 int err;
13236 char name[32];
13237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013238 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013239 return 0;
13240
13241 if (alc880_is_fixed_pin(pin)) {
13242 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13243 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013244 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013245 spec->multiout.hp_nid = nid_v;
13246 else
13247 spec->multiout.extra_out_nid[0] = nid_v;
13248 /* control HP volume/switch on the output mixer amp */
13249 nid_v = alc861vd_idx_to_mixer_vol(
13250 alc880_fixed_pin_idx(pin));
13251 nid_s = alc861vd_idx_to_mixer_switch(
13252 alc880_fixed_pin_idx(pin));
13253
13254 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013255 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13256 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13257 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013258 return err;
13259 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013260 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13261 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13262 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013263 return err;
13264 } else if (alc880_is_multi_pin(pin)) {
13265 /* set manual connection */
13266 /* we have only a switch on HP-out PIN */
13267 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013268 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13269 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13270 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013271 return err;
13272 }
13273 return 0;
13274}
13275
13276/* parse the BIOS configuration and set up the alc_spec
13277 * return 1 if successful, 0 if the proper config is not found,
13278 * or a negative error code
13279 * Based on ALC880 version - had to change it to override
13280 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13281static int alc861vd_parse_auto_config(struct hda_codec *codec)
13282{
13283 struct alc_spec *spec = codec->spec;
13284 int err;
13285 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13286
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013287 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13288 alc861vd_ignore);
13289 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013291 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013292 return 0; /* can't find valid BIOS pin config */
13293
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013294 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13295 if (err < 0)
13296 return err;
13297 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13298 if (err < 0)
13299 return err;
13300 err = alc861vd_auto_create_extra_out(spec,
13301 spec->autocfg.speaker_pins[0],
13302 "Speaker");
13303 if (err < 0)
13304 return err;
13305 err = alc861vd_auto_create_extra_out(spec,
13306 spec->autocfg.hp_pins[0],
13307 "Headphone");
13308 if (err < 0)
13309 return err;
13310 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13311 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013312 return err;
13313
13314 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13315
13316 if (spec->autocfg.dig_out_pin)
13317 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13318
13319 if (spec->kctl_alloc)
13320 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13321
13322 spec->init_verbs[spec->num_init_verbs++]
13323 = alc861vd_volume_init_verbs;
13324
13325 spec->num_mux_defs = 1;
13326 spec->input_mux = &spec->private_imux;
13327
Takashi Iwai776e1842007-08-29 15:07:11 +020013328 err = alc_auto_add_mic_boost(codec);
13329 if (err < 0)
13330 return err;
13331
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013332 return 1;
13333}
13334
13335/* additional initialization for auto-configuration model */
13336static void alc861vd_auto_init(struct hda_codec *codec)
13337{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013338 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013339 alc861vd_auto_init_multi_out(codec);
13340 alc861vd_auto_init_hp_out(codec);
13341 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013342 if (spec->unsol_event)
13343 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013344}
13345
13346static int patch_alc861vd(struct hda_codec *codec)
13347{
13348 struct alc_spec *spec;
13349 int err, board_config;
13350
13351 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13352 if (spec == NULL)
13353 return -ENOMEM;
13354
13355 codec->spec = spec;
13356
13357 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13358 alc861vd_models,
13359 alc861vd_cfg_tbl);
13360
13361 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13362 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13363 "ALC861VD, trying auto-probe from BIOS...\n");
13364 board_config = ALC861VD_AUTO;
13365 }
13366
13367 if (board_config == ALC861VD_AUTO) {
13368 /* automatic parse from the BIOS config */
13369 err = alc861vd_parse_auto_config(codec);
13370 if (err < 0) {
13371 alc_free(codec);
13372 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013373 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013374 printk(KERN_INFO
13375 "hda_codec: Cannot set up configuration "
13376 "from BIOS. Using base mode...\n");
13377 board_config = ALC861VD_3ST;
13378 }
13379 }
13380
13381 if (board_config != ALC861VD_AUTO)
13382 setup_preset(spec, &alc861vd_presets[board_config]);
13383
Kailang Yang2f893282008-05-27 12:14:47 +020013384 if (codec->vendor_id == 0x10ec0660) {
13385 spec->stream_name_analog = "ALC660-VD Analog";
13386 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013387 /* always turn on EAPD */
13388 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013389 } else {
13390 spec->stream_name_analog = "ALC861VD Analog";
13391 spec->stream_name_digital = "ALC861VD Digital";
13392 }
13393
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013394 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13395 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13396
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013397 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13398 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13399
13400 spec->adc_nids = alc861vd_adc_nids;
13401 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013402 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013403
13404 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13405 spec->num_mixers++;
13406
Takashi Iwai2134ea42008-01-10 16:53:55 +010013407 spec->vmaster_nid = 0x02;
13408
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013409 codec->patch_ops = alc_patch_ops;
13410
13411 if (board_config == ALC861VD_AUTO)
13412 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013413#ifdef CONFIG_SND_HDA_POWER_SAVE
13414 if (!spec->loopback.amplist)
13415 spec->loopback.amplist = alc861vd_loopbacks;
13416#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013417
13418 return 0;
13419}
13420
13421/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013422 * ALC662 support
13423 *
13424 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13425 * configuration. Each pin widget can choose any input DACs and a mixer.
13426 * Each ADC is connected from a mixer of all inputs. This makes possible
13427 * 6-channel independent captures.
13428 *
13429 * In addition, an independent DAC for the multi-playback (not used in this
13430 * driver yet).
13431 */
13432#define ALC662_DIGOUT_NID 0x06
13433#define ALC662_DIGIN_NID 0x0a
13434
13435static hda_nid_t alc662_dac_nids[4] = {
13436 /* front, rear, clfe, rear_surr */
13437 0x02, 0x03, 0x04
13438};
13439
13440static hda_nid_t alc662_adc_nids[1] = {
13441 /* ADC1-2 */
13442 0x09,
13443};
Takashi Iwaie1406342008-02-11 18:32:32 +010013444
Kailang Yang77a261b2008-02-19 11:38:05 +010013445static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013446
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013447/* input MUX */
13448/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013449static struct hda_input_mux alc662_capture_source = {
13450 .num_items = 4,
13451 .items = {
13452 { "Mic", 0x0 },
13453 { "Front Mic", 0x1 },
13454 { "Line", 0x2 },
13455 { "CD", 0x4 },
13456 },
13457};
13458
13459static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13460 .num_items = 2,
13461 .items = {
13462 { "Mic", 0x1 },
13463 { "Line", 0x2 },
13464 },
13465};
Kailang Yang291702f2007-10-16 14:28:03 +020013466
13467static struct hda_input_mux alc662_eeepc_capture_source = {
13468 .num_items = 2,
13469 .items = {
13470 { "i-Mic", 0x1 },
13471 { "e-Mic", 0x0 },
13472 },
13473};
13474
Kailang Yang6dda9f42008-05-27 12:05:31 +020013475static struct hda_input_mux alc663_capture_source = {
13476 .num_items = 3,
13477 .items = {
13478 { "Mic", 0x0 },
13479 { "Front Mic", 0x1 },
13480 { "Line", 0x2 },
13481 },
13482};
13483
13484static struct hda_input_mux alc663_m51va_capture_source = {
13485 .num_items = 2,
13486 .items = {
13487 { "Ext-Mic", 0x0 },
13488 { "D-Mic", 0x9 },
13489 },
13490};
13491
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013492#define alc662_mux_enum_info alc_mux_enum_info
13493#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013494#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013495
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013496/*
13497 * 2ch mode
13498 */
13499static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13500 { 2, NULL }
13501};
13502
13503/*
13504 * 2ch mode
13505 */
13506static struct hda_verb alc662_3ST_ch2_init[] = {
13507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13511 { } /* end */
13512};
13513
13514/*
13515 * 6ch mode
13516 */
13517static struct hda_verb alc662_3ST_ch6_init[] = {
13518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13520 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13523 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13524 { } /* end */
13525};
13526
13527static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13528 { 2, alc662_3ST_ch2_init },
13529 { 6, alc662_3ST_ch6_init },
13530};
13531
13532/*
13533 * 2ch mode
13534 */
13535static struct hda_verb alc662_sixstack_ch6_init[] = {
13536 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13537 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13538 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13539 { } /* end */
13540};
13541
13542/*
13543 * 6ch mode
13544 */
13545static struct hda_verb alc662_sixstack_ch8_init[] = {
13546 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13547 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13548 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13549 { } /* end */
13550};
13551
13552static struct hda_channel_mode alc662_5stack_modes[2] = {
13553 { 2, alc662_sixstack_ch6_init },
13554 { 6, alc662_sixstack_ch8_init },
13555};
13556
13557/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13558 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13559 */
13560
13561static struct snd_kcontrol_new alc662_base_mixer[] = {
13562 /* output mixer control */
13563 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013564 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013565 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013566 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013567 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13568 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013569 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13570 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13572
13573 /*Input mixer control */
13574 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13575 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13576 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13577 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13578 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13579 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013582 { } /* end */
13583};
13584
13585static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13586 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013587 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13595 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13596 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13597 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13598 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013599 { } /* end */
13600};
13601
13602static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13603 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013604 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013606 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013607 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13608 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013609 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13610 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13620 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13621 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013622 { } /* end */
13623};
13624
13625static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13626 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13627 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013628 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13629 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013635 { } /* end */
13636};
13637
Kailang Yang291702f2007-10-16 14:28:03 +020013638static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013639 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013640
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013641 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13642 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013643
13644 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13645 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13646 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13647
13648 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13649 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13650 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13651 { } /* end */
13652};
13653
Kailang Yang8c427222008-01-10 13:03:59 +010013654static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013655 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13656 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13658 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013663 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013664 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13669 { } /* end */
13670};
13671
Kailang Yang6dda9f42008-05-27 12:05:31 +020013672static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13673 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13674 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13678 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13679 { } /* end */
13680};
13681
13682static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13683 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13684 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13685 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13686 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13688
13689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13690 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13691 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13692 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13693 { } /* end */
13694};
13695
13696static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13697 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13699 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13700
13701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13702 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13703 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13704 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13707 { } /* end */
13708};
13709
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013710static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13711 {
13712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13713 .name = "Channel Mode",
13714 .info = alc_ch_mode_info,
13715 .get = alc_ch_mode_get,
13716 .put = alc_ch_mode_put,
13717 },
13718 { } /* end */
13719};
13720
13721static struct hda_verb alc662_init_verbs[] = {
13722 /* ADC: mute amp left and right */
13723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13724 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13725 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13726
Takashi Iwaicb53c622007-08-10 17:21:45 +020013727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013732
Kailang Yangb60dd392007-09-20 12:50:29 +020013733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013739
13740 /* Front Pin: output 0 (0x0c) */
13741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13743
13744 /* Rear Pin: output 1 (0x0d) */
13745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13747
13748 /* CLFE Pin: output 2 (0x0e) */
13749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13751
13752 /* Mic (rear) pin: input vref at 80% */
13753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13755 /* Front Mic pin: input vref at 80% */
13756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13758 /* Line In pin: input */
13759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13761 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13762 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13763 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13764 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13765 /* CD pin widget for input */
13766 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13767
13768 /* FIXME: use matrix-type input source selection */
13769 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13770 /* Input mixer */
13771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013775
13776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020013780
13781 /* always trun on EAPD */
13782 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13783 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13784
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013785 { }
13786};
13787
13788static struct hda_verb alc662_sue_init_verbs[] = {
13789 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13790 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013791 {}
13792};
13793
13794static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13795 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13797 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013798};
13799
Kailang Yang8c427222008-01-10 13:03:59 +010013800/* Set Unsolicited Event*/
13801static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13802 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13803 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13804 {}
13805};
13806
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013807/*
13808 * generic initialization of ADC, input mixers and output mixers
13809 */
13810static struct hda_verb alc662_auto_init_verbs[] = {
13811 /*
13812 * Unmute ADC and set the default input to mic-in
13813 */
13814 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13816
13817 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13818 * mixer widget
13819 * Note: PASD motherboards uses the Line In 2 as the input for front
13820 * panel mic (mic 2)
13821 */
13822 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013828
13829 /*
13830 * Set up output mixers (0x0c - 0x0f)
13831 */
13832 /* set vol=0 to output mixers */
13833 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13834 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13835 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13836
13837 /* set up input amps for analog loopback */
13838 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013845
13846
13847 /* FIXME: use matrix-type input source selection */
13848 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13849 /* Input mixer */
13850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013852 { }
13853};
13854
Kailang Yang6dda9f42008-05-27 12:05:31 +020013855static struct hda_verb alc663_m51va_init_verbs[] = {
13856 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13857 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13858 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13859
13860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
13861
13862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13863 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13864 {}
13865};
13866
13867static struct hda_verb alc663_g71v_init_verbs[] = {
13868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13869 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
13870 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
13871
13872 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13873 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13874 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13875
13876 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13877 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
13878 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13879 {}
13880};
13881
13882static struct hda_verb alc663_g50v_init_verbs[] = {
13883 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13884 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13885 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13886
13887 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13888 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13889 {}
13890};
13891
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013892/* capture mixer elements */
13893static struct snd_kcontrol_new alc662_capture_mixer[] = {
13894 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13895 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13896 {
13897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13898 /* The multiple "Capture Source" controls confuse alsamixer
13899 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013900 */
13901 /* .name = "Capture Source", */
13902 .name = "Input Source",
13903 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013904 .info = alc662_mux_enum_info,
13905 .get = alc662_mux_enum_get,
13906 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013907 },
13908 { } /* end */
13909};
13910
13911static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13912{
13913 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013914 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013915
13916 present = snd_hda_codec_read(codec, 0x14, 0,
13917 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013918 bits = present ? HDA_AMP_MUTE : 0;
13919 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13920 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013921}
13922
13923static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13924{
13925 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013926 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013927
13928 present = snd_hda_codec_read(codec, 0x1b, 0,
13929 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013930 bits = present ? HDA_AMP_MUTE : 0;
13931 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13932 HDA_AMP_MUTE, bits);
13933 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13934 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013935}
13936
13937static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13938 unsigned int res)
13939{
13940 if ((res >> 26) == ALC880_HP_EVENT)
13941 alc662_lenovo_101e_all_automute(codec);
13942 if ((res >> 26) == ALC880_FRONT_EVENT)
13943 alc662_lenovo_101e_ispeaker_automute(codec);
13944}
13945
Kailang Yang291702f2007-10-16 14:28:03 +020013946static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13947{
13948 unsigned int present;
13949
13950 present = snd_hda_codec_read(codec, 0x18, 0,
13951 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13952 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13953 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13954 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13955 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13956 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13957 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13958 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13959 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13960}
13961
13962/* unsolicited event for HP jack sensing */
13963static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13964 unsigned int res)
13965{
13966 if ((res >> 26) == ALC880_HP_EVENT)
13967 alc262_hippo1_automute( codec );
13968
13969 if ((res >> 26) == ALC880_MIC_EVENT)
13970 alc662_eeepc_mic_automute(codec);
13971}
13972
13973static void alc662_eeepc_inithook(struct hda_codec *codec)
13974{
13975 alc262_hippo1_automute( codec );
13976 alc662_eeepc_mic_automute(codec);
13977}
13978
Kailang Yang8c427222008-01-10 13:03:59 +010013979static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13980{
13981 unsigned int mute;
13982 unsigned int present;
13983
13984 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13985 present = snd_hda_codec_read(codec, 0x14, 0,
13986 AC_VERB_GET_PIN_SENSE, 0);
13987 present = (present & 0x80000000) != 0;
13988 if (present) {
13989 /* mute internal speaker */
13990 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13991 HDA_AMP_MUTE, HDA_AMP_MUTE);
13992 } else {
13993 /* unmute internal speaker if necessary */
13994 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13995 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13996 HDA_AMP_MUTE, mute);
13997 }
13998}
13999
14000/* unsolicited event for HP jack sensing */
14001static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14002 unsigned int res)
14003{
14004 if ((res >> 26) == ALC880_HP_EVENT)
14005 alc662_eeepc_ep20_automute(codec);
14006}
14007
14008static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14009{
14010 alc662_eeepc_ep20_automute(codec);
14011}
14012
Kailang Yang6dda9f42008-05-27 12:05:31 +020014013static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14014{
14015 unsigned int present;
14016 unsigned char bits;
14017
14018 present = snd_hda_codec_read(codec, 0x21, 0,
14019 AC_VERB_GET_PIN_SENSE, 0)
14020 & AC_PINSENSE_PRESENCE;
14021 bits = present ? HDA_AMP_MUTE : 0;
14022 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14023 HDA_AMP_MUTE, bits);
14024}
14025
14026static void alc663_m51va_mic_automute(struct hda_codec *codec)
14027{
14028 unsigned int present;
14029
14030 present = snd_hda_codec_read(codec, 0x18, 0,
14031 AC_VERB_GET_PIN_SENSE, 0)
14032 & AC_PINSENSE_PRESENCE;
14033 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14034 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14035 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14036 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14037 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14038 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14039 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14040 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14041}
14042
14043static void alc663_m51va_unsol_event(struct hda_codec *codec,
14044 unsigned int res)
14045{
14046 switch (res >> 26) {
14047 case ALC880_HP_EVENT:
14048 alc663_m51va_speaker_automute(codec);
14049 break;
14050 case ALC880_MIC_EVENT:
14051 alc663_m51va_mic_automute(codec);
14052 break;
14053 }
14054}
14055
14056static void alc663_m51va_inithook(struct hda_codec *codec)
14057{
14058 alc663_m51va_speaker_automute(codec);
14059 alc663_m51va_mic_automute(codec);
14060}
14061
14062static void alc663_g71v_hp_automute(struct hda_codec *codec)
14063{
14064 unsigned int present;
14065 unsigned char bits;
14066
14067 present = snd_hda_codec_read(codec, 0x21, 0,
14068 AC_VERB_GET_PIN_SENSE, 0)
14069 & AC_PINSENSE_PRESENCE;
14070 bits = present ? HDA_AMP_MUTE : 0;
14071 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14072 HDA_AMP_MUTE, bits);
14073 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14074 HDA_AMP_MUTE, bits);
14075}
14076
14077static void alc663_g71v_front_automute(struct hda_codec *codec)
14078{
14079 unsigned int present;
14080 unsigned char bits;
14081
14082 present = snd_hda_codec_read(codec, 0x15, 0,
14083 AC_VERB_GET_PIN_SENSE, 0)
14084 & AC_PINSENSE_PRESENCE;
14085 bits = present ? HDA_AMP_MUTE : 0;
14086 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14087 HDA_AMP_MUTE, bits);
14088}
14089
14090static void alc663_g71v_unsol_event(struct hda_codec *codec,
14091 unsigned int res)
14092{
14093 switch (res >> 26) {
14094 case ALC880_HP_EVENT:
14095 alc663_g71v_hp_automute(codec);
14096 break;
14097 case ALC880_FRONT_EVENT:
14098 alc663_g71v_front_automute(codec);
14099 break;
14100 case ALC880_MIC_EVENT:
14101 alc662_eeepc_mic_automute(codec);
14102 break;
14103 }
14104}
14105
14106static void alc663_g71v_inithook(struct hda_codec *codec)
14107{
14108 alc663_g71v_front_automute(codec);
14109 alc663_g71v_hp_automute(codec);
14110 alc662_eeepc_mic_automute(codec);
14111}
14112
14113static void alc663_g50v_unsol_event(struct hda_codec *codec,
14114 unsigned int res)
14115{
14116 switch (res >> 26) {
14117 case ALC880_HP_EVENT:
14118 alc663_m51va_speaker_automute(codec);
14119 break;
14120 case ALC880_MIC_EVENT:
14121 alc662_eeepc_mic_automute(codec);
14122 break;
14123 }
14124}
14125
14126static void alc663_g50v_inithook(struct hda_codec *codec)
14127{
14128 alc663_m51va_speaker_automute(codec);
14129 alc662_eeepc_mic_automute(codec);
14130}
14131
Takashi Iwaicb53c622007-08-10 17:21:45 +020014132#ifdef CONFIG_SND_HDA_POWER_SAVE
14133#define alc662_loopbacks alc880_loopbacks
14134#endif
14135
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014136
14137/* pcm configuration: identiacal with ALC880 */
14138#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14139#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14140#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14141#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14142
14143/*
14144 * configuration and preset
14145 */
14146static const char *alc662_models[ALC662_MODEL_LAST] = {
14147 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14148 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14149 [ALC662_3ST_6ch] = "3stack-6ch",
14150 [ALC662_5ST_DIG] = "6stack-dig",
14151 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014152 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014153 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014154 [ALC663_ASUS_M51VA] = "m51va",
14155 [ALC663_ASUS_G71V] = "g71v",
14156 [ALC663_ASUS_H13] = "h13",
14157 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014158 [ALC662_AUTO] = "auto",
14159};
14160
14161static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014162 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14163 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14164 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014165 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014166 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014167 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014168 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014169 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14170 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14171 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014172 {}
14173};
14174
14175static struct alc_config_preset alc662_presets[] = {
14176 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014177 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014178 .init_verbs = { alc662_init_verbs },
14179 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14180 .dac_nids = alc662_dac_nids,
14181 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014182 .dig_in_nid = ALC662_DIGIN_NID,
14183 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14184 .channel_mode = alc662_3ST_2ch_modes,
14185 .input_mux = &alc662_capture_source,
14186 },
14187 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014188 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14189 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014190 .init_verbs = { alc662_init_verbs },
14191 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14192 .dac_nids = alc662_dac_nids,
14193 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014194 .dig_in_nid = ALC662_DIGIN_NID,
14195 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14196 .channel_mode = alc662_3ST_6ch_modes,
14197 .need_dac_fix = 1,
14198 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014199 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014200 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014201 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14202 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014203 .init_verbs = { alc662_init_verbs },
14204 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14205 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014206 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14207 .channel_mode = alc662_3ST_6ch_modes,
14208 .need_dac_fix = 1,
14209 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014210 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014211 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014212 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14213 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014214 .init_verbs = { alc662_init_verbs },
14215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14216 .dac_nids = alc662_dac_nids,
14217 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014218 .dig_in_nid = ALC662_DIGIN_NID,
14219 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14220 .channel_mode = alc662_5stack_modes,
14221 .input_mux = &alc662_capture_source,
14222 },
14223 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014224 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014225 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14226 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14227 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014228 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14229 .channel_mode = alc662_3ST_2ch_modes,
14230 .input_mux = &alc662_lenovo_101e_capture_source,
14231 .unsol_event = alc662_lenovo_101e_unsol_event,
14232 .init_hook = alc662_lenovo_101e_all_automute,
14233 },
Kailang Yang291702f2007-10-16 14:28:03 +020014234 [ALC662_ASUS_EEEPC_P701] = {
14235 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14236 .init_verbs = { alc662_init_verbs,
14237 alc662_eeepc_sue_init_verbs },
14238 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14239 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014240 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14241 .channel_mode = alc662_3ST_2ch_modes,
14242 .input_mux = &alc662_eeepc_capture_source,
14243 .unsol_event = alc662_eeepc_unsol_event,
14244 .init_hook = alc662_eeepc_inithook,
14245 },
Kailang Yang8c427222008-01-10 13:03:59 +010014246 [ALC662_ASUS_EEEPC_EP20] = {
14247 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14248 alc662_chmode_mixer },
14249 .init_verbs = { alc662_init_verbs,
14250 alc662_eeepc_ep20_sue_init_verbs },
14251 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14252 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014253 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14254 .channel_mode = alc662_3ST_6ch_modes,
14255 .input_mux = &alc662_lenovo_101e_capture_source,
14256 .unsol_event = alc662_eeepc_ep20_unsol_event,
14257 .init_hook = alc662_eeepc_ep20_inithook,
14258 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014259 [ALC663_ASUS_M51VA] = {
14260 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14261 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14262 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14263 .dac_nids = alc662_dac_nids,
14264 .dig_out_nid = ALC662_DIGOUT_NID,
14265 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14266 .channel_mode = alc662_3ST_2ch_modes,
14267 .input_mux = &alc663_m51va_capture_source,
14268 .unsol_event = alc663_m51va_unsol_event,
14269 .init_hook = alc663_m51va_inithook,
14270 },
14271 [ALC663_ASUS_G71V] = {
14272 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14273 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14274 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14275 .dac_nids = alc662_dac_nids,
14276 .dig_out_nid = ALC662_DIGOUT_NID,
14277 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14278 .channel_mode = alc662_3ST_2ch_modes,
14279 .input_mux = &alc662_eeepc_capture_source,
14280 .unsol_event = alc663_g71v_unsol_event,
14281 .init_hook = alc663_g71v_inithook,
14282 },
14283 [ALC663_ASUS_H13] = {
14284 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14285 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14286 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14287 .dac_nids = alc662_dac_nids,
14288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14289 .channel_mode = alc662_3ST_2ch_modes,
14290 .input_mux = &alc663_m51va_capture_source,
14291 .unsol_event = alc663_m51va_unsol_event,
14292 .init_hook = alc663_m51va_inithook,
14293 },
14294 [ALC663_ASUS_G50V] = {
14295 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14296 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14297 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14298 .dac_nids = alc662_dac_nids,
14299 .dig_out_nid = ALC662_DIGOUT_NID,
14300 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14301 .channel_mode = alc662_3ST_6ch_modes,
14302 .input_mux = &alc663_capture_source,
14303 .unsol_event = alc663_g50v_unsol_event,
14304 .init_hook = alc663_g50v_inithook,
14305 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014306};
14307
14308
14309/*
14310 * BIOS auto configuration
14311 */
14312
14313/* add playback controls from the parsed DAC table */
14314static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14315 const struct auto_pin_cfg *cfg)
14316{
14317 char name[32];
14318 static const char *chname[4] = {
14319 "Front", "Surround", NULL /*CLFE*/, "Side"
14320 };
14321 hda_nid_t nid;
14322 int i, err;
14323
14324 for (i = 0; i < cfg->line_outs; i++) {
14325 if (!spec->multiout.dac_nids[i])
14326 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014327 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014328 if (i == 2) {
14329 /* Center/LFE */
14330 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14331 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014332 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14333 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014334 if (err < 0)
14335 return err;
14336 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14337 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014338 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14339 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014340 if (err < 0)
14341 return err;
14342 err = add_control(spec, ALC_CTL_BIND_MUTE,
14343 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014344 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14345 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014346 if (err < 0)
14347 return err;
14348 err = add_control(spec, ALC_CTL_BIND_MUTE,
14349 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014350 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14351 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014352 if (err < 0)
14353 return err;
14354 } else {
14355 sprintf(name, "%s Playback Volume", chname[i]);
14356 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014357 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14358 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014359 if (err < 0)
14360 return err;
14361 sprintf(name, "%s Playback Switch", chname[i]);
14362 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014363 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14364 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014365 if (err < 0)
14366 return err;
14367 }
14368 }
14369 return 0;
14370}
14371
14372/* add playback controls for speaker and HP outputs */
14373static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14374 const char *pfx)
14375{
14376 hda_nid_t nid;
14377 int err;
14378 char name[32];
14379
14380 if (!pin)
14381 return 0;
14382
14383 if (alc880_is_fixed_pin(pin)) {
14384 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14385 /* printk("DAC nid=%x\n",nid); */
14386 /* specify the DAC as the extra output */
14387 if (!spec->multiout.hp_nid)
14388 spec->multiout.hp_nid = nid;
14389 else
14390 spec->multiout.extra_out_nid[0] = nid;
14391 /* control HP volume/switch on the output mixer amp */
14392 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14393 sprintf(name, "%s Playback Volume", pfx);
14394 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14395 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14396 if (err < 0)
14397 return err;
14398 sprintf(name, "%s Playback Switch", pfx);
14399 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14400 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14401 if (err < 0)
14402 return err;
14403 } else if (alc880_is_multi_pin(pin)) {
14404 /* set manual connection */
14405 /* we have only a switch on HP-out PIN */
14406 sprintf(name, "%s Playback Switch", pfx);
14407 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14408 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14409 if (err < 0)
14410 return err;
14411 }
14412 return 0;
14413}
14414
14415/* create playback/capture controls for input pins */
14416static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14417 const struct auto_pin_cfg *cfg)
14418{
14419 struct hda_input_mux *imux = &spec->private_imux;
14420 int i, err, idx;
14421
14422 for (i = 0; i < AUTO_PIN_LAST; i++) {
14423 if (alc880_is_input_pin(cfg->input_pins[i])) {
14424 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14425 err = new_analog_input(spec, cfg->input_pins[i],
14426 auto_pin_cfg_labels[i],
14427 idx, 0x0b);
14428 if (err < 0)
14429 return err;
14430 imux->items[imux->num_items].label =
14431 auto_pin_cfg_labels[i];
14432 imux->items[imux->num_items].index =
14433 alc880_input_pin_idx(cfg->input_pins[i]);
14434 imux->num_items++;
14435 }
14436 }
14437 return 0;
14438}
14439
14440static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14441 hda_nid_t nid, int pin_type,
14442 int dac_idx)
14443{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014444 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014445 /* need the manual connection? */
14446 if (alc880_is_multi_pin(nid)) {
14447 struct alc_spec *spec = codec->spec;
14448 int idx = alc880_multi_pin_idx(nid);
14449 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14450 AC_VERB_SET_CONNECT_SEL,
14451 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14452 }
14453}
14454
14455static void alc662_auto_init_multi_out(struct hda_codec *codec)
14456{
14457 struct alc_spec *spec = codec->spec;
14458 int i;
14459
Kailang Yang8c427222008-01-10 13:03:59 +010014460 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014461 for (i = 0; i <= HDA_SIDE; i++) {
14462 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014463 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014464 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014465 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014466 i);
14467 }
14468}
14469
14470static void alc662_auto_init_hp_out(struct hda_codec *codec)
14471{
14472 struct alc_spec *spec = codec->spec;
14473 hda_nid_t pin;
14474
14475 pin = spec->autocfg.hp_pins[0];
14476 if (pin) /* connect to front */
14477 /* use dac 0 */
14478 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014479 pin = spec->autocfg.speaker_pins[0];
14480 if (pin)
14481 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014482}
14483
14484#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14485#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14486
14487static void alc662_auto_init_analog_input(struct hda_codec *codec)
14488{
14489 struct alc_spec *spec = codec->spec;
14490 int i;
14491
14492 for (i = 0; i < AUTO_PIN_LAST; i++) {
14493 hda_nid_t nid = spec->autocfg.input_pins[i];
14494 if (alc662_is_input_pin(nid)) {
14495 snd_hda_codec_write(codec, nid, 0,
14496 AC_VERB_SET_PIN_WIDGET_CONTROL,
14497 (i <= AUTO_PIN_FRONT_MIC ?
14498 PIN_VREF80 : PIN_IN));
14499 if (nid != ALC662_PIN_CD_NID)
14500 snd_hda_codec_write(codec, nid, 0,
14501 AC_VERB_SET_AMP_GAIN_MUTE,
14502 AMP_OUT_MUTE);
14503 }
14504 }
14505}
14506
14507static int alc662_parse_auto_config(struct hda_codec *codec)
14508{
14509 struct alc_spec *spec = codec->spec;
14510 int err;
14511 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14512
14513 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14514 alc662_ignore);
14515 if (err < 0)
14516 return err;
14517 if (!spec->autocfg.line_outs)
14518 return 0; /* can't find valid BIOS pin config */
14519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014520 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14521 if (err < 0)
14522 return err;
14523 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14524 if (err < 0)
14525 return err;
14526 err = alc662_auto_create_extra_out(spec,
14527 spec->autocfg.speaker_pins[0],
14528 "Speaker");
14529 if (err < 0)
14530 return err;
14531 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14532 "Headphone");
14533 if (err < 0)
14534 return err;
14535 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14536 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014537 return err;
14538
14539 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14540
14541 if (spec->autocfg.dig_out_pin)
14542 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14543
14544 if (spec->kctl_alloc)
14545 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14546
14547 spec->num_mux_defs = 1;
14548 spec->input_mux = &spec->private_imux;
14549
Takashi Iwai8c872862007-06-19 12:11:16 +020014550 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014551 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14552 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020014553 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014554}
14555
14556/* additional initialization for auto-configuration model */
14557static void alc662_auto_init(struct hda_codec *codec)
14558{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014559 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014560 alc662_auto_init_multi_out(codec);
14561 alc662_auto_init_hp_out(codec);
14562 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014563 if (spec->unsol_event)
14564 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014565}
14566
14567static int patch_alc662(struct hda_codec *codec)
14568{
14569 struct alc_spec *spec;
14570 int err, board_config;
14571
14572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14573 if (!spec)
14574 return -ENOMEM;
14575
14576 codec->spec = spec;
14577
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014578 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14579
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014580 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14581 alc662_models,
14582 alc662_cfg_tbl);
14583 if (board_config < 0) {
14584 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14585 "trying auto-probe from BIOS...\n");
14586 board_config = ALC662_AUTO;
14587 }
14588
14589 if (board_config == ALC662_AUTO) {
14590 /* automatic parse from the BIOS config */
14591 err = alc662_parse_auto_config(codec);
14592 if (err < 0) {
14593 alc_free(codec);
14594 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020014595 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014596 printk(KERN_INFO
14597 "hda_codec: Cannot set up configuration "
14598 "from BIOS. Using base mode...\n");
14599 board_config = ALC662_3ST_2ch_DIG;
14600 }
14601 }
14602
14603 if (board_config != ALC662_AUTO)
14604 setup_preset(spec, &alc662_presets[board_config]);
14605
Kailang Yang6dda9f42008-05-27 12:05:31 +020014606 if (codec->vendor_id == 0x10ec0663) {
14607 spec->stream_name_analog = "ALC663 Analog";
14608 spec->stream_name_digital = "ALC663 Digital";
14609 } else {
14610 spec->stream_name_analog = "ALC662 Analog";
14611 spec->stream_name_digital = "ALC662 Digital";
14612 }
14613
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014614 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14615 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14616
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014617 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14618 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14619
Takashi Iwaie1406342008-02-11 18:32:32 +010014620 spec->adc_nids = alc662_adc_nids;
14621 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14622 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014623
Takashi Iwai2134ea42008-01-10 16:53:55 +010014624 spec->vmaster_nid = 0x02;
14625
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014626 codec->patch_ops = alc_patch_ops;
14627 if (board_config == ALC662_AUTO)
14628 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014629#ifdef CONFIG_SND_HDA_POWER_SAVE
14630 if (!spec->loopback.amplist)
14631 spec->loopback.amplist = alc662_loopbacks;
14632#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014633
14634 return 0;
14635}
14636
14637/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070014638 * patch entries
14639 */
14640struct hda_codec_preset snd_hda_preset_realtek[] = {
14641 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014642 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014643 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020014644 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014645 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014646 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014647 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014648 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14649 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14650 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014651 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14652 .patch = patch_alc883 },
14653 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14654 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014655 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014656 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014657 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014658 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020014659 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020014660 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010014661 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014662 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014663 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014664 {} /* terminator */
14665};