blob: 4edde6094cd1f68744dd9b2a2af7d608fee850bd [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 Avdoninbab282b92006-08-22 13:31:58 +0200198 ALC883_ACER,
Tobin Davis2880a862007-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),
Travis Place1d116042008-06-23 11:42:30 +02003077 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003078 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003079 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003080 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003081 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3082 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003083 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003084 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3085 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3086 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3087 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003088 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3089 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003090 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003091 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003092 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3093 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003094 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3095 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3096 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003097 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3098 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3099 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003100 {}
3101};
3102
Takashi Iwai16ded522005-06-10 19:58:24 +02003103/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003104 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003106static struct alc_config_preset alc880_presets[] = {
3107 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003109 .init_verbs = { alc880_volume_init_verbs,
3110 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003111 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003113 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3114 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003115 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003116 .input_mux = &alc880_capture_source,
3117 },
3118 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003120 .init_verbs = { alc880_volume_init_verbs,
3121 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003122 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .dac_nids = alc880_dac_nids,
3124 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3126 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003127 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003128 .input_mux = &alc880_capture_source,
3129 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003130 [ALC880_TCL_S700] = {
3131 .mixers = { alc880_tcl_s700_mixer },
3132 .init_verbs = { alc880_volume_init_verbs,
3133 alc880_pin_tcl_S700_init_verbs,
3134 alc880_gpio2_init_verbs },
3135 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3136 .dac_nids = alc880_dac_nids,
3137 .hp_nid = 0x03,
3138 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3139 .channel_mode = alc880_2_jack_modes,
3140 .input_mux = &alc880_capture_source,
3141 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003142 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003143 .mixers = { alc880_three_stack_mixer,
3144 alc880_five_stack_mixer},
3145 .init_verbs = { alc880_volume_init_verbs,
3146 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003147 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3148 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003149 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3150 .channel_mode = alc880_fivestack_modes,
3151 .input_mux = &alc880_capture_source,
3152 },
3153 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003154 .mixers = { alc880_three_stack_mixer,
3155 alc880_five_stack_mixer },
3156 .init_verbs = { alc880_volume_init_verbs,
3157 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003158 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3159 .dac_nids = alc880_dac_nids,
3160 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003161 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3162 .channel_mode = alc880_fivestack_modes,
3163 .input_mux = &alc880_capture_source,
3164 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003165 [ALC880_6ST] = {
3166 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003167 .init_verbs = { alc880_volume_init_verbs,
3168 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003169 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3170 .dac_nids = alc880_6st_dac_nids,
3171 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3172 .channel_mode = alc880_sixstack_modes,
3173 .input_mux = &alc880_6stack_capture_source,
3174 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003175 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003177 .init_verbs = { alc880_volume_init_verbs,
3178 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003179 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3180 .dac_nids = alc880_6st_dac_nids,
3181 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3183 .channel_mode = alc880_sixstack_modes,
3184 .input_mux = &alc880_6stack_capture_source,
3185 },
3186 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003188 .init_verbs = { alc880_volume_init_verbs,
3189 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003190 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003191 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3192 .dac_nids = alc880_w810_dac_nids,
3193 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003194 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3195 .channel_mode = alc880_w810_modes,
3196 .input_mux = &alc880_capture_source,
3197 },
3198 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003200 .init_verbs = { alc880_volume_init_verbs,
3201 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003202 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3203 .dac_nids = alc880_z71v_dac_nids,
3204 .dig_out_nid = ALC880_DIGOUT_NID,
3205 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3207 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003208 .input_mux = &alc880_capture_source,
3209 },
3210 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003212 .init_verbs = { alc880_volume_init_verbs,
3213 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003214 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3215 .dac_nids = alc880_f1734_dac_nids,
3216 .hp_nid = 0x02,
3217 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3218 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003219 .input_mux = &alc880_f1734_capture_source,
3220 .unsol_event = alc880_uniwill_p53_unsol_event,
3221 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003222 },
3223 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003225 .init_verbs = { alc880_volume_init_verbs,
3226 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227 alc880_gpio1_init_verbs },
3228 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3229 .dac_nids = alc880_asus_dac_nids,
3230 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3231 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003232 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003233 .input_mux = &alc880_capture_source,
3234 },
3235 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239 alc880_gpio1_init_verbs },
3240 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3241 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3244 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003245 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003246 .input_mux = &alc880_capture_source,
3247 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003248 [ALC880_ASUS_DIG2] = {
3249 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 .init_verbs = { alc880_volume_init_verbs,
3251 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003252 alc880_gpio2_init_verbs }, /* use GPIO2 */
3253 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3254 .dac_nids = alc880_asus_dac_nids,
3255 .dig_out_nid = ALC880_DIGOUT_NID,
3256 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3257 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003258 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003259 .input_mux = &alc880_capture_source,
3260 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003261 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003263 .init_verbs = { alc880_volume_init_verbs,
3264 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 alc880_gpio1_init_verbs },
3266 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3267 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003268 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3270 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003271 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 .input_mux = &alc880_capture_source,
3273 },
3274 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003275 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003276 .init_verbs = { alc880_volume_init_verbs,
3277 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3279 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003280 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3282 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003283 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003284 .input_mux = &alc880_capture_source,
3285 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003286 [ALC880_UNIWILL] = {
3287 .mixers = { alc880_uniwill_mixer },
3288 .init_verbs = { alc880_volume_init_verbs,
3289 alc880_uniwill_init_verbs },
3290 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3291 .dac_nids = alc880_asus_dac_nids,
3292 .dig_out_nid = ALC880_DIGOUT_NID,
3293 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3294 .channel_mode = alc880_threestack_modes,
3295 .need_dac_fix = 1,
3296 .input_mux = &alc880_capture_source,
3297 .unsol_event = alc880_uniwill_unsol_event,
3298 .init_hook = alc880_uniwill_automute,
3299 },
3300 [ALC880_UNIWILL_P53] = {
3301 .mixers = { alc880_uniwill_p53_mixer },
3302 .init_verbs = { alc880_volume_init_verbs,
3303 alc880_uniwill_p53_init_verbs },
3304 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3305 .dac_nids = alc880_asus_dac_nids,
3306 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003307 .channel_mode = alc880_threestack_modes,
3308 .input_mux = &alc880_capture_source,
3309 .unsol_event = alc880_uniwill_p53_unsol_event,
3310 .init_hook = alc880_uniwill_p53_hp_automute,
3311 },
3312 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003313 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003314 alc880_pcbeep_mixer, },
3315 .init_verbs = { alc880_volume_init_verbs,
3316 alc880_uniwill_p53_init_verbs,
3317 alc880_beep_init_verbs },
3318 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3319 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003320 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003321 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3322 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003323 .input_mux = &alc880_capture_source,
3324 .unsol_event = alc880_uniwill_p53_unsol_event,
3325 .init_hook = alc880_uniwill_p53_hp_automute,
3326 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003327 [ALC880_CLEVO] = {
3328 .mixers = { alc880_three_stack_mixer },
3329 .init_verbs = { alc880_volume_init_verbs,
3330 alc880_pin_clevo_init_verbs },
3331 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3332 .dac_nids = alc880_dac_nids,
3333 .hp_nid = 0x03,
3334 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3335 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003336 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003337 .input_mux = &alc880_capture_source,
3338 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003339 [ALC880_LG] = {
3340 .mixers = { alc880_lg_mixer },
3341 .init_verbs = { alc880_volume_init_verbs,
3342 alc880_lg_init_verbs },
3343 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3344 .dac_nids = alc880_lg_dac_nids,
3345 .dig_out_nid = ALC880_DIGOUT_NID,
3346 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3347 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003348 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003349 .input_mux = &alc880_lg_capture_source,
3350 .unsol_event = alc880_lg_unsol_event,
3351 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003352#ifdef CONFIG_SND_HDA_POWER_SAVE
3353 .loopbacks = alc880_lg_loopbacks,
3354#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003355 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003356 [ALC880_LG_LW] = {
3357 .mixers = { alc880_lg_lw_mixer },
3358 .init_verbs = { alc880_volume_init_verbs,
3359 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003360 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003361 .dac_nids = alc880_dac_nids,
3362 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003363 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3364 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003365 .input_mux = &alc880_lg_lw_capture_source,
3366 .unsol_event = alc880_lg_lw_unsol_event,
3367 .init_hook = alc880_lg_lw_automute,
3368 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003369 [ALC880_MEDION_RIM] = {
3370 .mixers = { alc880_medion_rim_mixer },
3371 .init_verbs = { alc880_volume_init_verbs,
3372 alc880_medion_rim_init_verbs,
3373 alc_gpio2_init_verbs },
3374 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3375 .dac_nids = alc880_dac_nids,
3376 .dig_out_nid = ALC880_DIGOUT_NID,
3377 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3378 .channel_mode = alc880_2_jack_modes,
3379 .input_mux = &alc880_medion_rim_capture_source,
3380 .unsol_event = alc880_medion_rim_unsol_event,
3381 .init_hook = alc880_medion_rim_automute,
3382 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003383#ifdef CONFIG_SND_DEBUG
3384 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 .mixers = { alc880_test_mixer },
3386 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003387 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3388 .dac_nids = alc880_test_dac_nids,
3389 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003390 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3391 .channel_mode = alc880_test_modes,
3392 .input_mux = &alc880_test_capture_source,
3393 },
3394#endif
3395};
3396
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003397/*
3398 * Automatic parse of I/O pins from the BIOS configuration
3399 */
3400
3401#define NUM_CONTROL_ALLOC 32
3402#define NUM_VERB_ALLOC 32
3403
3404enum {
3405 ALC_CTL_WIDGET_VOL,
3406 ALC_CTL_WIDGET_MUTE,
3407 ALC_CTL_BIND_MUTE,
3408};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003409static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3411 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003412 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003413};
3414
3415/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003416static int add_control(struct alc_spec *spec, int type, const char *name,
3417 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003418{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003419 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420
3421 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3422 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3423
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 /* array + terminator */
3425 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3426 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427 return -ENOMEM;
3428 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003429 memcpy(knew, spec->kctl_alloc,
3430 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431 kfree(spec->kctl_alloc);
3432 }
3433 spec->kctl_alloc = knew;
3434 spec->num_kctl_alloc = num;
3435 }
3436
3437 knew = &spec->kctl_alloc[spec->num_kctl_used];
3438 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003439 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003440 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003441 return -ENOMEM;
3442 knew->private_value = val;
3443 spec->num_kctl_used++;
3444 return 0;
3445}
3446
3447#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3448#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3449#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3450#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3451#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3452#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3453#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3454#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3455#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3456#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3457#define ALC880_PIN_CD_NID 0x1c
3458
3459/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003460static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3461 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462{
3463 hda_nid_t nid;
3464 int assigned[4];
3465 int i, j;
3466
3467 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003468 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003469
3470 /* check the pins hardwired to audio widget */
3471 for (i = 0; i < cfg->line_outs; i++) {
3472 nid = cfg->line_out_pins[i];
3473 if (alc880_is_fixed_pin(nid)) {
3474 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003475 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476 assigned[idx] = 1;
3477 }
3478 }
3479 /* left pins can be connect to any audio widget */
3480 for (i = 0; i < cfg->line_outs; i++) {
3481 nid = cfg->line_out_pins[i];
3482 if (alc880_is_fixed_pin(nid))
3483 continue;
3484 /* search for an empty channel */
3485 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003486 if (!assigned[j]) {
3487 spec->multiout.dac_nids[i] =
3488 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 assigned[j] = 1;
3490 break;
3491 }
3492 }
3493 }
3494 spec->multiout.num_dacs = cfg->line_outs;
3495 return 0;
3496}
3497
3498/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003499static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3500 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501{
3502 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003503 static const char *chname[4] = {
3504 "Front", "Surround", NULL /*CLFE*/, "Side"
3505 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003506 hda_nid_t nid;
3507 int i, err;
3508
3509 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003510 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003511 continue;
3512 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3513 if (i == 2) {
3514 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003515 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3516 "Center Playback Volume",
3517 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3518 HDA_OUTPUT));
3519 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003521 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3522 "LFE Playback Volume",
3523 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3524 HDA_OUTPUT));
3525 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003526 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003527 err = add_control(spec, ALC_CTL_BIND_MUTE,
3528 "Center Playback Switch",
3529 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3530 HDA_INPUT));
3531 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003532 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003533 err = add_control(spec, ALC_CTL_BIND_MUTE,
3534 "LFE Playback Switch",
3535 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3536 HDA_INPUT));
3537 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 return err;
3539 } else {
3540 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003541 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3542 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3543 HDA_OUTPUT));
3544 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 return err;
3546 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003547 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3548 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3549 HDA_INPUT));
3550 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551 return err;
3552 }
3553 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003554 return 0;
3555}
3556
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003557/* add playback controls for speaker and HP outputs */
3558static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3559 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003560{
3561 hda_nid_t nid;
3562 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003563 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003564
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003565 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566 return 0;
3567
3568 if (alc880_is_fixed_pin(pin)) {
3569 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003570 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003571 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003573 else
3574 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 /* control HP volume/switch on the output mixer amp */
3576 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003577 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003578 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3579 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3580 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003581 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003582 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003583 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3584 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3585 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003586 return err;
3587 } else if (alc880_is_multi_pin(pin)) {
3588 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003590 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003591 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3592 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3593 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 return err;
3595 }
3596 return 0;
3597}
3598
3599/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003600static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3601 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003602 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603{
3604 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003605 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003606
3607 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003608 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3609 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003611 return err;
3612 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003613 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3614 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3615 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003616 return err;
3617 return 0;
3618}
3619
3620/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003621static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3622 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003624 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003625 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003626
3627 for (i = 0; i < AUTO_PIN_LAST; i++) {
3628 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003629 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003630 err = new_analog_input(spec, cfg->input_pins[i],
3631 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003632 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003633 if (err < 0)
3634 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003635 imux->items[imux->num_items].label =
3636 auto_pin_cfg_labels[i];
3637 imux->items[imux->num_items].index =
3638 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003639 imux->num_items++;
3640 }
3641 }
3642 return 0;
3643}
3644
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003645static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3646 unsigned int pin_type)
3647{
3648 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3649 pin_type);
3650 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003651 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3652 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003653}
3654
Kailang Yangdf694da2005-12-05 19:42:22 +01003655static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3656 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 int dac_idx)
3658{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003659 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003660 /* need the manual connection? */
3661 if (alc880_is_multi_pin(nid)) {
3662 struct alc_spec *spec = codec->spec;
3663 int idx = alc880_multi_pin_idx(nid);
3664 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3665 AC_VERB_SET_CONNECT_SEL,
3666 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3667 }
3668}
3669
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003670static int get_pin_type(int line_out_type)
3671{
3672 if (line_out_type == AUTO_PIN_HP_OUT)
3673 return PIN_HP;
3674 else
3675 return PIN_OUT;
3676}
3677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003678static void alc880_auto_init_multi_out(struct hda_codec *codec)
3679{
3680 struct alc_spec *spec = codec->spec;
3681 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003682
3683 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003684 for (i = 0; i < spec->autocfg.line_outs; i++) {
3685 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003686 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3687 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688 }
3689}
3690
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003691static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003692{
3693 struct alc_spec *spec = codec->spec;
3694 hda_nid_t pin;
3695
Takashi Iwai82bc9552006-03-21 11:24:42 +01003696 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003697 if (pin) /* connect to front */
3698 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003699 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003700 if (pin) /* connect to front */
3701 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3702}
3703
3704static void alc880_auto_init_analog_input(struct hda_codec *codec)
3705{
3706 struct alc_spec *spec = codec->spec;
3707 int i;
3708
3709 for (i = 0; i < AUTO_PIN_LAST; i++) {
3710 hda_nid_t nid = spec->autocfg.input_pins[i];
3711 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003712 snd_hda_codec_write(codec, nid, 0,
3713 AC_VERB_SET_PIN_WIDGET_CONTROL,
3714 i <= AUTO_PIN_FRONT_MIC ?
3715 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003717 snd_hda_codec_write(codec, nid, 0,
3718 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003719 AMP_OUT_MUTE);
3720 }
3721 }
3722}
3723
3724/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003725/* return 1 if successful, 0 if the proper config is not found,
3726 * or a negative error code
3727 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003728static int alc880_parse_auto_config(struct hda_codec *codec)
3729{
3730 struct alc_spec *spec = codec->spec;
3731 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003732 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003733
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003734 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3735 alc880_ignore);
3736 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003737 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003740
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003741 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3742 if (err < 0)
3743 return err;
3744 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3745 if (err < 0)
3746 return err;
3747 err = alc880_auto_create_extra_out(spec,
3748 spec->autocfg.speaker_pins[0],
3749 "Speaker");
3750 if (err < 0)
3751 return err;
3752 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3753 "Headphone");
3754 if (err < 0)
3755 return err;
3756 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3757 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758 return err;
3759
3760 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3761
3762 if (spec->autocfg.dig_out_pin)
3763 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3764 if (spec->autocfg.dig_in_pin)
3765 spec->dig_in_nid = ALC880_DIGIN_NID;
3766
3767 if (spec->kctl_alloc)
3768 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3769
3770 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3771
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003772 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 spec->input_mux = &spec->private_imux;
3774
3775 return 1;
3776}
3777
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003778/* additional initialization for auto-configuration model */
3779static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003780{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003781 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003782 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003783 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003785 if (spec->unsol_event)
3786 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787}
3788
3789/*
3790 * OK, here we have finally the patch for ALC880
3791 */
3792
Linus Torvalds1da177e2005-04-16 15:20:36 -07003793static int patch_alc880(struct hda_codec *codec)
3794{
3795 struct alc_spec *spec;
3796 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003797 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003798
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003799 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003800 if (spec == NULL)
3801 return -ENOMEM;
3802
3803 codec->spec = spec;
3804
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003805 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3806 alc880_models,
3807 alc880_cfg_tbl);
3808 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003809 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3810 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003812 }
3813
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003814 if (board_config == ALC880_AUTO) {
3815 /* automatic parse from the BIOS config */
3816 err = alc880_parse_auto_config(codec);
3817 if (err < 0) {
3818 alc_free(codec);
3819 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003820 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003821 printk(KERN_INFO
3822 "hda_codec: Cannot set up configuration "
3823 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003824 board_config = ALC880_3ST;
3825 }
3826 }
3827
Kailang Yangdf694da2005-12-05 19:42:22 +01003828 if (board_config != ALC880_AUTO)
3829 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003830
3831 spec->stream_name_analog = "ALC880 Analog";
3832 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3833 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003834 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835
3836 spec->stream_name_digital = "ALC880 Digital";
3837 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3838 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3839
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003840 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003842 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003843 /* get type */
3844 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003845 if (wcap != AC_WID_AUD_IN) {
3846 spec->adc_nids = alc880_adc_nids_alt;
3847 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003848 spec->mixers[spec->num_mixers] =
3849 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850 spec->num_mixers++;
3851 } else {
3852 spec->adc_nids = alc880_adc_nids;
3853 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3854 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3855 spec->num_mixers++;
3856 }
3857 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003858
Takashi Iwai2134ea42008-01-10 16:53:55 +01003859 spec->vmaster_nid = 0x0c;
3860
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003862 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003863 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003864#ifdef CONFIG_SND_HDA_POWER_SAVE
3865 if (!spec->loopback.amplist)
3866 spec->loopback.amplist = alc880_loopbacks;
3867#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003868
3869 return 0;
3870}
3871
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003872
Linus Torvalds1da177e2005-04-16 15:20:36 -07003873/*
3874 * ALC260 support
3875 */
3876
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003877static hda_nid_t alc260_dac_nids[1] = {
3878 /* front */
3879 0x02,
3880};
3881
3882static hda_nid_t alc260_adc_nids[1] = {
3883 /* ADC0 */
3884 0x04,
3885};
3886
Kailang Yangdf694da2005-12-05 19:42:22 +01003887static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003888 /* ADC1 */
3889 0x05,
3890};
3891
Kailang Yangdf694da2005-12-05 19:42:22 +01003892static hda_nid_t alc260_hp_adc_nids[2] = {
3893 /* ADC1, 0 */
3894 0x05, 0x04
3895};
3896
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003897/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3898 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3899 */
3900static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003901 /* ADC0, ADC1 */
3902 0x04, 0x05
3903};
3904
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003905#define ALC260_DIGOUT_NID 0x03
3906#define ALC260_DIGIN_NID 0x06
3907
3908static struct hda_input_mux alc260_capture_source = {
3909 .num_items = 4,
3910 .items = {
3911 { "Mic", 0x0 },
3912 { "Front Mic", 0x1 },
3913 { "Line", 0x2 },
3914 { "CD", 0x4 },
3915 },
3916};
3917
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003918/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003919 * headphone jack and the internal CD lines since these are the only pins at
3920 * which audio can appear. For flexibility, also allow the option of
3921 * recording the mixer output on the second ADC (ADC0 doesn't have a
3922 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003923 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003924static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3925 {
3926 .num_items = 3,
3927 .items = {
3928 { "Mic/Line", 0x0 },
3929 { "CD", 0x4 },
3930 { "Headphone", 0x2 },
3931 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003932 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003933 {
3934 .num_items = 4,
3935 .items = {
3936 { "Mic/Line", 0x0 },
3937 { "CD", 0x4 },
3938 { "Headphone", 0x2 },
3939 { "Mixer", 0x5 },
3940 },
3941 },
3942
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003943};
3944
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003945/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3946 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003947 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003948static struct hda_input_mux alc260_acer_capture_sources[2] = {
3949 {
3950 .num_items = 4,
3951 .items = {
3952 { "Mic", 0x0 },
3953 { "Line", 0x2 },
3954 { "CD", 0x4 },
3955 { "Headphone", 0x5 },
3956 },
3957 },
3958 {
3959 .num_items = 5,
3960 .items = {
3961 { "Mic", 0x0 },
3962 { "Line", 0x2 },
3963 { "CD", 0x4 },
3964 { "Headphone", 0x6 },
3965 { "Mixer", 0x5 },
3966 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003967 },
3968};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969/*
3970 * This is just place-holder, so there's something for alc_build_pcms to look
3971 * at when it calculates the maximum number of channels. ALC260 has no mixer
3972 * element which allows changing the channel mode, so the verb list is
3973 * never used.
3974 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003975static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003976 { 2, NULL },
3977};
3978
Kailang Yangdf694da2005-12-05 19:42:22 +01003979
3980/* Mixer combinations
3981 *
3982 * basic: base_output + input + pc_beep + capture
3983 * HP: base_output + input + capture_alt
3984 * HP_3013: hp_3013 + input + capture
3985 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003986 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003987 */
3988
3989static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003990 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003991 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003992 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3993 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3994 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3995 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3996 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997};
Kailang Yangdf694da2005-12-05 19:42:22 +01003998
3999static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4001 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4002 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4003 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4005 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004008 { } /* end */
4009};
4010
Kailang Yangdf694da2005-12-05 19:42:22 +01004011static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4012 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4013 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4014 { } /* end */
4015};
4016
Takashi Iwaibec15c32008-01-28 18:16:30 +01004017/* update HP, line and mono out pins according to the master switch */
4018static void alc260_hp_master_update(struct hda_codec *codec,
4019 hda_nid_t hp, hda_nid_t line,
4020 hda_nid_t mono)
4021{
4022 struct alc_spec *spec = codec->spec;
4023 unsigned int val = spec->master_sw ? PIN_HP : 0;
4024 /* change HP and line-out pins */
4025 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4026 val);
4027 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4028 val);
4029 /* mono (speaker) depending on the HP jack sense */
4030 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4031 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4032 val);
4033}
4034
4035static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4036 struct snd_ctl_elem_value *ucontrol)
4037{
4038 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4039 struct alc_spec *spec = codec->spec;
4040 *ucontrol->value.integer.value = spec->master_sw;
4041 return 0;
4042}
4043
4044static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4045 struct snd_ctl_elem_value *ucontrol)
4046{
4047 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4048 struct alc_spec *spec = codec->spec;
4049 int val = !!*ucontrol->value.integer.value;
4050 hda_nid_t hp, line, mono;
4051
4052 if (val == spec->master_sw)
4053 return 0;
4054 spec->master_sw = val;
4055 hp = (kcontrol->private_value >> 16) & 0xff;
4056 line = (kcontrol->private_value >> 8) & 0xff;
4057 mono = kcontrol->private_value & 0xff;
4058 alc260_hp_master_update(codec, hp, line, mono);
4059 return 1;
4060}
4061
4062static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4063 {
4064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4065 .name = "Master Playback Switch",
4066 .info = snd_ctl_boolean_mono_info,
4067 .get = alc260_hp_master_sw_get,
4068 .put = alc260_hp_master_sw_put,
4069 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4070 },
4071 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4072 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4073 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4074 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4075 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4076 HDA_OUTPUT),
4077 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4078 { } /* end */
4079};
4080
4081static struct hda_verb alc260_hp_unsol_verbs[] = {
4082 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4083 {},
4084};
4085
4086static void alc260_hp_automute(struct hda_codec *codec)
4087{
4088 struct alc_spec *spec = codec->spec;
4089 unsigned int present;
4090
4091 present = snd_hda_codec_read(codec, 0x10, 0,
4092 AC_VERB_GET_PIN_SENSE, 0);
4093 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4094 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4095}
4096
4097static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4098{
4099 if ((res >> 26) == ALC880_HP_EVENT)
4100 alc260_hp_automute(codec);
4101}
4102
Kailang Yangdf694da2005-12-05 19:42:22 +01004103static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004104 {
4105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4106 .name = "Master Playback Switch",
4107 .info = snd_ctl_boolean_mono_info,
4108 .get = alc260_hp_master_sw_get,
4109 .put = alc260_hp_master_sw_put,
4110 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4111 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004112 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4113 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4114 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4115 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4116 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004118 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4119 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004120 { } /* end */
4121};
4122
Takashi Iwaibec15c32008-01-28 18:16:30 +01004123static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4125 {},
4126};
4127
4128static void alc260_hp_3013_automute(struct hda_codec *codec)
4129{
4130 struct alc_spec *spec = codec->spec;
4131 unsigned int present;
4132
4133 present = snd_hda_codec_read(codec, 0x15, 0,
4134 AC_VERB_GET_PIN_SENSE, 0);
4135 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4136 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4137}
4138
4139static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4140 unsigned int res)
4141{
4142 if ((res >> 26) == ALC880_HP_EVENT)
4143 alc260_hp_3013_automute(codec);
4144}
4145
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004146/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4147 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4148 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004149static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004150 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004151 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004152 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004153 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4154 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4155 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4156 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004157 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004158 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4159 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4161 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004162 { } /* end */
4163};
4164
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004165/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4166 * versions of the ALC260 don't act on requests to enable mic bias from NID
4167 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4168 * datasheet doesn't mention this restriction. At this stage it's not clear
4169 * whether this behaviour is intentional or is a hardware bug in chip
4170 * revisions available in early 2006. Therefore for now allow the
4171 * "Headphone Jack Mode" control to span all choices, but if it turns out
4172 * that the lack of mic bias for this NID is intentional we could change the
4173 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4174 *
4175 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4176 * don't appear to make the mic bias available from the "line" jack, even
4177 * though the NID used for this jack (0x14) can supply it. The theory is
4178 * that perhaps Acer have included blocking capacitors between the ALC260
4179 * and the output jack. If this turns out to be the case for all such
4180 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4181 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004182 *
4183 * The C20x Tablet series have a mono internal speaker which is controlled
4184 * via the chip's Mono sum widget and pin complex, so include the necessary
4185 * controls for such models. On models without a "mono speaker" the control
4186 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004187 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004188static struct snd_kcontrol_new alc260_acer_mixer[] = {
4189 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4190 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004191 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004192 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004193 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004194 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004195 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004196 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4197 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4199 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4200 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4201 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4202 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4203 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4204 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4205 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4206 { } /* end */
4207};
4208
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004209/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4210 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4211 */
4212static struct snd_kcontrol_new alc260_will_mixer[] = {
4213 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4214 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4216 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4217 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4218 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4219 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4220 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4221 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4222 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4223 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4224 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4225 { } /* end */
4226};
4227
4228/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4229 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4230 */
4231static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4232 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4233 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4235 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4236 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4237 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4238 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4239 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4240 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4241 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4242 { } /* end */
4243};
4244
Kailang Yangdf694da2005-12-05 19:42:22 +01004245/* capture mixer elements */
4246static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004247 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4248 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004251 {
4252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004253 /* The multiple "Capture Source" controls confuse alsamixer
4254 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004255 */
4256 /* .name = "Capture Source", */
4257 .name = "Input Source",
4258 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004259 .info = alc_mux_enum_info,
4260 .get = alc_mux_enum_get,
4261 .put = alc_mux_enum_put,
4262 },
4263 { } /* end */
4264};
4265
Kailang Yangdf694da2005-12-05 19:42:22 +01004266static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4267 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4268 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4269 {
4270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4271 /* The multiple "Capture Source" controls confuse alsamixer
4272 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004273 */
4274 /* .name = "Capture Source", */
4275 .name = "Input Source",
4276 .count = 1,
4277 .info = alc_mux_enum_info,
4278 .get = alc_mux_enum_get,
4279 .put = alc_mux_enum_put,
4280 },
4281 { } /* end */
4282};
4283
4284/*
4285 * initialization verbs
4286 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004287static struct hda_verb alc260_init_verbs[] = {
4288 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004290 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004292 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004293 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004294 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004295 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004298 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004299 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004300 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004301 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004302 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004304 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004305 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4306 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004308 /* set connection select to line in (default select for this ADC) */
4309 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004310 /* mute capture amp left and right */
4311 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4312 /* set connection select to line in (default select for this ADC) */
4313 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004314 /* set vol=0 Line-Out mixer amp left and right */
4315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4316 /* unmute pin widget amp left and right (no gain on this amp) */
4317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4318 /* set vol=0 HP mixer amp left and right */
4319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4320 /* unmute pin widget amp left and right (no gain on this amp) */
4321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4322 /* set vol=0 Mono mixer amp left and right */
4323 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4324 /* unmute pin widget amp left and right (no gain on this amp) */
4325 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4326 /* unmute LINE-2 out pin */
4327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4329 * Line In 2 = 0x03
4330 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004331 /* mute analog inputs */
4332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004337 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004338 /* mute Front out path */
4339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4341 /* mute Headphone out path */
4342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4344 /* mute Mono out path */
4345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004347 { }
4348};
4349
Takashi Iwai474167d2006-05-17 17:17:43 +02004350#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004351static struct hda_verb alc260_hp_init_verbs[] = {
4352 /* Headphone and output */
4353 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4354 /* mono output */
4355 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4356 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4358 /* Mic2 (front panel) pin widget for input and vref at 80% */
4359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4360 /* Line In pin widget for input */
4361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4362 /* Line-2 pin widget for output */
4363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4364 /* CD pin widget for input */
4365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4366 /* unmute amp left and right */
4367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4368 /* set connection select to line in (default select for this ADC) */
4369 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4370 /* unmute Line-Out mixer amp left and right (volume = 0) */
4371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4372 /* mute pin widget amp left and right (no gain on this amp) */
4373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4374 /* unmute HP mixer amp left and right (volume = 0) */
4375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4376 /* mute pin widget amp left and right (no gain on this amp) */
4377 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4379 * Line In 2 = 0x03
4380 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004381 /* mute analog inputs */
4382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004387 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4388 /* Unmute Front out path */
4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4391 /* Unmute Headphone out path */
4392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4394 /* Unmute Mono out path */
4395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4397 { }
4398};
Takashi Iwai474167d2006-05-17 17:17:43 +02004399#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004400
4401static struct hda_verb alc260_hp_3013_init_verbs[] = {
4402 /* Line out and output */
4403 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4404 /* mono output */
4405 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4406 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4407 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4408 /* Mic2 (front panel) pin widget for input and vref at 80% */
4409 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4410 /* Line In pin widget for input */
4411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4412 /* Headphone pin widget for output */
4413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4414 /* CD pin widget for input */
4415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4416 /* unmute amp left and right */
4417 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4418 /* set connection select to line in (default select for this ADC) */
4419 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4420 /* unmute Line-Out mixer amp left and right (volume = 0) */
4421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4422 /* mute pin widget amp left and right (no gain on this amp) */
4423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4424 /* unmute HP mixer amp left and right (volume = 0) */
4425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4426 /* mute pin widget amp left and right (no gain on this amp) */
4427 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004428 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4429 * Line In 2 = 0x03
4430 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004431 /* mute analog inputs */
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004437 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4438 /* Unmute Front out path */
4439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4441 /* Unmute Headphone out path */
4442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4444 /* Unmute Mono out path */
4445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4447 { }
4448};
4449
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004450/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004451 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4452 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004453 */
4454static struct hda_verb alc260_fujitsu_init_verbs[] = {
4455 /* Disable all GPIOs */
4456 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4457 /* Internal speaker is connected to headphone pin */
4458 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4459 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004461 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4462 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4463 /* Ensure all other unused pins are disabled and muted. */
4464 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004466 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004467 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004468 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004469 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004472
Jonathan Woithef7ace402006-02-28 11:46:14 +01004473 /* Disable digital (SPDIF) pins */
4474 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4475 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004476
Jonathan Woithef7ace402006-02-28 11:46:14 +01004477 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4478 * when acting as an output.
4479 */
4480 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4481
4482 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004492
Jonathan Woithef7ace402006-02-28 11:46:14 +01004493 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4495 /* Unmute Line1 pin widget output buffer since it starts as an output.
4496 * If the pin mode is changed by the user the pin mode control will
4497 * take care of enabling the pin's input/output buffers as needed.
4498 * Therefore there's no need to enable the input buffer at this
4499 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004500 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004502 /* Unmute input buffer of pin widget used for Line-in (no equiv
4503 * mixer ctrl)
4504 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004505 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004506
Jonathan Woithef7ace402006-02-28 11:46:14 +01004507 /* Mute capture amp left and right */
4508 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4509 /* Set ADC connection select to match default mixer setting - line
4510 * in (on mic1 pin)
4511 */
4512 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004513
Jonathan Woithef7ace402006-02-28 11:46:14 +01004514 /* Do the same for the second ADC: mute capture input amp and
4515 * set ADC connection to line in (on mic1 pin)
4516 */
4517 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4518 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004519
Jonathan Woithef7ace402006-02-28 11:46:14 +01004520 /* Mute all inputs to mixer widget (even unconnected ones) */
4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004529
4530 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004531};
4532
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004533/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4534 * similar laptops (adapted from Fujitsu init verbs).
4535 */
4536static struct hda_verb alc260_acer_init_verbs[] = {
4537 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4538 * the headphone jack. Turn this on and rely on the standard mute
4539 * methods whenever the user wants to turn these outputs off.
4540 */
4541 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4542 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4543 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4544 /* Internal speaker/Headphone jack is connected to Line-out pin */
4545 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4546 /* Internal microphone/Mic jack is connected to Mic1 pin */
4547 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4548 /* Line In jack is connected to Line1 pin */
4549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004550 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4551 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004552 /* Ensure all other unused pins are disabled and muted. */
4553 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4554 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004555 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4556 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4559 /* Disable digital (SPDIF) pins */
4560 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4561 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4562
4563 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4564 * bus when acting as outputs.
4565 */
4566 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4567 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4568
4569 /* Start with output sum widgets muted and their output gains at min */
4570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4579
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004580 /* Unmute Line-out pin widget amp left and right
4581 * (no equiv mixer ctrl)
4582 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004584 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4585 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004586 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4587 * inputs. If the pin mode is changed by the user the pin mode control
4588 * will take care of enabling the pin's input/output buffers as needed.
4589 * Therefore there's no need to enable the input buffer at this
4590 * stage.
4591 */
4592 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4594
4595 /* Mute capture amp left and right */
4596 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4597 /* Set ADC connection select to match default mixer setting - mic
4598 * (on mic1 pin)
4599 */
4600 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4601
4602 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004603 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004604 */
4605 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004606 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004607
4608 /* Mute all inputs to mixer widget (even unconnected ones) */
4609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4617
4618 { }
4619};
4620
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004621static struct hda_verb alc260_will_verbs[] = {
4622 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4623 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4624 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4625 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4626 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4627 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4628 {}
4629};
4630
4631static struct hda_verb alc260_replacer_672v_verbs[] = {
4632 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4633 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4634 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4635
4636 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4637 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4638 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4639
4640 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4641 {}
4642};
4643
4644/* toggle speaker-output according to the hp-jack state */
4645static void alc260_replacer_672v_automute(struct hda_codec *codec)
4646{
4647 unsigned int present;
4648
4649 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4650 present = snd_hda_codec_read(codec, 0x0f, 0,
4651 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4652 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004653 snd_hda_codec_write_cache(codec, 0x01, 0,
4654 AC_VERB_SET_GPIO_DATA, 1);
4655 snd_hda_codec_write_cache(codec, 0x0f, 0,
4656 AC_VERB_SET_PIN_WIDGET_CONTROL,
4657 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004658 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004659 snd_hda_codec_write_cache(codec, 0x01, 0,
4660 AC_VERB_SET_GPIO_DATA, 0);
4661 snd_hda_codec_write_cache(codec, 0x0f, 0,
4662 AC_VERB_SET_PIN_WIDGET_CONTROL,
4663 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004664 }
4665}
4666
4667static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4668 unsigned int res)
4669{
4670 if ((res >> 26) == ALC880_HP_EVENT)
4671 alc260_replacer_672v_automute(codec);
4672}
4673
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004674/* Test configuration for debugging, modelled after the ALC880 test
4675 * configuration.
4676 */
4677#ifdef CONFIG_SND_DEBUG
4678static hda_nid_t alc260_test_dac_nids[1] = {
4679 0x02,
4680};
4681static hda_nid_t alc260_test_adc_nids[2] = {
4682 0x04, 0x05,
4683};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004684/* For testing the ALC260, each input MUX needs its own definition since
4685 * the signal assignments are different. This assumes that the first ADC
4686 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004687 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004688static struct hda_input_mux alc260_test_capture_sources[2] = {
4689 {
4690 .num_items = 7,
4691 .items = {
4692 { "MIC1 pin", 0x0 },
4693 { "MIC2 pin", 0x1 },
4694 { "LINE1 pin", 0x2 },
4695 { "LINE2 pin", 0x3 },
4696 { "CD pin", 0x4 },
4697 { "LINE-OUT pin", 0x5 },
4698 { "HP-OUT pin", 0x6 },
4699 },
4700 },
4701 {
4702 .num_items = 8,
4703 .items = {
4704 { "MIC1 pin", 0x0 },
4705 { "MIC2 pin", 0x1 },
4706 { "LINE1 pin", 0x2 },
4707 { "LINE2 pin", 0x3 },
4708 { "CD pin", 0x4 },
4709 { "Mixer", 0x5 },
4710 { "LINE-OUT pin", 0x6 },
4711 { "HP-OUT pin", 0x7 },
4712 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004713 },
4714};
4715static struct snd_kcontrol_new alc260_test_mixer[] = {
4716 /* Output driver widgets */
4717 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4718 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4719 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4720 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4721 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4722 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4723
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004724 /* Modes for retasking pin widgets
4725 * Note: the ALC260 doesn't seem to act on requests to enable mic
4726 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4727 * mention this restriction. At this stage it's not clear whether
4728 * this behaviour is intentional or is a hardware bug in chip
4729 * revisions available at least up until early 2006. Therefore for
4730 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4731 * choices, but if it turns out that the lack of mic bias for these
4732 * NIDs is intentional we could change their modes from
4733 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4734 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004735 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4736 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4737 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4738 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4739 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4740 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4741
4742 /* Loopback mixer controls */
4743 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4744 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4745 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4746 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4747 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4748 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4749 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4750 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4751 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4752 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4753 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4754 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4755 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4756 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4757 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4758 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004759
4760 /* Controls for GPIO pins, assuming they are configured as outputs */
4761 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4762 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4763 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4764 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4765
Jonathan Woithe92621f12006-02-28 11:47:47 +01004766 /* Switches to allow the digital IO pins to be enabled. The datasheet
4767 * is ambigious as to which NID is which; testing on laptops which
4768 * make this output available should provide clarification.
4769 */
4770 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4771 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4772
Jonathan Woithef8225f62008-01-08 12:16:54 +01004773 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4774 * this output to turn on an external amplifier.
4775 */
4776 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4777 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4778
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004779 { } /* end */
4780};
4781static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004782 /* Enable all GPIOs as outputs with an initial value of 0 */
4783 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4784 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4785 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4786
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004787 /* Enable retasking pins as output, initially without power amp */
4788 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4789 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4792 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4793 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4794
Jonathan Woithe92621f12006-02-28 11:47:47 +01004795 /* Disable digital (SPDIF) pins initially, but users can enable
4796 * them via a mixer switch. In the case of SPDIF-out, this initverb
4797 * payload also sets the generation to 0, output to be in "consumer"
4798 * PCM format, copyright asserted, no pre-emphasis and no validity
4799 * control.
4800 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004801 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4802 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4803
Jonathan Woithef7ace402006-02-28 11:46:14 +01004804 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004805 * OUT1 sum bus when acting as an output.
4806 */
4807 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4808 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4809 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4810 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4811
4812 /* Start with output sum widgets muted and their output gains at min */
4813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4815 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4819 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4820 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4821 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4822
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004823 /* Unmute retasking pin widget output buffers since the default
4824 * state appears to be output. As the pin mode is changed by the
4825 * user the pin mode control will take care of enabling the pin's
4826 * input/output buffers as needed.
4827 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004828 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4832 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4833 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4834 /* Also unmute the mono-out pin widget */
4835 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4836
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004837 /* Mute capture amp left and right */
4838 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004839 /* Set ADC connection select to match default mixer setting (mic1
4840 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004841 */
4842 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4843
4844 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004845 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004846 */
4847 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4848 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4849
4850 /* Mute all inputs to mixer widget (even unconnected ones) */
4851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4859
4860 { }
4861};
4862#endif
4863
Takashi Iwai63300792008-01-24 15:31:36 +01004864#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4865#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004866
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004867#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4868#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4869
Kailang Yangdf694da2005-12-05 19:42:22 +01004870/*
4871 * for BIOS auto-configuration
4872 */
4873
4874static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4875 const char *pfx)
4876{
4877 hda_nid_t nid_vol;
4878 unsigned long vol_val, sw_val;
4879 char name[32];
4880 int err;
4881
4882 if (nid >= 0x0f && nid < 0x11) {
4883 nid_vol = nid - 0x7;
4884 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4885 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4886 } else if (nid == 0x11) {
4887 nid_vol = nid - 0x7;
4888 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4889 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4890 } else if (nid >= 0x12 && nid <= 0x15) {
4891 nid_vol = 0x08;
4892 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4893 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4894 } else
4895 return 0; /* N/A */
4896
4897 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004898 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4899 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004900 return err;
4901 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004902 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4903 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004904 return err;
4905 return 1;
4906}
4907
4908/* add playback controls from the parsed DAC table */
4909static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4910 const struct auto_pin_cfg *cfg)
4911{
4912 hda_nid_t nid;
4913 int err;
4914
4915 spec->multiout.num_dacs = 1;
4916 spec->multiout.dac_nids = spec->private_dac_nids;
4917 spec->multiout.dac_nids[0] = 0x02;
4918
4919 nid = cfg->line_out_pins[0];
4920 if (nid) {
4921 err = alc260_add_playback_controls(spec, nid, "Front");
4922 if (err < 0)
4923 return err;
4924 }
4925
Takashi Iwai82bc9552006-03-21 11:24:42 +01004926 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004927 if (nid) {
4928 err = alc260_add_playback_controls(spec, nid, "Speaker");
4929 if (err < 0)
4930 return err;
4931 }
4932
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004933 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 if (nid) {
4935 err = alc260_add_playback_controls(spec, nid, "Headphone");
4936 if (err < 0)
4937 return err;
4938 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004939 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004940}
4941
4942/* create playback/capture controls for input pins */
4943static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4944 const struct auto_pin_cfg *cfg)
4945{
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 struct hda_input_mux *imux = &spec->private_imux;
4947 int i, err, idx;
4948
4949 for (i = 0; i < AUTO_PIN_LAST; i++) {
4950 if (cfg->input_pins[i] >= 0x12) {
4951 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004952 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004953 auto_pin_cfg_labels[i], idx,
4954 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004955 if (err < 0)
4956 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004957 imux->items[imux->num_items].label =
4958 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004959 imux->items[imux->num_items].index = idx;
4960 imux->num_items++;
4961 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004962 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004963 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004964 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004965 auto_pin_cfg_labels[i], idx,
4966 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004967 if (err < 0)
4968 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004969 imux->items[imux->num_items].label =
4970 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004971 imux->items[imux->num_items].index = idx;
4972 imux->num_items++;
4973 }
4974 }
4975 return 0;
4976}
4977
4978static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4979 hda_nid_t nid, int pin_type,
4980 int sel_idx)
4981{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004982 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004983 /* need the manual connection? */
4984 if (nid >= 0x12) {
4985 int idx = nid - 0x12;
4986 snd_hda_codec_write(codec, idx + 0x0b, 0,
4987 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004988 }
4989}
4990
4991static void alc260_auto_init_multi_out(struct hda_codec *codec)
4992{
4993 struct alc_spec *spec = codec->spec;
4994 hda_nid_t nid;
4995
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004996 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004997 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004998 if (nid) {
4999 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5000 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5001 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005002
Takashi Iwai82bc9552006-03-21 11:24:42 +01005003 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005004 if (nid)
5005 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5006
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005007 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005008 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005009 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005010}
Kailang Yangdf694da2005-12-05 19:42:22 +01005011
5012#define ALC260_PIN_CD_NID 0x16
5013static void alc260_auto_init_analog_input(struct hda_codec *codec)
5014{
5015 struct alc_spec *spec = codec->spec;
5016 int i;
5017
5018 for (i = 0; i < AUTO_PIN_LAST; i++) {
5019 hda_nid_t nid = spec->autocfg.input_pins[i];
5020 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005021 snd_hda_codec_write(codec, nid, 0,
5022 AC_VERB_SET_PIN_WIDGET_CONTROL,
5023 i <= AUTO_PIN_FRONT_MIC ?
5024 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005025 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005026 snd_hda_codec_write(codec, nid, 0,
5027 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005028 AMP_OUT_MUTE);
5029 }
5030 }
5031}
5032
5033/*
5034 * generic initialization of ADC, input mixers and output mixers
5035 */
5036static struct hda_verb alc260_volume_init_verbs[] = {
5037 /*
5038 * Unmute ADC0-1 and set the default input to mic-in
5039 */
5040 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5041 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5042 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5043 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5044
5045 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5046 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005047 * Note: PASD motherboards uses the Line In 2 as the input for
5048 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 */
5050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005051 /* mute analog inputs */
5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005057
5058 /*
5059 * Set up output mixers (0x08 - 0x0a)
5060 */
5061 /* set vol=0 to output mixers */
5062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5065 /* set up input amps for analog loopback */
5066 /* Amp Indices: DAC = 0, mixer = 1 */
5067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5072 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5073
5074 { }
5075};
5076
5077static int alc260_parse_auto_config(struct hda_codec *codec)
5078{
5079 struct alc_spec *spec = codec->spec;
5080 unsigned int wcap;
5081 int err;
5082 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5083
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005084 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5085 alc260_ignore);
5086 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005087 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005088 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5089 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005090 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005091 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005092 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005093 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5094 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005095 return err;
5096
5097 spec->multiout.max_channels = 2;
5098
5099 if (spec->autocfg.dig_out_pin)
5100 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5101 if (spec->kctl_alloc)
5102 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5103
5104 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5105
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005106 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005107 spec->input_mux = &spec->private_imux;
5108
5109 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005110 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005112 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005113 spec->adc_nids = alc260_adc_nids_alt;
5114 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5115 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005116 } else {
5117 spec->adc_nids = alc260_adc_nids;
5118 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5119 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005120 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005121 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005122
5123 return 1;
5124}
5125
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005126/* additional initialization for auto-configuration model */
5127static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005128{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005129 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005130 alc260_auto_init_multi_out(codec);
5131 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005132 if (spec->unsol_event)
5133 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005134}
5135
Takashi Iwaicb53c622007-08-10 17:21:45 +02005136#ifdef CONFIG_SND_HDA_POWER_SAVE
5137static struct hda_amp_list alc260_loopbacks[] = {
5138 { 0x07, HDA_INPUT, 0 },
5139 { 0x07, HDA_INPUT, 1 },
5140 { 0x07, HDA_INPUT, 2 },
5141 { 0x07, HDA_INPUT, 3 },
5142 { 0x07, HDA_INPUT, 4 },
5143 { } /* end */
5144};
5145#endif
5146
Kailang Yangdf694da2005-12-05 19:42:22 +01005147/*
5148 * ALC260 configurations
5149 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005150static const char *alc260_models[ALC260_MODEL_LAST] = {
5151 [ALC260_BASIC] = "basic",
5152 [ALC260_HP] = "hp",
5153 [ALC260_HP_3013] = "hp-3013",
5154 [ALC260_FUJITSU_S702X] = "fujitsu",
5155 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005156 [ALC260_WILL] = "will",
5157 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005158#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005159 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005160#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005161 [ALC260_AUTO] = "auto",
5162};
5163
5164static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005165 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005166 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005167 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005168 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005169 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5170 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5171 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5172 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5173 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5174 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5175 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5176 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5177 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5178 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5179 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5180 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005181 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005182 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005183 {}
5184};
5185
Kailang Yangdf694da2005-12-05 19:42:22 +01005186static struct alc_config_preset alc260_presets[] = {
5187 [ALC260_BASIC] = {
5188 .mixers = { alc260_base_output_mixer,
5189 alc260_input_mixer,
5190 alc260_pc_beep_mixer,
5191 alc260_capture_mixer },
5192 .init_verbs = { alc260_init_verbs },
5193 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5194 .dac_nids = alc260_dac_nids,
5195 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5196 .adc_nids = alc260_adc_nids,
5197 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5198 .channel_mode = alc260_modes,
5199 .input_mux = &alc260_capture_source,
5200 },
5201 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005202 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005203 alc260_input_mixer,
5204 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005205 .init_verbs = { alc260_init_verbs,
5206 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5208 .dac_nids = alc260_dac_nids,
5209 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5210 .adc_nids = alc260_hp_adc_nids,
5211 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5212 .channel_mode = alc260_modes,
5213 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005214 .unsol_event = alc260_hp_unsol_event,
5215 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005216 },
5217 [ALC260_HP_3013] = {
5218 .mixers = { alc260_hp_3013_mixer,
5219 alc260_input_mixer,
5220 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005221 .init_verbs = { alc260_hp_3013_init_verbs,
5222 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005223 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5224 .dac_nids = alc260_dac_nids,
5225 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5226 .adc_nids = alc260_hp_adc_nids,
5227 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5228 .channel_mode = alc260_modes,
5229 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005230 .unsol_event = alc260_hp_3013_unsol_event,
5231 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005232 },
5233 [ALC260_FUJITSU_S702X] = {
5234 .mixers = { alc260_fujitsu_mixer,
5235 alc260_capture_mixer },
5236 .init_verbs = { alc260_fujitsu_init_verbs },
5237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5238 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5240 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005241 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5242 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005243 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5244 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005245 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005246 [ALC260_ACER] = {
5247 .mixers = { alc260_acer_mixer,
5248 alc260_capture_mixer },
5249 .init_verbs = { alc260_acer_init_verbs },
5250 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5251 .dac_nids = alc260_dac_nids,
5252 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5253 .adc_nids = alc260_dual_adc_nids,
5254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5255 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005256 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5257 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005258 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005259 [ALC260_WILL] = {
5260 .mixers = { alc260_will_mixer,
5261 alc260_capture_mixer },
5262 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5263 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5264 .dac_nids = alc260_dac_nids,
5265 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5266 .adc_nids = alc260_adc_nids,
5267 .dig_out_nid = ALC260_DIGOUT_NID,
5268 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5269 .channel_mode = alc260_modes,
5270 .input_mux = &alc260_capture_source,
5271 },
5272 [ALC260_REPLACER_672V] = {
5273 .mixers = { alc260_replacer_672v_mixer,
5274 alc260_capture_mixer },
5275 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5276 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5277 .dac_nids = alc260_dac_nids,
5278 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5279 .adc_nids = alc260_adc_nids,
5280 .dig_out_nid = ALC260_DIGOUT_NID,
5281 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5282 .channel_mode = alc260_modes,
5283 .input_mux = &alc260_capture_source,
5284 .unsol_event = alc260_replacer_672v_unsol_event,
5285 .init_hook = alc260_replacer_672v_automute,
5286 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005287#ifdef CONFIG_SND_DEBUG
5288 [ALC260_TEST] = {
5289 .mixers = { alc260_test_mixer,
5290 alc260_capture_mixer },
5291 .init_verbs = { alc260_test_init_verbs },
5292 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5293 .dac_nids = alc260_test_dac_nids,
5294 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5295 .adc_nids = alc260_test_adc_nids,
5296 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5297 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005298 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5299 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005300 },
5301#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005302};
5303
Linus Torvalds1da177e2005-04-16 15:20:36 -07005304static int patch_alc260(struct hda_codec *codec)
5305{
5306 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005307 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005309 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 if (spec == NULL)
5311 return -ENOMEM;
5312
5313 codec->spec = spec;
5314
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005315 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5316 alc260_models,
5317 alc260_cfg_tbl);
5318 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005319 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5320 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005321 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005322 }
5323
Kailang Yangdf694da2005-12-05 19:42:22 +01005324 if (board_config == ALC260_AUTO) {
5325 /* automatic parse from the BIOS config */
5326 err = alc260_parse_auto_config(codec);
5327 if (err < 0) {
5328 alc_free(codec);
5329 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005330 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005331 printk(KERN_INFO
5332 "hda_codec: Cannot set up configuration "
5333 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005334 board_config = ALC260_BASIC;
5335 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005336 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005337
Kailang Yangdf694da2005-12-05 19:42:22 +01005338 if (board_config != ALC260_AUTO)
5339 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005340
5341 spec->stream_name_analog = "ALC260 Analog";
5342 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5343 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5344
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005345 spec->stream_name_digital = "ALC260 Digital";
5346 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5347 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5348
Takashi Iwai2134ea42008-01-10 16:53:55 +01005349 spec->vmaster_nid = 0x08;
5350
Linus Torvalds1da177e2005-04-16 15:20:36 -07005351 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005352 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005353 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005354#ifdef CONFIG_SND_HDA_POWER_SAVE
5355 if (!spec->loopback.amplist)
5356 spec->loopback.amplist = alc260_loopbacks;
5357#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005358
5359 return 0;
5360}
5361
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005362
Linus Torvalds1da177e2005-04-16 15:20:36 -07005363/*
5364 * ALC882 support
5365 *
5366 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5367 * configuration. Each pin widget can choose any input DACs and a mixer.
5368 * Each ADC is connected from a mixer of all inputs. This makes possible
5369 * 6-channel independent captures.
5370 *
5371 * In addition, an independent DAC for the multi-playback (not used in this
5372 * driver yet).
5373 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005374#define ALC882_DIGOUT_NID 0x06
5375#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005376
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005377static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005378 { 8, NULL }
5379};
5380
5381static hda_nid_t alc882_dac_nids[4] = {
5382 /* front, rear, clfe, rear_surr */
5383 0x02, 0x03, 0x04, 0x05
5384};
5385
Kailang Yangdf694da2005-12-05 19:42:22 +01005386/* identical with ALC880 */
5387#define alc882_adc_nids alc880_adc_nids
5388#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005389
Takashi Iwaie1406342008-02-11 18:32:32 +01005390static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5391static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5392
Linus Torvalds1da177e2005-04-16 15:20:36 -07005393/* input MUX */
5394/* FIXME: should be a matrix-type input source selection */
5395
5396static struct hda_input_mux alc882_capture_source = {
5397 .num_items = 4,
5398 .items = {
5399 { "Mic", 0x0 },
5400 { "Front Mic", 0x1 },
5401 { "Line", 0x2 },
5402 { "CD", 0x4 },
5403 },
5404};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005405#define alc882_mux_enum_info alc_mux_enum_info
5406#define alc882_mux_enum_get alc_mux_enum_get
5407
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005408static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5409 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005410{
5411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5412 struct alc_spec *spec = codec->spec;
5413 const struct hda_input_mux *imux = spec->input_mux;
5414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005415 hda_nid_t nid = spec->capsrc_nids ?
5416 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005417 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5418 unsigned int i, idx;
5419
5420 idx = ucontrol->value.enumerated.item[0];
5421 if (idx >= imux->num_items)
5422 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005423 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005424 return 0;
5425 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005426 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5427 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005428 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005429 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005430 }
5431 *cur_val = idx;
5432 return 1;
5433}
5434
Kailang Yangdf694da2005-12-05 19:42:22 +01005435/*
Kailang Yang272a5272007-05-14 11:00:38 +02005436 * 2ch mode
5437 */
5438static struct hda_verb alc882_3ST_ch2_init[] = {
5439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5443 { } /* end */
5444};
5445
5446/*
5447 * 6ch mode
5448 */
5449static struct hda_verb alc882_3ST_ch6_init[] = {
5450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5452 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5455 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5456 { } /* end */
5457};
5458
5459static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5460 { 2, alc882_3ST_ch2_init },
5461 { 6, alc882_3ST_ch6_init },
5462};
5463
5464/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005465 * 6ch mode
5466 */
5467static struct hda_verb alc882_sixstack_ch6_init[] = {
5468 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5469 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5470 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5471 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5472 { } /* end */
5473};
5474
5475/*
5476 * 8ch mode
5477 */
5478static struct hda_verb alc882_sixstack_ch8_init[] = {
5479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5483 { } /* end */
5484};
5485
5486static struct hda_channel_mode alc882_sixstack_modes[2] = {
5487 { 6, alc882_sixstack_ch6_init },
5488 { 8, alc882_sixstack_ch8_init },
5489};
5490
Takashi Iwai87350ad2007-08-16 18:19:38 +02005491/*
5492 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5493 */
5494
5495/*
5496 * 2ch mode
5497 */
5498static struct hda_verb alc885_mbp_ch2_init[] = {
5499 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5500 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5501 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5502 { } /* end */
5503};
5504
5505/*
5506 * 6ch mode
5507 */
5508static struct hda_verb alc885_mbp_ch6_init[] = {
5509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5511 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5513 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5514 { } /* end */
5515};
5516
5517static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5518 { 2, alc885_mbp_ch2_init },
5519 { 6, alc885_mbp_ch6_init },
5520};
5521
5522
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5524 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5525 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005526static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005528 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005529 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005530 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005531 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5532 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005533 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5534 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005535 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005536 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5540 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5541 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005543 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5545 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005546 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5548 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5549 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005550 { } /* end */
5551};
5552
Takashi Iwai87350ad2007-08-16 18:19:38 +02005553static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005554 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5555 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5556 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5557 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5558 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5559 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5561 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005562 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5564 { } /* end */
5565};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005566static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5569 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5570 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5571 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5572 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5576 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5577 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5578 { } /* end */
5579};
5580
Kailang Yang272a5272007-05-14 11:00:38 +02005581static struct snd_kcontrol_new alc882_targa_mixer[] = {
5582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005594 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005595 { } /* end */
5596};
5597
5598/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5599 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5600 */
5601static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5603 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5605 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5606 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5607 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5610 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5611 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005614 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005615 { } /* end */
5616};
5617
Takashi Iwai914759b2007-09-06 14:52:04 +02005618static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5622 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5623 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5624 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5625 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5629 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5630 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5631 { } /* end */
5632};
5633
Kailang Yangdf694da2005-12-05 19:42:22 +01005634static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5635 {
5636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5637 .name = "Channel Mode",
5638 .info = alc_ch_mode_info,
5639 .get = alc_ch_mode_get,
5640 .put = alc_ch_mode_put,
5641 },
5642 { } /* end */
5643};
5644
Linus Torvalds1da177e2005-04-16 15:20:36 -07005645static struct hda_verb alc882_init_verbs[] = {
5646 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005650 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005654 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005658 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005663 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005667 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005670 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005671 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005672 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005673 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005674 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005675 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005676 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005677 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005678 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005679 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005680 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5682 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5685 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5688 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5689 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5691 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005692 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694
5695 /* FIXME: use matrix-type input source selection */
5696 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5697 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005707 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5712 /* ADC1: mute amp left and right */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005714 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005715 /* ADC2: mute amp left and right */
5716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005717 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005718 /* ADC3: mute amp left and right */
5719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005720 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721
5722 { }
5723};
5724
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005725static struct hda_verb alc882_eapd_verbs[] = {
5726 /* change to EAPD mode */
5727 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005728 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005729 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005730};
5731
Tobin Davis9102cd12006-12-15 10:02:12 +01005732/* Mac Pro test */
5733static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5734 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5735 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5737 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5738 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5739 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5740 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5741 { } /* end */
5742};
5743
5744static struct hda_verb alc882_macpro_init_verbs[] = {
5745 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5749 /* Front Pin: output 0 (0x0c) */
5750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5753 /* Front Mic pin: input vref at 80% */
5754 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5755 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5756 /* Speaker: output */
5757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5759 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5760 /* Headphone output (output 0 - 0x0c) */
5761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5763 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5764
5765 /* FIXME: use matrix-type input source selection */
5766 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5767 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5772 /* Input mixer2 */
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5777 /* Input mixer3 */
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5782 /* ADC1: mute amp left and right */
5783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5784 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5785 /* ADC2: mute amp left and right */
5786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5787 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5788 /* ADC3: mute amp left and right */
5789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5790 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5791
5792 { }
5793};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005794
Takashi Iwai87350ad2007-08-16 18:19:38 +02005795/* Macbook Pro rev3 */
5796static struct hda_verb alc885_mbp3_init_verbs[] = {
5797 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5801 /* Rear mixer */
5802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5805 /* Front Pin: output 0 (0x0c) */
5806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5809 /* HP Pin: output 0 (0x0d) */
5810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5813 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5814 /* Mic (rear) pin: input vref at 80% */
5815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5817 /* Front Mic pin: input vref at 80% */
5818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5820 /* Line In pin: use output 1 when in LineOut mode */
5821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5823 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5824
5825 /* FIXME: use matrix-type input source selection */
5826 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5827 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5832 /* Input mixer2 */
5833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5836 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5837 /* Input mixer3 */
5838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5842 /* ADC1: mute amp left and right */
5843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5844 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5845 /* ADC2: mute amp left and right */
5846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5847 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5848 /* ADC3: mute amp left and right */
5849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5850 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5851
5852 { }
5853};
5854
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005855/* iMac 24 mixer. */
5856static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5857 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5858 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5859 { } /* end */
5860};
5861
5862/* iMac 24 init verbs. */
5863static struct hda_verb alc885_imac24_init_verbs[] = {
5864 /* Internal speakers: output 0 (0x0c) */
5865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5867 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5868 /* Internal speakers: output 0 (0x0c) */
5869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5871 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5872 /* Headphone: output 0 (0x0c) */
5873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5875 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5877 /* Front Mic: input vref at 80% */
5878 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5880 { }
5881};
5882
5883/* Toggle speaker-output according to the hp-jack state */
5884static void alc885_imac24_automute(struct hda_codec *codec)
5885{
5886 unsigned int present;
5887
5888 present = snd_hda_codec_read(codec, 0x14, 0,
5889 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005890 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5891 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5892 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005894}
5895
5896/* Processes unsolicited events. */
5897static void alc885_imac24_unsol_event(struct hda_codec *codec,
5898 unsigned int res)
5899{
5900 /* Headphone insertion or removal. */
5901 if ((res >> 26) == ALC880_HP_EVENT)
5902 alc885_imac24_automute(codec);
5903}
5904
Takashi Iwai87350ad2007-08-16 18:19:38 +02005905static void alc885_mbp3_automute(struct hda_codec *codec)
5906{
5907 unsigned int present;
5908
5909 present = snd_hda_codec_read(codec, 0x15, 0,
5910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5911 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5912 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5913 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5914 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5915
5916}
5917static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5918 unsigned int res)
5919{
5920 /* Headphone insertion or removal. */
5921 if ((res >> 26) == ALC880_HP_EVENT)
5922 alc885_mbp3_automute(codec);
5923}
5924
5925
Kailang Yang272a5272007-05-14 11:00:38 +02005926static struct hda_verb alc882_targa_verbs[] = {
5927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5929
5930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5932
5933 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5934 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5935 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5936
5937 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5938 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5939 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5940 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5941 { } /* end */
5942};
5943
5944/* toggle speaker-output according to the hp-jack state */
5945static void alc882_targa_automute(struct hda_codec *codec)
5946{
5947 unsigned int present;
5948
5949 present = snd_hda_codec_read(codec, 0x14, 0,
5950 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005951 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5952 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005953 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5954 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005955}
5956
5957static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5958{
5959 /* Looks like the unsol event is incompatible with the standard
5960 * definition. 4bit tag is placed at 26 bit!
5961 */
5962 if (((res >> 26) == ALC880_HP_EVENT)) {
5963 alc882_targa_automute(codec);
5964 }
5965}
5966
5967static struct hda_verb alc882_asus_a7j_verbs[] = {
5968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5970
5971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5974
5975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5976 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5977 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5978
5979 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5980 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5981 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5982 { } /* end */
5983};
5984
Takashi Iwai914759b2007-09-06 14:52:04 +02005985static struct hda_verb alc882_asus_a7m_verbs[] = {
5986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5988
5989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5992
5993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5995 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5996
5997 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5998 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6000 { } /* end */
6001};
6002
Tobin Davis9102cd12006-12-15 10:02:12 +01006003static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6004{
6005 unsigned int gpiostate, gpiomask, gpiodir;
6006
6007 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6008 AC_VERB_GET_GPIO_DATA, 0);
6009
6010 if (!muted)
6011 gpiostate |= (1 << pin);
6012 else
6013 gpiostate &= ~(1 << pin);
6014
6015 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6016 AC_VERB_GET_GPIO_MASK, 0);
6017 gpiomask |= (1 << pin);
6018
6019 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6020 AC_VERB_GET_GPIO_DIRECTION, 0);
6021 gpiodir |= (1 << pin);
6022
6023
6024 snd_hda_codec_write(codec, codec->afg, 0,
6025 AC_VERB_SET_GPIO_MASK, gpiomask);
6026 snd_hda_codec_write(codec, codec->afg, 0,
6027 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6028
6029 msleep(1);
6030
6031 snd_hda_codec_write(codec, codec->afg, 0,
6032 AC_VERB_SET_GPIO_DATA, gpiostate);
6033}
6034
Takashi Iwai7debbe52007-08-16 15:01:03 +02006035/* set up GPIO at initialization */
6036static void alc885_macpro_init_hook(struct hda_codec *codec)
6037{
6038 alc882_gpio_mute(codec, 0, 0);
6039 alc882_gpio_mute(codec, 1, 0);
6040}
6041
6042/* set up GPIO and update auto-muting at initialization */
6043static void alc885_imac24_init_hook(struct hda_codec *codec)
6044{
6045 alc885_macpro_init_hook(codec);
6046 alc885_imac24_automute(codec);
6047}
6048
Kailang Yangdf694da2005-12-05 19:42:22 +01006049/*
6050 * generic initialization of ADC, input mixers and output mixers
6051 */
6052static struct hda_verb alc882_auto_init_verbs[] = {
6053 /*
6054 * Unmute ADC0-2 and set the default input to mic-in
6055 */
6056 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6058 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6060 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062
Takashi Iwaicb53c622007-08-10 17:21:45 +02006063 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006064 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006065 * Note: PASD motherboards uses the Line In 2 as the input for
6066 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 */
6068 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006074
6075 /*
6076 * Set up output mixers (0x0c - 0x0f)
6077 */
6078 /* set vol=0 to output mixers */
6079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6083 /* set up input amps for analog loopback */
6084 /* Amp Indices: DAC = 0, mixer = 1 */
6085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6093 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6094 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6095
6096 /* FIXME: use matrix-type input source selection */
6097 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6098 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6103 /* Input mixer2 */
6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6108 /* Input mixer3 */
6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6113
6114 { }
6115};
6116
6117/* capture mixer elements */
6118static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6119 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6121 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6122 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6123 {
6124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6125 /* The multiple "Capture Source" controls confuse alsamixer
6126 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006127 */
6128 /* .name = "Capture Source", */
6129 .name = "Input Source",
6130 .count = 2,
6131 .info = alc882_mux_enum_info,
6132 .get = alc882_mux_enum_get,
6133 .put = alc882_mux_enum_put,
6134 },
6135 { } /* end */
6136};
6137
6138static struct snd_kcontrol_new alc882_capture_mixer[] = {
6139 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6140 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6141 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6142 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6143 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6144 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6145 {
6146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6147 /* The multiple "Capture Source" controls confuse alsamixer
6148 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 */
6150 /* .name = "Capture Source", */
6151 .name = "Input Source",
6152 .count = 3,
6153 .info = alc882_mux_enum_info,
6154 .get = alc882_mux_enum_get,
6155 .put = alc882_mux_enum_put,
6156 },
6157 { } /* end */
6158};
6159
Takashi Iwaicb53c622007-08-10 17:21:45 +02006160#ifdef CONFIG_SND_HDA_POWER_SAVE
6161#define alc882_loopbacks alc880_loopbacks
6162#endif
6163
Kailang Yangdf694da2005-12-05 19:42:22 +01006164/* pcm configuration: identiacal with ALC880 */
6165#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6166#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6167#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6168#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6169
6170/*
6171 * configuration and preset
6172 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006173static const char *alc882_models[ALC882_MODEL_LAST] = {
6174 [ALC882_3ST_DIG] = "3stack-dig",
6175 [ALC882_6ST_DIG] = "6stack-dig",
6176 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006177 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006178 [ALC882_TARGA] = "targa",
6179 [ALC882_ASUS_A7J] = "asus-a7j",
6180 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006181 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006182 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006183 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006184 [ALC882_AUTO] = "auto",
6185};
6186
6187static struct snd_pci_quirk alc882_cfg_tbl[] = {
6188 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006189 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006190 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006191 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006192 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006193 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006194 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006195 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Travis Place3e0e4692008-06-20 16:51:45 +02006196 SND_PCI_QUIRK(0x106b, 0x00a0, "Apple iMac 24''", ALC885_IMAC24),
Jiang zhe44447042008-01-28 12:28:24 +01006197 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006198 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6199 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6200 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006201 {}
6202};
6203
6204static struct alc_config_preset alc882_presets[] = {
6205 [ALC882_3ST_DIG] = {
6206 .mixers = { alc882_base_mixer },
6207 .init_verbs = { alc882_init_verbs },
6208 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6209 .dac_nids = alc882_dac_nids,
6210 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 .dig_in_nid = ALC882_DIGIN_NID,
6212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6213 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006214 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 .input_mux = &alc882_capture_source,
6216 },
6217 [ALC882_6ST_DIG] = {
6218 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6219 .init_verbs = { alc882_init_verbs },
6220 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6221 .dac_nids = alc882_dac_nids,
6222 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006223 .dig_in_nid = ALC882_DIGIN_NID,
6224 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6225 .channel_mode = alc882_sixstack_modes,
6226 .input_mux = &alc882_capture_source,
6227 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006228 [ALC882_ARIMA] = {
6229 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6230 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6231 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6232 .dac_nids = alc882_dac_nids,
6233 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6234 .channel_mode = alc882_sixstack_modes,
6235 .input_mux = &alc882_capture_source,
6236 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006237 [ALC882_W2JC] = {
6238 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6239 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6240 alc880_gpio1_init_verbs },
6241 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6242 .dac_nids = alc882_dac_nids,
6243 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6244 .channel_mode = alc880_threestack_modes,
6245 .need_dac_fix = 1,
6246 .input_mux = &alc882_capture_source,
6247 .dig_out_nid = ALC882_DIGOUT_NID,
6248 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006249 [ALC885_MBP3] = {
6250 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6251 .init_verbs = { alc885_mbp3_init_verbs,
6252 alc880_gpio1_init_verbs },
6253 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6254 .dac_nids = alc882_dac_nids,
6255 .channel_mode = alc885_mbp_6ch_modes,
6256 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6257 .input_mux = &alc882_capture_source,
6258 .dig_out_nid = ALC882_DIGOUT_NID,
6259 .dig_in_nid = ALC882_DIGIN_NID,
6260 .unsol_event = alc885_mbp3_unsol_event,
6261 .init_hook = alc885_mbp3_automute,
6262 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006263 [ALC885_MACPRO] = {
6264 .mixers = { alc882_macpro_mixer },
6265 .init_verbs = { alc882_macpro_init_verbs },
6266 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6267 .dac_nids = alc882_dac_nids,
6268 .dig_out_nid = ALC882_DIGOUT_NID,
6269 .dig_in_nid = ALC882_DIGIN_NID,
6270 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6271 .channel_mode = alc882_ch_modes,
6272 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006273 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006274 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006275 [ALC885_IMAC24] = {
6276 .mixers = { alc885_imac24_mixer },
6277 .init_verbs = { alc885_imac24_init_verbs },
6278 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6279 .dac_nids = alc882_dac_nids,
6280 .dig_out_nid = ALC882_DIGOUT_NID,
6281 .dig_in_nid = ALC882_DIGIN_NID,
6282 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6283 .channel_mode = alc882_ch_modes,
6284 .input_mux = &alc882_capture_source,
6285 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006286 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006287 },
Kailang Yang272a5272007-05-14 11:00:38 +02006288 [ALC882_TARGA] = {
6289 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6290 alc882_capture_mixer },
6291 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6292 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6293 .dac_nids = alc882_dac_nids,
6294 .dig_out_nid = ALC882_DIGOUT_NID,
6295 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6296 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006297 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006298 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6299 .channel_mode = alc882_3ST_6ch_modes,
6300 .need_dac_fix = 1,
6301 .input_mux = &alc882_capture_source,
6302 .unsol_event = alc882_targa_unsol_event,
6303 .init_hook = alc882_targa_automute,
6304 },
6305 [ALC882_ASUS_A7J] = {
6306 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6307 alc882_capture_mixer },
6308 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6309 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6310 .dac_nids = alc882_dac_nids,
6311 .dig_out_nid = ALC882_DIGOUT_NID,
6312 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6313 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006314 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006315 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6316 .channel_mode = alc882_3ST_6ch_modes,
6317 .need_dac_fix = 1,
6318 .input_mux = &alc882_capture_source,
6319 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006320 [ALC882_ASUS_A7M] = {
6321 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6322 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6323 alc880_gpio1_init_verbs,
6324 alc882_asus_a7m_verbs },
6325 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6326 .dac_nids = alc882_dac_nids,
6327 .dig_out_nid = ALC882_DIGOUT_NID,
6328 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6329 .channel_mode = alc880_threestack_modes,
6330 .need_dac_fix = 1,
6331 .input_mux = &alc882_capture_source,
6332 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006333};
6334
6335
6336/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006337 * Pin config fixes
6338 */
6339enum {
6340 PINFIX_ABIT_AW9D_MAX
6341};
6342
6343static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6344 { 0x15, 0x01080104 }, /* side */
6345 { 0x16, 0x01011012 }, /* rear */
6346 { 0x17, 0x01016011 }, /* clfe */
6347 { }
6348};
6349
6350static const struct alc_pincfg *alc882_pin_fixes[] = {
6351 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6352};
6353
6354static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6355 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6356 {}
6357};
6358
6359/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006360 * BIOS auto configuration
6361 */
6362static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6363 hda_nid_t nid, int pin_type,
6364 int dac_idx)
6365{
6366 /* set as output */
6367 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006368 int idx;
6369
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006370 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006371 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6372 idx = 4;
6373 else
6374 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6376
6377}
6378
6379static void alc882_auto_init_multi_out(struct hda_codec *codec)
6380{
6381 struct alc_spec *spec = codec->spec;
6382 int i;
6383
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006384 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006385 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006386 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006387 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006389 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006390 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006391 }
6392}
6393
6394static void alc882_auto_init_hp_out(struct hda_codec *codec)
6395{
6396 struct alc_spec *spec = codec->spec;
6397 hda_nid_t pin;
6398
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006399 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006400 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006401 /* use dac 0 */
6402 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006403 pin = spec->autocfg.speaker_pins[0];
6404 if (pin)
6405 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006406}
6407
6408#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6409#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6410
6411static void alc882_auto_init_analog_input(struct hda_codec *codec)
6412{
6413 struct alc_spec *spec = codec->spec;
6414 int i;
6415
6416 for (i = 0; i < AUTO_PIN_LAST; i++) {
6417 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006418 unsigned int vref;
6419 if (!nid)
6420 continue;
6421 vref = PIN_IN;
6422 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006423 unsigned int pincap;
6424 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6425 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006426 AC_PINCAP_VREF_80)
6427 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006428 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006429 snd_hda_codec_write(codec, nid, 0,
6430 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6431 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6432 snd_hda_codec_write(codec, nid, 0,
6433 AC_VERB_SET_AMP_GAIN_MUTE,
6434 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006435 }
6436}
6437
Takashi Iwai776e1842007-08-29 15:07:11 +02006438/* add mic boosts if needed */
6439static int alc_auto_add_mic_boost(struct hda_codec *codec)
6440{
6441 struct alc_spec *spec = codec->spec;
6442 int err;
6443 hda_nid_t nid;
6444
6445 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006446 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006447 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6448 "Mic Boost",
6449 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6450 if (err < 0)
6451 return err;
6452 }
6453 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006454 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006455 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6456 "Front Mic Boost",
6457 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6458 if (err < 0)
6459 return err;
6460 }
6461 return 0;
6462}
6463
Kailang Yangdf694da2005-12-05 19:42:22 +01006464/* almost identical with ALC880 parser... */
6465static int alc882_parse_auto_config(struct hda_codec *codec)
6466{
6467 struct alc_spec *spec = codec->spec;
6468 int err = alc880_parse_auto_config(codec);
6469
6470 if (err < 0)
6471 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006472 else if (!err)
6473 return 0; /* no config found */
6474
6475 err = alc_auto_add_mic_boost(codec);
6476 if (err < 0)
6477 return err;
6478
6479 /* hack - override the init verbs */
6480 spec->init_verbs[0] = alc882_auto_init_verbs;
6481
6482 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006483}
6484
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006485/* additional initialization for auto-configuration model */
6486static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006487{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006488 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006489 alc882_auto_init_multi_out(codec);
6490 alc882_auto_init_hp_out(codec);
6491 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006492 if (spec->unsol_event)
6493 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006494}
6495
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006496static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6497
Linus Torvalds1da177e2005-04-16 15:20:36 -07006498static int patch_alc882(struct hda_codec *codec)
6499{
6500 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006501 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006504 if (spec == NULL)
6505 return -ENOMEM;
6506
Linus Torvalds1da177e2005-04-16 15:20:36 -07006507 codec->spec = spec;
6508
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006509 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6510 alc882_models,
6511 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006512
Kailang Yangdf694da2005-12-05 19:42:22 +01006513 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006514 /* Pick up systems that don't supply PCI SSID */
6515 switch (codec->subsystem_id) {
6516 case 0x106b0c00: /* Mac Pro */
6517 board_config = ALC885_MACPRO;
6518 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006519 case 0x106b1000: /* iMac 24 */
6520 board_config = ALC885_IMAC24;
6521 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006522 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006523 case 0x106b2c00: /* Macbook Pro rev3 */
6524 board_config = ALC885_MBP3;
6525 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006526 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006527 /* ALC889A is handled better as ALC888-compatible */
6528 if (codec->revision_id == 0x100103) {
6529 alc_free(codec);
6530 return patch_alc883(codec);
6531 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006532 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6533 "trying auto-probe from BIOS...\n");
6534 board_config = ALC882_AUTO;
6535 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006536 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006537
Takashi Iwaif95474e2007-07-10 00:47:43 +02006538 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6539
Kailang Yangdf694da2005-12-05 19:42:22 +01006540 if (board_config == ALC882_AUTO) {
6541 /* automatic parse from the BIOS config */
6542 err = alc882_parse_auto_config(codec);
6543 if (err < 0) {
6544 alc_free(codec);
6545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006546 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006547 printk(KERN_INFO
6548 "hda_codec: Cannot set up configuration "
6549 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006550 board_config = ALC882_3ST_DIG;
6551 }
6552 }
6553
6554 if (board_config != ALC882_AUTO)
6555 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006556
Kailang Yang2f893282008-05-27 12:14:47 +02006557 if (codec->vendor_id == 0x10ec0885) {
6558 spec->stream_name_analog = "ALC885 Analog";
6559 spec->stream_name_digital = "ALC885 Digital";
6560 } else {
6561 spec->stream_name_analog = "ALC882 Analog";
6562 spec->stream_name_digital = "ALC882 Digital";
6563 }
6564
Kailang Yangdf694da2005-12-05 19:42:22 +01006565 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6566 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006567 /* FIXME: setup DAC5 */
6568 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6569 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006570
Kailang Yangdf694da2005-12-05 19:42:22 +01006571 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6572 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006573
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006574 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006575 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006576 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006577 /* get type */
6578 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006579 if (wcap != AC_WID_AUD_IN) {
6580 spec->adc_nids = alc882_adc_nids_alt;
6581 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006582 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006583 spec->mixers[spec->num_mixers] =
6584 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006585 spec->num_mixers++;
6586 } else {
6587 spec->adc_nids = alc882_adc_nids;
6588 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006589 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006590 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6591 spec->num_mixers++;
6592 }
6593 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006594
Takashi Iwai2134ea42008-01-10 16:53:55 +01006595 spec->vmaster_nid = 0x0c;
6596
Linus Torvalds1da177e2005-04-16 15:20:36 -07006597 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006598 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006599 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006600#ifdef CONFIG_SND_HDA_POWER_SAVE
6601 if (!spec->loopback.amplist)
6602 spec->loopback.amplist = alc882_loopbacks;
6603#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006604
6605 return 0;
6606}
6607
6608/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006609 * ALC883 support
6610 *
6611 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6612 * configuration. Each pin widget can choose any input DACs and a mixer.
6613 * Each ADC is connected from a mixer of all inputs. This makes possible
6614 * 6-channel independent captures.
6615 *
6616 * In addition, an independent DAC for the multi-playback (not used in this
6617 * driver yet).
6618 */
6619#define ALC883_DIGOUT_NID 0x06
6620#define ALC883_DIGIN_NID 0x0a
6621
6622static hda_nid_t alc883_dac_nids[4] = {
6623 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006624 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006625};
6626
6627static hda_nid_t alc883_adc_nids[2] = {
6628 /* ADC1-2 */
6629 0x08, 0x09,
6630};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006631
Takashi Iwaie1406342008-02-11 18:32:32 +01006632static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6633
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006634/* input MUX */
6635/* FIXME: should be a matrix-type input source selection */
6636
6637static struct hda_input_mux alc883_capture_source = {
6638 .num_items = 4,
6639 .items = {
6640 { "Mic", 0x0 },
6641 { "Front Mic", 0x1 },
6642 { "Line", 0x2 },
6643 { "CD", 0x4 },
6644 },
6645};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006646
Jiang zhe17bba1b2008-06-04 12:11:07 +02006647static struct hda_input_mux alc883_3stack_6ch_intel = {
6648 .num_items = 4,
6649 .items = {
6650 { "Mic", 0x1 },
6651 { "Front Mic", 0x0 },
6652 { "Line", 0x2 },
6653 { "CD", 0x4 },
6654 },
6655};
6656
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006657static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6658 .num_items = 2,
6659 .items = {
6660 { "Mic", 0x1 },
6661 { "Line", 0x2 },
6662 },
6663};
6664
Kailang Yang272a5272007-05-14 11:00:38 +02006665static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6666 .num_items = 4,
6667 .items = {
6668 { "Mic", 0x0 },
6669 { "iMic", 0x1 },
6670 { "Line", 0x2 },
6671 { "CD", 0x4 },
6672 },
6673};
6674
Jiang zhefb97dc62008-03-06 11:07:11 +01006675static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6676 .num_items = 2,
6677 .items = {
6678 { "Mic", 0x0 },
6679 { "Int Mic", 0x1 },
6680 },
6681};
6682
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006683#define alc883_mux_enum_info alc_mux_enum_info
6684#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006685/* ALC883 has the ALC882-type input selection */
6686#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006687
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006688/*
6689 * 2ch mode
6690 */
6691static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6692 { 2, NULL }
6693};
6694
6695/*
6696 * 2ch mode
6697 */
6698static struct hda_verb alc883_3ST_ch2_init[] = {
6699 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6700 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6701 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6702 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6703 { } /* end */
6704};
6705
6706/*
Tobin Davisb2011312007-09-17 12:45:11 +02006707 * 4ch mode
6708 */
6709static struct hda_verb alc883_3ST_ch4_init[] = {
6710 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6711 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6712 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6714 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6715 { } /* end */
6716};
6717
6718/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006719 * 6ch mode
6720 */
6721static struct hda_verb alc883_3ST_ch6_init[] = {
6722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6724 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6725 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6726 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6727 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6728 { } /* end */
6729};
6730
Tobin Davisb2011312007-09-17 12:45:11 +02006731static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006732 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006733 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006734 { 6, alc883_3ST_ch6_init },
6735};
6736
6737/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006738 * 2ch mode
6739 */
6740static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6741 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6742 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6745 { } /* end */
6746};
6747
6748/*
6749 * 4ch mode
6750 */
6751static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6752 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6753 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6754 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6755 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6756 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6757 { } /* end */
6758};
6759
6760/*
6761 * 6ch mode
6762 */
6763static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6764 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6765 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6766 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6770 { } /* end */
6771};
6772
6773static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6774 { 2, alc883_3ST_ch2_intel_init },
6775 { 4, alc883_3ST_ch4_intel_init },
6776 { 6, alc883_3ST_ch6_intel_init },
6777};
6778
6779/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006780 * 6ch mode
6781 */
6782static struct hda_verb alc883_sixstack_ch6_init[] = {
6783 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6784 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6785 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6786 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6787 { } /* end */
6788};
6789
6790/*
6791 * 8ch mode
6792 */
6793static struct hda_verb alc883_sixstack_ch8_init[] = {
6794 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6795 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6797 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6798 { } /* end */
6799};
6800
6801static struct hda_channel_mode alc883_sixstack_modes[2] = {
6802 { 6, alc883_sixstack_ch6_init },
6803 { 8, alc883_sixstack_ch8_init },
6804};
6805
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006806static struct hda_verb alc883_medion_eapd_verbs[] = {
6807 /* eanable EAPD on medion laptop */
6808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6809 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6810 { }
6811};
6812
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006813/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6814 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6815 */
6816
6817static struct snd_kcontrol_new alc883_base_mixer[] = {
6818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6820 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6821 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6822 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6823 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6824 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6825 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6826 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6827 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006837 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6839 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6840 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6841 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6845 {
6846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6847 /* .name = "Capture Source", */
6848 .name = "Input Source",
6849 .count = 2,
6850 .info = alc883_mux_enum_info,
6851 .get = alc883_mux_enum_get,
6852 .put = alc883_mux_enum_put,
6853 },
6854 { } /* end */
6855};
6856
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006857static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6860 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6862 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6863 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6871 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6872 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6873 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6874 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6875 {
6876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6877 /* .name = "Capture Source", */
6878 .name = "Input Source",
6879 .count = 2,
6880 .info = alc883_mux_enum_info,
6881 .get = alc883_mux_enum_get,
6882 .put = alc883_mux_enum_put,
6883 },
6884 { } /* end */
6885};
6886
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01006887static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01006888 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6897 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6899 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6900 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6901 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6902 {
6903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6904 /* .name = "Capture Source", */
6905 .name = "Input Source",
6906 .count = 2,
6907 .info = alc883_mux_enum_info,
6908 .get = alc883_mux_enum_get,
6909 .put = alc883_mux_enum_put,
6910 },
6911 { } /* end */
6912};
6913
Jiang zhefb97dc62008-03-06 11:07:11 +01006914static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6915 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6916 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6918 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6922 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6923 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6924 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6925 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6926 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6927 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6928 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6929 {
6930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6931 /* .name = "Capture Source", */
6932 .name = "Input Source",
6933 .count = 2,
6934 .info = alc883_mux_enum_info,
6935 .get = alc883_mux_enum_get,
6936 .put = alc883_mux_enum_put,
6937 },
6938 { } /* end */
6939};
6940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006941static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6942 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6943 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006950 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006953 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6955 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6956 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6957 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6958 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6959 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6960 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6961 {
6962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6963 /* .name = "Capture Source", */
6964 .name = "Input Source",
6965 .count = 2,
6966 .info = alc883_mux_enum_info,
6967 .get = alc883_mux_enum_get,
6968 .put = alc883_mux_enum_put,
6969 },
6970 { } /* end */
6971};
6972
6973static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006988 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006991 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6993 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6994 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6996 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6997 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6998 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6999 {
7000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7001 /* .name = "Capture Source", */
7002 .name = "Input Source",
7003 .count = 2,
7004 .info = alc883_mux_enum_info,
7005 .get = alc883_mux_enum_get,
7006 .put = alc883_mux_enum_put,
7007 },
7008 { } /* end */
7009};
7010
Jiang zhe17bba1b2008-06-04 12:11:07 +02007011static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7015 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7017 HDA_OUTPUT),
7018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7032 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7033 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7034 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7035 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7036 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7037 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7038 {
7039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7040 /* .name = "Capture Source", */
7041 .name = "Input Source",
7042 .count = 2,
7043 .info = alc883_mux_enum_info,
7044 .get = alc883_mux_enum_get,
7045 .put = alc883_mux_enum_put,
7046 },
7047 { } /* end */
7048};
7049
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007050static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7053 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7055 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7056 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7057 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
7058 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007065 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7067 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007068 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007069 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7070 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7071 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7073 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7074
7075 {
7076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7077 /* .name = "Capture Source", */
7078 .name = "Input Source",
7079 .count = 1,
7080 .info = alc883_mux_enum_info,
7081 .get = alc883_mux_enum_get,
7082 .put = alc883_mux_enum_put,
7083 },
7084 { } /* end */
7085};
7086
Kailang Yangccc656c2006-10-17 12:32:26 +02007087static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7092 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7093 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7094 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7095 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7096 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7105 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7106 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7107 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7108 {
7109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7110 /* .name = "Capture Source", */
7111 .name = "Input Source",
7112 .count = 2,
7113 .info = alc883_mux_enum_info,
7114 .get = alc883_mux_enum_get,
7115 .put = alc883_mux_enum_put,
7116 },
7117 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007118};
Kailang Yangccc656c2006-10-17 12:32:26 +02007119
7120static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7123 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007129 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7130 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7131 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007132 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7133 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7134 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7135 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7136 {
7137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7138 /* .name = "Capture Source", */
7139 .name = "Input Source",
7140 .count = 2,
7141 .info = alc883_mux_enum_info,
7142 .get = alc883_mux_enum_get,
7143 .put = alc883_mux_enum_put,
7144 },
7145 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007146};
Kailang Yangccc656c2006-10-17 12:32:26 +02007147
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007148static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7149 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7150 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007151 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7152 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7157 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7158 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7159 {
7160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7161 /* .name = "Capture Source", */
7162 .name = "Input Source",
7163 .count = 1,
7164 .info = alc883_mux_enum_info,
7165 .get = alc883_mux_enum_get,
7166 .put = alc883_mux_enum_put,
7167 },
7168 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007169};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007170
Kailang Yang272a5272007-05-14 11:00:38 +02007171static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7172 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7173 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7179 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7180 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7182 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7183 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7184 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7185 {
7186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7187 /* .name = "Capture Source", */
7188 .name = "Input Source",
7189 .count = 2,
7190 .info = alc883_mux_enum_info,
7191 .get = alc883_mux_enum_get,
7192 .put = alc883_mux_enum_put,
7193 },
7194 { } /* end */
7195};
7196
7197static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7200 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7207 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7208 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7209 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7210 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7211 {
7212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7213 /* .name = "Capture Source", */
7214 .name = "Input Source",
7215 .count = 2,
7216 .info = alc883_mux_enum_info,
7217 .get = alc883_mux_enum_get,
7218 .put = alc883_mux_enum_put,
7219 },
7220 { } /* end */
7221};
7222
Tobin Davis2880a862007-08-07 11:50:26 +02007223static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007232 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7233 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7236 {
7237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7238 /* .name = "Capture Source", */
7239 .name = "Input Source",
7240 .count = 2,
7241 .info = alc883_mux_enum_info,
7242 .get = alc883_mux_enum_get,
7243 .put = alc883_mux_enum_put,
7244 },
7245 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007246};
Tobin Davis2880a862007-08-07 11:50:26 +02007247
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007248static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7249 {
7250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7251 .name = "Channel Mode",
7252 .info = alc_ch_mode_info,
7253 .get = alc_ch_mode_get,
7254 .put = alc_ch_mode_put,
7255 },
7256 { } /* end */
7257};
7258
7259static struct hda_verb alc883_init_verbs[] = {
7260 /* ADC1: mute amp left and right */
7261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7263 /* ADC2: mute amp left and right */
7264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7265 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7266 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7270 /* Rear mixer */
7271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7272 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7274 /* CLFE mixer */
7275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7278 /* Side mixer */
7279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7282
Takashi Iwaicb53c622007-08-10 17:21:45 +02007283 /* mute analog input loopbacks */
7284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007289
7290 /* Front Pin: output 0 (0x0c) */
7291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7293 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7294 /* Rear Pin: output 1 (0x0d) */
7295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7298 /* CLFE Pin: output 2 (0x0e) */
7299 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7300 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7301 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7302 /* Side Pin: output 3 (0x0f) */
7303 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7305 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7306 /* Mic (rear) pin: input vref at 80% */
7307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7309 /* Front Mic pin: input vref at 80% */
7310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7312 /* Line In pin: input */
7313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7315 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7318 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7319 /* CD pin widget for input */
7320 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7321
7322 /* FIXME: use matrix-type input source selection */
7323 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7324 /* Input mixer2 */
7325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7329 /* Input mixer3 */
7330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7334 { }
7335};
7336
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007337/* toggle speaker-output according to the hp-jack state */
7338static void alc883_mitac_hp_automute(struct hda_codec *codec)
7339{
7340 unsigned int present;
7341
7342 present = snd_hda_codec_read(codec, 0x15, 0,
7343 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7344 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7345 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7346 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7347 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7348}
7349
7350/* auto-toggle front mic */
7351/*
7352static void alc883_mitac_mic_automute(struct hda_codec *codec)
7353{
7354 unsigned int present;
7355 unsigned char bits;
7356
7357 present = snd_hda_codec_read(codec, 0x18, 0,
7358 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7359 bits = present ? HDA_AMP_MUTE : 0;
7360 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7361}
7362*/
7363
7364static void alc883_mitac_automute(struct hda_codec *codec)
7365{
7366 alc883_mitac_hp_automute(codec);
7367 /* alc883_mitac_mic_automute(codec); */
7368}
7369
7370static void alc883_mitac_unsol_event(struct hda_codec *codec,
7371 unsigned int res)
7372{
7373 switch (res >> 26) {
7374 case ALC880_HP_EVENT:
7375 alc883_mitac_hp_automute(codec);
7376 break;
7377 case ALC880_MIC_EVENT:
7378 /* alc883_mitac_mic_automute(codec); */
7379 break;
7380 }
7381}
7382
7383static struct hda_verb alc883_mitac_verbs[] = {
7384 /* HP */
7385 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7387 /* Subwoofer */
7388 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7389 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7390
7391 /* enable unsolicited event */
7392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7393 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7394
7395 { } /* end */
7396};
7397
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007398static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007399 /* HP */
7400 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7401 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7402 /* Int speaker */
7403 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7405
7406 /* enable unsolicited event */
7407 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007408 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007409
7410 { } /* end */
7411};
7412
Jiang zhefb97dc62008-03-06 11:07:11 +01007413static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7414 /* HP */
7415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7417 /* Subwoofer */
7418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7420
7421 /* enable unsolicited event */
7422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7423
7424 { } /* end */
7425};
7426
Kailang Yangccc656c2006-10-17 12:32:26 +02007427static struct hda_verb alc883_tagra_verbs[] = {
7428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7430
7431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7433
7434 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7435 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7436 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7437
7438 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007439 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7440 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7441 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007442
7443 { } /* end */
7444};
7445
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007446static struct hda_verb alc883_lenovo_101e_verbs[] = {
7447 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7449 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7450 { } /* end */
7451};
7452
Kailang Yang272a5272007-05-14 11:00:38 +02007453static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7454 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7458 { } /* end */
7459};
7460
7461static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7465 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7466 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7467 { } /* end */
7468};
7469
Kailang Yang189609a2007-08-20 11:31:23 +02007470static struct hda_verb alc883_haier_w66_verbs[] = {
7471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7473
7474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7475
7476 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7478 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7480 { } /* end */
7481};
7482
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007483static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007485 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7486 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007487 { }
7488};
7489
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007490static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7492 { }
7493};
7494
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007495static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007496 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7497 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7498 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7499 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7500 { }
7501};
7502
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007503static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007504 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7505 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7506 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7507 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7508 { }
7509};
7510
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007511static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7512 { 2, alc888_3st_hp_2ch_init },
7513 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007514};
7515
Kailang Yang272a5272007-05-14 11:00:38 +02007516/* toggle front-jack and RCA according to the hp-jack state */
7517static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7518{
7519 unsigned int present;
7520
7521 present = snd_hda_codec_read(codec, 0x1b, 0,
7522 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007523 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7524 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7525 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7526 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007527}
7528
7529/* toggle RCA according to the front-jack state */
7530static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7531{
7532 unsigned int present;
7533
7534 present = snd_hda_codec_read(codec, 0x14, 0,
7535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007536 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7537 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007538}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007539
Kailang Yang272a5272007-05-14 11:00:38 +02007540static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7541 unsigned int res)
7542{
7543 if ((res >> 26) == ALC880_HP_EVENT)
7544 alc888_lenovo_ms7195_front_automute(codec);
7545 if ((res >> 26) == ALC880_FRONT_EVENT)
7546 alc888_lenovo_ms7195_rca_automute(codec);
7547}
7548
7549static struct hda_verb alc883_medion_md2_verbs[] = {
7550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7552
7553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7554
7555 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7556 { } /* end */
7557};
7558
7559/* toggle speaker-output according to the hp-jack state */
7560static void alc883_medion_md2_automute(struct hda_codec *codec)
7561{
7562 unsigned int present;
7563
7564 present = snd_hda_codec_read(codec, 0x14, 0,
7565 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007566 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7567 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007568}
7569
7570static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7571 unsigned int res)
7572{
7573 if ((res >> 26) == ALC880_HP_EVENT)
7574 alc883_medion_md2_automute(codec);
7575}
7576
Kailang Yangccc656c2006-10-17 12:32:26 +02007577/* toggle speaker-output according to the hp-jack state */
7578static void alc883_tagra_automute(struct hda_codec *codec)
7579{
7580 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007581 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007582
7583 present = snd_hda_codec_read(codec, 0x14, 0,
7584 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007585 bits = present ? HDA_AMP_MUTE : 0;
7586 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7587 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007588 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7589 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007590}
7591
7592static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7593{
7594 if ((res >> 26) == ALC880_HP_EVENT)
7595 alc883_tagra_automute(codec);
7596}
7597
Jiang zhe368c7a92008-03-04 11:20:33 +01007598/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007599static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007600{
7601 unsigned int present;
7602 unsigned char bits;
7603
7604 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7605 & AC_PINSENSE_PRESENCE;
7606 bits = present ? HDA_AMP_MUTE : 0;
7607 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7608 HDA_AMP_MUTE, bits);
7609}
7610
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007611static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7612{
7613 unsigned int present;
7614
7615 present = snd_hda_codec_read(codec, 0x18, 0,
7616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7617 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7618 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7619}
7620
7621static void alc883_clevo_m720_automute(struct hda_codec *codec)
7622{
7623 alc883_clevo_m720_hp_automute(codec);
7624 alc883_clevo_m720_mic_automute(codec);
7625}
7626
7627static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007628 unsigned int res)
7629{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007630 switch (res >> 26) {
7631 case ALC880_HP_EVENT:
7632 alc883_clevo_m720_hp_automute(codec);
7633 break;
7634 case ALC880_MIC_EVENT:
7635 alc883_clevo_m720_mic_automute(codec);
7636 break;
7637 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007638}
7639
Jiang zhefb97dc62008-03-06 11:07:11 +01007640/* toggle speaker-output according to the hp-jack state */
7641static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7642{
7643 unsigned int present;
7644 unsigned char bits;
7645
7646 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7647 & AC_PINSENSE_PRESENCE;
7648 bits = present ? HDA_AMP_MUTE : 0;
7649 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7650 HDA_AMP_MUTE, bits);
7651}
7652
7653static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7654 unsigned int res)
7655{
7656 if ((res >> 26) == ALC880_HP_EVENT)
7657 alc883_2ch_fujitsu_pi2515_automute(codec);
7658}
7659
Kailang Yang189609a2007-08-20 11:31:23 +02007660static void alc883_haier_w66_automute(struct hda_codec *codec)
7661{
7662 unsigned int present;
7663 unsigned char bits;
7664
7665 present = snd_hda_codec_read(codec, 0x1b, 0,
7666 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7667 bits = present ? 0x80 : 0;
7668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7669 0x80, bits);
7670}
7671
7672static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7673 unsigned int res)
7674{
7675 if ((res >> 26) == ALC880_HP_EVENT)
7676 alc883_haier_w66_automute(codec);
7677}
7678
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007679static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7680{
7681 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007682 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007683
7684 present = snd_hda_codec_read(codec, 0x14, 0,
7685 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007686 bits = present ? HDA_AMP_MUTE : 0;
7687 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7688 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007689}
7690
7691static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7692{
7693 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007694 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007695
7696 present = snd_hda_codec_read(codec, 0x1b, 0,
7697 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007698 bits = present ? HDA_AMP_MUTE : 0;
7699 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7700 HDA_AMP_MUTE, bits);
7701 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7702 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007703}
7704
7705static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7706 unsigned int res)
7707{
7708 if ((res >> 26) == ALC880_HP_EVENT)
7709 alc883_lenovo_101e_all_automute(codec);
7710 if ((res >> 26) == ALC880_FRONT_EVENT)
7711 alc883_lenovo_101e_ispeaker_automute(codec);
7712}
7713
Takashi Iwai676a9b52007-08-16 15:23:35 +02007714/* toggle speaker-output according to the hp-jack state */
7715static void alc883_acer_aspire_automute(struct hda_codec *codec)
7716{
7717 unsigned int present;
7718
7719 present = snd_hda_codec_read(codec, 0x14, 0,
7720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7721 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7722 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7723 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7724 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7725}
7726
7727static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7728 unsigned int res)
7729{
7730 if ((res >> 26) == ALC880_HP_EVENT)
7731 alc883_acer_aspire_automute(codec);
7732}
7733
Kailang Yangd1a991a2007-08-15 16:21:59 +02007734static struct hda_verb alc883_acer_eapd_verbs[] = {
7735 /* HP Pin: output 0 (0x0c) */
7736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7738 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7739 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7741 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007742 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007743 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7744 /* eanable EAPD on medion laptop */
7745 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7746 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007747 /* enable unsolicited event */
7748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007749 { }
7750};
7751
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007752static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7753{
7754 unsigned int present;
7755
7756 present = snd_hda_codec_read(codec, 0x1b, 0,
7757 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7758 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7759 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7760 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7761 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7762 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7764 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7766}
7767
7768static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7769 unsigned int res)
7770{
7771 switch (res >> 26) {
7772 case ALC880_HP_EVENT:
7773 printk("hp_event\n");
7774 alc888_6st_dell_front_automute(codec);
7775 break;
7776 }
7777}
7778
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007779/*
7780 * generic initialization of ADC, input mixers and output mixers
7781 */
7782static struct hda_verb alc883_auto_init_verbs[] = {
7783 /*
7784 * Unmute ADC0-2 and set the default input to mic-in
7785 */
7786 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7788 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7790
Takashi Iwaicb53c622007-08-10 17:21:45 +02007791 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007792 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007793 * Note: PASD motherboards uses the Line In 2 as the input for
7794 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007795 */
7796 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007802
7803 /*
7804 * Set up output mixers (0x0c - 0x0f)
7805 */
7806 /* set vol=0 to output mixers */
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7811 /* set up input amps for analog loopback */
7812 /* Amp Indices: DAC = 0, mixer = 1 */
7813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7821 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7822 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7823
7824 /* FIXME: use matrix-type input source selection */
7825 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7826 /* Input mixer1 */
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007830 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7832 /* Input mixer2 */
7833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007836 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007838
7839 { }
7840};
7841
7842/* capture mixer elements */
7843static struct snd_kcontrol_new alc883_capture_mixer[] = {
7844 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7845 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7846 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7847 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7848 {
7849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7850 /* The multiple "Capture Source" controls confuse alsamixer
7851 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007852 */
7853 /* .name = "Capture Source", */
7854 .name = "Input Source",
7855 .count = 2,
7856 .info = alc882_mux_enum_info,
7857 .get = alc882_mux_enum_get,
7858 .put = alc882_mux_enum_put,
7859 },
7860 { } /* end */
7861};
7862
Takashi Iwaicb53c622007-08-10 17:21:45 +02007863#ifdef CONFIG_SND_HDA_POWER_SAVE
7864#define alc883_loopbacks alc880_loopbacks
7865#endif
7866
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007867/* pcm configuration: identiacal with ALC880 */
7868#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7869#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007870#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007871#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7872#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7873
7874/*
7875 * configuration and preset
7876 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007877static const char *alc883_models[ALC883_MODEL_LAST] = {
7878 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7879 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7880 [ALC883_3ST_6ch] = "3stack-6ch",
7881 [ALC883_6ST_DIG] = "6stack-dig",
7882 [ALC883_TARGA_DIG] = "targa-dig",
7883 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007884 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007885 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007886 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007887 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007888 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007889 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007890 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7891 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007892 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007893 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007894 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007895 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007896 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01007897 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02007898 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007899 [ALC883_AUTO] = "auto",
7900};
7901
7902static struct snd_pci_quirk alc883_cfg_tbl[] = {
7903 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007904 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7905 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7906 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7907 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007908 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007909 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007910 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7911 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01007912 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007913 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02007914 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007915 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007916 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7917 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7918 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007919 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007920 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7921 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7922 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02007923 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007924 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007925 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007926 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7927 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7928 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7929 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7930 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7931 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7932 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7933 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7934 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007935 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7936 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007937 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01007938 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007939 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007940 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007941 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007942 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007943 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7944 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007945 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007946 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007947 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007948 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007949 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007950 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007951 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7952 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007953 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007954 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007955 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007956 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7957 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007958 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007959 {}
7960};
7961
7962static struct alc_config_preset alc883_presets[] = {
7963 [ALC883_3ST_2ch_DIG] = {
7964 .mixers = { alc883_3ST_2ch_mixer },
7965 .init_verbs = { alc883_init_verbs },
7966 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7967 .dac_nids = alc883_dac_nids,
7968 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007969 .dig_in_nid = ALC883_DIGIN_NID,
7970 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7971 .channel_mode = alc883_3ST_2ch_modes,
7972 .input_mux = &alc883_capture_source,
7973 },
7974 [ALC883_3ST_6ch_DIG] = {
7975 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7976 .init_verbs = { alc883_init_verbs },
7977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7978 .dac_nids = alc883_dac_nids,
7979 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007980 .dig_in_nid = ALC883_DIGIN_NID,
7981 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7982 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007983 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007984 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007985 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007986 [ALC883_3ST_6ch] = {
7987 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7988 .init_verbs = { alc883_init_verbs },
7989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7990 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7992 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007993 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007994 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007995 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02007996 [ALC883_3ST_6ch_INTEL] = {
7997 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
7998 .init_verbs = { alc883_init_verbs },
7999 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8000 .dac_nids = alc883_dac_nids,
8001 .dig_out_nid = ALC883_DIGOUT_NID,
8002 .dig_in_nid = ALC883_DIGIN_NID,
8003 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8004 .channel_mode = alc883_3ST_6ch_intel_modes,
8005 .need_dac_fix = 1,
8006 .input_mux = &alc883_3stack_6ch_intel,
8007 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008008 [ALC883_6ST_DIG] = {
8009 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8010 .init_verbs = { alc883_init_verbs },
8011 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8012 .dac_nids = alc883_dac_nids,
8013 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008014 .dig_in_nid = ALC883_DIGIN_NID,
8015 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8016 .channel_mode = alc883_sixstack_modes,
8017 .input_mux = &alc883_capture_source,
8018 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008019 [ALC883_TARGA_DIG] = {
8020 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8021 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8022 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8023 .dac_nids = alc883_dac_nids,
8024 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8026 .channel_mode = alc883_3ST_6ch_modes,
8027 .need_dac_fix = 1,
8028 .input_mux = &alc883_capture_source,
8029 .unsol_event = alc883_tagra_unsol_event,
8030 .init_hook = alc883_tagra_automute,
8031 },
8032 [ALC883_TARGA_2ch_DIG] = {
8033 .mixers = { alc883_tagra_2ch_mixer},
8034 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8036 .dac_nids = alc883_dac_nids,
8037 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8039 .channel_mode = alc883_3ST_2ch_modes,
8040 .input_mux = &alc883_capture_source,
8041 .unsol_event = alc883_tagra_unsol_event,
8042 .init_hook = alc883_tagra_automute,
8043 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008044 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008045 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008046 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8047 * and the headphone jack. Turn this on and rely on the
8048 * standard mute methods whenever the user wants to turn
8049 * these outputs off.
8050 */
8051 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8052 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8053 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008054 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8055 .channel_mode = alc883_3ST_2ch_modes,
8056 .input_mux = &alc883_capture_source,
8057 },
Tobin Davis2880a862007-08-07 11:50:26 +02008058 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008059 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008060 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008061 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8062 .dac_nids = alc883_dac_nids,
8063 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008064 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8065 .channel_mode = alc883_3ST_2ch_modes,
8066 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008067 .unsol_event = alc883_acer_aspire_unsol_event,
8068 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008069 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008070 [ALC883_MEDION] = {
8071 .mixers = { alc883_fivestack_mixer,
8072 alc883_chmode_mixer },
8073 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008074 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8076 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008077 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8078 .channel_mode = alc883_sixstack_modes,
8079 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008080 },
Kailang Yang272a5272007-05-14 11:00:38 +02008081 [ALC883_MEDION_MD2] = {
8082 .mixers = { alc883_medion_md2_mixer},
8083 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8084 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8085 .dac_nids = alc883_dac_nids,
8086 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8088 .channel_mode = alc883_3ST_2ch_modes,
8089 .input_mux = &alc883_capture_source,
8090 .unsol_event = alc883_medion_md2_unsol_event,
8091 .init_hook = alc883_medion_md2_automute,
8092 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008093 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008094 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008095 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8096 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8097 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8099 .channel_mode = alc883_3ST_2ch_modes,
8100 .input_mux = &alc883_capture_source,
8101 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008102 [ALC883_CLEVO_M720] = {
8103 .mixers = { alc883_clevo_m720_mixer },
8104 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8106 .dac_nids = alc883_dac_nids,
8107 .dig_out_nid = ALC883_DIGOUT_NID,
8108 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8109 .channel_mode = alc883_3ST_2ch_modes,
8110 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008111 .unsol_event = alc883_clevo_m720_unsol_event,
8112 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008113 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008114 [ALC883_LENOVO_101E_2ch] = {
8115 .mixers = { alc883_lenovo_101e_2ch_mixer},
8116 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8118 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008119 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8120 .channel_mode = alc883_3ST_2ch_modes,
8121 .input_mux = &alc883_lenovo_101e_capture_source,
8122 .unsol_event = alc883_lenovo_101e_unsol_event,
8123 .init_hook = alc883_lenovo_101e_all_automute,
8124 },
Kailang Yang272a5272007-05-14 11:00:38 +02008125 [ALC883_LENOVO_NB0763] = {
8126 .mixers = { alc883_lenovo_nb0763_mixer },
8127 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8128 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8129 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008130 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8131 .channel_mode = alc883_3ST_2ch_modes,
8132 .need_dac_fix = 1,
8133 .input_mux = &alc883_lenovo_nb0763_capture_source,
8134 .unsol_event = alc883_medion_md2_unsol_event,
8135 .init_hook = alc883_medion_md2_automute,
8136 },
8137 [ALC888_LENOVO_MS7195_DIG] = {
8138 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8139 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8141 .dac_nids = alc883_dac_nids,
8142 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008143 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8144 .channel_mode = alc883_3ST_6ch_modes,
8145 .need_dac_fix = 1,
8146 .input_mux = &alc883_capture_source,
8147 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8148 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008149 },
8150 [ALC883_HAIER_W66] = {
8151 .mixers = { alc883_tagra_2ch_mixer},
8152 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8154 .dac_nids = alc883_dac_nids,
8155 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008156 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8157 .channel_mode = alc883_3ST_2ch_modes,
8158 .input_mux = &alc883_capture_source,
8159 .unsol_event = alc883_haier_w66_unsol_event,
8160 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008161 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008162 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008163 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008164 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8166 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008167 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8168 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008169 .need_dac_fix = 1,
8170 .input_mux = &alc883_capture_source,
8171 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008172 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008173 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008174 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8175 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8176 .dac_nids = alc883_dac_nids,
8177 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008178 .dig_in_nid = ALC883_DIGIN_NID,
8179 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8180 .channel_mode = alc883_sixstack_modes,
8181 .input_mux = &alc883_capture_source,
8182 .unsol_event = alc888_6st_dell_unsol_event,
8183 .init_hook = alc888_6st_dell_front_automute,
8184 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008185 [ALC883_MITAC] = {
8186 .mixers = { alc883_mitac_mixer },
8187 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8189 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8191 .channel_mode = alc883_3ST_2ch_modes,
8192 .input_mux = &alc883_capture_source,
8193 .unsol_event = alc883_mitac_unsol_event,
8194 .init_hook = alc883_mitac_automute,
8195 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008196 [ALC883_FUJITSU_PI2515] = {
8197 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8198 .init_verbs = { alc883_init_verbs,
8199 alc883_2ch_fujitsu_pi2515_verbs},
8200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8201 .dac_nids = alc883_dac_nids,
8202 .dig_out_nid = ALC883_DIGOUT_NID,
8203 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8204 .channel_mode = alc883_3ST_2ch_modes,
8205 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8206 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8207 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8208 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008209};
8210
8211
8212/*
8213 * BIOS auto configuration
8214 */
8215static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8216 hda_nid_t nid, int pin_type,
8217 int dac_idx)
8218{
8219 /* set as output */
8220 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008221 int idx;
8222
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008223 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008224 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8225 idx = 4;
8226 else
8227 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008228 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8229
8230}
8231
8232static void alc883_auto_init_multi_out(struct hda_codec *codec)
8233{
8234 struct alc_spec *spec = codec->spec;
8235 int i;
8236
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008237 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008238 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008239 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008240 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008241 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008242 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008243 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008244 }
8245}
8246
8247static void alc883_auto_init_hp_out(struct hda_codec *codec)
8248{
8249 struct alc_spec *spec = codec->spec;
8250 hda_nid_t pin;
8251
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008252 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008253 if (pin) /* connect to front */
8254 /* use dac 0 */
8255 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008256 pin = spec->autocfg.speaker_pins[0];
8257 if (pin)
8258 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008259}
8260
8261#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8262#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8263
8264static void alc883_auto_init_analog_input(struct hda_codec *codec)
8265{
8266 struct alc_spec *spec = codec->spec;
8267 int i;
8268
8269 for (i = 0; i < AUTO_PIN_LAST; i++) {
8270 hda_nid_t nid = spec->autocfg.input_pins[i];
8271 if (alc883_is_input_pin(nid)) {
8272 snd_hda_codec_write(codec, nid, 0,
8273 AC_VERB_SET_PIN_WIDGET_CONTROL,
8274 (i <= AUTO_PIN_FRONT_MIC ?
8275 PIN_VREF80 : PIN_IN));
8276 if (nid != ALC883_PIN_CD_NID)
8277 snd_hda_codec_write(codec, nid, 0,
8278 AC_VERB_SET_AMP_GAIN_MUTE,
8279 AMP_OUT_MUTE);
8280 }
8281 }
8282}
8283
8284/* almost identical with ALC880 parser... */
8285static int alc883_parse_auto_config(struct hda_codec *codec)
8286{
8287 struct alc_spec *spec = codec->spec;
8288 int err = alc880_parse_auto_config(codec);
8289
8290 if (err < 0)
8291 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008292 else if (!err)
8293 return 0; /* no config found */
8294
8295 err = alc_auto_add_mic_boost(codec);
8296 if (err < 0)
8297 return err;
8298
8299 /* hack - override the init verbs */
8300 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008301 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8302 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008303
8304 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008305}
8306
8307/* additional initialization for auto-configuration model */
8308static void alc883_auto_init(struct hda_codec *codec)
8309{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008310 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008311 alc883_auto_init_multi_out(codec);
8312 alc883_auto_init_hp_out(codec);
8313 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008314 if (spec->unsol_event)
8315 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008316}
8317
8318static int patch_alc883(struct hda_codec *codec)
8319{
8320 struct alc_spec *spec;
8321 int err, board_config;
8322
8323 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8324 if (spec == NULL)
8325 return -ENOMEM;
8326
8327 codec->spec = spec;
8328
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008329 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8330
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008331 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8332 alc883_models,
8333 alc883_cfg_tbl);
8334 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008335 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8336 "trying auto-probe from BIOS...\n");
8337 board_config = ALC883_AUTO;
8338 }
8339
8340 if (board_config == ALC883_AUTO) {
8341 /* automatic parse from the BIOS config */
8342 err = alc883_parse_auto_config(codec);
8343 if (err < 0) {
8344 alc_free(codec);
8345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008346 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008347 printk(KERN_INFO
8348 "hda_codec: Cannot set up configuration "
8349 "from BIOS. Using base mode...\n");
8350 board_config = ALC883_3ST_2ch_DIG;
8351 }
8352 }
8353
8354 if (board_config != ALC883_AUTO)
8355 setup_preset(spec, &alc883_presets[board_config]);
8356
Kailang Yang2f893282008-05-27 12:14:47 +02008357 switch (codec->vendor_id) {
8358 case 0x10ec0888:
8359 spec->stream_name_analog = "ALC888 Analog";
8360 spec->stream_name_digital = "ALC888 Digital";
8361 break;
8362 case 0x10ec0889:
8363 spec->stream_name_analog = "ALC889 Analog";
8364 spec->stream_name_digital = "ALC889 Digital";
8365 break;
8366 default:
8367 spec->stream_name_analog = "ALC883 Analog";
8368 spec->stream_name_digital = "ALC883 Digital";
8369 break;
8370 }
8371
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008372 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8373 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008374 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008376 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8377 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8378
Takashi Iwaie1406342008-02-11 18:32:32 +01008379 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8380 spec->adc_nids = alc883_adc_nids;
8381 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382
Takashi Iwai2134ea42008-01-10 16:53:55 +01008383 spec->vmaster_nid = 0x0c;
8384
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008385 codec->patch_ops = alc_patch_ops;
8386 if (board_config == ALC883_AUTO)
8387 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008388 else if (codec->vendor_id == 0x10ec0888)
8389 spec->init_hook = alc888_coef_init;
8390
Takashi Iwaicb53c622007-08-10 17:21:45 +02008391#ifdef CONFIG_SND_HDA_POWER_SAVE
8392 if (!spec->loopback.amplist)
8393 spec->loopback.amplist = alc883_loopbacks;
8394#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008395
8396 return 0;
8397}
8398
8399/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008400 * ALC262 support
8401 */
8402
8403#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8404#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8405
8406#define alc262_dac_nids alc260_dac_nids
8407#define alc262_adc_nids alc882_adc_nids
8408#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008409#define alc262_capsrc_nids alc882_capsrc_nids
8410#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008411
8412#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008413#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008414
8415static struct snd_kcontrol_new alc262_base_mixer[] = {
8416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8417 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008424 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008425 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8426 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008427 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008428 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008429 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008430 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8432 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8433 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008434 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008435};
8436
Kailang Yangccc656c2006-10-17 12:32:26 +02008437static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8439 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008446 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008449 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008450 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008451 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008452 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8454 { } /* end */
8455};
8456
Takashi Iwaice875f02008-01-28 18:17:43 +01008457/* update HP, line and mono-out pins according to the master switch */
8458static void alc262_hp_master_update(struct hda_codec *codec)
8459{
8460 struct alc_spec *spec = codec->spec;
8461 int val = spec->master_sw;
8462
8463 /* HP & line-out */
8464 snd_hda_codec_write_cache(codec, 0x1b, 0,
8465 AC_VERB_SET_PIN_WIDGET_CONTROL,
8466 val ? PIN_HP : 0);
8467 snd_hda_codec_write_cache(codec, 0x15, 0,
8468 AC_VERB_SET_PIN_WIDGET_CONTROL,
8469 val ? PIN_HP : 0);
8470 /* mono (speaker) depending on the HP jack sense */
8471 val = val && !spec->jack_present;
8472 snd_hda_codec_write_cache(codec, 0x16, 0,
8473 AC_VERB_SET_PIN_WIDGET_CONTROL,
8474 val ? PIN_OUT : 0);
8475}
8476
8477static void alc262_hp_bpc_automute(struct hda_codec *codec)
8478{
8479 struct alc_spec *spec = codec->spec;
8480 unsigned int presence;
8481 presence = snd_hda_codec_read(codec, 0x1b, 0,
8482 AC_VERB_GET_PIN_SENSE, 0);
8483 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8484 alc262_hp_master_update(codec);
8485}
8486
8487static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8488{
8489 if ((res >> 26) != ALC880_HP_EVENT)
8490 return;
8491 alc262_hp_bpc_automute(codec);
8492}
8493
8494static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8495{
8496 struct alc_spec *spec = codec->spec;
8497 unsigned int presence;
8498 presence = snd_hda_codec_read(codec, 0x15, 0,
8499 AC_VERB_GET_PIN_SENSE, 0);
8500 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8501 alc262_hp_master_update(codec);
8502}
8503
8504static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8505 unsigned int res)
8506{
8507 if ((res >> 26) != ALC880_HP_EVENT)
8508 return;
8509 alc262_hp_wildwest_automute(codec);
8510}
8511
8512static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8513 struct snd_ctl_elem_value *ucontrol)
8514{
8515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8516 struct alc_spec *spec = codec->spec;
8517 *ucontrol->value.integer.value = spec->master_sw;
8518 return 0;
8519}
8520
8521static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8522 struct snd_ctl_elem_value *ucontrol)
8523{
8524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8525 struct alc_spec *spec = codec->spec;
8526 int val = !!*ucontrol->value.integer.value;
8527
8528 if (val == spec->master_sw)
8529 return 0;
8530 spec->master_sw = val;
8531 alc262_hp_master_update(codec);
8532 return 1;
8533}
8534
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008535static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008536 {
8537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8538 .name = "Master Playback Switch",
8539 .info = snd_ctl_boolean_mono_info,
8540 .get = alc262_hp_master_sw_get,
8541 .put = alc262_hp_master_sw_put,
8542 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8544 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008546 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8547 HDA_OUTPUT),
8548 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8549 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008553 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8554 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008555 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8558 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8559 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8560 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8561 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8562 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8563 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8564 { } /* end */
8565};
8566
Kailang Yangcd7509a2007-01-26 18:33:17 +01008567static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008568 {
8569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8570 .name = "Master Playback Switch",
8571 .info = snd_ctl_boolean_mono_info,
8572 .get = alc262_hp_master_sw_get,
8573 .put = alc262_hp_master_sw_put,
8574 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008575 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8577 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008579 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8580 HDA_OUTPUT),
8581 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8582 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008583 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8584 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008585 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8590 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8591 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8592 { } /* end */
8593};
8594
8595static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8596 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8597 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008598 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008599 { } /* end */
8600};
8601
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008602/* mute/unmute internal speaker according to the hp jack and mute state */
8603static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8604{
8605 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008606
8607 if (force || !spec->sense_updated) {
8608 unsigned int present;
8609 present = snd_hda_codec_read(codec, 0x15, 0,
8610 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008611 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008612 spec->sense_updated = 1;
8613 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008614 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8615 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008616}
8617
8618static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8619 unsigned int res)
8620{
8621 if ((res >> 26) != ALC880_HP_EVENT)
8622 return;
8623 alc262_hp_t5735_automute(codec, 1);
8624}
8625
8626static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8627{
8628 alc262_hp_t5735_automute(codec, 1);
8629}
8630
8631static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008632 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8633 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008634 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8638 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8639 { } /* end */
8640};
8641
8642static struct hda_verb alc262_hp_t5735_verbs[] = {
8643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8645
8646 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8647 { }
8648};
8649
Kailang Yang8c427222008-01-10 13:03:59 +01008650static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8657 { } /* end */
8658};
8659
8660static struct hda_verb alc262_hp_rp5700_verbs[] = {
8661 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8662 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8663 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8664 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8666 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8671 {}
8672};
8673
8674static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8675 .num_items = 1,
8676 .items = {
8677 { "Line", 0x1 },
8678 },
8679};
8680
Takashi Iwai0724ea22007-08-23 00:31:43 +02008681/* bind hp and internal speaker mute (with plug check) */
8682static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8683 struct snd_ctl_elem_value *ucontrol)
8684{
8685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8686 long *valp = ucontrol->value.integer.value;
8687 int change;
8688
8689 /* change hp mute */
8690 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8691 HDA_AMP_MUTE,
8692 valp[0] ? 0 : HDA_AMP_MUTE);
8693 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8694 HDA_AMP_MUTE,
8695 valp[1] ? 0 : HDA_AMP_MUTE);
8696 if (change) {
8697 /* change speaker according to HP jack state */
8698 struct alc_spec *spec = codec->spec;
8699 unsigned int mute;
8700 if (spec->jack_present)
8701 mute = HDA_AMP_MUTE;
8702 else
8703 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8704 HDA_OUTPUT, 0);
8705 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8706 HDA_AMP_MUTE, mute);
8707 }
8708 return change;
8709}
Takashi Iwai5b319542007-07-26 11:49:22 +02008710
Kailang Yang272a5272007-05-14 11:00:38 +02008711static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008712 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8713 {
8714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8715 .name = "Master Playback Switch",
8716 .info = snd_hda_mixer_amp_switch_info,
8717 .get = snd_hda_mixer_amp_switch_get,
8718 .put = alc262_sony_master_sw_put,
8719 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8720 },
Kailang Yang272a5272007-05-14 11:00:38 +02008721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8723 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8724 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8725 { } /* end */
8726};
8727
Kailang Yang83c34212007-07-05 11:43:05 +02008728static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8730 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8734 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8735 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8736 { } /* end */
8737};
Kailang Yang272a5272007-05-14 11:00:38 +02008738
Kailang Yangdf694da2005-12-05 19:42:22 +01008739#define alc262_capture_mixer alc882_capture_mixer
8740#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8741
8742/*
8743 * generic initialization of ADC, input mixers and output mixers
8744 */
8745static struct hda_verb alc262_init_verbs[] = {
8746 /*
8747 * Unmute ADC0-2 and set the default input to mic-in
8748 */
8749 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8753 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8755
Takashi Iwaicb53c622007-08-10 17:21:45 +02008756 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008757 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008758 * Note: PASD motherboards uses the Line In 2 as the input for
8759 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008760 */
8761 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008767
8768 /*
8769 * Set up output mixers (0x0c - 0x0e)
8770 */
8771 /* set vol=0 to output mixers */
8772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8775 /* set up input amps for analog loopback */
8776 /* Amp Indices: DAC = 0, mixer = 1 */
8777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8783
8784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8786 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8789 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8790
8791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8796
8797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8798 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8799
8800 /* FIXME: use matrix-type input source selection */
8801 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8802 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8807 /* Input mixer2 */
8808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8812 /* Input mixer3 */
8813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008817
8818 { }
8819};
8820
Kailang Yangccc656c2006-10-17 12:32:26 +02008821static struct hda_verb alc262_hippo_unsol_verbs[] = {
8822 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8823 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8824 {}
8825};
8826
8827static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8828 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8829 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8831
8832 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8834 {}
8835};
8836
Kailang Yang272a5272007-05-14 11:00:38 +02008837static struct hda_verb alc262_sony_unsol_verbs[] = {
8838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8841
8842 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008844 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008845};
8846
Kailang Yangccc656c2006-10-17 12:32:26 +02008847/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008848static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008849{
8850 struct alc_spec *spec = codec->spec;
8851 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008852 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008853
Takashi Iwai5b319542007-07-26 11:49:22 +02008854 /* need to execute and sync at first */
8855 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8856 present = snd_hda_codec_read(codec, 0x15, 0,
8857 AC_VERB_GET_PIN_SENSE, 0);
8858 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008859 if (spec->jack_present) {
8860 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008861 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8862 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008863 } else {
8864 /* unmute internal speaker if necessary */
8865 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008866 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8867 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008868 }
8869}
8870
8871/* unsolicited event for HP jack sensing */
8872static void alc262_hippo_unsol_event(struct hda_codec *codec,
8873 unsigned int res)
8874{
8875 if ((res >> 26) != ALC880_HP_EVENT)
8876 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008877 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008878}
8879
Takashi Iwai5b319542007-07-26 11:49:22 +02008880static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008881{
Kailang Yangccc656c2006-10-17 12:32:26 +02008882 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008883 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008884
Takashi Iwai5b319542007-07-26 11:49:22 +02008885 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8886 present = snd_hda_codec_read(codec, 0x1b, 0,
8887 AC_VERB_GET_PIN_SENSE, 0);
8888 present = (present & 0x80000000) != 0;
8889 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008890 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008891 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8892 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008893 } else {
8894 /* unmute internal speaker if necessary */
8895 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008896 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8897 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008898 }
8899}
8900
8901/* unsolicited event for HP jack sensing */
8902static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8903 unsigned int res)
8904{
8905 if ((res >> 26) != ALC880_HP_EVENT)
8906 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008907 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008908}
8909
Takashi Iwai834be882006-03-01 14:16:17 +01008910/*
8911 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008912 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8913 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008914 */
8915
8916#define ALC_HP_EVENT 0x37
8917
8918static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01008923 {}
8924};
8925
Jiang zhe0e31daf2008-03-20 12:12:39 +01008926static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8927 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8929 {}
8930};
8931
Takashi Iwai834be882006-03-01 14:16:17 +01008932static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008933 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008934 .items = {
8935 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008936 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008937 { "CD", 0x4 },
8938 },
8939};
8940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008941static struct hda_input_mux alc262_HP_capture_source = {
8942 .num_items = 5,
8943 .items = {
8944 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008945 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008946 { "Line", 0x2 },
8947 { "CD", 0x4 },
8948 { "AUX IN", 0x6 },
8949 },
8950};
8951
zhejiangaccbe492007-08-31 12:36:05 +02008952static struct hda_input_mux alc262_HP_D7000_capture_source = {
8953 .num_items = 4,
8954 .items = {
8955 { "Mic", 0x0 },
8956 { "Front Mic", 0x2 },
8957 { "Line", 0x1 },
8958 { "CD", 0x4 },
8959 },
8960};
8961
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008962/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01008963static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8964{
8965 struct alc_spec *spec = codec->spec;
8966 unsigned int mute;
8967
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008968 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008969 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01008970 /* need to execute and sync at first */
8971 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008972 /* check laptop HP jack */
8973 present = snd_hda_codec_read(codec, 0x14, 0,
8974 AC_VERB_GET_PIN_SENSE, 0);
8975 /* need to execute and sync at first */
8976 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8977 /* check docking HP jack */
8978 present |= snd_hda_codec_read(codec, 0x1b, 0,
8979 AC_VERB_GET_PIN_SENSE, 0);
8980 if (present & AC_PINSENSE_PRESENCE)
8981 spec->jack_present = 1;
8982 else
8983 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01008984 spec->sense_updated = 1;
8985 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008986 /* unmute internal speaker only if both HPs are unplugged and
8987 * master switch is on
8988 */
8989 if (spec->jack_present)
8990 mute = HDA_AMP_MUTE;
8991 else
Takashi Iwai834be882006-03-01 14:16:17 +01008992 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008993 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8994 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008995}
8996
8997/* unsolicited event for HP jack sensing */
8998static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8999 unsigned int res)
9000{
9001 if ((res >> 26) != ALC_HP_EVENT)
9002 return;
9003 alc262_fujitsu_automute(codec, 1);
9004}
9005
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009006static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9007{
9008 alc262_fujitsu_automute(codec, 1);
9009}
9010
Takashi Iwai834be882006-03-01 14:16:17 +01009011/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009012static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9013 .ops = &snd_hda_bind_vol,
9014 .values = {
9015 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9016 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9017 0
9018 },
9019};
Takashi Iwai834be882006-03-01 14:16:17 +01009020
Jiang zhe0e31daf2008-03-20 12:12:39 +01009021/* mute/unmute internal speaker according to the hp jack and mute state */
9022static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9023{
9024 struct alc_spec *spec = codec->spec;
9025 unsigned int mute;
9026
9027 if (force || !spec->sense_updated) {
9028 unsigned int present_int_hp;
9029 /* need to execute and sync at first */
9030 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9031 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9032 AC_VERB_GET_PIN_SENSE, 0);
9033 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9034 spec->sense_updated = 1;
9035 }
9036 if (spec->jack_present) {
9037 /* mute internal speaker */
9038 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9039 HDA_AMP_MUTE, HDA_AMP_MUTE);
9040 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9041 HDA_AMP_MUTE, HDA_AMP_MUTE);
9042 } else {
9043 /* unmute internal speaker if necessary */
9044 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9045 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9046 HDA_AMP_MUTE, mute);
9047 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9048 HDA_AMP_MUTE, mute);
9049 }
9050}
9051
9052/* unsolicited event for HP jack sensing */
9053static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9054 unsigned int res)
9055{
9056 if ((res >> 26) != ALC_HP_EVENT)
9057 return;
9058 alc262_lenovo_3000_automute(codec, 1);
9059}
9060
Takashi Iwai834be882006-03-01 14:16:17 +01009061/* bind hp and internal speaker mute (with plug check) */
9062static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9063 struct snd_ctl_elem_value *ucontrol)
9064{
9065 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9066 long *valp = ucontrol->value.integer.value;
9067 int change;
9068
Tony Vroon5d9fab22008-03-14 17:09:18 +01009069 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9070 HDA_AMP_MUTE,
9071 valp ? 0 : HDA_AMP_MUTE);
9072 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9073 HDA_AMP_MUTE,
9074 valp ? 0 : HDA_AMP_MUTE);
9075
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009076 if (change)
9077 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009078 return change;
9079}
9080
9081static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009082 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009083 {
9084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9085 .name = "Master Playback Switch",
9086 .info = snd_hda_mixer_amp_switch_info,
9087 .get = snd_hda_mixer_amp_switch_get,
9088 .put = alc262_fujitsu_master_sw_put,
9089 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9090 },
9091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009093 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9094 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009095 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009098 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9099 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9100 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009101 { } /* end */
9102};
9103
Jiang zhe0e31daf2008-03-20 12:12:39 +01009104/* bind hp and internal speaker mute (with plug check) */
9105static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9106 struct snd_ctl_elem_value *ucontrol)
9107{
9108 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9109 long *valp = ucontrol->value.integer.value;
9110 int change;
9111
9112 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9113 HDA_AMP_MUTE,
9114 valp ? 0 : HDA_AMP_MUTE);
9115
9116 if (change)
9117 alc262_lenovo_3000_automute(codec, 0);
9118 return change;
9119}
9120
9121static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9122 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9123 {
9124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9125 .name = "Master Playback Switch",
9126 .info = snd_hda_mixer_amp_switch_info,
9127 .get = snd_hda_mixer_amp_switch_get,
9128 .put = alc262_lenovo_3000_master_sw_put,
9129 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9130 },
9131 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9132 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9137 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9138 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9139 { } /* end */
9140};
9141
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009142/* additional init verbs for Benq laptops */
9143static struct hda_verb alc262_EAPD_verbs[] = {
9144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9145 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9146 {}
9147};
9148
Kailang Yang83c34212007-07-05 11:43:05 +02009149static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9151 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9152
9153 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9154 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9155 {}
9156};
9157
Tobin Davisf651b502007-10-26 12:40:47 +02009158/* Samsung Q1 Ultra Vista model setup */
9159static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009160 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9161 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009165 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009166 { } /* end */
9167};
9168
9169static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009170 /* output mixer */
9171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9174 /* speaker */
9175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9176 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9177 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9179 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9184 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9185 /* internal mic */
9186 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9188 /* ADC, choose mic */
9189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009199 {}
9200};
9201
Tobin Davisf651b502007-10-26 12:40:47 +02009202/* mute/unmute internal speaker according to the hp jack and mute state */
9203static void alc262_ultra_automute(struct hda_codec *codec)
9204{
9205 struct alc_spec *spec = codec->spec;
9206 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009207
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009208 mute = 0;
9209 /* auto-mute only when HP is used as HP */
9210 if (!spec->cur_mux[0]) {
9211 unsigned int present;
9212 /* need to execute and sync at first */
9213 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9214 present = snd_hda_codec_read(codec, 0x15, 0,
9215 AC_VERB_GET_PIN_SENSE, 0);
9216 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9217 if (spec->jack_present)
9218 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009219 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009220 /* mute/unmute internal speaker */
9221 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9222 HDA_AMP_MUTE, mute);
9223 /* mute/unmute HP */
9224 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9225 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009226}
9227
9228/* unsolicited event for HP jack sensing */
9229static void alc262_ultra_unsol_event(struct hda_codec *codec,
9230 unsigned int res)
9231{
9232 if ((res >> 26) != ALC880_HP_EVENT)
9233 return;
9234 alc262_ultra_automute(codec);
9235}
9236
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009237static struct hda_input_mux alc262_ultra_capture_source = {
9238 .num_items = 2,
9239 .items = {
9240 { "Mic", 0x1 },
9241 { "Headphone", 0x7 },
9242 },
9243};
9244
9245static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9246 struct snd_ctl_elem_value *ucontrol)
9247{
9248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9249 struct alc_spec *spec = codec->spec;
9250 int ret;
9251
9252 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9253 if (!ret)
9254 return 0;
9255 /* reprogram the HP pin as mic or HP according to the input source */
9256 snd_hda_codec_write_cache(codec, 0x15, 0,
9257 AC_VERB_SET_PIN_WIDGET_CONTROL,
9258 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9259 alc262_ultra_automute(codec); /* mute/unmute HP */
9260 return ret;
9261}
9262
9263static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9264 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9265 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9266 {
9267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9268 .name = "Capture Source",
9269 .info = alc882_mux_enum_info,
9270 .get = alc882_mux_enum_get,
9271 .put = alc262_ultra_mux_enum_put,
9272 },
9273 { } /* end */
9274};
9275
Kailang Yangdf694da2005-12-05 19:42:22 +01009276/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009277static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9278 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009279{
9280 hda_nid_t nid;
9281 int err;
9282
9283 spec->multiout.num_dacs = 1; /* only use one dac */
9284 spec->multiout.dac_nids = spec->private_dac_nids;
9285 spec->multiout.dac_nids[0] = 2;
9286
9287 nid = cfg->line_out_pins[0];
9288 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009289 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9290 "Front Playback Volume",
9291 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9292 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009293 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009294 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9295 "Front Playback Switch",
9296 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9297 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009298 return err;
9299 }
9300
Takashi Iwai82bc9552006-03-21 11:24:42 +01009301 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009302 if (nid) {
9303 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009304 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9305 "Speaker Playback Volume",
9306 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9307 HDA_OUTPUT));
9308 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009309 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009310 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9311 "Speaker Playback Switch",
9312 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9313 HDA_OUTPUT));
9314 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009315 return err;
9316 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009317 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9318 "Speaker Playback Switch",
9319 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9320 HDA_OUTPUT));
9321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009322 return err;
9323 }
9324 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009325 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009326 if (nid) {
9327 /* spec->multiout.hp_nid = 2; */
9328 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009329 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9330 "Headphone Playback Volume",
9331 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9332 HDA_OUTPUT));
9333 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009334 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009335 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9336 "Headphone Playback Switch",
9337 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9338 HDA_OUTPUT));
9339 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009340 return err;
9341 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009342 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9343 "Headphone Playback Switch",
9344 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9345 HDA_OUTPUT));
9346 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009347 return err;
9348 }
9349 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009350 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009351}
9352
9353/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009354#define alc262_auto_create_analog_input_ctls \
9355 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009356
9357/*
9358 * generic initialization of ADC, input mixers and output mixers
9359 */
9360static struct hda_verb alc262_volume_init_verbs[] = {
9361 /*
9362 * Unmute ADC0-2 and set the default input to mic-in
9363 */
9364 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9366 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9367 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9368 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9370
Takashi Iwaicb53c622007-08-10 17:21:45 +02009371 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009372 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009373 * Note: PASD motherboards uses the Line In 2 as the input for
9374 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009375 */
9376 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009382
9383 /*
9384 * Set up output mixers (0x0c - 0x0f)
9385 */
9386 /* set vol=0 to output mixers */
9387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9390
9391 /* set up input amps for analog loopback */
9392 /* Amp Indices: DAC = 0, mixer = 1 */
9393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9399
9400 /* FIXME: use matrix-type input source selection */
9401 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9402 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9407 /* Input mixer2 */
9408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9412 /* Input mixer3 */
9413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9417
9418 { }
9419};
9420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009421static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9422 /*
9423 * Unmute ADC0-2 and set the default input to mic-in
9424 */
9425 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9427 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9429 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9431
Takashi Iwaicb53c622007-08-10 17:21:45 +02009432 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009433 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009434 * Note: PASD motherboards uses the Line In 2 as the input for
9435 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009436 */
9437 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009445
9446 /*
9447 * Set up output mixers (0x0c - 0x0e)
9448 */
9449 /* set vol=0 to output mixers */
9450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9452 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9453
9454 /* set up input amps for analog loopback */
9455 /* Amp Indices: DAC = 0, mixer = 1 */
9456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9462
Takashi Iwaice875f02008-01-28 18:17:43 +01009463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9465 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9466
9467 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9469
9470 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9472
9473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9478
9479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9483 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9484 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9485
9486
9487 /* FIXME: use matrix-type input source selection */
9488 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9489 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9494 /* Input mixer2 */
9495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9499 /* Input mixer3 */
9500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9504
Takashi Iwaice875f02008-01-28 18:17:43 +01009505 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9506
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009507 { }
9508};
9509
Kailang Yangcd7509a2007-01-26 18:33:17 +01009510static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9511 /*
9512 * Unmute ADC0-2 and set the default input to mic-in
9513 */
9514 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9515 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9516 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9518 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9520
Takashi Iwaicb53c622007-08-10 17:21:45 +02009521 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009522 * mixer widget
9523 * Note: PASD motherboards uses the Line In 2 as the input for front
9524 * panel mic (mic 2)
9525 */
9526 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009535 /*
9536 * Set up output mixers (0x0c - 0x0e)
9537 */
9538 /* set vol=0 to output mixers */
9539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9542
9543 /* set up input amps for analog loopback */
9544 /* Amp Indices: DAC = 0, mixer = 1 */
9545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9551
9552
9553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9554 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9556 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9559 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9560
9561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9563
9564 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9565 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9566
9567 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9569 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9570 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9571 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9572 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9573
9574 /* FIXME: use matrix-type input source selection */
9575 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9576 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9582 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9583 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9584 /* Input mixer2 */
9585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9590 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9592 /* Input mixer3 */
9593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9598 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9600
Takashi Iwaice875f02008-01-28 18:17:43 +01009601 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9602
Kailang Yangcd7509a2007-01-26 18:33:17 +01009603 { }
9604};
9605
Takashi Iwaicb53c622007-08-10 17:21:45 +02009606#ifdef CONFIG_SND_HDA_POWER_SAVE
9607#define alc262_loopbacks alc880_loopbacks
9608#endif
9609
Kailang Yangdf694da2005-12-05 19:42:22 +01009610/* pcm configuration: identiacal with ALC880 */
9611#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9612#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9613#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9614#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9615
9616/*
9617 * BIOS auto configuration
9618 */
9619static int alc262_parse_auto_config(struct hda_codec *codec)
9620{
9621 struct alc_spec *spec = codec->spec;
9622 int err;
9623 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9624
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009625 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9626 alc262_ignore);
9627 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009628 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009630 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009631 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9632 if (err < 0)
9633 return err;
9634 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009636 return err;
9637
9638 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9639
9640 if (spec->autocfg.dig_out_pin)
9641 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9642 if (spec->autocfg.dig_in_pin)
9643 spec->dig_in_nid = ALC262_DIGIN_NID;
9644
9645 if (spec->kctl_alloc)
9646 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9647
9648 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009649 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009650 spec->input_mux = &spec->private_imux;
9651
Takashi Iwai776e1842007-08-29 15:07:11 +02009652 err = alc_auto_add_mic_boost(codec);
9653 if (err < 0)
9654 return err;
9655
Kailang Yangdf694da2005-12-05 19:42:22 +01009656 return 1;
9657}
9658
9659#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9660#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9661#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9662
9663
9664/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009665static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009666{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009667 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009668 alc262_auto_init_multi_out(codec);
9669 alc262_auto_init_hp_out(codec);
9670 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009671 if (spec->unsol_event)
9672 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009673}
9674
9675/*
9676 * configuration and preset
9677 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009678static const char *alc262_models[ALC262_MODEL_LAST] = {
9679 [ALC262_BASIC] = "basic",
9680 [ALC262_HIPPO] = "hippo",
9681 [ALC262_HIPPO_1] = "hippo_1",
9682 [ALC262_FUJITSU] = "fujitsu",
9683 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009684 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009685 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009686 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009687 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009688 [ALC262_BENQ_T31] = "benq-t31",
9689 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009690 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009691 [ALC262_LENOVO_3000] = "lenovo-3000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009692 [ALC262_AUTO] = "auto",
9693};
9694
9695static struct snd_pci_quirk alc262_cfg_tbl[] = {
9696 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9697 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009698 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009699 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9700 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009701 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009702 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009703 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009704 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009705 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009706 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009707 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009708 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009709 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009710 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009711 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009712 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009713 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9714 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9715 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009716 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9717 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009718 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009719 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009720 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009721 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9722 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9723 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009724 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9725 ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009726 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009727 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009728 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009729 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009730 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009731 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009732 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009733 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009734 {}
9735};
9736
9737static struct alc_config_preset alc262_presets[] = {
9738 [ALC262_BASIC] = {
9739 .mixers = { alc262_base_mixer },
9740 .init_verbs = { alc262_init_verbs },
9741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9742 .dac_nids = alc262_dac_nids,
9743 .hp_nid = 0x03,
9744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9745 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009746 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009747 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009748 [ALC262_HIPPO] = {
9749 .mixers = { alc262_base_mixer },
9750 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9751 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9752 .dac_nids = alc262_dac_nids,
9753 .hp_nid = 0x03,
9754 .dig_out_nid = ALC262_DIGOUT_NID,
9755 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9756 .channel_mode = alc262_modes,
9757 .input_mux = &alc262_capture_source,
9758 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009759 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009760 },
9761 [ALC262_HIPPO_1] = {
9762 .mixers = { alc262_hippo1_mixer },
9763 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9764 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9765 .dac_nids = alc262_dac_nids,
9766 .hp_nid = 0x02,
9767 .dig_out_nid = ALC262_DIGOUT_NID,
9768 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9769 .channel_mode = alc262_modes,
9770 .input_mux = &alc262_capture_source,
9771 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009772 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009773 },
Takashi Iwai834be882006-03-01 14:16:17 +01009774 [ALC262_FUJITSU] = {
9775 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009776 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9777 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009778 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9779 .dac_nids = alc262_dac_nids,
9780 .hp_nid = 0x03,
9781 .dig_out_nid = ALC262_DIGOUT_NID,
9782 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9783 .channel_mode = alc262_modes,
9784 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009785 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009786 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009787 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009788 [ALC262_HP_BPC] = {
9789 .mixers = { alc262_HP_BPC_mixer },
9790 .init_verbs = { alc262_HP_BPC_init_verbs },
9791 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9792 .dac_nids = alc262_dac_nids,
9793 .hp_nid = 0x03,
9794 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9795 .channel_mode = alc262_modes,
9796 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009797 .unsol_event = alc262_hp_bpc_unsol_event,
9798 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009799 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009800 [ALC262_HP_BPC_D7000_WF] = {
9801 .mixers = { alc262_HP_BPC_WildWest_mixer },
9802 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9803 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9804 .dac_nids = alc262_dac_nids,
9805 .hp_nid = 0x03,
9806 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9807 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009808 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009809 .unsol_event = alc262_hp_wildwest_unsol_event,
9810 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009811 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009812 [ALC262_HP_BPC_D7000_WL] = {
9813 .mixers = { alc262_HP_BPC_WildWest_mixer,
9814 alc262_HP_BPC_WildWest_option_mixer },
9815 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9816 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9817 .dac_nids = alc262_dac_nids,
9818 .hp_nid = 0x03,
9819 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9820 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009821 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009822 .unsol_event = alc262_hp_wildwest_unsol_event,
9823 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009824 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009825 [ALC262_HP_TC_T5735] = {
9826 .mixers = { alc262_hp_t5735_mixer },
9827 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9828 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9829 .dac_nids = alc262_dac_nids,
9830 .hp_nid = 0x03,
9831 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9832 .channel_mode = alc262_modes,
9833 .input_mux = &alc262_capture_source,
9834 .unsol_event = alc262_hp_t5735_unsol_event,
9835 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009836 },
9837 [ALC262_HP_RP5700] = {
9838 .mixers = { alc262_hp_rp5700_mixer },
9839 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9840 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9841 .dac_nids = alc262_dac_nids,
9842 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9843 .channel_mode = alc262_modes,
9844 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009845 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009846 [ALC262_BENQ_ED8] = {
9847 .mixers = { alc262_base_mixer },
9848 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9849 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9850 .dac_nids = alc262_dac_nids,
9851 .hp_nid = 0x03,
9852 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9853 .channel_mode = alc262_modes,
9854 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009855 },
Kailang Yang272a5272007-05-14 11:00:38 +02009856 [ALC262_SONY_ASSAMD] = {
9857 .mixers = { alc262_sony_mixer },
9858 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9860 .dac_nids = alc262_dac_nids,
9861 .hp_nid = 0x02,
9862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9863 .channel_mode = alc262_modes,
9864 .input_mux = &alc262_capture_source,
9865 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009866 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009867 },
9868 [ALC262_BENQ_T31] = {
9869 .mixers = { alc262_benq_t31_mixer },
9870 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9871 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9872 .dac_nids = alc262_dac_nids,
9873 .hp_nid = 0x03,
9874 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9875 .channel_mode = alc262_modes,
9876 .input_mux = &alc262_capture_source,
9877 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009878 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009879 },
Tobin Davisf651b502007-10-26 12:40:47 +02009880 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009881 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9882 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009883 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9884 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9886 .channel_mode = alc262_modes,
9887 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009888 .adc_nids = alc262_adc_nids, /* ADC0 */
9889 .capsrc_nids = alc262_capsrc_nids,
9890 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009891 .unsol_event = alc262_ultra_unsol_event,
9892 .init_hook = alc262_ultra_automute,
9893 },
Jiang zhe0e31daf2008-03-20 12:12:39 +01009894 [ALC262_LENOVO_3000] = {
9895 .mixers = { alc262_lenovo_3000_mixer },
9896 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9897 alc262_lenovo_3000_unsol_verbs },
9898 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9899 .dac_nids = alc262_dac_nids,
9900 .hp_nid = 0x03,
9901 .dig_out_nid = ALC262_DIGOUT_NID,
9902 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9903 .channel_mode = alc262_modes,
9904 .input_mux = &alc262_fujitsu_capture_source,
9905 .unsol_event = alc262_lenovo_3000_unsol_event,
9906 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009907};
9908
9909static int patch_alc262(struct hda_codec *codec)
9910{
9911 struct alc_spec *spec;
9912 int board_config;
9913 int err;
9914
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009915 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009916 if (spec == NULL)
9917 return -ENOMEM;
9918
9919 codec->spec = spec;
9920#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009921 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9922 * under-run
9923 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009924 {
9925 int tmp;
9926 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9927 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9928 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9929 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9930 }
9931#endif
9932
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009933 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9934
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009935 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9936 alc262_models,
9937 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009938
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009939 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009940 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9941 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009942 board_config = ALC262_AUTO;
9943 }
9944
9945 if (board_config == ALC262_AUTO) {
9946 /* automatic parse from the BIOS config */
9947 err = alc262_parse_auto_config(codec);
9948 if (err < 0) {
9949 alc_free(codec);
9950 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009951 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009952 printk(KERN_INFO
9953 "hda_codec: Cannot set up configuration "
9954 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009955 board_config = ALC262_BASIC;
9956 }
9957 }
9958
9959 if (board_config != ALC262_AUTO)
9960 setup_preset(spec, &alc262_presets[board_config]);
9961
9962 spec->stream_name_analog = "ALC262 Analog";
9963 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9964 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9965
9966 spec->stream_name_digital = "ALC262 Digital";
9967 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9968 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9969
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009970 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009971 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009972 unsigned int wcap = get_wcaps(codec, 0x07);
9973
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009974 /* get type */
9975 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009976 if (wcap != AC_WID_AUD_IN) {
9977 spec->adc_nids = alc262_adc_nids_alt;
9978 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009979 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009980 spec->mixers[spec->num_mixers] =
9981 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009982 spec->num_mixers++;
9983 } else {
9984 spec->adc_nids = alc262_adc_nids;
9985 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009986 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009987 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9988 spec->num_mixers++;
9989 }
9990 }
9991
Takashi Iwai2134ea42008-01-10 16:53:55 +01009992 spec->vmaster_nid = 0x0c;
9993
Kailang Yangdf694da2005-12-05 19:42:22 +01009994 codec->patch_ops = alc_patch_ops;
9995 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009996 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009997#ifdef CONFIG_SND_HDA_POWER_SAVE
9998 if (!spec->loopback.amplist)
9999 spec->loopback.amplist = alc262_loopbacks;
10000#endif
Takashi Iwai834be882006-03-01 14:16:17 +010010001
Kailang Yangdf694da2005-12-05 19:42:22 +010010002 return 0;
10003}
10004
Kailang Yangdf694da2005-12-05 19:42:22 +010010005/*
Kailang Yanga361d842007-06-05 12:30:55 +020010006 * ALC268 channel source setting (2 channel)
10007 */
10008#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10009#define alc268_modes alc260_modes
10010
10011static hda_nid_t alc268_dac_nids[2] = {
10012 /* front, hp */
10013 0x02, 0x03
10014};
10015
10016static hda_nid_t alc268_adc_nids[2] = {
10017 /* ADC0-1 */
10018 0x08, 0x07
10019};
10020
10021static hda_nid_t alc268_adc_nids_alt[1] = {
10022 /* ADC0 */
10023 0x08
10024};
10025
Takashi Iwaie1406342008-02-11 18:32:32 +010010026static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10027
Kailang Yanga361d842007-06-05 12:30:55 +020010028static struct snd_kcontrol_new alc268_base_mixer[] = {
10029 /* output mixer control */
10030 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10031 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10035 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10036 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010037 { }
10038};
10039
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010040/* bind Beep switches of both NID 0x0f and 0x10 */
10041static struct hda_bind_ctls alc268_bind_beep_sw = {
10042 .ops = &snd_hda_bind_sw,
10043 .values = {
10044 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10045 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10046 0
10047 },
10048};
10049
10050static struct snd_kcontrol_new alc268_beep_mixer[] = {
10051 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10052 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10053 { }
10054};
10055
Kailang Yangd1a991a2007-08-15 16:21:59 +020010056static struct hda_verb alc268_eapd_verbs[] = {
10057 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10058 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10059 { }
10060};
10061
Takashi Iwaid2738092007-08-16 14:59:45 +020010062/* Toshiba specific */
10063#define alc268_toshiba_automute alc262_hippo_automute
10064
10065static struct hda_verb alc268_toshiba_verbs[] = {
10066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10067 { } /* end */
10068};
10069
10070/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010071/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010072static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10073 .ops = &snd_hda_bind_vol,
10074 .values = {
10075 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10076 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10077 0
10078 },
10079};
10080
Takashi Iwai889c4392007-08-23 18:56:52 +020010081/* mute/unmute internal speaker according to the hp jack and mute state */
10082static void alc268_acer_automute(struct hda_codec *codec, int force)
10083{
10084 struct alc_spec *spec = codec->spec;
10085 unsigned int mute;
10086
10087 if (force || !spec->sense_updated) {
10088 unsigned int present;
10089 present = snd_hda_codec_read(codec, 0x14, 0,
10090 AC_VERB_GET_PIN_SENSE, 0);
10091 spec->jack_present = (present & 0x80000000) != 0;
10092 spec->sense_updated = 1;
10093 }
10094 if (spec->jack_present)
10095 mute = HDA_AMP_MUTE; /* mute internal speaker */
10096 else /* unmute internal speaker if necessary */
10097 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10098 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10099 HDA_AMP_MUTE, mute);
10100}
10101
10102
10103/* bind hp and internal speaker mute (with plug check) */
10104static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10105 struct snd_ctl_elem_value *ucontrol)
10106{
10107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10108 long *valp = ucontrol->value.integer.value;
10109 int change;
10110
10111 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10112 HDA_AMP_MUTE,
10113 valp[0] ? 0 : HDA_AMP_MUTE);
10114 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10115 HDA_AMP_MUTE,
10116 valp[1] ? 0 : HDA_AMP_MUTE);
10117 if (change)
10118 alc268_acer_automute(codec, 0);
10119 return change;
10120}
Takashi Iwaid2738092007-08-16 14:59:45 +020010121
10122static struct snd_kcontrol_new alc268_acer_mixer[] = {
10123 /* output mixer control */
10124 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10125 {
10126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10127 .name = "Master Playback Switch",
10128 .info = snd_hda_mixer_amp_switch_info,
10129 .get = snd_hda_mixer_amp_switch_get,
10130 .put = alc268_acer_master_sw_put,
10131 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10132 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10134 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10135 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010136 { }
10137};
10138
10139static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010140 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10141 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10143 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010146
10147 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10148 { }
10149};
10150
10151/* unsolicited event for HP jack sensing */
10152static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10153 unsigned int res)
10154{
Takashi Iwai889c4392007-08-23 18:56:52 +020010155 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010156 return;
10157 alc268_toshiba_automute(codec);
10158}
10159
10160static void alc268_acer_unsol_event(struct hda_codec *codec,
10161 unsigned int res)
10162{
Takashi Iwai889c4392007-08-23 18:56:52 +020010163 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010164 return;
10165 alc268_acer_automute(codec, 1);
10166}
10167
Takashi Iwai889c4392007-08-23 18:56:52 +020010168static void alc268_acer_init_hook(struct hda_codec *codec)
10169{
10170 alc268_acer_automute(codec, 1);
10171}
10172
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010173static struct snd_kcontrol_new alc268_dell_mixer[] = {
10174 /* output mixer control */
10175 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10176 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10177 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10179 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10180 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10181 { }
10182};
10183
10184static struct hda_verb alc268_dell_verbs[] = {
10185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10187 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10188 { }
10189};
10190
10191/* mute/unmute internal speaker according to the hp jack and mute state */
10192static void alc268_dell_automute(struct hda_codec *codec)
10193{
10194 unsigned int present;
10195 unsigned int mute;
10196
10197 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10198 if (present & 0x80000000)
10199 mute = HDA_AMP_MUTE;
10200 else
10201 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10202 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10203 HDA_AMP_MUTE, mute);
10204}
10205
10206static void alc268_dell_unsol_event(struct hda_codec *codec,
10207 unsigned int res)
10208{
10209 if ((res >> 26) != ALC880_HP_EVENT)
10210 return;
10211 alc268_dell_automute(codec);
10212}
10213
10214#define alc268_dell_init_hook alc268_dell_automute
10215
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010216static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10217 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10218 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10221 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10222 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10223 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10225 { }
10226};
10227
10228static struct hda_verb alc267_quanta_il1_verbs[] = {
10229 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10230 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10231 { }
10232};
10233
10234static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10235{
10236 unsigned int present;
10237
10238 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10239 & AC_PINSENSE_PRESENCE;
10240 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10241 present ? 0 : PIN_OUT);
10242}
10243
10244static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10245{
10246 unsigned int present;
10247
10248 present = snd_hda_codec_read(codec, 0x18, 0,
10249 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10250 snd_hda_codec_write(codec, 0x23, 0,
10251 AC_VERB_SET_CONNECT_SEL,
10252 present ? 0x00 : 0x01);
10253}
10254
10255static void alc267_quanta_il1_automute(struct hda_codec *codec)
10256{
10257 alc267_quanta_il1_hp_automute(codec);
10258 alc267_quanta_il1_mic_automute(codec);
10259}
10260
10261static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10262 unsigned int res)
10263{
10264 switch (res >> 26) {
10265 case ALC880_HP_EVENT:
10266 alc267_quanta_il1_hp_automute(codec);
10267 break;
10268 case ALC880_MIC_EVENT:
10269 alc267_quanta_il1_mic_automute(codec);
10270 break;
10271 }
10272}
10273
Kailang Yanga361d842007-06-05 12:30:55 +020010274/*
10275 * generic initialization of ADC, input mixers and output mixers
10276 */
10277static struct hda_verb alc268_base_init_verbs[] = {
10278 /* Unmute DAC0-1 and set vol = 0 */
10279 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10280 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10283 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10284 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10285
10286 /*
10287 * Set up output mixers (0x0c - 0x0e)
10288 */
10289 /* set vol=0 to output mixers */
10290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10293 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10294
10295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10296 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10297
10298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10300 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10305 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10306
10307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10309 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10313 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010314
10315 /* set PCBEEP vol = 0, mute connections */
10316 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010319
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010320 /* Unmute Selector 23h,24h and set the default input to mic-in */
10321
10322 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10324 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010326
Kailang Yanga361d842007-06-05 12:30:55 +020010327 { }
10328};
10329
10330/*
10331 * generic initialization of ADC, input mixers and output mixers
10332 */
10333static struct hda_verb alc268_volume_init_verbs[] = {
10334 /* set output DAC */
10335 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10336 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10337 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10338 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10339
10340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10342 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10343 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10344 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10345
10346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10350 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10351
10352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10355 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10356
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010357 /* set PCBEEP vol = 0, mute connections */
10358 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10359 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010361
10362 { }
10363};
10364
10365#define alc268_mux_enum_info alc_mux_enum_info
10366#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010367#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010368
10369static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10370 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10371 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10372 {
10373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10374 /* The multiple "Capture Source" controls confuse alsamixer
10375 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010376 */
10377 /* .name = "Capture Source", */
10378 .name = "Input Source",
10379 .count = 1,
10380 .info = alc268_mux_enum_info,
10381 .get = alc268_mux_enum_get,
10382 .put = alc268_mux_enum_put,
10383 },
10384 { } /* end */
10385};
10386
10387static struct snd_kcontrol_new alc268_capture_mixer[] = {
10388 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10389 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10390 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10391 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10392 {
10393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10394 /* The multiple "Capture Source" controls confuse alsamixer
10395 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010396 */
10397 /* .name = "Capture Source", */
10398 .name = "Input Source",
10399 .count = 2,
10400 .info = alc268_mux_enum_info,
10401 .get = alc268_mux_enum_get,
10402 .put = alc268_mux_enum_put,
10403 },
10404 { } /* end */
10405};
10406
10407static struct hda_input_mux alc268_capture_source = {
10408 .num_items = 4,
10409 .items = {
10410 { "Mic", 0x0 },
10411 { "Front Mic", 0x1 },
10412 { "Line", 0x2 },
10413 { "CD", 0x3 },
10414 },
10415};
10416
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010417static struct hda_input_mux alc268_acer_capture_source = {
10418 .num_items = 3,
10419 .items = {
10420 { "Mic", 0x0 },
10421 { "Internal Mic", 0x6 },
10422 { "Line", 0x2 },
10423 },
10424};
10425
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010426#ifdef CONFIG_SND_DEBUG
10427static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010428 /* Volume widgets */
10429 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10430 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10431 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10432 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10433 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10434 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10435 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10436 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10437 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10438 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10439 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10440 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10441 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010442 /* The below appears problematic on some hardwares */
10443 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010444 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10445 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10446 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10447 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10448
10449 /* Modes for retasking pin widgets */
10450 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10451 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10452 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10453 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10454
10455 /* Controls for GPIO pins, assuming they are configured as outputs */
10456 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10457 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10458 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10459 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10460
10461 /* Switches to allow the digital SPDIF output pin to be enabled.
10462 * The ALC268 does not have an SPDIF input.
10463 */
10464 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10465
10466 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10467 * this output to turn on an external amplifier.
10468 */
10469 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10470 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10471
10472 { } /* end */
10473};
10474#endif
10475
Kailang Yanga361d842007-06-05 12:30:55 +020010476/* create input playback/capture controls for the given pin */
10477static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10478 const char *ctlname, int idx)
10479{
10480 char name[32];
10481 int err;
10482
10483 sprintf(name, "%s Playback Volume", ctlname);
10484 if (nid == 0x14) {
10485 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10486 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10487 HDA_OUTPUT));
10488 if (err < 0)
10489 return err;
10490 } else if (nid == 0x15) {
10491 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10492 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10493 HDA_OUTPUT));
10494 if (err < 0)
10495 return err;
10496 } else
10497 return -1;
10498 sprintf(name, "%s Playback Switch", ctlname);
10499 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10500 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10501 if (err < 0)
10502 return err;
10503 return 0;
10504}
10505
10506/* add playback controls from the parsed DAC table */
10507static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10508 const struct auto_pin_cfg *cfg)
10509{
10510 hda_nid_t nid;
10511 int err;
10512
10513 spec->multiout.num_dacs = 2; /* only use one dac */
10514 spec->multiout.dac_nids = spec->private_dac_nids;
10515 spec->multiout.dac_nids[0] = 2;
10516 spec->multiout.dac_nids[1] = 3;
10517
10518 nid = cfg->line_out_pins[0];
10519 if (nid)
10520 alc268_new_analog_output(spec, nid, "Front", 0);
10521
10522 nid = cfg->speaker_pins[0];
10523 if (nid == 0x1d) {
10524 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10525 "Speaker Playback Volume",
10526 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10527 if (err < 0)
10528 return err;
10529 }
10530 nid = cfg->hp_pins[0];
10531 if (nid)
10532 alc268_new_analog_output(spec, nid, "Headphone", 0);
10533
10534 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10535 if (nid == 0x16) {
10536 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10537 "Mono Playback Switch",
10538 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10539 if (err < 0)
10540 return err;
10541 }
10542 return 0;
10543}
10544
10545/* create playback/capture controls for input pins */
10546static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10547 const struct auto_pin_cfg *cfg)
10548{
10549 struct hda_input_mux *imux = &spec->private_imux;
10550 int i, idx1;
10551
10552 for (i = 0; i < AUTO_PIN_LAST; i++) {
10553 switch(cfg->input_pins[i]) {
10554 case 0x18:
10555 idx1 = 0; /* Mic 1 */
10556 break;
10557 case 0x19:
10558 idx1 = 1; /* Mic 2 */
10559 break;
10560 case 0x1a:
10561 idx1 = 2; /* Line In */
10562 break;
10563 case 0x1c:
10564 idx1 = 3; /* CD */
10565 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010566 case 0x12:
10567 case 0x13:
10568 idx1 = 6; /* digital mics */
10569 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010570 default:
10571 continue;
10572 }
10573 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10574 imux->items[imux->num_items].index = idx1;
10575 imux->num_items++;
10576 }
10577 return 0;
10578}
10579
10580static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10581{
10582 struct alc_spec *spec = codec->spec;
10583 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10584 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10585 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10586 unsigned int dac_vol1, dac_vol2;
10587
10588 if (speaker_nid) {
10589 snd_hda_codec_write(codec, speaker_nid, 0,
10590 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10591 snd_hda_codec_write(codec, 0x0f, 0,
10592 AC_VERB_SET_AMP_GAIN_MUTE,
10593 AMP_IN_UNMUTE(1));
10594 snd_hda_codec_write(codec, 0x10, 0,
10595 AC_VERB_SET_AMP_GAIN_MUTE,
10596 AMP_IN_UNMUTE(1));
10597 } else {
10598 snd_hda_codec_write(codec, 0x0f, 0,
10599 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10600 snd_hda_codec_write(codec, 0x10, 0,
10601 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10602 }
10603
10604 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10605 if (line_nid == 0x14)
10606 dac_vol2 = AMP_OUT_ZERO;
10607 else if (line_nid == 0x15)
10608 dac_vol1 = AMP_OUT_ZERO;
10609 if (hp_nid == 0x14)
10610 dac_vol2 = AMP_OUT_ZERO;
10611 else if (hp_nid == 0x15)
10612 dac_vol1 = AMP_OUT_ZERO;
10613 if (line_nid != 0x16 || hp_nid != 0x16 ||
10614 spec->autocfg.line_out_pins[1] != 0x16 ||
10615 spec->autocfg.line_out_pins[2] != 0x16)
10616 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10617
10618 snd_hda_codec_write(codec, 0x02, 0,
10619 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10620 snd_hda_codec_write(codec, 0x03, 0,
10621 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10622}
10623
10624/* pcm configuration: identiacal with ALC880 */
10625#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10626#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010627#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010628#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10629
10630/*
10631 * BIOS auto configuration
10632 */
10633static int alc268_parse_auto_config(struct hda_codec *codec)
10634{
10635 struct alc_spec *spec = codec->spec;
10636 int err;
10637 static hda_nid_t alc268_ignore[] = { 0 };
10638
10639 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10640 alc268_ignore);
10641 if (err < 0)
10642 return err;
10643 if (!spec->autocfg.line_outs)
10644 return 0; /* can't find valid BIOS pin config */
10645
10646 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10647 if (err < 0)
10648 return err;
10649 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10650 if (err < 0)
10651 return err;
10652
10653 spec->multiout.max_channels = 2;
10654
10655 /* digital only support output */
10656 if (spec->autocfg.dig_out_pin)
10657 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10658
10659 if (spec->kctl_alloc)
10660 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10661
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010662 if (spec->autocfg.speaker_pins[0] != 0x1d)
10663 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10664
Kailang Yanga361d842007-06-05 12:30:55 +020010665 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10666 spec->num_mux_defs = 1;
10667 spec->input_mux = &spec->private_imux;
10668
Takashi Iwai776e1842007-08-29 15:07:11 +020010669 err = alc_auto_add_mic_boost(codec);
10670 if (err < 0)
10671 return err;
10672
Kailang Yanga361d842007-06-05 12:30:55 +020010673 return 1;
10674}
10675
10676#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10677#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10678#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10679
10680/* init callback for auto-configuration model -- overriding the default init */
10681static void alc268_auto_init(struct hda_codec *codec)
10682{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010683 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010684 alc268_auto_init_multi_out(codec);
10685 alc268_auto_init_hp_out(codec);
10686 alc268_auto_init_mono_speaker_out(codec);
10687 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010688 if (spec->unsol_event)
10689 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010690}
10691
10692/*
10693 * configuration and preset
10694 */
10695static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010696 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010697 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010698 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010699 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010700 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010701 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010702#ifdef CONFIG_SND_DEBUG
10703 [ALC268_TEST] = "test",
10704#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010705 [ALC268_AUTO] = "auto",
10706};
10707
10708static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010709 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010710 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010711 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010712 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010713 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010714 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010715 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010716 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010717 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010718 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010719 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010720 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010721 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010722 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010723 {}
10724};
10725
10726static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010727 [ALC267_QUANTA_IL1] = {
10728 .mixers = { alc267_quanta_il1_mixer },
10729 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10730 alc267_quanta_il1_verbs },
10731 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10732 .dac_nids = alc268_dac_nids,
10733 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10734 .adc_nids = alc268_adc_nids_alt,
10735 .hp_nid = 0x03,
10736 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10737 .channel_mode = alc268_modes,
10738 .input_mux = &alc268_capture_source,
10739 .unsol_event = alc267_quanta_il1_unsol_event,
10740 .init_hook = alc267_quanta_il1_automute,
10741 },
Kailang Yanga361d842007-06-05 12:30:55 +020010742 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010743 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10744 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010745 .init_verbs = { alc268_base_init_verbs },
10746 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10747 .dac_nids = alc268_dac_nids,
10748 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10749 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010750 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010751 .hp_nid = 0x03,
10752 .dig_out_nid = ALC268_DIGOUT_NID,
10753 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10754 .channel_mode = alc268_modes,
10755 .input_mux = &alc268_capture_source,
10756 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010757 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010758 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10759 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010760 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10761 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010762 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10763 .dac_nids = alc268_dac_nids,
10764 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10765 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010766 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010767 .hp_nid = 0x03,
10768 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10769 .channel_mode = alc268_modes,
10770 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010771 .unsol_event = alc268_toshiba_unsol_event,
10772 .init_hook = alc268_toshiba_automute,
10773 },
10774 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010775 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10776 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010777 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10778 alc268_acer_verbs },
10779 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10780 .dac_nids = alc268_dac_nids,
10781 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10782 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010783 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010784 .hp_nid = 0x02,
10785 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10786 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010787 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010788 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010789 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010790 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010791 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010792 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010793 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10794 alc268_dell_verbs },
10795 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10796 .dac_nids = alc268_dac_nids,
10797 .hp_nid = 0x02,
10798 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10799 .channel_mode = alc268_modes,
10800 .unsol_event = alc268_dell_unsol_event,
10801 .init_hook = alc268_dell_init_hook,
10802 .input_mux = &alc268_capture_source,
10803 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010804 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010805 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10806 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010807 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10808 alc268_toshiba_verbs },
10809 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10810 .dac_nids = alc268_dac_nids,
10811 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10812 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010813 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010814 .hp_nid = 0x03,
10815 .dig_out_nid = ALC268_DIGOUT_NID,
10816 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10817 .channel_mode = alc268_modes,
10818 .input_mux = &alc268_capture_source,
10819 .unsol_event = alc268_toshiba_unsol_event,
10820 .init_hook = alc268_toshiba_automute
10821 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010822#ifdef CONFIG_SND_DEBUG
10823 [ALC268_TEST] = {
10824 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10825 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10826 alc268_volume_init_verbs },
10827 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10828 .dac_nids = alc268_dac_nids,
10829 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10830 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010831 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010832 .hp_nid = 0x03,
10833 .dig_out_nid = ALC268_DIGOUT_NID,
10834 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10835 .channel_mode = alc268_modes,
10836 .input_mux = &alc268_capture_source,
10837 },
10838#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010839};
10840
10841static int patch_alc268(struct hda_codec *codec)
10842{
10843 struct alc_spec *spec;
10844 int board_config;
10845 int err;
10846
10847 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10848 if (spec == NULL)
10849 return -ENOMEM;
10850
10851 codec->spec = spec;
10852
10853 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10854 alc268_models,
10855 alc268_cfg_tbl);
10856
10857 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10858 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10859 "trying auto-probe from BIOS...\n");
10860 board_config = ALC268_AUTO;
10861 }
10862
10863 if (board_config == ALC268_AUTO) {
10864 /* automatic parse from the BIOS config */
10865 err = alc268_parse_auto_config(codec);
10866 if (err < 0) {
10867 alc_free(codec);
10868 return err;
10869 } else if (!err) {
10870 printk(KERN_INFO
10871 "hda_codec: Cannot set up configuration "
10872 "from BIOS. Using base mode...\n");
10873 board_config = ALC268_3ST;
10874 }
10875 }
10876
10877 if (board_config != ALC268_AUTO)
10878 setup_preset(spec, &alc268_presets[board_config]);
10879
Kailang Yang2f893282008-05-27 12:14:47 +020010880 if (codec->vendor_id == 0x10ec0267) {
10881 spec->stream_name_analog = "ALC267 Analog";
10882 spec->stream_name_digital = "ALC267 Digital";
10883 } else {
10884 spec->stream_name_analog = "ALC268 Analog";
10885 spec->stream_name_digital = "ALC268 Digital";
10886 }
10887
Kailang Yanga361d842007-06-05 12:30:55 +020010888 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10889 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010890 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010891
Kailang Yanga361d842007-06-05 12:30:55 +020010892 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10893
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010894 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10895 /* override the amp caps for beep generator */
10896 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10897 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10898 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10899 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10900 (0 << AC_AMPCAP_MUTE_SHIFT));
10901
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010902 if (!spec->adc_nids && spec->input_mux) {
10903 /* check whether NID 0x07 is valid */
10904 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010905 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010906
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010907 /* get type */
10908 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010909 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010910 spec->adc_nids = alc268_adc_nids_alt;
10911 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10912 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010913 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010914 spec->num_mixers++;
10915 } else {
10916 spec->adc_nids = alc268_adc_nids;
10917 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10918 spec->mixers[spec->num_mixers] =
10919 alc268_capture_mixer;
10920 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010921 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010922 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010923 /* set default input source */
10924 for (i = 0; i < spec->num_adc_nids; i++)
10925 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10926 0, AC_VERB_SET_CONNECT_SEL,
10927 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010928 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010929
10930 spec->vmaster_nid = 0x02;
10931
Kailang Yanga361d842007-06-05 12:30:55 +020010932 codec->patch_ops = alc_patch_ops;
10933 if (board_config == ALC268_AUTO)
10934 spec->init_hook = alc268_auto_init;
10935
10936 return 0;
10937}
10938
10939/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010940 * ALC269 channel source setting (2 channel)
10941 */
10942#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10943
10944#define alc269_dac_nids alc260_dac_nids
10945
10946static hda_nid_t alc269_adc_nids[1] = {
10947 /* ADC1 */
10948 0x07,
10949};
10950
10951#define alc269_modes alc260_modes
10952#define alc269_capture_source alc880_lg_lw_capture_source
10953
10954static struct snd_kcontrol_new alc269_base_mixer[] = {
10955 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10956 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10964 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10965 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10966 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10967 { } /* end */
10968};
10969
10970/* capture mixer elements */
10971static struct snd_kcontrol_new alc269_capture_mixer[] = {
10972 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10973 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10974 {
10975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10976 /* The multiple "Capture Source" controls confuse alsamixer
10977 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010978 */
10979 /* .name = "Capture Source", */
10980 .name = "Input Source",
10981 .count = 1,
10982 .info = alc_mux_enum_info,
10983 .get = alc_mux_enum_get,
10984 .put = alc_mux_enum_put,
10985 },
10986 { } /* end */
10987};
10988
10989/*
10990 * generic initialization of ADC, input mixers and output mixers
10991 */
10992static struct hda_verb alc269_init_verbs[] = {
10993 /*
10994 * Unmute ADC0 and set the default input to mic-in
10995 */
10996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10997
10998 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10999 * analog-loopback mixer widget
11000 * Note: PASD motherboards uses the Line In 2 as the input for
11001 * front panel mic (mic 2)
11002 */
11003 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11009
11010 /*
11011 * Set up output mixers (0x0c - 0x0e)
11012 */
11013 /* set vol=0 to output mixers */
11014 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11015 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11016
11017 /* set up input amps for analog loopback */
11018 /* Amp Indices: DAC = 0, mixer = 1 */
11019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025
11026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11033
11034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11036 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11037 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11040 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11041
11042 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11043 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11044
11045 /* FIXME: use matrix-type input source selection */
11046 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11047 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11052
11053 /* set EAPD */
11054 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11055 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11056 { }
11057};
11058
11059/* add playback controls from the parsed DAC table */
11060static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11061 const struct auto_pin_cfg *cfg)
11062{
11063 hda_nid_t nid;
11064 int err;
11065
11066 spec->multiout.num_dacs = 1; /* only use one dac */
11067 spec->multiout.dac_nids = spec->private_dac_nids;
11068 spec->multiout.dac_nids[0] = 2;
11069
11070 nid = cfg->line_out_pins[0];
11071 if (nid) {
11072 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11073 "Front Playback Volume",
11074 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11075 if (err < 0)
11076 return err;
11077 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11078 "Front Playback Switch",
11079 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11080 if (err < 0)
11081 return err;
11082 }
11083
11084 nid = cfg->speaker_pins[0];
11085 if (nid) {
11086 if (!cfg->line_out_pins[0]) {
11087 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11088 "Speaker Playback Volume",
11089 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11090 HDA_OUTPUT));
11091 if (err < 0)
11092 return err;
11093 }
11094 if (nid == 0x16) {
11095 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11096 "Speaker Playback Switch",
11097 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11098 HDA_OUTPUT));
11099 if (err < 0)
11100 return err;
11101 } else {
11102 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11103 "Speaker Playback Switch",
11104 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11105 HDA_OUTPUT));
11106 if (err < 0)
11107 return err;
11108 }
11109 }
11110 nid = cfg->hp_pins[0];
11111 if (nid) {
11112 /* spec->multiout.hp_nid = 2; */
11113 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11114 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11115 "Headphone Playback Volume",
11116 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11117 HDA_OUTPUT));
11118 if (err < 0)
11119 return err;
11120 }
11121 if (nid == 0x16) {
11122 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11123 "Headphone Playback Switch",
11124 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11125 HDA_OUTPUT));
11126 if (err < 0)
11127 return err;
11128 } else {
11129 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11130 "Headphone Playback Switch",
11131 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11132 HDA_OUTPUT));
11133 if (err < 0)
11134 return err;
11135 }
11136 }
11137 return 0;
11138}
11139
11140#define alc269_auto_create_analog_input_ctls \
11141 alc880_auto_create_analog_input_ctls
11142
11143#ifdef CONFIG_SND_HDA_POWER_SAVE
11144#define alc269_loopbacks alc880_loopbacks
11145#endif
11146
11147/* pcm configuration: identiacal with ALC880 */
11148#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11149#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11150#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11151#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11152
11153/*
11154 * BIOS auto configuration
11155 */
11156static int alc269_parse_auto_config(struct hda_codec *codec)
11157{
11158 struct alc_spec *spec = codec->spec;
11159 int err;
11160 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11161
11162 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11163 alc269_ignore);
11164 if (err < 0)
11165 return err;
11166
11167 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11168 if (err < 0)
11169 return err;
11170 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11171 if (err < 0)
11172 return err;
11173
11174 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11175
11176 if (spec->autocfg.dig_out_pin)
11177 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11178
11179 if (spec->kctl_alloc)
11180 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11181
11182 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11183 spec->num_mux_defs = 1;
11184 spec->input_mux = &spec->private_imux;
11185
11186 err = alc_auto_add_mic_boost(codec);
11187 if (err < 0)
11188 return err;
11189
11190 return 1;
11191}
11192
11193#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11194#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11195#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11196
11197
11198/* init callback for auto-configuration model -- overriding the default init */
11199static void alc269_auto_init(struct hda_codec *codec)
11200{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011201 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011202 alc269_auto_init_multi_out(codec);
11203 alc269_auto_init_hp_out(codec);
11204 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011205 if (spec->unsol_event)
11206 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011207}
11208
11209/*
11210 * configuration and preset
11211 */
11212static const char *alc269_models[ALC269_MODEL_LAST] = {
11213 [ALC269_BASIC] = "basic",
11214};
11215
11216static struct snd_pci_quirk alc269_cfg_tbl[] = {
11217 {}
11218};
11219
11220static struct alc_config_preset alc269_presets[] = {
11221 [ALC269_BASIC] = {
11222 .mixers = { alc269_base_mixer },
11223 .init_verbs = { alc269_init_verbs },
11224 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11225 .dac_nids = alc269_dac_nids,
11226 .hp_nid = 0x03,
11227 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11228 .channel_mode = alc269_modes,
11229 .input_mux = &alc269_capture_source,
11230 },
11231};
11232
11233static int patch_alc269(struct hda_codec *codec)
11234{
11235 struct alc_spec *spec;
11236 int board_config;
11237 int err;
11238
11239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11240 if (spec == NULL)
11241 return -ENOMEM;
11242
11243 codec->spec = spec;
11244
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011245 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11246
Kailang Yangf6a92242007-12-13 16:52:54 +010011247 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11248 alc269_models,
11249 alc269_cfg_tbl);
11250
11251 if (board_config < 0) {
11252 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11253 "trying auto-probe from BIOS...\n");
11254 board_config = ALC269_AUTO;
11255 }
11256
11257 if (board_config == ALC269_AUTO) {
11258 /* automatic parse from the BIOS config */
11259 err = alc269_parse_auto_config(codec);
11260 if (err < 0) {
11261 alc_free(codec);
11262 return err;
11263 } else if (!err) {
11264 printk(KERN_INFO
11265 "hda_codec: Cannot set up configuration "
11266 "from BIOS. Using base mode...\n");
11267 board_config = ALC269_BASIC;
11268 }
11269 }
11270
11271 if (board_config != ALC269_AUTO)
11272 setup_preset(spec, &alc269_presets[board_config]);
11273
11274 spec->stream_name_analog = "ALC269 Analog";
11275 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11276 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11277
11278 spec->stream_name_digital = "ALC269 Digital";
11279 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11280 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11281
11282 spec->adc_nids = alc269_adc_nids;
11283 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11284 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11285 spec->num_mixers++;
11286
11287 codec->patch_ops = alc_patch_ops;
11288 if (board_config == ALC269_AUTO)
11289 spec->init_hook = alc269_auto_init;
11290#ifdef CONFIG_SND_HDA_POWER_SAVE
11291 if (!spec->loopback.amplist)
11292 spec->loopback.amplist = alc269_loopbacks;
11293#endif
11294
11295 return 0;
11296}
11297
11298/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011299 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11300 */
11301
11302/*
11303 * set the path ways for 2 channel output
11304 * need to set the codec line out and mic 1 pin widgets to inputs
11305 */
11306static struct hda_verb alc861_threestack_ch2_init[] = {
11307 /* set pin widget 1Ah (line in) for input */
11308 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011309 /* set pin widget 18h (mic1/2) for input, for mic also enable
11310 * the vref
11311 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011312 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11313
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011314 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11315#if 0
11316 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11317 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11318#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011319 { } /* end */
11320};
11321/*
11322 * 6ch mode
11323 * need to set the codec line out and mic 1 pin widgets to outputs
11324 */
11325static struct hda_verb alc861_threestack_ch6_init[] = {
11326 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11327 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11328 /* set pin widget 18h (mic1) for output (CLFE)*/
11329 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11330
11331 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011332 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011333
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011334 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11335#if 0
11336 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11337 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11338#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011339 { } /* end */
11340};
11341
11342static struct hda_channel_mode alc861_threestack_modes[2] = {
11343 { 2, alc861_threestack_ch2_init },
11344 { 6, alc861_threestack_ch6_init },
11345};
Takashi Iwai22309c32006-08-09 16:57:28 +020011346/* Set mic1 as input and unmute the mixer */
11347static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11348 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11350 { } /* end */
11351};
11352/* Set mic1 as output and mute mixer */
11353static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11354 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11355 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11356 { } /* end */
11357};
11358
11359static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11360 { 2, alc861_uniwill_m31_ch2_init },
11361 { 4, alc861_uniwill_m31_ch4_init },
11362};
Kailang Yangdf694da2005-12-05 19:42:22 +010011363
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011364/* Set mic1 and line-in as input and unmute the mixer */
11365static struct hda_verb alc861_asus_ch2_init[] = {
11366 /* set pin widget 1Ah (line in) for input */
11367 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011368 /* set pin widget 18h (mic1/2) for input, for mic also enable
11369 * the vref
11370 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011371 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11372
11373 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11374#if 0
11375 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11377#endif
11378 { } /* end */
11379};
11380/* Set mic1 nad line-in as output and mute mixer */
11381static struct hda_verb alc861_asus_ch6_init[] = {
11382 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11383 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11384 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11385 /* set pin widget 18h (mic1) for output (CLFE)*/
11386 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11387 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11388 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11389 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11390
11391 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11392#if 0
11393 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11394 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11395#endif
11396 { } /* end */
11397};
11398
11399static struct hda_channel_mode alc861_asus_modes[2] = {
11400 { 2, alc861_asus_ch2_init },
11401 { 6, alc861_asus_ch6_init },
11402};
11403
Kailang Yangdf694da2005-12-05 19:42:22 +010011404/* patch-ALC861 */
11405
11406static struct snd_kcontrol_new alc861_base_mixer[] = {
11407 /* output mixer control */
11408 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11411 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11413
11414 /*Input mixer control */
11415 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11416 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11417 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11418 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11419 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11420 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11422 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11423 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011425
Kailang Yangdf694da2005-12-05 19:42:22 +010011426 /* Capture mixer control */
11427 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11428 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11429 {
11430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11431 .name = "Capture Source",
11432 .count = 1,
11433 .info = alc_mux_enum_info,
11434 .get = alc_mux_enum_get,
11435 .put = alc_mux_enum_put,
11436 },
11437 { } /* end */
11438};
11439
11440static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11441 /* output mixer control */
11442 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11443 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11444 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11445 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11446 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11447
11448 /* Input mixer control */
11449 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11450 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11451 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11452 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11453 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11454 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11456 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11457 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011459
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 /* Capture mixer control */
11461 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11462 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11463 {
11464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11465 .name = "Capture Source",
11466 .count = 1,
11467 .info = alc_mux_enum_info,
11468 .get = alc_mux_enum_get,
11469 .put = alc_mux_enum_put,
11470 },
11471 {
11472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11473 .name = "Channel Mode",
11474 .info = alc_ch_mode_info,
11475 .get = alc_ch_mode_get,
11476 .put = alc_ch_mode_put,
11477 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11478 },
11479 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011480};
11481
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011482static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011483 /* output mixer control */
11484 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11486 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11487
11488 /*Capture mixer control */
11489 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11490 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11491 {
11492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11493 .name = "Capture Source",
11494 .count = 1,
11495 .info = alc_mux_enum_info,
11496 .get = alc_mux_enum_get,
11497 .put = alc_mux_enum_put,
11498 },
11499
11500 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011501};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011502
Takashi Iwai22309c32006-08-09 16:57:28 +020011503static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11504 /* output mixer control */
11505 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11506 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11507 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11508 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11509 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11510
11511 /* Input mixer control */
11512 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11513 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11514 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11515 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11516 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11517 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11519 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011522
Takashi Iwai22309c32006-08-09 16:57:28 +020011523 /* Capture mixer control */
11524 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11525 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11526 {
11527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11528 .name = "Capture Source",
11529 .count = 1,
11530 .info = alc_mux_enum_info,
11531 .get = alc_mux_enum_get,
11532 .put = alc_mux_enum_put,
11533 },
11534 {
11535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11536 .name = "Channel Mode",
11537 .info = alc_ch_mode_info,
11538 .get = alc_ch_mode_get,
11539 .put = alc_ch_mode_put,
11540 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11541 },
11542 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011543};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011544
11545static struct snd_kcontrol_new alc861_asus_mixer[] = {
11546 /* output mixer control */
11547 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11548 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11549 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11552
11553 /* Input mixer control */
11554 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11556 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11557 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11558 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11559 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11561 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11562 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11564
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011565 /* Capture mixer control */
11566 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11567 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11568 {
11569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11570 .name = "Capture Source",
11571 .count = 1,
11572 .info = alc_mux_enum_info,
11573 .get = alc_mux_enum_get,
11574 .put = alc_mux_enum_put,
11575 },
11576 {
11577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11578 .name = "Channel Mode",
11579 .info = alc_ch_mode_info,
11580 .get = alc_ch_mode_get,
11581 .put = alc_ch_mode_put,
11582 .private_value = ARRAY_SIZE(alc861_asus_modes),
11583 },
11584 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011585};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011586
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011587/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011588static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011589 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11590 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11591 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11592 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11593 { }
11594};
11595
Kailang Yangdf694da2005-12-05 19:42:22 +010011596/*
11597 * generic initialization of ADC, input mixers and output mixers
11598 */
11599static struct hda_verb alc861_base_init_verbs[] = {
11600 /*
11601 * Unmute ADC0 and set the default input to mic-in
11602 */
11603 /* port-A for surround (rear panel) */
11604 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11605 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11606 /* port-B for mic-in (rear panel) with vref */
11607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11608 /* port-C for line-in (rear panel) */
11609 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11610 /* port-D for Front */
11611 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11612 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11613 /* port-E for HP out (front panel) */
11614 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11615 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011616 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011617 /* port-F for mic-in (front panel) with vref */
11618 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11619 /* port-G for CLFE (rear panel) */
11620 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11621 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11622 /* port-H for side (rear panel) */
11623 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11624 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11625 /* CD-in */
11626 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11627 /* route front mic to ADC1*/
11628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11630
11631 /* Unmute DAC0~3 & spdif out*/
11632 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11634 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11635 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11637
11638 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11639 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11640 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11641 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11642 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11643
11644 /* Unmute Stereo Mixer 15 */
11645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011649
11650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11652 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011658 /* hp used DAC 3 (Front) */
11659 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11661
11662 { }
11663};
11664
11665static struct hda_verb alc861_threestack_init_verbs[] = {
11666 /*
11667 * Unmute ADC0 and set the default input to mic-in
11668 */
11669 /* port-A for surround (rear panel) */
11670 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11671 /* port-B for mic-in (rear panel) with vref */
11672 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11673 /* port-C for line-in (rear panel) */
11674 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11675 /* port-D for Front */
11676 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11677 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11678 /* port-E for HP out (front panel) */
11679 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11680 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011681 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011682 /* port-F for mic-in (front panel) with vref */
11683 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11684 /* port-G for CLFE (rear panel) */
11685 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11686 /* port-H for side (rear panel) */
11687 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11688 /* CD-in */
11689 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11690 /* route front mic to ADC1*/
11691 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11693 /* Unmute DAC0~3 & spdif out*/
11694 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11695 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11696 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11697 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11699
11700 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11701 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11702 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11703 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11704 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11705
11706 /* Unmute Stereo Mixer 15 */
11707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011711
11712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11716 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11718 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011720 /* hp used DAC 3 (Front) */
11721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11723 { }
11724};
Takashi Iwai22309c32006-08-09 16:57:28 +020011725
11726static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11727 /*
11728 * Unmute ADC0 and set the default input to mic-in
11729 */
11730 /* port-A for surround (rear panel) */
11731 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11732 /* port-B for mic-in (rear panel) with vref */
11733 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11734 /* port-C for line-in (rear panel) */
11735 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11736 /* port-D for Front */
11737 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11738 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11739 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011740 /* this has to be set to VREF80 */
11741 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011742 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011743 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011744 /* port-F for mic-in (front panel) with vref */
11745 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11746 /* port-G for CLFE (rear panel) */
11747 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11748 /* port-H for side (rear panel) */
11749 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11750 /* CD-in */
11751 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11752 /* route front mic to ADC1*/
11753 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11755 /* Unmute DAC0~3 & spdif out*/
11756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11758 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11759 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11761
11762 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11763 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11764 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11765 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11766 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11767
11768 /* Unmute Stereo Mixer 15 */
11769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011773
11774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11776 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11778 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011782 /* hp used DAC 3 (Front) */
11783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11785 { }
11786};
11787
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011788static struct hda_verb alc861_asus_init_verbs[] = {
11789 /*
11790 * Unmute ADC0 and set the default input to mic-in
11791 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011792 /* port-A for surround (rear panel)
11793 * according to codec#0 this is the HP jack
11794 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011795 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11796 /* route front PCM to HP */
11797 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11798 /* port-B for mic-in (rear panel) with vref */
11799 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11800 /* port-C for line-in (rear panel) */
11801 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11802 /* port-D for Front */
11803 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11804 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11805 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011806 /* this has to be set to VREF80 */
11807 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011808 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011809 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011810 /* port-F for mic-in (front panel) with vref */
11811 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11812 /* port-G for CLFE (rear panel) */
11813 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11814 /* port-H for side (rear panel) */
11815 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11816 /* CD-in */
11817 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11818 /* route front mic to ADC1*/
11819 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11821 /* Unmute DAC0~3 & spdif out*/
11822 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11823 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11824 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11825 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11827 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11828 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11829 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11830 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11831 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11832
11833 /* Unmute Stereo Mixer 15 */
11834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011838
11839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11842 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11845 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11846 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011847 /* hp used DAC 3 (Front) */
11848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11850 { }
11851};
11852
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011853/* additional init verbs for ASUS laptops */
11854static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11856 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11857 { }
11858};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011859
Kailang Yangdf694da2005-12-05 19:42:22 +010011860/*
11861 * generic initialization of ADC, input mixers and output mixers
11862 */
11863static struct hda_verb alc861_auto_init_verbs[] = {
11864 /*
11865 * Unmute ADC0 and set the default input to mic-in
11866 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011867 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11869
11870 /* Unmute DAC0~3 & spdif out*/
11871 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11872 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11873 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11874 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11876
11877 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11878 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11879 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11880 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11881 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11882
11883 /* Unmute Stereo Mixer 15 */
11884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11888
11889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11894 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11897
11898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011902 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11905 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011906
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011907 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011908
11909 { }
11910};
11911
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011912static struct hda_verb alc861_toshiba_init_verbs[] = {
11913 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011914
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011915 { }
11916};
11917
11918/* toggle speaker-output according to the hp-jack state */
11919static void alc861_toshiba_automute(struct hda_codec *codec)
11920{
11921 unsigned int present;
11922
11923 present = snd_hda_codec_read(codec, 0x0f, 0,
11924 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011925 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11926 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11927 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11928 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011929}
11930
11931static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11932 unsigned int res)
11933{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011934 if ((res >> 26) == ALC880_HP_EVENT)
11935 alc861_toshiba_automute(codec);
11936}
11937
Kailang Yangdf694da2005-12-05 19:42:22 +010011938/* pcm configuration: identiacal with ALC880 */
11939#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11940#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11941#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11942#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11943
11944
11945#define ALC861_DIGOUT_NID 0x07
11946
11947static struct hda_channel_mode alc861_8ch_modes[1] = {
11948 { 8, NULL }
11949};
11950
11951static hda_nid_t alc861_dac_nids[4] = {
11952 /* front, surround, clfe, side */
11953 0x03, 0x06, 0x05, 0x04
11954};
11955
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011956static hda_nid_t alc660_dac_nids[3] = {
11957 /* front, clfe, surround */
11958 0x03, 0x05, 0x06
11959};
11960
Kailang Yangdf694da2005-12-05 19:42:22 +010011961static hda_nid_t alc861_adc_nids[1] = {
11962 /* ADC0-2 */
11963 0x08,
11964};
11965
11966static struct hda_input_mux alc861_capture_source = {
11967 .num_items = 5,
11968 .items = {
11969 { "Mic", 0x0 },
11970 { "Front Mic", 0x3 },
11971 { "Line", 0x1 },
11972 { "CD", 0x4 },
11973 { "Mixer", 0x5 },
11974 },
11975};
11976
11977/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011978static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11979 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011980{
11981 int i;
11982 hda_nid_t nid;
11983
11984 spec->multiout.dac_nids = spec->private_dac_nids;
11985 for (i = 0; i < cfg->line_outs; i++) {
11986 nid = cfg->line_out_pins[i];
11987 if (nid) {
11988 if (i >= ARRAY_SIZE(alc861_dac_nids))
11989 continue;
11990 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11991 }
11992 }
11993 spec->multiout.num_dacs = cfg->line_outs;
11994 return 0;
11995}
11996
11997/* add playback controls from the parsed DAC table */
11998static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11999 const struct auto_pin_cfg *cfg)
12000{
12001 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012002 static const char *chname[4] = {
12003 "Front", "Surround", NULL /*CLFE*/, "Side"
12004 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012005 hda_nid_t nid;
12006 int i, idx, err;
12007
12008 for (i = 0; i < cfg->line_outs; i++) {
12009 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012010 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012011 continue;
12012 if (nid == 0x05) {
12013 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012014 err = add_control(spec, ALC_CTL_BIND_MUTE,
12015 "Center Playback Switch",
12016 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12017 HDA_OUTPUT));
12018 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012020 err = add_control(spec, ALC_CTL_BIND_MUTE,
12021 "LFE Playback Switch",
12022 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12023 HDA_OUTPUT));
12024 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012025 return err;
12026 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012027 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12028 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012029 if (nid == alc861_dac_nids[idx])
12030 break;
12031 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012032 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12033 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12034 HDA_OUTPUT));
12035 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012036 return err;
12037 }
12038 }
12039 return 0;
12040}
12041
12042static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12043{
12044 int err;
12045 hda_nid_t nid;
12046
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012047 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012048 return 0;
12049
12050 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12051 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012052 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12053 "Headphone Playback Switch",
12054 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12055 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012056 return err;
12057 spec->multiout.hp_nid = nid;
12058 }
12059 return 0;
12060}
12061
12062/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012063static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12064 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012065{
Kailang Yangdf694da2005-12-05 19:42:22 +010012066 struct hda_input_mux *imux = &spec->private_imux;
12067 int i, err, idx, idx1;
12068
12069 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012070 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012071 case 0x0c:
12072 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012073 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012074 break;
12075 case 0x0f:
12076 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012077 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012078 break;
12079 case 0x0d:
12080 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012081 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012082 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012083 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012084 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012085 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012086 break;
12087 case 0x11:
12088 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012089 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012090 break;
12091 default:
12092 continue;
12093 }
12094
Takashi Iwai4a471b72005-12-07 13:56:29 +010012095 err = new_analog_input(spec, cfg->input_pins[i],
12096 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012097 if (err < 0)
12098 return err;
12099
Takashi Iwai4a471b72005-12-07 13:56:29 +010012100 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012101 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012102 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012103 }
12104 return 0;
12105}
12106
12107static struct snd_kcontrol_new alc861_capture_mixer[] = {
12108 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12109 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12110
12111 {
12112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12113 /* The multiple "Capture Source" controls confuse alsamixer
12114 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012115 */
12116 /* .name = "Capture Source", */
12117 .name = "Input Source",
12118 .count = 1,
12119 .info = alc_mux_enum_info,
12120 .get = alc_mux_enum_get,
12121 .put = alc_mux_enum_put,
12122 },
12123 { } /* end */
12124};
12125
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012126static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12127 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012128 int pin_type, int dac_idx)
12129{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012130 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12131 pin_type);
12132 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12133 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012134}
12135
12136static void alc861_auto_init_multi_out(struct hda_codec *codec)
12137{
12138 struct alc_spec *spec = codec->spec;
12139 int i;
12140
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012141 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012142 for (i = 0; i < spec->autocfg.line_outs; i++) {
12143 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012144 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012145 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012146 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012147 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012148 }
12149}
12150
12151static void alc861_auto_init_hp_out(struct hda_codec *codec)
12152{
12153 struct alc_spec *spec = codec->spec;
12154 hda_nid_t pin;
12155
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012156 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012157 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012158 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12159 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012160 pin = spec->autocfg.speaker_pins[0];
12161 if (pin)
12162 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012163}
12164
12165static void alc861_auto_init_analog_input(struct hda_codec *codec)
12166{
12167 struct alc_spec *spec = codec->spec;
12168 int i;
12169
12170 for (i = 0; i < AUTO_PIN_LAST; i++) {
12171 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012172 if (nid >= 0x0c && nid <= 0x11) {
12173 snd_hda_codec_write(codec, nid, 0,
12174 AC_VERB_SET_PIN_WIDGET_CONTROL,
12175 i <= AUTO_PIN_FRONT_MIC ?
12176 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012177 }
12178 }
12179}
12180
12181/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012182/* return 1 if successful, 0 if the proper config is not found,
12183 * or a negative error code
12184 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012185static int alc861_parse_auto_config(struct hda_codec *codec)
12186{
12187 struct alc_spec *spec = codec->spec;
12188 int err;
12189 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12190
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012191 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12192 alc861_ignore);
12193 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012194 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012195 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012196 return 0; /* can't find valid BIOS pin config */
12197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012198 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12199 if (err < 0)
12200 return err;
12201 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12202 if (err < 0)
12203 return err;
12204 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12205 if (err < 0)
12206 return err;
12207 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12208 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012209 return err;
12210
12211 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12212
12213 if (spec->autocfg.dig_out_pin)
12214 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12215
12216 if (spec->kctl_alloc)
12217 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12218
12219 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12220
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012221 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012222 spec->input_mux = &spec->private_imux;
12223
12224 spec->adc_nids = alc861_adc_nids;
12225 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12226 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12227 spec->num_mixers++;
12228
12229 return 1;
12230}
12231
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012232/* additional initialization for auto-configuration model */
12233static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012234{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012235 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012236 alc861_auto_init_multi_out(codec);
12237 alc861_auto_init_hp_out(codec);
12238 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012239 if (spec->unsol_event)
12240 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012241}
12242
Takashi Iwaicb53c622007-08-10 17:21:45 +020012243#ifdef CONFIG_SND_HDA_POWER_SAVE
12244static struct hda_amp_list alc861_loopbacks[] = {
12245 { 0x15, HDA_INPUT, 0 },
12246 { 0x15, HDA_INPUT, 1 },
12247 { 0x15, HDA_INPUT, 2 },
12248 { 0x15, HDA_INPUT, 3 },
12249 { } /* end */
12250};
12251#endif
12252
Kailang Yangdf694da2005-12-05 19:42:22 +010012253
12254/*
12255 * configuration and preset
12256 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012257static const char *alc861_models[ALC861_MODEL_LAST] = {
12258 [ALC861_3ST] = "3stack",
12259 [ALC660_3ST] = "3stack-660",
12260 [ALC861_3ST_DIG] = "3stack-dig",
12261 [ALC861_6ST_DIG] = "6stack-dig",
12262 [ALC861_UNIWILL_M31] = "uniwill-m31",
12263 [ALC861_TOSHIBA] = "toshiba",
12264 [ALC861_ASUS] = "asus",
12265 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12266 [ALC861_AUTO] = "auto",
12267};
12268
12269static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012270 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012271 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12272 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12273 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012274 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012275 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012276 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012277 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12278 * Any other models that need this preset?
12279 */
12280 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012281 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12282 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012283 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12284 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12285 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12286 /* FIXME: the below seems conflict */
12287 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12288 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12289 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012290 {}
12291};
12292
12293static struct alc_config_preset alc861_presets[] = {
12294 [ALC861_3ST] = {
12295 .mixers = { alc861_3ST_mixer },
12296 .init_verbs = { alc861_threestack_init_verbs },
12297 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12298 .dac_nids = alc861_dac_nids,
12299 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12300 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012301 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012302 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12303 .adc_nids = alc861_adc_nids,
12304 .input_mux = &alc861_capture_source,
12305 },
12306 [ALC861_3ST_DIG] = {
12307 .mixers = { alc861_base_mixer },
12308 .init_verbs = { alc861_threestack_init_verbs },
12309 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12310 .dac_nids = alc861_dac_nids,
12311 .dig_out_nid = ALC861_DIGOUT_NID,
12312 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12313 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012314 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012315 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12316 .adc_nids = alc861_adc_nids,
12317 .input_mux = &alc861_capture_source,
12318 },
12319 [ALC861_6ST_DIG] = {
12320 .mixers = { alc861_base_mixer },
12321 .init_verbs = { alc861_base_init_verbs },
12322 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12323 .dac_nids = alc861_dac_nids,
12324 .dig_out_nid = ALC861_DIGOUT_NID,
12325 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12326 .channel_mode = alc861_8ch_modes,
12327 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12328 .adc_nids = alc861_adc_nids,
12329 .input_mux = &alc861_capture_source,
12330 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012331 [ALC660_3ST] = {
12332 .mixers = { alc861_3ST_mixer },
12333 .init_verbs = { alc861_threestack_init_verbs },
12334 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12335 .dac_nids = alc660_dac_nids,
12336 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12337 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012338 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012339 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12340 .adc_nids = alc861_adc_nids,
12341 .input_mux = &alc861_capture_source,
12342 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012343 [ALC861_UNIWILL_M31] = {
12344 .mixers = { alc861_uniwill_m31_mixer },
12345 .init_verbs = { alc861_uniwill_m31_init_verbs },
12346 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12347 .dac_nids = alc861_dac_nids,
12348 .dig_out_nid = ALC861_DIGOUT_NID,
12349 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12350 .channel_mode = alc861_uniwill_m31_modes,
12351 .need_dac_fix = 1,
12352 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12353 .adc_nids = alc861_adc_nids,
12354 .input_mux = &alc861_capture_source,
12355 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012356 [ALC861_TOSHIBA] = {
12357 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012358 .init_verbs = { alc861_base_init_verbs,
12359 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012360 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12361 .dac_nids = alc861_dac_nids,
12362 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12363 .channel_mode = alc883_3ST_2ch_modes,
12364 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12365 .adc_nids = alc861_adc_nids,
12366 .input_mux = &alc861_capture_source,
12367 .unsol_event = alc861_toshiba_unsol_event,
12368 .init_hook = alc861_toshiba_automute,
12369 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012370 [ALC861_ASUS] = {
12371 .mixers = { alc861_asus_mixer },
12372 .init_verbs = { alc861_asus_init_verbs },
12373 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12374 .dac_nids = alc861_dac_nids,
12375 .dig_out_nid = ALC861_DIGOUT_NID,
12376 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12377 .channel_mode = alc861_asus_modes,
12378 .need_dac_fix = 1,
12379 .hp_nid = 0x06,
12380 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12381 .adc_nids = alc861_adc_nids,
12382 .input_mux = &alc861_capture_source,
12383 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012384 [ALC861_ASUS_LAPTOP] = {
12385 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12386 .init_verbs = { alc861_asus_init_verbs,
12387 alc861_asus_laptop_init_verbs },
12388 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12389 .dac_nids = alc861_dac_nids,
12390 .dig_out_nid = ALC861_DIGOUT_NID,
12391 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12392 .channel_mode = alc883_3ST_2ch_modes,
12393 .need_dac_fix = 1,
12394 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12395 .adc_nids = alc861_adc_nids,
12396 .input_mux = &alc861_capture_source,
12397 },
12398};
Kailang Yangdf694da2005-12-05 19:42:22 +010012399
12400
12401static int patch_alc861(struct hda_codec *codec)
12402{
12403 struct alc_spec *spec;
12404 int board_config;
12405 int err;
12406
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012407 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012408 if (spec == NULL)
12409 return -ENOMEM;
12410
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012411 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012412
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012413 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12414 alc861_models,
12415 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012416
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012417 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012418 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12419 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012420 board_config = ALC861_AUTO;
12421 }
12422
12423 if (board_config == ALC861_AUTO) {
12424 /* automatic parse from the BIOS config */
12425 err = alc861_parse_auto_config(codec);
12426 if (err < 0) {
12427 alc_free(codec);
12428 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012429 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012430 printk(KERN_INFO
12431 "hda_codec: Cannot set up configuration "
12432 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012433 board_config = ALC861_3ST_DIG;
12434 }
12435 }
12436
12437 if (board_config != ALC861_AUTO)
12438 setup_preset(spec, &alc861_presets[board_config]);
12439
12440 spec->stream_name_analog = "ALC861 Analog";
12441 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12442 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12443
12444 spec->stream_name_digital = "ALC861 Digital";
12445 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12446 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12447
Takashi Iwai2134ea42008-01-10 16:53:55 +010012448 spec->vmaster_nid = 0x03;
12449
Kailang Yangdf694da2005-12-05 19:42:22 +010012450 codec->patch_ops = alc_patch_ops;
12451 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012452 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012453#ifdef CONFIG_SND_HDA_POWER_SAVE
12454 if (!spec->loopback.amplist)
12455 spec->loopback.amplist = alc861_loopbacks;
12456#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012457
12458 return 0;
12459}
12460
12461/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012462 * ALC861-VD support
12463 *
12464 * Based on ALC882
12465 *
12466 * In addition, an independent DAC
12467 */
12468#define ALC861VD_DIGOUT_NID 0x06
12469
12470static hda_nid_t alc861vd_dac_nids[4] = {
12471 /* front, surr, clfe, side surr */
12472 0x02, 0x03, 0x04, 0x05
12473};
12474
12475/* dac_nids for ALC660vd are in a different order - according to
12476 * Realtek's driver.
12477 * This should probably tesult in a different mixer for 6stack models
12478 * of ALC660vd codecs, but for now there is only 3stack mixer
12479 * - and it is the same as in 861vd.
12480 * adc_nids in ALC660vd are (is) the same as in 861vd
12481 */
12482static hda_nid_t alc660vd_dac_nids[3] = {
12483 /* front, rear, clfe, rear_surr */
12484 0x02, 0x04, 0x03
12485};
12486
12487static hda_nid_t alc861vd_adc_nids[1] = {
12488 /* ADC0 */
12489 0x09,
12490};
12491
Takashi Iwaie1406342008-02-11 18:32:32 +010012492static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12493
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012494/* input MUX */
12495/* FIXME: should be a matrix-type input source selection */
12496static struct hda_input_mux alc861vd_capture_source = {
12497 .num_items = 4,
12498 .items = {
12499 { "Mic", 0x0 },
12500 { "Front Mic", 0x1 },
12501 { "Line", 0x2 },
12502 { "CD", 0x4 },
12503 },
12504};
12505
Kailang Yang272a5272007-05-14 11:00:38 +020012506static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012507 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012508 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012509 { "Ext Mic", 0x0 },
12510 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012511 },
12512};
12513
Kailang Yangd1a991a2007-08-15 16:21:59 +020012514static struct hda_input_mux alc861vd_hp_capture_source = {
12515 .num_items = 2,
12516 .items = {
12517 { "Front Mic", 0x0 },
12518 { "ATAPI Mic", 0x1 },
12519 },
12520};
12521
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012522#define alc861vd_mux_enum_info alc_mux_enum_info
12523#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012524/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12525#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012526
12527/*
12528 * 2ch mode
12529 */
12530static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12531 { 2, NULL }
12532};
12533
12534/*
12535 * 6ch mode
12536 */
12537static struct hda_verb alc861vd_6stack_ch6_init[] = {
12538 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12540 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12541 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12542 { } /* end */
12543};
12544
12545/*
12546 * 8ch mode
12547 */
12548static struct hda_verb alc861vd_6stack_ch8_init[] = {
12549 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12550 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12551 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12552 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12553 { } /* end */
12554};
12555
12556static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12557 { 6, alc861vd_6stack_ch6_init },
12558 { 8, alc861vd_6stack_ch8_init },
12559};
12560
12561static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12562 {
12563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12564 .name = "Channel Mode",
12565 .info = alc_ch_mode_info,
12566 .get = alc_ch_mode_get,
12567 .put = alc_ch_mode_put,
12568 },
12569 { } /* end */
12570};
12571
12572static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12573 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12574 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12575
12576 {
12577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12578 /* The multiple "Capture Source" controls confuse alsamixer
12579 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012580 */
12581 /* .name = "Capture Source", */
12582 .name = "Input Source",
12583 .count = 1,
12584 .info = alc861vd_mux_enum_info,
12585 .get = alc861vd_mux_enum_get,
12586 .put = alc861vd_mux_enum_put,
12587 },
12588 { } /* end */
12589};
12590
12591/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12592 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12593 */
12594static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12595 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12596 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12597
12598 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12599 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12600
12601 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12602 HDA_OUTPUT),
12603 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12604 HDA_OUTPUT),
12605 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12606 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12607
12608 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12609 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12610
12611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12612
12613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12616
12617 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12620
12621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12623
12624 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12625 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12626
12627 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12628 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12629
12630 { } /* end */
12631};
12632
12633static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12634 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12636
12637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12638
12639 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12642
12643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12644 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12645 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12646
12647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12649
12650 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12651 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12652
12653 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12654 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12655
12656 { } /* end */
12657};
12658
Kailang Yangbdd148a2007-05-08 15:19:08 +020012659static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12660 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12661 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12662 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12663
12664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12665
12666 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12669
12670 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12671 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12672 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12673
12674 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12675 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12676
12677 { } /* end */
12678};
12679
Tobin Davisb419f342008-03-07 11:57:51 +010012680/* Pin assignment: Speaker=0x14, HP = 0x15,
12681 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012682 */
12683static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012684 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12685 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012686 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12687 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012688 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12689 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12690 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12691 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12692 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12693 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12694 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12695 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012696 { } /* end */
12697};
12698
Kailang Yangd1a991a2007-08-15 16:21:59 +020012699/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12700 * Front Mic=0x18, ATAPI Mic = 0x19,
12701 */
12702static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12703 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12705 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12706 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12709 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12710 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12711
12712 { } /* end */
12713};
12714
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012715/*
12716 * generic initialization of ADC, input mixers and output mixers
12717 */
12718static struct hda_verb alc861vd_volume_init_verbs[] = {
12719 /*
12720 * Unmute ADC0 and set the default input to mic-in
12721 */
12722 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12724
12725 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12726 * the analog-loopback mixer widget
12727 */
12728 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012734
12735 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012740
12741 /*
12742 * Set up output mixers (0x02 - 0x05)
12743 */
12744 /* set vol=0 to output mixers */
12745 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12746 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12747 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12748 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12749
12750 /* set up input amps for analog loopback */
12751 /* Amp Indices: DAC = 0, mixer = 1 */
12752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12758 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12760
12761 { }
12762};
12763
12764/*
12765 * 3-stack pin configuration:
12766 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12767 */
12768static struct hda_verb alc861vd_3stack_init_verbs[] = {
12769 /*
12770 * Set pin mode and muting
12771 */
12772 /* set front pin widgets 0x14 for output */
12773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12774 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12775 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12776
12777 /* Mic (rear) pin: input vref at 80% */
12778 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12780 /* Front Mic pin: input vref at 80% */
12781 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12782 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12783 /* Line In pin: input */
12784 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12786 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12789 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12790 /* CD pin widget for input */
12791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12792
12793 { }
12794};
12795
12796/*
12797 * 6-stack pin configuration:
12798 */
12799static struct hda_verb alc861vd_6stack_init_verbs[] = {
12800 /*
12801 * Set pin mode and muting
12802 */
12803 /* set front pin widgets 0x14 for output */
12804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12807
12808 /* Rear Pin: output 1 (0x0d) */
12809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12812 /* CLFE Pin: output 2 (0x0e) */
12813 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12814 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12815 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12816 /* Side Pin: output 3 (0x0f) */
12817 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12819 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12820
12821 /* Mic (rear) pin: input vref at 80% */
12822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12824 /* Front Mic pin: input vref at 80% */
12825 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12827 /* Line In pin: input */
12828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12830 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12833 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12834 /* CD pin widget for input */
12835 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12836
12837 { }
12838};
12839
Kailang Yangbdd148a2007-05-08 15:19:08 +020012840static struct hda_verb alc861vd_eapd_verbs[] = {
12841 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12842 { }
12843};
12844
Kailang Yangf9423e72008-05-27 12:32:25 +020012845static struct hda_verb alc660vd_eapd_verbs[] = {
12846 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12847 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12848 { }
12849};
12850
Kailang Yangbdd148a2007-05-08 15:19:08 +020012851static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12856 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12857 {}
12858};
12859
12860/* toggle speaker-output according to the hp-jack state */
12861static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12862{
12863 unsigned int present;
12864 unsigned char bits;
12865
12866 present = snd_hda_codec_read(codec, 0x1b, 0,
12867 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012868 bits = present ? HDA_AMP_MUTE : 0;
12869 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12870 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012871}
12872
12873static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12874{
12875 unsigned int present;
12876 unsigned char bits;
12877
12878 present = snd_hda_codec_read(codec, 0x18, 0,
12879 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012880 bits = present ? HDA_AMP_MUTE : 0;
12881 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12882 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012883}
12884
12885static void alc861vd_lenovo_automute(struct hda_codec *codec)
12886{
12887 alc861vd_lenovo_hp_automute(codec);
12888 alc861vd_lenovo_mic_automute(codec);
12889}
12890
12891static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12892 unsigned int res)
12893{
12894 switch (res >> 26) {
12895 case ALC880_HP_EVENT:
12896 alc861vd_lenovo_hp_automute(codec);
12897 break;
12898 case ALC880_MIC_EVENT:
12899 alc861vd_lenovo_mic_automute(codec);
12900 break;
12901 }
12902}
12903
Kailang Yang272a5272007-05-14 11:00:38 +020012904static struct hda_verb alc861vd_dallas_verbs[] = {
12905 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12906 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12907 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12908 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12909
12910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12912 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12914 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12916 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12918
12919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12922 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12923 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12924 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12927
12928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12933 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12934 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12935 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12936
12937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12941
12942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12943 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12944 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12945
12946 { } /* end */
12947};
12948
12949/* toggle speaker-output according to the hp-jack state */
12950static void alc861vd_dallas_automute(struct hda_codec *codec)
12951{
12952 unsigned int present;
12953
12954 present = snd_hda_codec_read(codec, 0x15, 0,
12955 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012956 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12957 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012958}
12959
12960static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12961{
12962 if ((res >> 26) == ALC880_HP_EVENT)
12963 alc861vd_dallas_automute(codec);
12964}
12965
Takashi Iwaicb53c622007-08-10 17:21:45 +020012966#ifdef CONFIG_SND_HDA_POWER_SAVE
12967#define alc861vd_loopbacks alc880_loopbacks
12968#endif
12969
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012970/* pcm configuration: identiacal with ALC880 */
12971#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12972#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12973#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12974#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12975
12976/*
12977 * configuration and preset
12978 */
12979static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12980 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012981 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012982 [ALC861VD_3ST] = "3stack",
12983 [ALC861VD_3ST_DIG] = "3stack-digout",
12984 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012985 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012986 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012987 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012988 [ALC861VD_AUTO] = "auto",
12989};
12990
12991static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012992 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12993 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012994 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012995 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012996 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012997 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012998 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012999 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013000 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013001 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013002 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013003 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013004 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13005 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013006 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013007 {}
13008};
13009
13010static struct alc_config_preset alc861vd_presets[] = {
13011 [ALC660VD_3ST] = {
13012 .mixers = { alc861vd_3st_mixer },
13013 .init_verbs = { alc861vd_volume_init_verbs,
13014 alc861vd_3stack_init_verbs },
13015 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13016 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013017 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13018 .channel_mode = alc861vd_3stack_2ch_modes,
13019 .input_mux = &alc861vd_capture_source,
13020 },
Mike Crash6963f842007-06-25 12:12:51 +020013021 [ALC660VD_3ST_DIG] = {
13022 .mixers = { alc861vd_3st_mixer },
13023 .init_verbs = { alc861vd_volume_init_verbs,
13024 alc861vd_3stack_init_verbs },
13025 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13026 .dac_nids = alc660vd_dac_nids,
13027 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013028 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13029 .channel_mode = alc861vd_3stack_2ch_modes,
13030 .input_mux = &alc861vd_capture_source,
13031 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013032 [ALC861VD_3ST] = {
13033 .mixers = { alc861vd_3st_mixer },
13034 .init_verbs = { alc861vd_volume_init_verbs,
13035 alc861vd_3stack_init_verbs },
13036 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13037 .dac_nids = alc861vd_dac_nids,
13038 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13039 .channel_mode = alc861vd_3stack_2ch_modes,
13040 .input_mux = &alc861vd_capture_source,
13041 },
13042 [ALC861VD_3ST_DIG] = {
13043 .mixers = { alc861vd_3st_mixer },
13044 .init_verbs = { alc861vd_volume_init_verbs,
13045 alc861vd_3stack_init_verbs },
13046 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13047 .dac_nids = alc861vd_dac_nids,
13048 .dig_out_nid = ALC861VD_DIGOUT_NID,
13049 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13050 .channel_mode = alc861vd_3stack_2ch_modes,
13051 .input_mux = &alc861vd_capture_source,
13052 },
13053 [ALC861VD_6ST_DIG] = {
13054 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13055 .init_verbs = { alc861vd_volume_init_verbs,
13056 alc861vd_6stack_init_verbs },
13057 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13058 .dac_nids = alc861vd_dac_nids,
13059 .dig_out_nid = ALC861VD_DIGOUT_NID,
13060 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13061 .channel_mode = alc861vd_6stack_modes,
13062 .input_mux = &alc861vd_capture_source,
13063 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013064 [ALC861VD_LENOVO] = {
13065 .mixers = { alc861vd_lenovo_mixer },
13066 .init_verbs = { alc861vd_volume_init_verbs,
13067 alc861vd_3stack_init_verbs,
13068 alc861vd_eapd_verbs,
13069 alc861vd_lenovo_unsol_verbs },
13070 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13071 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013072 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13073 .channel_mode = alc861vd_3stack_2ch_modes,
13074 .input_mux = &alc861vd_capture_source,
13075 .unsol_event = alc861vd_lenovo_unsol_event,
13076 .init_hook = alc861vd_lenovo_automute,
13077 },
Kailang Yang272a5272007-05-14 11:00:38 +020013078 [ALC861VD_DALLAS] = {
13079 .mixers = { alc861vd_dallas_mixer },
13080 .init_verbs = { alc861vd_dallas_verbs },
13081 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13082 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013083 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13084 .channel_mode = alc861vd_3stack_2ch_modes,
13085 .input_mux = &alc861vd_dallas_capture_source,
13086 .unsol_event = alc861vd_dallas_unsol_event,
13087 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013088 },
13089 [ALC861VD_HP] = {
13090 .mixers = { alc861vd_hp_mixer },
13091 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13092 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13093 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013094 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013095 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13096 .channel_mode = alc861vd_3stack_2ch_modes,
13097 .input_mux = &alc861vd_hp_capture_source,
13098 .unsol_event = alc861vd_dallas_unsol_event,
13099 .init_hook = alc861vd_dallas_automute,
13100 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013101};
13102
13103/*
13104 * BIOS auto configuration
13105 */
13106static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13107 hda_nid_t nid, int pin_type, int dac_idx)
13108{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013109 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013110}
13111
13112static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13113{
13114 struct alc_spec *spec = codec->spec;
13115 int i;
13116
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013117 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013118 for (i = 0; i <= HDA_SIDE; i++) {
13119 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013120 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013121 if (nid)
13122 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013123 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013124 }
13125}
13126
13127
13128static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13129{
13130 struct alc_spec *spec = codec->spec;
13131 hda_nid_t pin;
13132
13133 pin = spec->autocfg.hp_pins[0];
13134 if (pin) /* connect to front and use dac 0 */
13135 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013136 pin = spec->autocfg.speaker_pins[0];
13137 if (pin)
13138 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013139}
13140
13141#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13142#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13143
13144static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13145{
13146 struct alc_spec *spec = codec->spec;
13147 int i;
13148
13149 for (i = 0; i < AUTO_PIN_LAST; i++) {
13150 hda_nid_t nid = spec->autocfg.input_pins[i];
13151 if (alc861vd_is_input_pin(nid)) {
13152 snd_hda_codec_write(codec, nid, 0,
13153 AC_VERB_SET_PIN_WIDGET_CONTROL,
13154 i <= AUTO_PIN_FRONT_MIC ?
13155 PIN_VREF80 : PIN_IN);
13156 if (nid != ALC861VD_PIN_CD_NID)
13157 snd_hda_codec_write(codec, nid, 0,
13158 AC_VERB_SET_AMP_GAIN_MUTE,
13159 AMP_OUT_MUTE);
13160 }
13161 }
13162}
13163
13164#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13165#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13166
13167/* add playback controls from the parsed DAC table */
13168/* Based on ALC880 version. But ALC861VD has separate,
13169 * different NIDs for mute/unmute switch and volume control */
13170static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13171 const struct auto_pin_cfg *cfg)
13172{
13173 char name[32];
13174 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13175 hda_nid_t nid_v, nid_s;
13176 int i, err;
13177
13178 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013179 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013180 continue;
13181 nid_v = alc861vd_idx_to_mixer_vol(
13182 alc880_dac_to_idx(
13183 spec->multiout.dac_nids[i]));
13184 nid_s = alc861vd_idx_to_mixer_switch(
13185 alc880_dac_to_idx(
13186 spec->multiout.dac_nids[i]));
13187
13188 if (i == 2) {
13189 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013190 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13191 "Center Playback Volume",
13192 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13193 HDA_OUTPUT));
13194 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013195 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013196 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13197 "LFE Playback Volume",
13198 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13199 HDA_OUTPUT));
13200 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013202 err = add_control(spec, ALC_CTL_BIND_MUTE,
13203 "Center Playback Switch",
13204 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13205 HDA_INPUT));
13206 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013207 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013208 err = add_control(spec, ALC_CTL_BIND_MUTE,
13209 "LFE Playback Switch",
13210 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13211 HDA_INPUT));
13212 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013213 return err;
13214 } else {
13215 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013216 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13217 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13218 HDA_OUTPUT));
13219 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013220 return err;
13221 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013223 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013224 HDA_INPUT));
13225 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013226 return err;
13227 }
13228 }
13229 return 0;
13230}
13231
13232/* add playback controls for speaker and HP outputs */
13233/* Based on ALC880 version. But ALC861VD has separate,
13234 * different NIDs for mute/unmute switch and volume control */
13235static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13236 hda_nid_t pin, const char *pfx)
13237{
13238 hda_nid_t nid_v, nid_s;
13239 int err;
13240 char name[32];
13241
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013242 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013243 return 0;
13244
13245 if (alc880_is_fixed_pin(pin)) {
13246 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13247 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013248 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013249 spec->multiout.hp_nid = nid_v;
13250 else
13251 spec->multiout.extra_out_nid[0] = nid_v;
13252 /* control HP volume/switch on the output mixer amp */
13253 nid_v = alc861vd_idx_to_mixer_vol(
13254 alc880_fixed_pin_idx(pin));
13255 nid_s = alc861vd_idx_to_mixer_switch(
13256 alc880_fixed_pin_idx(pin));
13257
13258 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013259 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13260 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13261 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013262 return err;
13263 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013264 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13265 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13266 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013267 return err;
13268 } else if (alc880_is_multi_pin(pin)) {
13269 /* set manual connection */
13270 /* we have only a switch on HP-out PIN */
13271 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013272 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13273 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13274 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013275 return err;
13276 }
13277 return 0;
13278}
13279
13280/* parse the BIOS configuration and set up the alc_spec
13281 * return 1 if successful, 0 if the proper config is not found,
13282 * or a negative error code
13283 * Based on ALC880 version - had to change it to override
13284 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13285static int alc861vd_parse_auto_config(struct hda_codec *codec)
13286{
13287 struct alc_spec *spec = codec->spec;
13288 int err;
13289 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13290
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013291 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13292 alc861vd_ignore);
13293 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013294 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013295 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013296 return 0; /* can't find valid BIOS pin config */
13297
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013298 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13299 if (err < 0)
13300 return err;
13301 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13302 if (err < 0)
13303 return err;
13304 err = alc861vd_auto_create_extra_out(spec,
13305 spec->autocfg.speaker_pins[0],
13306 "Speaker");
13307 if (err < 0)
13308 return err;
13309 err = alc861vd_auto_create_extra_out(spec,
13310 spec->autocfg.hp_pins[0],
13311 "Headphone");
13312 if (err < 0)
13313 return err;
13314 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13315 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013316 return err;
13317
13318 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13319
13320 if (spec->autocfg.dig_out_pin)
13321 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13322
13323 if (spec->kctl_alloc)
13324 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13325
13326 spec->init_verbs[spec->num_init_verbs++]
13327 = alc861vd_volume_init_verbs;
13328
13329 spec->num_mux_defs = 1;
13330 spec->input_mux = &spec->private_imux;
13331
Takashi Iwai776e1842007-08-29 15:07:11 +020013332 err = alc_auto_add_mic_boost(codec);
13333 if (err < 0)
13334 return err;
13335
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013336 return 1;
13337}
13338
13339/* additional initialization for auto-configuration model */
13340static void alc861vd_auto_init(struct hda_codec *codec)
13341{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013342 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013343 alc861vd_auto_init_multi_out(codec);
13344 alc861vd_auto_init_hp_out(codec);
13345 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013346 if (spec->unsol_event)
13347 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013348}
13349
13350static int patch_alc861vd(struct hda_codec *codec)
13351{
13352 struct alc_spec *spec;
13353 int err, board_config;
13354
13355 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13356 if (spec == NULL)
13357 return -ENOMEM;
13358
13359 codec->spec = spec;
13360
13361 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13362 alc861vd_models,
13363 alc861vd_cfg_tbl);
13364
13365 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13366 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13367 "ALC861VD, trying auto-probe from BIOS...\n");
13368 board_config = ALC861VD_AUTO;
13369 }
13370
13371 if (board_config == ALC861VD_AUTO) {
13372 /* automatic parse from the BIOS config */
13373 err = alc861vd_parse_auto_config(codec);
13374 if (err < 0) {
13375 alc_free(codec);
13376 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013377 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013378 printk(KERN_INFO
13379 "hda_codec: Cannot set up configuration "
13380 "from BIOS. Using base mode...\n");
13381 board_config = ALC861VD_3ST;
13382 }
13383 }
13384
13385 if (board_config != ALC861VD_AUTO)
13386 setup_preset(spec, &alc861vd_presets[board_config]);
13387
Kailang Yang2f893282008-05-27 12:14:47 +020013388 if (codec->vendor_id == 0x10ec0660) {
13389 spec->stream_name_analog = "ALC660-VD Analog";
13390 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013391 /* always turn on EAPD */
13392 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013393 } else {
13394 spec->stream_name_analog = "ALC861VD Analog";
13395 spec->stream_name_digital = "ALC861VD Digital";
13396 }
13397
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013398 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13399 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13400
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013401 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13402 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13403
13404 spec->adc_nids = alc861vd_adc_nids;
13405 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013406 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013407
13408 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13409 spec->num_mixers++;
13410
Takashi Iwai2134ea42008-01-10 16:53:55 +010013411 spec->vmaster_nid = 0x02;
13412
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013413 codec->patch_ops = alc_patch_ops;
13414
13415 if (board_config == ALC861VD_AUTO)
13416 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013417#ifdef CONFIG_SND_HDA_POWER_SAVE
13418 if (!spec->loopback.amplist)
13419 spec->loopback.amplist = alc861vd_loopbacks;
13420#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013421
13422 return 0;
13423}
13424
13425/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013426 * ALC662 support
13427 *
13428 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13429 * configuration. Each pin widget can choose any input DACs and a mixer.
13430 * Each ADC is connected from a mixer of all inputs. This makes possible
13431 * 6-channel independent captures.
13432 *
13433 * In addition, an independent DAC for the multi-playback (not used in this
13434 * driver yet).
13435 */
13436#define ALC662_DIGOUT_NID 0x06
13437#define ALC662_DIGIN_NID 0x0a
13438
13439static hda_nid_t alc662_dac_nids[4] = {
13440 /* front, rear, clfe, rear_surr */
13441 0x02, 0x03, 0x04
13442};
13443
13444static hda_nid_t alc662_adc_nids[1] = {
13445 /* ADC1-2 */
13446 0x09,
13447};
Takashi Iwaie1406342008-02-11 18:32:32 +010013448
Kailang Yang77a261b2008-02-19 11:38:05 +010013449static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013450
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013451/* input MUX */
13452/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013453static struct hda_input_mux alc662_capture_source = {
13454 .num_items = 4,
13455 .items = {
13456 { "Mic", 0x0 },
13457 { "Front Mic", 0x1 },
13458 { "Line", 0x2 },
13459 { "CD", 0x4 },
13460 },
13461};
13462
13463static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13464 .num_items = 2,
13465 .items = {
13466 { "Mic", 0x1 },
13467 { "Line", 0x2 },
13468 },
13469};
Kailang Yang291702f2007-10-16 14:28:03 +020013470
13471static struct hda_input_mux alc662_eeepc_capture_source = {
13472 .num_items = 2,
13473 .items = {
13474 { "i-Mic", 0x1 },
13475 { "e-Mic", 0x0 },
13476 },
13477};
13478
Kailang Yang6dda9f42008-05-27 12:05:31 +020013479static struct hda_input_mux alc663_capture_source = {
13480 .num_items = 3,
13481 .items = {
13482 { "Mic", 0x0 },
13483 { "Front Mic", 0x1 },
13484 { "Line", 0x2 },
13485 },
13486};
13487
13488static struct hda_input_mux alc663_m51va_capture_source = {
13489 .num_items = 2,
13490 .items = {
13491 { "Ext-Mic", 0x0 },
13492 { "D-Mic", 0x9 },
13493 },
13494};
13495
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013496#define alc662_mux_enum_info alc_mux_enum_info
13497#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013498#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013499
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013500/*
13501 * 2ch mode
13502 */
13503static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13504 { 2, NULL }
13505};
13506
13507/*
13508 * 2ch mode
13509 */
13510static struct hda_verb alc662_3ST_ch2_init[] = {
13511 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13512 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13513 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13514 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13515 { } /* end */
13516};
13517
13518/*
13519 * 6ch mode
13520 */
13521static struct hda_verb alc662_3ST_ch6_init[] = {
13522 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13523 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13524 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13525 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13526 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13527 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13528 { } /* end */
13529};
13530
13531static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13532 { 2, alc662_3ST_ch2_init },
13533 { 6, alc662_3ST_ch6_init },
13534};
13535
13536/*
13537 * 2ch mode
13538 */
13539static struct hda_verb alc662_sixstack_ch6_init[] = {
13540 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13541 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13542 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13543 { } /* end */
13544};
13545
13546/*
13547 * 6ch mode
13548 */
13549static struct hda_verb alc662_sixstack_ch8_init[] = {
13550 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13551 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13552 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13553 { } /* end */
13554};
13555
13556static struct hda_channel_mode alc662_5stack_modes[2] = {
13557 { 2, alc662_sixstack_ch6_init },
13558 { 6, alc662_sixstack_ch8_init },
13559};
13560
13561/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13562 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13563 */
13564
13565static struct snd_kcontrol_new alc662_base_mixer[] = {
13566 /* output mixer control */
13567 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013568 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013569 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013570 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013571 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13572 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013573 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13574 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013575 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13576
13577 /*Input mixer control */
13578 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13579 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13580 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13581 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13582 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13583 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13584 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13585 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013586 { } /* end */
13587};
13588
13589static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13590 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013591 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13601 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13602 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013603 { } /* end */
13604};
13605
13606static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13607 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013608 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013609 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013610 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013611 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13612 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013613 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13614 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13616 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13617 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13623 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13624 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13625 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013626 { } /* end */
13627};
13628
13629static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13630 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13631 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013632 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13633 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13635 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13636 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013639 { } /* end */
13640};
13641
Kailang Yang291702f2007-10-16 14:28:03 +020013642static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013643 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013644
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013645 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13646 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013647
13648 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13649 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13650 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13651
13652 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13653 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13654 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13655 { } /* end */
13656};
13657
Kailang Yang8c427222008-01-10 13:03:59 +010013658static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013659 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13660 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13662 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013667 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013668 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13673 { } /* end */
13674};
13675
Kailang Yang6dda9f42008-05-27 12:05:31 +020013676static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13677 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13678 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13682 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13683 { } /* end */
13684};
13685
13686static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13687 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13688 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13689 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13690 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13692
13693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13695 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13696 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13697 { } /* end */
13698};
13699
13700static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13701 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13702 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13704
13705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13707 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13708 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13709 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13710 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13711 { } /* end */
13712};
13713
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013714static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13715 {
13716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13717 .name = "Channel Mode",
13718 .info = alc_ch_mode_info,
13719 .get = alc_ch_mode_get,
13720 .put = alc_ch_mode_put,
13721 },
13722 { } /* end */
13723};
13724
13725static struct hda_verb alc662_init_verbs[] = {
13726 /* ADC: mute amp left and right */
13727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13728 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13729 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13730
Takashi Iwaicb53c622007-08-10 17:21:45 +020013731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013736
Kailang Yangb60dd392007-09-20 12:50:29 +020013737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013743
13744 /* Front Pin: output 0 (0x0c) */
13745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13747
13748 /* Rear Pin: output 1 (0x0d) */
13749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13751
13752 /* CLFE Pin: output 2 (0x0e) */
13753 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13754 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13755
13756 /* Mic (rear) pin: input vref at 80% */
13757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13759 /* Front Mic pin: input vref at 80% */
13760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13762 /* Line In pin: input */
13763 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13765 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13767 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13768 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13769 /* CD pin widget for input */
13770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13771
13772 /* FIXME: use matrix-type input source selection */
13773 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13774 /* Input mixer */
13775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013779
13780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020013784
13785 /* always trun on EAPD */
13786 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13787 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13788
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013789 { }
13790};
13791
13792static struct hda_verb alc662_sue_init_verbs[] = {
13793 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13794 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013795 {}
13796};
13797
13798static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13799 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13800 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13801 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013802};
13803
Kailang Yang8c427222008-01-10 13:03:59 +010013804/* Set Unsolicited Event*/
13805static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13807 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13808 {}
13809};
13810
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013811/*
13812 * generic initialization of ADC, input mixers and output mixers
13813 */
13814static struct hda_verb alc662_auto_init_verbs[] = {
13815 /*
13816 * Unmute ADC and set the default input to mic-in
13817 */
13818 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13819 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13820
13821 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13822 * mixer widget
13823 * Note: PASD motherboards uses the Line In 2 as the input for front
13824 * panel mic (mic 2)
13825 */
13826 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013832
13833 /*
13834 * Set up output mixers (0x0c - 0x0f)
13835 */
13836 /* set vol=0 to output mixers */
13837 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13838 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13839 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13840
13841 /* set up input amps for analog loopback */
13842 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013849
13850
13851 /* FIXME: use matrix-type input source selection */
13852 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13853 /* Input mixer */
13854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013856 { }
13857};
13858
Kailang Yang6dda9f42008-05-27 12:05:31 +020013859static struct hda_verb alc663_m51va_init_verbs[] = {
13860 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13861 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13862 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13863
13864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
13865
13866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13867 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13868 {}
13869};
13870
13871static struct hda_verb alc663_g71v_init_verbs[] = {
13872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13873 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
13874 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
13875
13876 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13877 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13878 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13879
13880 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13881 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
13882 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13883 {}
13884};
13885
13886static struct hda_verb alc663_g50v_init_verbs[] = {
13887 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13888 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13889 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13890
13891 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13892 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13893 {}
13894};
13895
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013896/* capture mixer elements */
13897static struct snd_kcontrol_new alc662_capture_mixer[] = {
13898 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13899 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13900 {
13901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13902 /* The multiple "Capture Source" controls confuse alsamixer
13903 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013904 */
13905 /* .name = "Capture Source", */
13906 .name = "Input Source",
13907 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013908 .info = alc662_mux_enum_info,
13909 .get = alc662_mux_enum_get,
13910 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013911 },
13912 { } /* end */
13913};
13914
13915static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13916{
13917 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013918 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013919
13920 present = snd_hda_codec_read(codec, 0x14, 0,
13921 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013922 bits = present ? HDA_AMP_MUTE : 0;
13923 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13924 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013925}
13926
13927static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13928{
13929 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013930 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013931
13932 present = snd_hda_codec_read(codec, 0x1b, 0,
13933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013934 bits = present ? HDA_AMP_MUTE : 0;
13935 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13936 HDA_AMP_MUTE, bits);
13937 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13938 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013939}
13940
13941static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13942 unsigned int res)
13943{
13944 if ((res >> 26) == ALC880_HP_EVENT)
13945 alc662_lenovo_101e_all_automute(codec);
13946 if ((res >> 26) == ALC880_FRONT_EVENT)
13947 alc662_lenovo_101e_ispeaker_automute(codec);
13948}
13949
Kailang Yang291702f2007-10-16 14:28:03 +020013950static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13951{
13952 unsigned int present;
13953
13954 present = snd_hda_codec_read(codec, 0x18, 0,
13955 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13956 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13957 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13958 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13959 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13960 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13961 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13962 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13963 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13964}
13965
13966/* unsolicited event for HP jack sensing */
13967static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13968 unsigned int res)
13969{
13970 if ((res >> 26) == ALC880_HP_EVENT)
13971 alc262_hippo1_automute( codec );
13972
13973 if ((res >> 26) == ALC880_MIC_EVENT)
13974 alc662_eeepc_mic_automute(codec);
13975}
13976
13977static void alc662_eeepc_inithook(struct hda_codec *codec)
13978{
13979 alc262_hippo1_automute( codec );
13980 alc662_eeepc_mic_automute(codec);
13981}
13982
Kailang Yang8c427222008-01-10 13:03:59 +010013983static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13984{
13985 unsigned int mute;
13986 unsigned int present;
13987
13988 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13989 present = snd_hda_codec_read(codec, 0x14, 0,
13990 AC_VERB_GET_PIN_SENSE, 0);
13991 present = (present & 0x80000000) != 0;
13992 if (present) {
13993 /* mute internal speaker */
13994 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13995 HDA_AMP_MUTE, HDA_AMP_MUTE);
13996 } else {
13997 /* unmute internal speaker if necessary */
13998 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13999 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
14000 HDA_AMP_MUTE, mute);
14001 }
14002}
14003
14004/* unsolicited event for HP jack sensing */
14005static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14006 unsigned int res)
14007{
14008 if ((res >> 26) == ALC880_HP_EVENT)
14009 alc662_eeepc_ep20_automute(codec);
14010}
14011
14012static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14013{
14014 alc662_eeepc_ep20_automute(codec);
14015}
14016
Kailang Yang6dda9f42008-05-27 12:05:31 +020014017static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14018{
14019 unsigned int present;
14020 unsigned char bits;
14021
14022 present = snd_hda_codec_read(codec, 0x21, 0,
14023 AC_VERB_GET_PIN_SENSE, 0)
14024 & AC_PINSENSE_PRESENCE;
14025 bits = present ? HDA_AMP_MUTE : 0;
14026 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14027 HDA_AMP_MUTE, bits);
14028}
14029
14030static void alc663_m51va_mic_automute(struct hda_codec *codec)
14031{
14032 unsigned int present;
14033
14034 present = snd_hda_codec_read(codec, 0x18, 0,
14035 AC_VERB_GET_PIN_SENSE, 0)
14036 & AC_PINSENSE_PRESENCE;
14037 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14038 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14039 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14040 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14041 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14042 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14043 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14044 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14045}
14046
14047static void alc663_m51va_unsol_event(struct hda_codec *codec,
14048 unsigned int res)
14049{
14050 switch (res >> 26) {
14051 case ALC880_HP_EVENT:
14052 alc663_m51va_speaker_automute(codec);
14053 break;
14054 case ALC880_MIC_EVENT:
14055 alc663_m51va_mic_automute(codec);
14056 break;
14057 }
14058}
14059
14060static void alc663_m51va_inithook(struct hda_codec *codec)
14061{
14062 alc663_m51va_speaker_automute(codec);
14063 alc663_m51va_mic_automute(codec);
14064}
14065
14066static void alc663_g71v_hp_automute(struct hda_codec *codec)
14067{
14068 unsigned int present;
14069 unsigned char bits;
14070
14071 present = snd_hda_codec_read(codec, 0x21, 0,
14072 AC_VERB_GET_PIN_SENSE, 0)
14073 & AC_PINSENSE_PRESENCE;
14074 bits = present ? HDA_AMP_MUTE : 0;
14075 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14076 HDA_AMP_MUTE, bits);
14077 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14078 HDA_AMP_MUTE, bits);
14079}
14080
14081static void alc663_g71v_front_automute(struct hda_codec *codec)
14082{
14083 unsigned int present;
14084 unsigned char bits;
14085
14086 present = snd_hda_codec_read(codec, 0x15, 0,
14087 AC_VERB_GET_PIN_SENSE, 0)
14088 & AC_PINSENSE_PRESENCE;
14089 bits = present ? HDA_AMP_MUTE : 0;
14090 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14091 HDA_AMP_MUTE, bits);
14092}
14093
14094static void alc663_g71v_unsol_event(struct hda_codec *codec,
14095 unsigned int res)
14096{
14097 switch (res >> 26) {
14098 case ALC880_HP_EVENT:
14099 alc663_g71v_hp_automute(codec);
14100 break;
14101 case ALC880_FRONT_EVENT:
14102 alc663_g71v_front_automute(codec);
14103 break;
14104 case ALC880_MIC_EVENT:
14105 alc662_eeepc_mic_automute(codec);
14106 break;
14107 }
14108}
14109
14110static void alc663_g71v_inithook(struct hda_codec *codec)
14111{
14112 alc663_g71v_front_automute(codec);
14113 alc663_g71v_hp_automute(codec);
14114 alc662_eeepc_mic_automute(codec);
14115}
14116
14117static void alc663_g50v_unsol_event(struct hda_codec *codec,
14118 unsigned int res)
14119{
14120 switch (res >> 26) {
14121 case ALC880_HP_EVENT:
14122 alc663_m51va_speaker_automute(codec);
14123 break;
14124 case ALC880_MIC_EVENT:
14125 alc662_eeepc_mic_automute(codec);
14126 break;
14127 }
14128}
14129
14130static void alc663_g50v_inithook(struct hda_codec *codec)
14131{
14132 alc663_m51va_speaker_automute(codec);
14133 alc662_eeepc_mic_automute(codec);
14134}
14135
Takashi Iwaicb53c622007-08-10 17:21:45 +020014136#ifdef CONFIG_SND_HDA_POWER_SAVE
14137#define alc662_loopbacks alc880_loopbacks
14138#endif
14139
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014140
14141/* pcm configuration: identiacal with ALC880 */
14142#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14143#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14144#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14145#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14146
14147/*
14148 * configuration and preset
14149 */
14150static const char *alc662_models[ALC662_MODEL_LAST] = {
14151 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14152 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14153 [ALC662_3ST_6ch] = "3stack-6ch",
14154 [ALC662_5ST_DIG] = "6stack-dig",
14155 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014156 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014157 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014158 [ALC663_ASUS_M51VA] = "m51va",
14159 [ALC663_ASUS_G71V] = "g71v",
14160 [ALC663_ASUS_H13] = "h13",
14161 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014162 [ALC662_AUTO] = "auto",
14163};
14164
14165static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014166 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14167 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14168 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014169 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014170 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014171 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014172 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014173 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14174 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14175 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014176 {}
14177};
14178
14179static struct alc_config_preset alc662_presets[] = {
14180 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014181 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014182 .init_verbs = { alc662_init_verbs },
14183 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14184 .dac_nids = alc662_dac_nids,
14185 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014186 .dig_in_nid = ALC662_DIGIN_NID,
14187 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14188 .channel_mode = alc662_3ST_2ch_modes,
14189 .input_mux = &alc662_capture_source,
14190 },
14191 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014192 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14193 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014194 .init_verbs = { alc662_init_verbs },
14195 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14196 .dac_nids = alc662_dac_nids,
14197 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014198 .dig_in_nid = ALC662_DIGIN_NID,
14199 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14200 .channel_mode = alc662_3ST_6ch_modes,
14201 .need_dac_fix = 1,
14202 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014203 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014204 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014205 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14206 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014207 .init_verbs = { alc662_init_verbs },
14208 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14209 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014210 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14211 .channel_mode = alc662_3ST_6ch_modes,
14212 .need_dac_fix = 1,
14213 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014214 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014215 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014216 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14217 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014218 .init_verbs = { alc662_init_verbs },
14219 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14220 .dac_nids = alc662_dac_nids,
14221 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014222 .dig_in_nid = ALC662_DIGIN_NID,
14223 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14224 .channel_mode = alc662_5stack_modes,
14225 .input_mux = &alc662_capture_source,
14226 },
14227 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014228 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014229 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14230 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14231 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014232 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14233 .channel_mode = alc662_3ST_2ch_modes,
14234 .input_mux = &alc662_lenovo_101e_capture_source,
14235 .unsol_event = alc662_lenovo_101e_unsol_event,
14236 .init_hook = alc662_lenovo_101e_all_automute,
14237 },
Kailang Yang291702f2007-10-16 14:28:03 +020014238 [ALC662_ASUS_EEEPC_P701] = {
14239 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14240 .init_verbs = { alc662_init_verbs,
14241 alc662_eeepc_sue_init_verbs },
14242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14243 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014244 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14245 .channel_mode = alc662_3ST_2ch_modes,
14246 .input_mux = &alc662_eeepc_capture_source,
14247 .unsol_event = alc662_eeepc_unsol_event,
14248 .init_hook = alc662_eeepc_inithook,
14249 },
Kailang Yang8c427222008-01-10 13:03:59 +010014250 [ALC662_ASUS_EEEPC_EP20] = {
14251 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14252 alc662_chmode_mixer },
14253 .init_verbs = { alc662_init_verbs,
14254 alc662_eeepc_ep20_sue_init_verbs },
14255 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14256 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014257 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14258 .channel_mode = alc662_3ST_6ch_modes,
14259 .input_mux = &alc662_lenovo_101e_capture_source,
14260 .unsol_event = alc662_eeepc_ep20_unsol_event,
14261 .init_hook = alc662_eeepc_ep20_inithook,
14262 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014263 [ALC663_ASUS_M51VA] = {
14264 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14265 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14266 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14267 .dac_nids = alc662_dac_nids,
14268 .dig_out_nid = ALC662_DIGOUT_NID,
14269 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14270 .channel_mode = alc662_3ST_2ch_modes,
14271 .input_mux = &alc663_m51va_capture_source,
14272 .unsol_event = alc663_m51va_unsol_event,
14273 .init_hook = alc663_m51va_inithook,
14274 },
14275 [ALC663_ASUS_G71V] = {
14276 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14277 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14278 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14279 .dac_nids = alc662_dac_nids,
14280 .dig_out_nid = ALC662_DIGOUT_NID,
14281 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14282 .channel_mode = alc662_3ST_2ch_modes,
14283 .input_mux = &alc662_eeepc_capture_source,
14284 .unsol_event = alc663_g71v_unsol_event,
14285 .init_hook = alc663_g71v_inithook,
14286 },
14287 [ALC663_ASUS_H13] = {
14288 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14289 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14290 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14291 .dac_nids = alc662_dac_nids,
14292 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14293 .channel_mode = alc662_3ST_2ch_modes,
14294 .input_mux = &alc663_m51va_capture_source,
14295 .unsol_event = alc663_m51va_unsol_event,
14296 .init_hook = alc663_m51va_inithook,
14297 },
14298 [ALC663_ASUS_G50V] = {
14299 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14300 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14301 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14302 .dac_nids = alc662_dac_nids,
14303 .dig_out_nid = ALC662_DIGOUT_NID,
14304 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14305 .channel_mode = alc662_3ST_6ch_modes,
14306 .input_mux = &alc663_capture_source,
14307 .unsol_event = alc663_g50v_unsol_event,
14308 .init_hook = alc663_g50v_inithook,
14309 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014310};
14311
14312
14313/*
14314 * BIOS auto configuration
14315 */
14316
14317/* add playback controls from the parsed DAC table */
14318static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14319 const struct auto_pin_cfg *cfg)
14320{
14321 char name[32];
14322 static const char *chname[4] = {
14323 "Front", "Surround", NULL /*CLFE*/, "Side"
14324 };
14325 hda_nid_t nid;
14326 int i, err;
14327
14328 for (i = 0; i < cfg->line_outs; i++) {
14329 if (!spec->multiout.dac_nids[i])
14330 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014331 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014332 if (i == 2) {
14333 /* Center/LFE */
14334 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14335 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014336 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14337 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014338 if (err < 0)
14339 return err;
14340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14341 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014342 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14343 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014344 if (err < 0)
14345 return err;
14346 err = add_control(spec, ALC_CTL_BIND_MUTE,
14347 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014348 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14349 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014350 if (err < 0)
14351 return err;
14352 err = add_control(spec, ALC_CTL_BIND_MUTE,
14353 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014354 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14355 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014356 if (err < 0)
14357 return err;
14358 } else {
14359 sprintf(name, "%s Playback Volume", chname[i]);
14360 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014361 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14362 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014363 if (err < 0)
14364 return err;
14365 sprintf(name, "%s Playback Switch", chname[i]);
14366 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014367 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14368 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014369 if (err < 0)
14370 return err;
14371 }
14372 }
14373 return 0;
14374}
14375
14376/* add playback controls for speaker and HP outputs */
14377static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14378 const char *pfx)
14379{
14380 hda_nid_t nid;
14381 int err;
14382 char name[32];
14383
14384 if (!pin)
14385 return 0;
14386
14387 if (alc880_is_fixed_pin(pin)) {
14388 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14389 /* printk("DAC nid=%x\n",nid); */
14390 /* specify the DAC as the extra output */
14391 if (!spec->multiout.hp_nid)
14392 spec->multiout.hp_nid = nid;
14393 else
14394 spec->multiout.extra_out_nid[0] = nid;
14395 /* control HP volume/switch on the output mixer amp */
14396 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14397 sprintf(name, "%s Playback Volume", pfx);
14398 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14399 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14400 if (err < 0)
14401 return err;
14402 sprintf(name, "%s Playback Switch", pfx);
14403 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14404 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14405 if (err < 0)
14406 return err;
14407 } else if (alc880_is_multi_pin(pin)) {
14408 /* set manual connection */
14409 /* we have only a switch on HP-out PIN */
14410 sprintf(name, "%s Playback Switch", pfx);
14411 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14412 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14413 if (err < 0)
14414 return err;
14415 }
14416 return 0;
14417}
14418
14419/* create playback/capture controls for input pins */
14420static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14421 const struct auto_pin_cfg *cfg)
14422{
14423 struct hda_input_mux *imux = &spec->private_imux;
14424 int i, err, idx;
14425
14426 for (i = 0; i < AUTO_PIN_LAST; i++) {
14427 if (alc880_is_input_pin(cfg->input_pins[i])) {
14428 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14429 err = new_analog_input(spec, cfg->input_pins[i],
14430 auto_pin_cfg_labels[i],
14431 idx, 0x0b);
14432 if (err < 0)
14433 return err;
14434 imux->items[imux->num_items].label =
14435 auto_pin_cfg_labels[i];
14436 imux->items[imux->num_items].index =
14437 alc880_input_pin_idx(cfg->input_pins[i]);
14438 imux->num_items++;
14439 }
14440 }
14441 return 0;
14442}
14443
14444static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14445 hda_nid_t nid, int pin_type,
14446 int dac_idx)
14447{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014448 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014449 /* need the manual connection? */
14450 if (alc880_is_multi_pin(nid)) {
14451 struct alc_spec *spec = codec->spec;
14452 int idx = alc880_multi_pin_idx(nid);
14453 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14454 AC_VERB_SET_CONNECT_SEL,
14455 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14456 }
14457}
14458
14459static void alc662_auto_init_multi_out(struct hda_codec *codec)
14460{
14461 struct alc_spec *spec = codec->spec;
14462 int i;
14463
Kailang Yang8c427222008-01-10 13:03:59 +010014464 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014465 for (i = 0; i <= HDA_SIDE; i++) {
14466 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014467 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014468 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014469 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014470 i);
14471 }
14472}
14473
14474static void alc662_auto_init_hp_out(struct hda_codec *codec)
14475{
14476 struct alc_spec *spec = codec->spec;
14477 hda_nid_t pin;
14478
14479 pin = spec->autocfg.hp_pins[0];
14480 if (pin) /* connect to front */
14481 /* use dac 0 */
14482 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014483 pin = spec->autocfg.speaker_pins[0];
14484 if (pin)
14485 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014486}
14487
14488#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14489#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14490
14491static void alc662_auto_init_analog_input(struct hda_codec *codec)
14492{
14493 struct alc_spec *spec = codec->spec;
14494 int i;
14495
14496 for (i = 0; i < AUTO_PIN_LAST; i++) {
14497 hda_nid_t nid = spec->autocfg.input_pins[i];
14498 if (alc662_is_input_pin(nid)) {
14499 snd_hda_codec_write(codec, nid, 0,
14500 AC_VERB_SET_PIN_WIDGET_CONTROL,
14501 (i <= AUTO_PIN_FRONT_MIC ?
14502 PIN_VREF80 : PIN_IN));
14503 if (nid != ALC662_PIN_CD_NID)
14504 snd_hda_codec_write(codec, nid, 0,
14505 AC_VERB_SET_AMP_GAIN_MUTE,
14506 AMP_OUT_MUTE);
14507 }
14508 }
14509}
14510
14511static int alc662_parse_auto_config(struct hda_codec *codec)
14512{
14513 struct alc_spec *spec = codec->spec;
14514 int err;
14515 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14516
14517 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14518 alc662_ignore);
14519 if (err < 0)
14520 return err;
14521 if (!spec->autocfg.line_outs)
14522 return 0; /* can't find valid BIOS pin config */
14523
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014524 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14525 if (err < 0)
14526 return err;
14527 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14528 if (err < 0)
14529 return err;
14530 err = alc662_auto_create_extra_out(spec,
14531 spec->autocfg.speaker_pins[0],
14532 "Speaker");
14533 if (err < 0)
14534 return err;
14535 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14536 "Headphone");
14537 if (err < 0)
14538 return err;
14539 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14540 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014541 return err;
14542
14543 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14544
14545 if (spec->autocfg.dig_out_pin)
14546 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14547
14548 if (spec->kctl_alloc)
14549 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14550
14551 spec->num_mux_defs = 1;
14552 spec->input_mux = &spec->private_imux;
14553
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014554 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014555 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14556 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014557 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014558}
14559
14560/* additional initialization for auto-configuration model */
14561static void alc662_auto_init(struct hda_codec *codec)
14562{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014563 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014564 alc662_auto_init_multi_out(codec);
14565 alc662_auto_init_hp_out(codec);
14566 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014567 if (spec->unsol_event)
14568 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014569}
14570
14571static int patch_alc662(struct hda_codec *codec)
14572{
14573 struct alc_spec *spec;
14574 int err, board_config;
14575
14576 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14577 if (!spec)
14578 return -ENOMEM;
14579
14580 codec->spec = spec;
14581
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014582 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14583
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014584 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14585 alc662_models,
14586 alc662_cfg_tbl);
14587 if (board_config < 0) {
14588 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14589 "trying auto-probe from BIOS...\n");
14590 board_config = ALC662_AUTO;
14591 }
14592
14593 if (board_config == ALC662_AUTO) {
14594 /* automatic parse from the BIOS config */
14595 err = alc662_parse_auto_config(codec);
14596 if (err < 0) {
14597 alc_free(codec);
14598 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014599 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014600 printk(KERN_INFO
14601 "hda_codec: Cannot set up configuration "
14602 "from BIOS. Using base mode...\n");
14603 board_config = ALC662_3ST_2ch_DIG;
14604 }
14605 }
14606
14607 if (board_config != ALC662_AUTO)
14608 setup_preset(spec, &alc662_presets[board_config]);
14609
Kailang Yang6dda9f42008-05-27 12:05:31 +020014610 if (codec->vendor_id == 0x10ec0663) {
14611 spec->stream_name_analog = "ALC663 Analog";
14612 spec->stream_name_digital = "ALC663 Digital";
14613 } else {
14614 spec->stream_name_analog = "ALC662 Analog";
14615 spec->stream_name_digital = "ALC662 Digital";
14616 }
14617
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014618 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14619 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14620
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014621 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14622 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14623
Takashi Iwaie1406342008-02-11 18:32:32 +010014624 spec->adc_nids = alc662_adc_nids;
14625 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14626 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014627
Takashi Iwai2134ea42008-01-10 16:53:55 +010014628 spec->vmaster_nid = 0x02;
14629
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014630 codec->patch_ops = alc_patch_ops;
14631 if (board_config == ALC662_AUTO)
14632 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014633#ifdef CONFIG_SND_HDA_POWER_SAVE
14634 if (!spec->loopback.amplist)
14635 spec->loopback.amplist = alc662_loopbacks;
14636#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014637
14638 return 0;
14639}
14640
14641/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070014642 * patch entries
14643 */
14644struct hda_codec_preset snd_hda_preset_realtek[] = {
14645 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014646 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014647 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020014648 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014649 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014650 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014651 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014652 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14653 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14654 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014655 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14656 .patch = patch_alc883 },
14657 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14658 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014659 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014660 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014661 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014662 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020014663 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020014664 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010014665 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014666 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014667 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014668 {} /* terminator */
14669};