blob: 61f8c13b2bb9459291bb41af5386916d8c448e1a [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 Woithe7cf51e42006-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 Woithe7cf51e42006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Kailang Yangdf694da2005-12-05 19:42:22 +0100103 ALC262_AUTO,
104 ALC262_MODEL_LAST /* last tag */
105};
106
Kailang Yanga361d842007-06-05 12:30:55 +0200107/* ALC268 models */
108enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200109 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200110 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200111 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200112 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100113 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100114 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100115#ifdef CONFIG_SND_DEBUG
116 ALC268_TEST,
117#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200118 ALC268_AUTO,
119 ALC268_MODEL_LAST /* last tag */
120};
121
Kailang Yangf6a92242007-12-13 16:52:54 +0100122/* ALC269 models */
123enum {
124 ALC269_BASIC,
125 ALC269_AUTO,
126 ALC269_MODEL_LAST /* last tag */
127};
128
Kailang Yangdf694da2005-12-05 19:42:22 +0100129/* ALC861 models */
130enum {
131 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200132 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100133 ALC861_3ST_DIG,
134 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200135 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200136 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200137 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100138 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100139 ALC861_AUTO,
140 ALC861_MODEL_LAST,
141};
142
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100143/* ALC861-VD models */
144enum {
145 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200146 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147 ALC861VD_3ST,
148 ALC861VD_3ST_DIG,
149 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200150 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200151 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200152 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153 ALC861VD_AUTO,
154 ALC861VD_MODEL_LAST,
155};
156
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200157/* ALC662 models */
158enum {
159 ALC662_3ST_2ch_DIG,
160 ALC662_3ST_6ch_DIG,
161 ALC662_3ST_6ch,
162 ALC662_5ST_DIG,
163 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200164 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100165 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200166 ALC663_ASUS_M51VA,
167 ALC663_ASUS_G71V,
168 ALC663_ASUS_H13,
169 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170 ALC662_AUTO,
171 ALC662_MODEL_LAST,
172};
173
Kailang Yangdf694da2005-12-05 19:42:22 +0100174/* ALC882 models */
175enum {
176 ALC882_3ST_DIG,
177 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200178 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200179 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200180 ALC882_TARGA,
181 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200182 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100183 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200184 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200185 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200186 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100187 ALC882_MODEL_LAST,
188};
189
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200190/* ALC883 models */
191enum {
192 ALC883_3ST_2ch_DIG,
193 ALC883_3ST_6ch_DIG,
194 ALC883_3ST_6ch,
195 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200196 ALC883_TARGA_DIG,
197 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200198 ALC883_ACER,
Tobin 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 Iwaic8b6bf9b2005-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-11-17 14:57:47 +01002903static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2905 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2906 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2907 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2909 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2910 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002912 PIN_CTL_TEST("Front Pin Mode", 0x14),
2913 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2914 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2915 PIN_CTL_TEST("Side Pin Mode", 0x17),
2916 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2917 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2918 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2919 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2920 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2921 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2922 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2923 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2924 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2925 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2926 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2927 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2928 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2929 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2930 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2931 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002934 {
2935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2936 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002937 .info = alc_ch_mode_info,
2938 .get = alc_ch_mode_get,
2939 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002940 },
2941 { } /* end */
2942};
2943
2944static struct hda_verb alc880_test_init_verbs[] = {
2945 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002954 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2958 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002959 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2963 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002964 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2968 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002969 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002975 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2979 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002980 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002982 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002985 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002986 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002987 /* Analog input/passthru */
2988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002993 { }
2994};
2995#endif
2996
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997/*
2998 */
2999
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003000static const char *alc880_models[ALC880_MODEL_LAST] = {
3001 [ALC880_3ST] = "3stack",
3002 [ALC880_TCL_S700] = "tcl",
3003 [ALC880_3ST_DIG] = "3stack-digout",
3004 [ALC880_CLEVO] = "clevo",
3005 [ALC880_5ST] = "5stack",
3006 [ALC880_5ST_DIG] = "5stack-digout",
3007 [ALC880_W810] = "w810",
3008 [ALC880_Z71V] = "z71v",
3009 [ALC880_6ST] = "6stack",
3010 [ALC880_6ST_DIG] = "6stack-digout",
3011 [ALC880_ASUS] = "asus",
3012 [ALC880_ASUS_W1V] = "asus-w1v",
3013 [ALC880_ASUS_DIG] = "asus-dig",
3014 [ALC880_ASUS_DIG2] = "asus-dig2",
3015 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003016 [ALC880_UNIWILL_P53] = "uniwill-p53",
3017 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003018 [ALC880_F1734] = "F1734",
3019 [ALC880_LG] = "lg",
3020 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003021 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003022#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003023 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003024#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003025 [ALC880_AUTO] = "auto",
3026};
3027
3028static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003029 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003030 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3031 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3032 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3033 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3034 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3035 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3036 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3037 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003038 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3039 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003040 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3041 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3042 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3043 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3044 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3045 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3046 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3047 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3048 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3049 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003050 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003051 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3052 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3053 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003054 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003055 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003056 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3057 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003058 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3059 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003060 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3061 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3062 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3063 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003064 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3065 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003066 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003067 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003068 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003069 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003070 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3071 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003072 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003073 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003074 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003075 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003076 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003077 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003078 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003079 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003080 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3081 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003083 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3084 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3085 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3086 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003087 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3088 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003089 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003090 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3092 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003093 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3094 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3095 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003096 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3097 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3098 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099 {}
3100};
3101
Takashi Iwai16ded522005-06-10 19:58:24 +02003102/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003103 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003104 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003105static struct alc_config_preset alc880_presets[] = {
3106 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003108 .init_verbs = { alc880_volume_init_verbs,
3109 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003110 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003111 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3113 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003114 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003115 .input_mux = &alc880_capture_source,
3116 },
3117 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003119 .init_verbs = { alc880_volume_init_verbs,
3120 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003121 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003122 .dac_nids = alc880_dac_nids,
3123 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3125 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .input_mux = &alc880_capture_source,
3128 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003129 [ALC880_TCL_S700] = {
3130 .mixers = { alc880_tcl_s700_mixer },
3131 .init_verbs = { alc880_volume_init_verbs,
3132 alc880_pin_tcl_S700_init_verbs,
3133 alc880_gpio2_init_verbs },
3134 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3135 .dac_nids = alc880_dac_nids,
3136 .hp_nid = 0x03,
3137 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3138 .channel_mode = alc880_2_jack_modes,
3139 .input_mux = &alc880_capture_source,
3140 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003142 .mixers = { alc880_three_stack_mixer,
3143 alc880_five_stack_mixer},
3144 .init_verbs = { alc880_volume_init_verbs,
3145 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003146 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3147 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003148 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3149 .channel_mode = alc880_fivestack_modes,
3150 .input_mux = &alc880_capture_source,
3151 },
3152 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003153 .mixers = { alc880_three_stack_mixer,
3154 alc880_five_stack_mixer },
3155 .init_verbs = { alc880_volume_init_verbs,
3156 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
3159 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3161 .channel_mode = alc880_fivestack_modes,
3162 .input_mux = &alc880_capture_source,
3163 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003164 [ALC880_6ST] = {
3165 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003166 .init_verbs = { alc880_volume_init_verbs,
3167 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003168 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3169 .dac_nids = alc880_6st_dac_nids,
3170 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3171 .channel_mode = alc880_sixstack_modes,
3172 .input_mux = &alc880_6stack_capture_source,
3173 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003174 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003175 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003176 .init_verbs = { alc880_volume_init_verbs,
3177 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003178 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3179 .dac_nids = alc880_6st_dac_nids,
3180 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003181 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3182 .channel_mode = alc880_sixstack_modes,
3183 .input_mux = &alc880_6stack_capture_source,
3184 },
3185 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003187 .init_verbs = { alc880_volume_init_verbs,
3188 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003189 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003190 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3191 .dac_nids = alc880_w810_dac_nids,
3192 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3194 .channel_mode = alc880_w810_modes,
3195 .input_mux = &alc880_capture_source,
3196 },
3197 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003199 .init_verbs = { alc880_volume_init_verbs,
3200 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003201 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3202 .dac_nids = alc880_z71v_dac_nids,
3203 .dig_out_nid = ALC880_DIGOUT_NID,
3204 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3206 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003207 .input_mux = &alc880_capture_source,
3208 },
3209 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003211 .init_verbs = { alc880_volume_init_verbs,
3212 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3214 .dac_nids = alc880_f1734_dac_nids,
3215 .hp_nid = 0x02,
3216 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3217 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003218 .input_mux = &alc880_f1734_capture_source,
3219 .unsol_event = alc880_uniwill_p53_unsol_event,
3220 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003221 },
3222 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 alc880_gpio1_init_verbs },
3227 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3228 .dac_nids = alc880_asus_dac_nids,
3229 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3230 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003231 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003232 .input_mux = &alc880_capture_source,
3233 },
3234 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003236 .init_verbs = { alc880_volume_init_verbs,
3237 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 alc880_gpio1_init_verbs },
3239 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3240 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3243 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003244 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003245 .input_mux = &alc880_capture_source,
3246 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003247 [ALC880_ASUS_DIG2] = {
3248 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 .init_verbs = { alc880_volume_init_verbs,
3250 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003251 alc880_gpio2_init_verbs }, /* use GPIO2 */
3252 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3253 .dac_nids = alc880_asus_dac_nids,
3254 .dig_out_nid = ALC880_DIGOUT_NID,
3255 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3256 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003257 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003258 .input_mux = &alc880_capture_source,
3259 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262 .init_verbs = { alc880_volume_init_verbs,
3263 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264 alc880_gpio1_init_verbs },
3265 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3266 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3269 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003270 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 .input_mux = &alc880_capture_source,
3272 },
3273 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003274 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003275 .init_verbs = { alc880_volume_init_verbs,
3276 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3278 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003279 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3281 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003282 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003283 .input_mux = &alc880_capture_source,
3284 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003285 [ALC880_UNIWILL] = {
3286 .mixers = { alc880_uniwill_mixer },
3287 .init_verbs = { alc880_volume_init_verbs,
3288 alc880_uniwill_init_verbs },
3289 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3290 .dac_nids = alc880_asus_dac_nids,
3291 .dig_out_nid = ALC880_DIGOUT_NID,
3292 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3293 .channel_mode = alc880_threestack_modes,
3294 .need_dac_fix = 1,
3295 .input_mux = &alc880_capture_source,
3296 .unsol_event = alc880_uniwill_unsol_event,
3297 .init_hook = alc880_uniwill_automute,
3298 },
3299 [ALC880_UNIWILL_P53] = {
3300 .mixers = { alc880_uniwill_p53_mixer },
3301 .init_verbs = { alc880_volume_init_verbs,
3302 alc880_uniwill_p53_init_verbs },
3303 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3304 .dac_nids = alc880_asus_dac_nids,
3305 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003306 .channel_mode = alc880_threestack_modes,
3307 .input_mux = &alc880_capture_source,
3308 .unsol_event = alc880_uniwill_p53_unsol_event,
3309 .init_hook = alc880_uniwill_p53_hp_automute,
3310 },
3311 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003312 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003313 alc880_pcbeep_mixer, },
3314 .init_verbs = { alc880_volume_init_verbs,
3315 alc880_uniwill_p53_init_verbs,
3316 alc880_beep_init_verbs },
3317 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3318 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003319 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003320 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3321 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 .input_mux = &alc880_capture_source,
3323 .unsol_event = alc880_uniwill_p53_unsol_event,
3324 .init_hook = alc880_uniwill_p53_hp_automute,
3325 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003326 [ALC880_CLEVO] = {
3327 .mixers = { alc880_three_stack_mixer },
3328 .init_verbs = { alc880_volume_init_verbs,
3329 alc880_pin_clevo_init_verbs },
3330 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3331 .dac_nids = alc880_dac_nids,
3332 .hp_nid = 0x03,
3333 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3334 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003335 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003336 .input_mux = &alc880_capture_source,
3337 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003338 [ALC880_LG] = {
3339 .mixers = { alc880_lg_mixer },
3340 .init_verbs = { alc880_volume_init_verbs,
3341 alc880_lg_init_verbs },
3342 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3343 .dac_nids = alc880_lg_dac_nids,
3344 .dig_out_nid = ALC880_DIGOUT_NID,
3345 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3346 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003347 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003348 .input_mux = &alc880_lg_capture_source,
3349 .unsol_event = alc880_lg_unsol_event,
3350 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003351#ifdef CONFIG_SND_HDA_POWER_SAVE
3352 .loopbacks = alc880_lg_loopbacks,
3353#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003354 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003355 [ALC880_LG_LW] = {
3356 .mixers = { alc880_lg_lw_mixer },
3357 .init_verbs = { alc880_volume_init_verbs,
3358 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003359 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003360 .dac_nids = alc880_dac_nids,
3361 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003362 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3363 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003364 .input_mux = &alc880_lg_lw_capture_source,
3365 .unsol_event = alc880_lg_lw_unsol_event,
3366 .init_hook = alc880_lg_lw_automute,
3367 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003368 [ALC880_MEDION_RIM] = {
3369 .mixers = { alc880_medion_rim_mixer },
3370 .init_verbs = { alc880_volume_init_verbs,
3371 alc880_medion_rim_init_verbs,
3372 alc_gpio2_init_verbs },
3373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3374 .dac_nids = alc880_dac_nids,
3375 .dig_out_nid = ALC880_DIGOUT_NID,
3376 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3377 .channel_mode = alc880_2_jack_modes,
3378 .input_mux = &alc880_medion_rim_capture_source,
3379 .unsol_event = alc880_medion_rim_unsol_event,
3380 .init_hook = alc880_medion_rim_automute,
3381 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003382#ifdef CONFIG_SND_DEBUG
3383 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 .mixers = { alc880_test_mixer },
3385 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003386 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3387 .dac_nids = alc880_test_dac_nids,
3388 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003389 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3390 .channel_mode = alc880_test_modes,
3391 .input_mux = &alc880_test_capture_source,
3392 },
3393#endif
3394};
3395
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003396/*
3397 * Automatic parse of I/O pins from the BIOS configuration
3398 */
3399
3400#define NUM_CONTROL_ALLOC 32
3401#define NUM_VERB_ALLOC 32
3402
3403enum {
3404 ALC_CTL_WIDGET_VOL,
3405 ALC_CTL_WIDGET_MUTE,
3406 ALC_CTL_BIND_MUTE,
3407};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003408static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3410 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003411 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412};
3413
3414/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003415static int add_control(struct alc_spec *spec, int type, const char *name,
3416 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003418 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419
3420 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3421 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3422
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423 /* array + terminator */
3424 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3425 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426 return -ENOMEM;
3427 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003428 memcpy(knew, spec->kctl_alloc,
3429 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 kfree(spec->kctl_alloc);
3431 }
3432 spec->kctl_alloc = knew;
3433 spec->num_kctl_alloc = num;
3434 }
3435
3436 knew = &spec->kctl_alloc[spec->num_kctl_used];
3437 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003438 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003439 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 return -ENOMEM;
3441 knew->private_value = val;
3442 spec->num_kctl_used++;
3443 return 0;
3444}
3445
3446#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3447#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3448#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3449#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3450#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3451#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3452#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3453#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3454#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3455#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3456#define ALC880_PIN_CD_NID 0x1c
3457
3458/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003459static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3460 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461{
3462 hda_nid_t nid;
3463 int assigned[4];
3464 int i, j;
3465
3466 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003467 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468
3469 /* check the pins hardwired to audio widget */
3470 for (i = 0; i < cfg->line_outs; i++) {
3471 nid = cfg->line_out_pins[i];
3472 if (alc880_is_fixed_pin(nid)) {
3473 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003474 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 assigned[idx] = 1;
3476 }
3477 }
3478 /* left pins can be connect to any audio widget */
3479 for (i = 0; i < cfg->line_outs; i++) {
3480 nid = cfg->line_out_pins[i];
3481 if (alc880_is_fixed_pin(nid))
3482 continue;
3483 /* search for an empty channel */
3484 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003485 if (!assigned[j]) {
3486 spec->multiout.dac_nids[i] =
3487 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488 assigned[j] = 1;
3489 break;
3490 }
3491 }
3492 }
3493 spec->multiout.num_dacs = cfg->line_outs;
3494 return 0;
3495}
3496
3497/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003498static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3499 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500{
3501 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003502 static const char *chname[4] = {
3503 "Front", "Surround", NULL /*CLFE*/, "Side"
3504 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003505 hda_nid_t nid;
3506 int i, err;
3507
3508 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003509 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003510 continue;
3511 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3512 if (i == 2) {
3513 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003514 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3515 "Center Playback Volume",
3516 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3517 HDA_OUTPUT));
3518 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003520 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3521 "LFE Playback Volume",
3522 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3523 HDA_OUTPUT));
3524 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003526 err = add_control(spec, ALC_CTL_BIND_MUTE,
3527 "Center Playback Switch",
3528 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3529 HDA_INPUT));
3530 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003532 err = add_control(spec, ALC_CTL_BIND_MUTE,
3533 "LFE Playback Switch",
3534 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3535 HDA_INPUT));
3536 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003537 return err;
3538 } else {
3539 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003540 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3541 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3542 HDA_OUTPUT));
3543 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 return err;
3545 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003546 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3547 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3548 HDA_INPUT));
3549 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 return err;
3551 }
3552 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003553 return 0;
3554}
3555
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003556/* add playback controls for speaker and HP outputs */
3557static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3558 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559{
3560 hda_nid_t nid;
3561 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003562 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003564 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 return 0;
3566
3567 if (alc880_is_fixed_pin(pin)) {
3568 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003569 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003570 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003572 else
3573 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574 /* control HP volume/switch on the output mixer amp */
3575 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003576 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003577 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3578 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3579 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003581 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003582 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3583 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3584 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 return err;
3586 } else if (alc880_is_multi_pin(pin)) {
3587 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003589 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3591 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 return err;
3594 }
3595 return 0;
3596}
3597
3598/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003599static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3600 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003601 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602{
3603 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003604 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605
3606 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003607 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3608 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3609 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003610 return err;
3611 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003612 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3613 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3614 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003615 return err;
3616 return 0;
3617}
3618
3619/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003620static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3621 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003624 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625
3626 for (i = 0; i < AUTO_PIN_LAST; i++) {
3627 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003628 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003629 err = new_analog_input(spec, cfg->input_pins[i],
3630 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003631 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 if (err < 0)
3633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003634 imux->items[imux->num_items].label =
3635 auto_pin_cfg_labels[i];
3636 imux->items[imux->num_items].index =
3637 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638 imux->num_items++;
3639 }
3640 }
3641 return 0;
3642}
3643
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003644static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3645 unsigned int pin_type)
3646{
3647 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3648 pin_type);
3649 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003650 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3651 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003652}
3653
Kailang Yangdf694da2005-12-05 19:42:22 +01003654static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3655 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656 int dac_idx)
3657{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003658 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003659 /* need the manual connection? */
3660 if (alc880_is_multi_pin(nid)) {
3661 struct alc_spec *spec = codec->spec;
3662 int idx = alc880_multi_pin_idx(nid);
3663 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3664 AC_VERB_SET_CONNECT_SEL,
3665 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3666 }
3667}
3668
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003669static int get_pin_type(int line_out_type)
3670{
3671 if (line_out_type == AUTO_PIN_HP_OUT)
3672 return PIN_HP;
3673 else
3674 return PIN_OUT;
3675}
3676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677static void alc880_auto_init_multi_out(struct hda_codec *codec)
3678{
3679 struct alc_spec *spec = codec->spec;
3680 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003681
3682 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003683 for (i = 0; i < spec->autocfg.line_outs; i++) {
3684 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003685 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3686 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003687 }
3688}
3689
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003690static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691{
3692 struct alc_spec *spec = codec->spec;
3693 hda_nid_t pin;
3694
Takashi Iwai82bc9552006-03-21 11:24:42 +01003695 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003696 if (pin) /* connect to front */
3697 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003698 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 if (pin) /* connect to front */
3700 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3701}
3702
3703static void alc880_auto_init_analog_input(struct hda_codec *codec)
3704{
3705 struct alc_spec *spec = codec->spec;
3706 int i;
3707
3708 for (i = 0; i < AUTO_PIN_LAST; i++) {
3709 hda_nid_t nid = spec->autocfg.input_pins[i];
3710 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003711 snd_hda_codec_write(codec, nid, 0,
3712 AC_VERB_SET_PIN_WIDGET_CONTROL,
3713 i <= AUTO_PIN_FRONT_MIC ?
3714 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003716 snd_hda_codec_write(codec, nid, 0,
3717 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003718 AMP_OUT_MUTE);
3719 }
3720 }
3721}
3722
3723/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724/* return 1 if successful, 0 if the proper config is not found,
3725 * or a negative error code
3726 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003727static int alc880_parse_auto_config(struct hda_codec *codec)
3728{
3729 struct alc_spec *spec = codec->spec;
3730 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003731 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003733 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3734 alc880_ignore);
3735 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003738 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003739
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003740 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3741 if (err < 0)
3742 return err;
3743 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3744 if (err < 0)
3745 return err;
3746 err = alc880_auto_create_extra_out(spec,
3747 spec->autocfg.speaker_pins[0],
3748 "Speaker");
3749 if (err < 0)
3750 return err;
3751 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3752 "Headphone");
3753 if (err < 0)
3754 return err;
3755 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3756 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003757 return err;
3758
3759 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3760
3761 if (spec->autocfg.dig_out_pin)
3762 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3763 if (spec->autocfg.dig_in_pin)
3764 spec->dig_in_nid = ALC880_DIGIN_NID;
3765
3766 if (spec->kctl_alloc)
3767 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3768
3769 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3770
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003771 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 spec->input_mux = &spec->private_imux;
3773
3774 return 1;
3775}
3776
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003777/* additional initialization for auto-configuration model */
3778static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003780 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003781 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003782 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003784 if (spec->unsol_event)
3785 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003786}
3787
3788/*
3789 * OK, here we have finally the patch for ALC880
3790 */
3791
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792static int patch_alc880(struct hda_codec *codec)
3793{
3794 struct alc_spec *spec;
3795 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003796 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003797
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003798 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003799 if (spec == NULL)
3800 return -ENOMEM;
3801
3802 codec->spec = spec;
3803
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003804 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3805 alc880_models,
3806 alc880_cfg_tbl);
3807 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003808 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3809 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811 }
3812
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003813 if (board_config == ALC880_AUTO) {
3814 /* automatic parse from the BIOS config */
3815 err = alc880_parse_auto_config(codec);
3816 if (err < 0) {
3817 alc_free(codec);
3818 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003819 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003820 printk(KERN_INFO
3821 "hda_codec: Cannot set up configuration "
3822 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 board_config = ALC880_3ST;
3824 }
3825 }
3826
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 if (board_config != ALC880_AUTO)
3828 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003829
3830 spec->stream_name_analog = "ALC880 Analog";
3831 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3832 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003833 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003834
3835 spec->stream_name_digital = "ALC880 Digital";
3836 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3837 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003839 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003840 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003841 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 /* get type */
3843 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 if (wcap != AC_WID_AUD_IN) {
3845 spec->adc_nids = alc880_adc_nids_alt;
3846 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847 spec->mixers[spec->num_mixers] =
3848 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 spec->num_mixers++;
3850 } else {
3851 spec->adc_nids = alc880_adc_nids;
3852 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3853 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3854 spec->num_mixers++;
3855 }
3856 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857
Takashi Iwai2134ea42008-01-10 16:53:55 +01003858 spec->vmaster_nid = 0x0c;
3859
Linus Torvalds1da177e2005-04-16 15:20:36 -07003860 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003862 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003863#ifdef CONFIG_SND_HDA_POWER_SAVE
3864 if (!spec->loopback.amplist)
3865 spec->loopback.amplist = alc880_loopbacks;
3866#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867
3868 return 0;
3869}
3870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003871
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872/*
3873 * ALC260 support
3874 */
3875
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003876static hda_nid_t alc260_dac_nids[1] = {
3877 /* front */
3878 0x02,
3879};
3880
3881static hda_nid_t alc260_adc_nids[1] = {
3882 /* ADC0 */
3883 0x04,
3884};
3885
Kailang Yangdf694da2005-12-05 19:42:22 +01003886static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003887 /* ADC1 */
3888 0x05,
3889};
3890
Kailang Yangdf694da2005-12-05 19:42:22 +01003891static hda_nid_t alc260_hp_adc_nids[2] = {
3892 /* ADC1, 0 */
3893 0x05, 0x04
3894};
3895
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003896/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3897 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3898 */
3899static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003900 /* ADC0, ADC1 */
3901 0x04, 0x05
3902};
3903
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003904#define ALC260_DIGOUT_NID 0x03
3905#define ALC260_DIGIN_NID 0x06
3906
3907static struct hda_input_mux alc260_capture_source = {
3908 .num_items = 4,
3909 .items = {
3910 { "Mic", 0x0 },
3911 { "Front Mic", 0x1 },
3912 { "Line", 0x2 },
3913 { "CD", 0x4 },
3914 },
3915};
3916
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003917/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003918 * headphone jack and the internal CD lines since these are the only pins at
3919 * which audio can appear. For flexibility, also allow the option of
3920 * recording the mixer output on the second ADC (ADC0 doesn't have a
3921 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003922 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003923static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3924 {
3925 .num_items = 3,
3926 .items = {
3927 { "Mic/Line", 0x0 },
3928 { "CD", 0x4 },
3929 { "Headphone", 0x2 },
3930 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003931 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003932 {
3933 .num_items = 4,
3934 .items = {
3935 { "Mic/Line", 0x0 },
3936 { "CD", 0x4 },
3937 { "Headphone", 0x2 },
3938 { "Mixer", 0x5 },
3939 },
3940 },
3941
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003942};
3943
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003944/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3945 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003946 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003947static struct hda_input_mux alc260_acer_capture_sources[2] = {
3948 {
3949 .num_items = 4,
3950 .items = {
3951 { "Mic", 0x0 },
3952 { "Line", 0x2 },
3953 { "CD", 0x4 },
3954 { "Headphone", 0x5 },
3955 },
3956 },
3957 {
3958 .num_items = 5,
3959 .items = {
3960 { "Mic", 0x0 },
3961 { "Line", 0x2 },
3962 { "CD", 0x4 },
3963 { "Headphone", 0x6 },
3964 { "Mixer", 0x5 },
3965 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003966 },
3967};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968/*
3969 * This is just place-holder, so there's something for alc_build_pcms to look
3970 * at when it calculates the maximum number of channels. ALC260 has no mixer
3971 * element which allows changing the channel mode, so the verb list is
3972 * never used.
3973 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003974static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975 { 2, NULL },
3976};
3977
Kailang Yangdf694da2005-12-05 19:42:22 +01003978
3979/* Mixer combinations
3980 *
3981 * basic: base_output + input + pc_beep + capture
3982 * HP: base_output + input + capture_alt
3983 * HP_3013: hp_3013 + input + capture
3984 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003985 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003986 */
3987
3988static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003989 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003990 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3992 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3993 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3994 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3995 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996};
Kailang Yangdf694da2005-12-05 19:42:22 +01003997
3998static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4000 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4001 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4002 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4004 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007 { } /* end */
4008};
4009
Kailang Yangdf694da2005-12-05 19:42:22 +01004010static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4013 { } /* end */
4014};
4015
Takashi Iwaibec15c32008-01-28 18:16:30 +01004016/* update HP, line and mono out pins according to the master switch */
4017static void alc260_hp_master_update(struct hda_codec *codec,
4018 hda_nid_t hp, hda_nid_t line,
4019 hda_nid_t mono)
4020{
4021 struct alc_spec *spec = codec->spec;
4022 unsigned int val = spec->master_sw ? PIN_HP : 0;
4023 /* change HP and line-out pins */
4024 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4025 val);
4026 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4027 val);
4028 /* mono (speaker) depending on the HP jack sense */
4029 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4030 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4031 val);
4032}
4033
4034static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4035 struct snd_ctl_elem_value *ucontrol)
4036{
4037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4038 struct alc_spec *spec = codec->spec;
4039 *ucontrol->value.integer.value = spec->master_sw;
4040 return 0;
4041}
4042
4043static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4044 struct snd_ctl_elem_value *ucontrol)
4045{
4046 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4047 struct alc_spec *spec = codec->spec;
4048 int val = !!*ucontrol->value.integer.value;
4049 hda_nid_t hp, line, mono;
4050
4051 if (val == spec->master_sw)
4052 return 0;
4053 spec->master_sw = val;
4054 hp = (kcontrol->private_value >> 16) & 0xff;
4055 line = (kcontrol->private_value >> 8) & 0xff;
4056 mono = kcontrol->private_value & 0xff;
4057 alc260_hp_master_update(codec, hp, line, mono);
4058 return 1;
4059}
4060
4061static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4062 {
4063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4064 .name = "Master Playback Switch",
4065 .info = snd_ctl_boolean_mono_info,
4066 .get = alc260_hp_master_sw_get,
4067 .put = alc260_hp_master_sw_put,
4068 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4069 },
4070 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4071 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4073 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4075 HDA_OUTPUT),
4076 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4077 { } /* end */
4078};
4079
4080static struct hda_verb alc260_hp_unsol_verbs[] = {
4081 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4082 {},
4083};
4084
4085static void alc260_hp_automute(struct hda_codec *codec)
4086{
4087 struct alc_spec *spec = codec->spec;
4088 unsigned int present;
4089
4090 present = snd_hda_codec_read(codec, 0x10, 0,
4091 AC_VERB_GET_PIN_SENSE, 0);
4092 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4093 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4094}
4095
4096static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4097{
4098 if ((res >> 26) == ALC880_HP_EVENT)
4099 alc260_hp_automute(codec);
4100}
4101
Kailang Yangdf694da2005-12-05 19:42:22 +01004102static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004103 {
4104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4105 .name = "Master Playback Switch",
4106 .info = snd_ctl_boolean_mono_info,
4107 .get = alc260_hp_master_sw_get,
4108 .put = alc260_hp_master_sw_put,
4109 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4110 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004111 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4112 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4113 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4114 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004117 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4118 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004119 { } /* end */
4120};
4121
Takashi Iwaibec15c32008-01-28 18:16:30 +01004122static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4124 {},
4125};
4126
4127static void alc260_hp_3013_automute(struct hda_codec *codec)
4128{
4129 struct alc_spec *spec = codec->spec;
4130 unsigned int present;
4131
4132 present = snd_hda_codec_read(codec, 0x15, 0,
4133 AC_VERB_GET_PIN_SENSE, 0);
4134 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4135 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4136}
4137
4138static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4139 unsigned int res)
4140{
4141 if ((res >> 26) == ALC880_HP_EVENT)
4142 alc260_hp_3013_automute(codec);
4143}
4144
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004145/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4146 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4147 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004148static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004149 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004150 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004151 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004152 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4153 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4154 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4155 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004156 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004157 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4158 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4160 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004161 { } /* end */
4162};
4163
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004164/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4165 * versions of the ALC260 don't act on requests to enable mic bias from NID
4166 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4167 * datasheet doesn't mention this restriction. At this stage it's not clear
4168 * whether this behaviour is intentional or is a hardware bug in chip
4169 * revisions available in early 2006. Therefore for now allow the
4170 * "Headphone Jack Mode" control to span all choices, but if it turns out
4171 * that the lack of mic bias for this NID is intentional we could change the
4172 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4173 *
4174 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4175 * don't appear to make the mic bias available from the "line" jack, even
4176 * though the NID used for this jack (0x14) can supply it. The theory is
4177 * that perhaps Acer have included blocking capacitors between the ALC260
4178 * and the output jack. If this turns out to be the case for all such
4179 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4180 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004181 *
4182 * The C20x Tablet series have a mono internal speaker which is controlled
4183 * via the chip's Mono sum widget and pin complex, so include the necessary
4184 * controls for such models. On models without a "mono speaker" the control
4185 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004186 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004187static struct snd_kcontrol_new alc260_acer_mixer[] = {
4188 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4189 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004190 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004191 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004192 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004193 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004194 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004195 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4196 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4198 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4199 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4200 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4201 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4202 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4203 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4204 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4205 { } /* end */
4206};
4207
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004208/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4209 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4210 */
4211static struct snd_kcontrol_new alc260_will_mixer[] = {
4212 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4213 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4215 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4216 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4217 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4218 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4219 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4220 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4221 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4222 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4223 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4224 { } /* end */
4225};
4226
4227/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4228 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4229 */
4230static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4231 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4232 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4234 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4235 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4236 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4237 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4238 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4239 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4240 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4241 { } /* end */
4242};
4243
Kailang Yangdf694da2005-12-05 19:42:22 +01004244/* capture mixer elements */
4245static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004246 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4247 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004248 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4249 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004250 {
4251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004252 /* The multiple "Capture Source" controls confuse alsamixer
4253 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004254 */
4255 /* .name = "Capture Source", */
4256 .name = "Input Source",
4257 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004258 .info = alc_mux_enum_info,
4259 .get = alc_mux_enum_get,
4260 .put = alc_mux_enum_put,
4261 },
4262 { } /* end */
4263};
4264
Kailang Yangdf694da2005-12-05 19:42:22 +01004265static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4266 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4267 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4268 {
4269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4270 /* The multiple "Capture Source" controls confuse alsamixer
4271 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004272 */
4273 /* .name = "Capture Source", */
4274 .name = "Input Source",
4275 .count = 1,
4276 .info = alc_mux_enum_info,
4277 .get = alc_mux_enum_get,
4278 .put = alc_mux_enum_put,
4279 },
4280 { } /* end */
4281};
4282
4283/*
4284 * initialization verbs
4285 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286static struct hda_verb alc260_init_verbs[] = {
4287 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004289 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004291 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004292 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004293 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004294 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004295 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004297 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004298 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004299 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004300 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004302 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004304 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4305 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004306 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307 /* set connection select to line in (default select for this ADC) */
4308 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004309 /* mute capture amp left and right */
4310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4311 /* set connection select to line in (default select for this ADC) */
4312 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004313 /* set vol=0 Line-Out mixer amp left and right */
4314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4315 /* unmute pin widget amp left and right (no gain on this amp) */
4316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4317 /* set vol=0 HP mixer amp left and right */
4318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4319 /* unmute pin widget amp left and right (no gain on this amp) */
4320 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4321 /* set vol=0 Mono mixer amp left and right */
4322 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4323 /* unmute pin widget amp left and right (no gain on this amp) */
4324 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4325 /* unmute LINE-2 out pin */
4326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004327 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4328 * Line In 2 = 0x03
4329 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004330 /* mute analog inputs */
4331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004336 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004337 /* mute Front out path */
4338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4340 /* mute Headphone out path */
4341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4343 /* mute Mono out path */
4344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004346 { }
4347};
4348
Takashi Iwai474167d2006-05-17 17:17:43 +02004349#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004350static struct hda_verb alc260_hp_init_verbs[] = {
4351 /* Headphone and output */
4352 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4353 /* mono output */
4354 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4357 /* Mic2 (front panel) pin widget for input and vref at 80% */
4358 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4359 /* Line In pin widget for input */
4360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4361 /* Line-2 pin widget for output */
4362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4363 /* CD pin widget for input */
4364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4365 /* unmute amp left and right */
4366 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4367 /* set connection select to line in (default select for this ADC) */
4368 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4369 /* unmute Line-Out mixer amp left and right (volume = 0) */
4370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4371 /* mute pin widget amp left and right (no gain on this amp) */
4372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4373 /* unmute HP mixer amp left and right (volume = 0) */
4374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4375 /* mute pin widget amp left and right (no gain on this amp) */
4376 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4378 * Line In 2 = 0x03
4379 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004380 /* mute analog inputs */
4381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004386 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4387 /* Unmute Front out path */
4388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4390 /* Unmute Headphone out path */
4391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4393 /* Unmute Mono out path */
4394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4396 { }
4397};
Takashi Iwai474167d2006-05-17 17:17:43 +02004398#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004399
4400static struct hda_verb alc260_hp_3013_init_verbs[] = {
4401 /* Line out and output */
4402 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4403 /* mono output */
4404 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4405 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4407 /* Mic2 (front panel) pin widget for input and vref at 80% */
4408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4409 /* Line In pin widget for input */
4410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4411 /* Headphone pin widget for output */
4412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4413 /* CD pin widget for input */
4414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4415 /* unmute amp left and right */
4416 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4417 /* set connection select to line in (default select for this ADC) */
4418 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4419 /* unmute Line-Out mixer amp left and right (volume = 0) */
4420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4421 /* mute pin widget amp left and right (no gain on this amp) */
4422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4423 /* unmute HP mixer amp left and right (volume = 0) */
4424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4425 /* mute pin widget amp left and right (no gain on this amp) */
4426 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4428 * Line In 2 = 0x03
4429 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004430 /* mute analog inputs */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004436 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4437 /* Unmute Front out path */
4438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4440 /* Unmute Headphone out path */
4441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4443 /* Unmute Mono out path */
4444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4446 { }
4447};
4448
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004449/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004450 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4451 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004452 */
4453static struct hda_verb alc260_fujitsu_init_verbs[] = {
4454 /* Disable all GPIOs */
4455 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4456 /* Internal speaker is connected to headphone pin */
4457 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4458 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004460 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4461 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4462 /* Ensure all other unused pins are disabled and muted. */
4463 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004465 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004466 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004467 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004468 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004471
Jonathan Woithef7ace402006-02-28 11:46:14 +01004472 /* Disable digital (SPDIF) pins */
4473 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4474 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004475
Jonathan Woithef7ace402006-02-28 11:46:14 +01004476 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4477 * when acting as an output.
4478 */
4479 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4480
4481 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004491
Jonathan Woithef7ace402006-02-28 11:46:14 +01004492 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4494 /* Unmute Line1 pin widget output buffer since it starts as an output.
4495 * If the pin mode is changed by the user the pin mode control will
4496 * take care of enabling the pin's input/output buffers as needed.
4497 * Therefore there's no need to enable the input buffer at this
4498 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004499 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004501 /* Unmute input buffer of pin widget used for Line-in (no equiv
4502 * mixer ctrl)
4503 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004504 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004505
Jonathan Woithef7ace402006-02-28 11:46:14 +01004506 /* Mute capture amp left and right */
4507 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4508 /* Set ADC connection select to match default mixer setting - line
4509 * in (on mic1 pin)
4510 */
4511 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004512
Jonathan Woithef7ace402006-02-28 11:46:14 +01004513 /* Do the same for the second ADC: mute capture input amp and
4514 * set ADC connection to line in (on mic1 pin)
4515 */
4516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4517 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004518
Jonathan Woithef7ace402006-02-28 11:46:14 +01004519 /* Mute all inputs to mixer widget (even unconnected ones) */
4520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004528
4529 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004530};
4531
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004532/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4533 * similar laptops (adapted from Fujitsu init verbs).
4534 */
4535static struct hda_verb alc260_acer_init_verbs[] = {
4536 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4537 * the headphone jack. Turn this on and rely on the standard mute
4538 * methods whenever the user wants to turn these outputs off.
4539 */
4540 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4541 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4542 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4543 /* Internal speaker/Headphone jack is connected to Line-out pin */
4544 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4545 /* Internal microphone/Mic jack is connected to Mic1 pin */
4546 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4547 /* Line In jack is connected to Line1 pin */
4548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004549 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4550 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004551 /* Ensure all other unused pins are disabled and muted. */
4552 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004554 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4555 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4558 /* Disable digital (SPDIF) pins */
4559 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4560 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4561
4562 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4563 * bus when acting as outputs.
4564 */
4565 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4566 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4567
4568 /* Start with output sum widgets muted and their output gains at min */
4569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4575 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004579 /* Unmute Line-out pin widget amp left and right
4580 * (no equiv mixer ctrl)
4581 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004582 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004583 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4584 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004585 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4586 * inputs. If the pin mode is changed by the user the pin mode control
4587 * will take care of enabling the pin's input/output buffers as needed.
4588 * Therefore there's no need to enable the input buffer at this
4589 * stage.
4590 */
4591 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4593
4594 /* Mute capture amp left and right */
4595 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4596 /* Set ADC connection select to match default mixer setting - mic
4597 * (on mic1 pin)
4598 */
4599 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4600
4601 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004602 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004603 */
4604 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004605 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004606
4607 /* Mute all inputs to mixer widget (even unconnected ones) */
4608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4616
4617 { }
4618};
4619
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004620static struct hda_verb alc260_will_verbs[] = {
4621 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4622 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4623 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4624 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4625 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4626 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4627 {}
4628};
4629
4630static struct hda_verb alc260_replacer_672v_verbs[] = {
4631 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4632 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4633 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4634
4635 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4636 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4637 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4638
4639 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4640 {}
4641};
4642
4643/* toggle speaker-output according to the hp-jack state */
4644static void alc260_replacer_672v_automute(struct hda_codec *codec)
4645{
4646 unsigned int present;
4647
4648 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4649 present = snd_hda_codec_read(codec, 0x0f, 0,
4650 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4651 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004652 snd_hda_codec_write_cache(codec, 0x01, 0,
4653 AC_VERB_SET_GPIO_DATA, 1);
4654 snd_hda_codec_write_cache(codec, 0x0f, 0,
4655 AC_VERB_SET_PIN_WIDGET_CONTROL,
4656 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004657 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004658 snd_hda_codec_write_cache(codec, 0x01, 0,
4659 AC_VERB_SET_GPIO_DATA, 0);
4660 snd_hda_codec_write_cache(codec, 0x0f, 0,
4661 AC_VERB_SET_PIN_WIDGET_CONTROL,
4662 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004663 }
4664}
4665
4666static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4667 unsigned int res)
4668{
4669 if ((res >> 26) == ALC880_HP_EVENT)
4670 alc260_replacer_672v_automute(codec);
4671}
4672
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004673/* Test configuration for debugging, modelled after the ALC880 test
4674 * configuration.
4675 */
4676#ifdef CONFIG_SND_DEBUG
4677static hda_nid_t alc260_test_dac_nids[1] = {
4678 0x02,
4679};
4680static hda_nid_t alc260_test_adc_nids[2] = {
4681 0x04, 0x05,
4682};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004683/* For testing the ALC260, each input MUX needs its own definition since
4684 * the signal assignments are different. This assumes that the first ADC
4685 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004686 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004687static struct hda_input_mux alc260_test_capture_sources[2] = {
4688 {
4689 .num_items = 7,
4690 .items = {
4691 { "MIC1 pin", 0x0 },
4692 { "MIC2 pin", 0x1 },
4693 { "LINE1 pin", 0x2 },
4694 { "LINE2 pin", 0x3 },
4695 { "CD pin", 0x4 },
4696 { "LINE-OUT pin", 0x5 },
4697 { "HP-OUT pin", 0x6 },
4698 },
4699 },
4700 {
4701 .num_items = 8,
4702 .items = {
4703 { "MIC1 pin", 0x0 },
4704 { "MIC2 pin", 0x1 },
4705 { "LINE1 pin", 0x2 },
4706 { "LINE2 pin", 0x3 },
4707 { "CD pin", 0x4 },
4708 { "Mixer", 0x5 },
4709 { "LINE-OUT pin", 0x6 },
4710 { "HP-OUT pin", 0x7 },
4711 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004712 },
4713};
4714static struct snd_kcontrol_new alc260_test_mixer[] = {
4715 /* Output driver widgets */
4716 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4717 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4718 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4719 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4720 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4721 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4722
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004723 /* Modes for retasking pin widgets
4724 * Note: the ALC260 doesn't seem to act on requests to enable mic
4725 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4726 * mention this restriction. At this stage it's not clear whether
4727 * this behaviour is intentional or is a hardware bug in chip
4728 * revisions available at least up until early 2006. Therefore for
4729 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4730 * choices, but if it turns out that the lack of mic bias for these
4731 * NIDs is intentional we could change their modes from
4732 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4733 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004734 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4735 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4736 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4737 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4738 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4739 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4740
4741 /* Loopback mixer controls */
4742 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4743 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4744 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4745 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4746 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4747 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4748 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4749 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4750 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4751 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4752 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4753 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4754 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4755 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4756 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4757 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004758
4759 /* Controls for GPIO pins, assuming they are configured as outputs */
4760 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4761 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4762 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4763 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4764
Jonathan Woithe92621f12006-02-28 11:47:47 +01004765 /* Switches to allow the digital IO pins to be enabled. The datasheet
4766 * is ambigious as to which NID is which; testing on laptops which
4767 * make this output available should provide clarification.
4768 */
4769 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4770 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4771
Jonathan Woithef8225f62008-01-08 12:16:54 +01004772 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4773 * this output to turn on an external amplifier.
4774 */
4775 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4776 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4777
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004778 { } /* end */
4779};
4780static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004781 /* Enable all GPIOs as outputs with an initial value of 0 */
4782 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4783 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4784 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4785
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004786 /* Enable retasking pins as output, initially without power amp */
4787 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4788 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4791 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4792 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4793
Jonathan Woithe92621f12006-02-28 11:47:47 +01004794 /* Disable digital (SPDIF) pins initially, but users can enable
4795 * them via a mixer switch. In the case of SPDIF-out, this initverb
4796 * payload also sets the generation to 0, output to be in "consumer"
4797 * PCM format, copyright asserted, no pre-emphasis and no validity
4798 * control.
4799 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004800 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4801 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4802
Jonathan Woithef7ace402006-02-28 11:46:14 +01004803 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004804 * OUT1 sum bus when acting as an output.
4805 */
4806 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4807 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4808 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4809 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4810
4811 /* Start with output sum widgets muted and their output gains at min */
4812 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4818 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4819 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4820 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4821
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004822 /* Unmute retasking pin widget output buffers since the default
4823 * state appears to be output. As the pin mode is changed by the
4824 * user the pin mode control will take care of enabling the pin's
4825 * input/output buffers as needed.
4826 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004827 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4831 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4832 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4833 /* Also unmute the mono-out pin widget */
4834 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4835
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004836 /* Mute capture amp left and right */
4837 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004838 /* Set ADC connection select to match default mixer setting (mic1
4839 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004840 */
4841 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4842
4843 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004844 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004845 */
4846 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4847 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4848
4849 /* Mute all inputs to mixer widget (even unconnected ones) */
4850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4858
4859 { }
4860};
4861#endif
4862
Takashi Iwai63300792008-01-24 15:31:36 +01004863#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4864#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004866#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4867#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4868
Kailang Yangdf694da2005-12-05 19:42:22 +01004869/*
4870 * for BIOS auto-configuration
4871 */
4872
4873static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4874 const char *pfx)
4875{
4876 hda_nid_t nid_vol;
4877 unsigned long vol_val, sw_val;
4878 char name[32];
4879 int err;
4880
4881 if (nid >= 0x0f && nid < 0x11) {
4882 nid_vol = nid - 0x7;
4883 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4884 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4885 } else if (nid == 0x11) {
4886 nid_vol = nid - 0x7;
4887 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4888 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4889 } else if (nid >= 0x12 && nid <= 0x15) {
4890 nid_vol = 0x08;
4891 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4892 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4893 } else
4894 return 0; /* N/A */
4895
4896 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004897 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4898 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004899 return err;
4900 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004901 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4902 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004903 return err;
4904 return 1;
4905}
4906
4907/* add playback controls from the parsed DAC table */
4908static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4909 const struct auto_pin_cfg *cfg)
4910{
4911 hda_nid_t nid;
4912 int err;
4913
4914 spec->multiout.num_dacs = 1;
4915 spec->multiout.dac_nids = spec->private_dac_nids;
4916 spec->multiout.dac_nids[0] = 0x02;
4917
4918 nid = cfg->line_out_pins[0];
4919 if (nid) {
4920 err = alc260_add_playback_controls(spec, nid, "Front");
4921 if (err < 0)
4922 return err;
4923 }
4924
Takashi Iwai82bc9552006-03-21 11:24:42 +01004925 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004926 if (nid) {
4927 err = alc260_add_playback_controls(spec, nid, "Speaker");
4928 if (err < 0)
4929 return err;
4930 }
4931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004932 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004933 if (nid) {
4934 err = alc260_add_playback_controls(spec, nid, "Headphone");
4935 if (err < 0)
4936 return err;
4937 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004939}
4940
4941/* create playback/capture controls for input pins */
4942static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4943 const struct auto_pin_cfg *cfg)
4944{
Kailang Yangdf694da2005-12-05 19:42:22 +01004945 struct hda_input_mux *imux = &spec->private_imux;
4946 int i, err, idx;
4947
4948 for (i = 0; i < AUTO_PIN_LAST; i++) {
4949 if (cfg->input_pins[i] >= 0x12) {
4950 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004951 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004952 auto_pin_cfg_labels[i], idx,
4953 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004954 if (err < 0)
4955 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 imux->items[imux->num_items].label =
4957 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004958 imux->items[imux->num_items].index = idx;
4959 imux->num_items++;
4960 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004962 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004963 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004964 auto_pin_cfg_labels[i], idx,
4965 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004966 if (err < 0)
4967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004968 imux->items[imux->num_items].label =
4969 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004970 imux->items[imux->num_items].index = idx;
4971 imux->num_items++;
4972 }
4973 }
4974 return 0;
4975}
4976
4977static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4978 hda_nid_t nid, int pin_type,
4979 int sel_idx)
4980{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004981 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 /* need the manual connection? */
4983 if (nid >= 0x12) {
4984 int idx = nid - 0x12;
4985 snd_hda_codec_write(codec, idx + 0x0b, 0,
4986 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004987 }
4988}
4989
4990static void alc260_auto_init_multi_out(struct hda_codec *codec)
4991{
4992 struct alc_spec *spec = codec->spec;
4993 hda_nid_t nid;
4994
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004995 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004996 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004997 if (nid) {
4998 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4999 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5000 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005001
Takashi Iwai82bc9552006-03-21 11:24:42 +01005002 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005003 if (nid)
5004 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5005
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005006 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005008 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005009}
Kailang Yangdf694da2005-12-05 19:42:22 +01005010
5011#define ALC260_PIN_CD_NID 0x16
5012static void alc260_auto_init_analog_input(struct hda_codec *codec)
5013{
5014 struct alc_spec *spec = codec->spec;
5015 int i;
5016
5017 for (i = 0; i < AUTO_PIN_LAST; i++) {
5018 hda_nid_t nid = spec->autocfg.input_pins[i];
5019 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005020 snd_hda_codec_write(codec, nid, 0,
5021 AC_VERB_SET_PIN_WIDGET_CONTROL,
5022 i <= AUTO_PIN_FRONT_MIC ?
5023 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005024 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005025 snd_hda_codec_write(codec, nid, 0,
5026 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005027 AMP_OUT_MUTE);
5028 }
5029 }
5030}
5031
5032/*
5033 * generic initialization of ADC, input mixers and output mixers
5034 */
5035static struct hda_verb alc260_volume_init_verbs[] = {
5036 /*
5037 * Unmute ADC0-1 and set the default input to mic-in
5038 */
5039 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5040 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5041 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5042 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5043
5044 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5045 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005046 * Note: PASD motherboards uses the Line In 2 as the input for
5047 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 */
5049 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005050 /* mute analog inputs */
5051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005056
5057 /*
5058 * Set up output mixers (0x08 - 0x0a)
5059 */
5060 /* set vol=0 to output mixers */
5061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5064 /* set up input amps for analog loopback */
5065 /* Amp Indices: DAC = 0, mixer = 1 */
5066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5068 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5070 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5072
5073 { }
5074};
5075
5076static int alc260_parse_auto_config(struct hda_codec *codec)
5077{
5078 struct alc_spec *spec = codec->spec;
5079 unsigned int wcap;
5080 int err;
5081 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5082
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005083 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5084 alc260_ignore);
5085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005087 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5088 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005089 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005090 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005091 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005092 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5093 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005094 return err;
5095
5096 spec->multiout.max_channels = 2;
5097
5098 if (spec->autocfg.dig_out_pin)
5099 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5100 if (spec->kctl_alloc)
5101 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5102
5103 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5104
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005105 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005106 spec->input_mux = &spec->private_imux;
5107
5108 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005109 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005110 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005111 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005112 spec->adc_nids = alc260_adc_nids_alt;
5113 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5114 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005115 } else {
5116 spec->adc_nids = alc260_adc_nids;
5117 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5118 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005119 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005120 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005121
5122 return 1;
5123}
5124
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005125/* additional initialization for auto-configuration model */
5126static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005127{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005128 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005129 alc260_auto_init_multi_out(codec);
5130 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005131 if (spec->unsol_event)
5132 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005133}
5134
Takashi Iwaicb53c622007-08-10 17:21:45 +02005135#ifdef CONFIG_SND_HDA_POWER_SAVE
5136static struct hda_amp_list alc260_loopbacks[] = {
5137 { 0x07, HDA_INPUT, 0 },
5138 { 0x07, HDA_INPUT, 1 },
5139 { 0x07, HDA_INPUT, 2 },
5140 { 0x07, HDA_INPUT, 3 },
5141 { 0x07, HDA_INPUT, 4 },
5142 { } /* end */
5143};
5144#endif
5145
Kailang Yangdf694da2005-12-05 19:42:22 +01005146/*
5147 * ALC260 configurations
5148 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005149static const char *alc260_models[ALC260_MODEL_LAST] = {
5150 [ALC260_BASIC] = "basic",
5151 [ALC260_HP] = "hp",
5152 [ALC260_HP_3013] = "hp-3013",
5153 [ALC260_FUJITSU_S702X] = "fujitsu",
5154 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005155 [ALC260_WILL] = "will",
5156 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005157#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005158 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005159#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005160 [ALC260_AUTO] = "auto",
5161};
5162
5163static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005164 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005165 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005166 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005167 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005168 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5169 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5170 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5171 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5172 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5173 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5174 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5175 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5176 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5177 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5178 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5179 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005180 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005181 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005182 {}
5183};
5184
Kailang Yangdf694da2005-12-05 19:42:22 +01005185static struct alc_config_preset alc260_presets[] = {
5186 [ALC260_BASIC] = {
5187 .mixers = { alc260_base_output_mixer,
5188 alc260_input_mixer,
5189 alc260_pc_beep_mixer,
5190 alc260_capture_mixer },
5191 .init_verbs = { alc260_init_verbs },
5192 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5193 .dac_nids = alc260_dac_nids,
5194 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5195 .adc_nids = alc260_adc_nids,
5196 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5197 .channel_mode = alc260_modes,
5198 .input_mux = &alc260_capture_source,
5199 },
5200 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005201 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 alc260_input_mixer,
5203 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005204 .init_verbs = { alc260_init_verbs,
5205 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005206 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5207 .dac_nids = alc260_dac_nids,
5208 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5209 .adc_nids = alc260_hp_adc_nids,
5210 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5211 .channel_mode = alc260_modes,
5212 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005213 .unsol_event = alc260_hp_unsol_event,
5214 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005215 },
5216 [ALC260_HP_3013] = {
5217 .mixers = { alc260_hp_3013_mixer,
5218 alc260_input_mixer,
5219 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005220 .init_verbs = { alc260_hp_3013_init_verbs,
5221 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005222 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5223 .dac_nids = alc260_dac_nids,
5224 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5225 .adc_nids = alc260_hp_adc_nids,
5226 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5227 .channel_mode = alc260_modes,
5228 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005229 .unsol_event = alc260_hp_3013_unsol_event,
5230 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005231 },
5232 [ALC260_FUJITSU_S702X] = {
5233 .mixers = { alc260_fujitsu_mixer,
5234 alc260_capture_mixer },
5235 .init_verbs = { alc260_fujitsu_init_verbs },
5236 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5237 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005238 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5239 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5241 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005242 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5243 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005244 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005245 [ALC260_ACER] = {
5246 .mixers = { alc260_acer_mixer,
5247 alc260_capture_mixer },
5248 .init_verbs = { alc260_acer_init_verbs },
5249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5250 .dac_nids = alc260_dac_nids,
5251 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5252 .adc_nids = alc260_dual_adc_nids,
5253 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5254 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005255 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5256 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005257 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005258 [ALC260_WILL] = {
5259 .mixers = { alc260_will_mixer,
5260 alc260_capture_mixer },
5261 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5262 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5263 .dac_nids = alc260_dac_nids,
5264 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5265 .adc_nids = alc260_adc_nids,
5266 .dig_out_nid = ALC260_DIGOUT_NID,
5267 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5268 .channel_mode = alc260_modes,
5269 .input_mux = &alc260_capture_source,
5270 },
5271 [ALC260_REPLACER_672V] = {
5272 .mixers = { alc260_replacer_672v_mixer,
5273 alc260_capture_mixer },
5274 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5276 .dac_nids = alc260_dac_nids,
5277 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5278 .adc_nids = alc260_adc_nids,
5279 .dig_out_nid = ALC260_DIGOUT_NID,
5280 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5281 .channel_mode = alc260_modes,
5282 .input_mux = &alc260_capture_source,
5283 .unsol_event = alc260_replacer_672v_unsol_event,
5284 .init_hook = alc260_replacer_672v_automute,
5285 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005286#ifdef CONFIG_SND_DEBUG
5287 [ALC260_TEST] = {
5288 .mixers = { alc260_test_mixer,
5289 alc260_capture_mixer },
5290 .init_verbs = { alc260_test_init_verbs },
5291 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5292 .dac_nids = alc260_test_dac_nids,
5293 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5294 .adc_nids = alc260_test_adc_nids,
5295 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5296 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005297 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5298 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005299 },
5300#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005301};
5302
Linus Torvalds1da177e2005-04-16 15:20:36 -07005303static int patch_alc260(struct hda_codec *codec)
5304{
5305 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005307
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005308 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005309 if (spec == NULL)
5310 return -ENOMEM;
5311
5312 codec->spec = spec;
5313
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005314 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5315 alc260_models,
5316 alc260_cfg_tbl);
5317 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005318 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5319 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005320 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005321 }
5322
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 if (board_config == ALC260_AUTO) {
5324 /* automatic parse from the BIOS config */
5325 err = alc260_parse_auto_config(codec);
5326 if (err < 0) {
5327 alc_free(codec);
5328 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005329 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005330 printk(KERN_INFO
5331 "hda_codec: Cannot set up configuration "
5332 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005333 board_config = ALC260_BASIC;
5334 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005335 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336
Kailang Yangdf694da2005-12-05 19:42:22 +01005337 if (board_config != ALC260_AUTO)
5338 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005339
5340 spec->stream_name_analog = "ALC260 Analog";
5341 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5342 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5343
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005344 spec->stream_name_digital = "ALC260 Digital";
5345 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5346 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5347
Takashi Iwai2134ea42008-01-10 16:53:55 +01005348 spec->vmaster_nid = 0x08;
5349
Linus Torvalds1da177e2005-04-16 15:20:36 -07005350 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005352 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005353#ifdef CONFIG_SND_HDA_POWER_SAVE
5354 if (!spec->loopback.amplist)
5355 spec->loopback.amplist = alc260_loopbacks;
5356#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005357
5358 return 0;
5359}
5360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005361
Linus Torvalds1da177e2005-04-16 15:20:36 -07005362/*
5363 * ALC882 support
5364 *
5365 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5366 * configuration. Each pin widget can choose any input DACs and a mixer.
5367 * Each ADC is connected from a mixer of all inputs. This makes possible
5368 * 6-channel independent captures.
5369 *
5370 * In addition, an independent DAC for the multi-playback (not used in this
5371 * driver yet).
5372 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005373#define ALC882_DIGOUT_NID 0x06
5374#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005375
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005376static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005377 { 8, NULL }
5378};
5379
5380static hda_nid_t alc882_dac_nids[4] = {
5381 /* front, rear, clfe, rear_surr */
5382 0x02, 0x03, 0x04, 0x05
5383};
5384
Kailang Yangdf694da2005-12-05 19:42:22 +01005385/* identical with ALC880 */
5386#define alc882_adc_nids alc880_adc_nids
5387#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388
Takashi Iwaie1406342008-02-11 18:32:32 +01005389static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5390static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5391
Linus Torvalds1da177e2005-04-16 15:20:36 -07005392/* input MUX */
5393/* FIXME: should be a matrix-type input source selection */
5394
5395static struct hda_input_mux alc882_capture_source = {
5396 .num_items = 4,
5397 .items = {
5398 { "Mic", 0x0 },
5399 { "Front Mic", 0x1 },
5400 { "Line", 0x2 },
5401 { "CD", 0x4 },
5402 },
5403};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404#define alc882_mux_enum_info alc_mux_enum_info
5405#define alc882_mux_enum_get alc_mux_enum_get
5406
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005407static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5408 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005409{
5410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5411 struct alc_spec *spec = codec->spec;
5412 const struct hda_input_mux *imux = spec->input_mux;
5413 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005414 hda_nid_t nid = spec->capsrc_nids ?
5415 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005416 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5417 unsigned int i, idx;
5418
5419 idx = ucontrol->value.enumerated.item[0];
5420 if (idx >= imux->num_items)
5421 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005422 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005423 return 0;
5424 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005425 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5426 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005427 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005428 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005429 }
5430 *cur_val = idx;
5431 return 1;
5432}
5433
Kailang Yangdf694da2005-12-05 19:42:22 +01005434/*
Kailang Yang272a5272007-05-14 11:00:38 +02005435 * 2ch mode
5436 */
5437static struct hda_verb alc882_3ST_ch2_init[] = {
5438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5440 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5441 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5442 { } /* end */
5443};
5444
5445/*
5446 * 6ch mode
5447 */
5448static struct hda_verb alc882_3ST_ch6_init[] = {
5449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5451 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5452 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5453 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5454 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5455 { } /* end */
5456};
5457
5458static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5459 { 2, alc882_3ST_ch2_init },
5460 { 6, alc882_3ST_ch6_init },
5461};
5462
5463/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005464 * 6ch mode
5465 */
5466static struct hda_verb alc882_sixstack_ch6_init[] = {
5467 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5468 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5469 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5470 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5471 { } /* end */
5472};
5473
5474/*
5475 * 8ch mode
5476 */
5477static struct hda_verb alc882_sixstack_ch8_init[] = {
5478 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5482 { } /* end */
5483};
5484
5485static struct hda_channel_mode alc882_sixstack_modes[2] = {
5486 { 6, alc882_sixstack_ch6_init },
5487 { 8, alc882_sixstack_ch8_init },
5488};
5489
Takashi Iwai87350ad2007-08-16 18:19:38 +02005490/*
5491 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5492 */
5493
5494/*
5495 * 2ch mode
5496 */
5497static struct hda_verb alc885_mbp_ch2_init[] = {
5498 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5499 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5500 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5501 { } /* end */
5502};
5503
5504/*
5505 * 6ch mode
5506 */
5507static struct hda_verb alc885_mbp_ch6_init[] = {
5508 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5509 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5510 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5511 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5513 { } /* end */
5514};
5515
5516static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5517 { 2, alc885_mbp_ch2_init },
5518 { 6, alc885_mbp_ch6_init },
5519};
5520
5521
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5523 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5524 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01005525static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005527 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005528 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005529 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005530 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5531 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005532 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5533 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005534 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005535 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5539 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5540 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005542 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005545 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5547 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5548 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005549 { } /* end */
5550};
5551
Takashi Iwai87350ad2007-08-16 18:19:38 +02005552static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5554 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5555 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5556 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5558 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5560 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005561 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5563 { } /* end */
5564};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005565static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5575 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5576 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5577 { } /* end */
5578};
5579
Kailang Yang272a5272007-05-14 11:00:38 +02005580static struct snd_kcontrol_new alc882_targa_mixer[] = {
5581 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5582 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02005590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02005593 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005594 { } /* end */
5595};
5596
5597/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5598 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5599 */
5600static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5602 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5604 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5609 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5610 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5611 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5612 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02005613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005614 { } /* end */
5615};
5616
Takashi Iwai914759b2007-09-06 14:52:04 +02005617static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5619 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5621 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5622 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5626 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5628 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5629 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5630 { } /* end */
5631};
5632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5634 {
5635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5636 .name = "Channel Mode",
5637 .info = alc_ch_mode_info,
5638 .get = alc_ch_mode_get,
5639 .put = alc_ch_mode_put,
5640 },
5641 { } /* end */
5642};
5643
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644static struct hda_verb alc882_init_verbs[] = {
5645 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005649 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005653 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005662 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005665 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005666 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005670 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005671 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005672 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005674 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005675 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005676 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005677 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005678 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5681 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5684 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5687 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005693
5694 /* FIXME: use matrix-type input source selection */
5695 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5696 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005701 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5711 /* ADC1: mute amp left and right */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005713 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005714 /* ADC2: mute amp left and right */
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005717 /* ADC3: mute amp left and right */
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005719 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005720
5721 { }
5722};
5723
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005724static struct hda_verb alc882_eapd_verbs[] = {
5725 /* change to EAPD mode */
5726 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005727 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005728 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005729};
5730
Tobin Davis9102cd12006-12-15 10:02:12 +01005731/* Mac Pro test */
5732static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5734 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5738 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5739 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5740 { } /* end */
5741};
5742
5743static struct hda_verb alc882_macpro_init_verbs[] = {
5744 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5748 /* Front Pin: output 0 (0x0c) */
5749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5751 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5752 /* Front Mic pin: input vref at 80% */
5753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5755 /* Speaker: output */
5756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5759 /* Headphone output (output 0 - 0x0c) */
5760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5762 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5763
5764 /* FIXME: use matrix-type input source selection */
5765 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5766 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5771 /* Input mixer2 */
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5776 /* Input mixer3 */
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5781 /* ADC1: mute amp left and right */
5782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5784 /* ADC2: mute amp left and right */
5785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5786 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5787 /* ADC3: mute amp left and right */
5788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5789 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5790
5791 { }
5792};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005793
Takashi Iwai87350ad2007-08-16 18:19:38 +02005794/* Macbook Pro rev3 */
5795static struct hda_verb alc885_mbp3_init_verbs[] = {
5796 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5800 /* Rear mixer */
5801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5804 /* Front Pin: output 0 (0x0c) */
5805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5807 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5808 /* HP Pin: output 0 (0x0d) */
5809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5812 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5813 /* Mic (rear) pin: input vref at 80% */
5814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5815 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5816 /* Front Mic pin: input vref at 80% */
5817 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5819 /* Line In pin: use output 1 when in LineOut mode */
5820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5822 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5823
5824 /* FIXME: use matrix-type input source selection */
5825 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5826 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5831 /* Input mixer2 */
5832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5834 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5835 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5836 /* Input mixer3 */
5837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5841 /* ADC1: mute amp left and right */
5842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5843 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5844 /* ADC2: mute amp left and right */
5845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5847 /* ADC3: mute amp left and right */
5848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5849 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5850
5851 { }
5852};
5853
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005854/* iMac 24 mixer. */
5855static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5856 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5857 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5858 { } /* end */
5859};
5860
5861/* iMac 24 init verbs. */
5862static struct hda_verb alc885_imac24_init_verbs[] = {
5863 /* Internal speakers: output 0 (0x0c) */
5864 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5866 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5867 /* Internal speakers: output 0 (0x0c) */
5868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5870 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5871 /* Headphone: output 0 (0x0c) */
5872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5874 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5876 /* Front Mic: input vref at 80% */
5877 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5878 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5879 { }
5880};
5881
5882/* Toggle speaker-output according to the hp-jack state */
5883static void alc885_imac24_automute(struct hda_codec *codec)
5884{
5885 unsigned int present;
5886
5887 present = snd_hda_codec_read(codec, 0x14, 0,
5888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005889 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5891 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5892 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005893}
5894
5895/* Processes unsolicited events. */
5896static void alc885_imac24_unsol_event(struct hda_codec *codec,
5897 unsigned int res)
5898{
5899 /* Headphone insertion or removal. */
5900 if ((res >> 26) == ALC880_HP_EVENT)
5901 alc885_imac24_automute(codec);
5902}
5903
Takashi Iwai87350ad2007-08-16 18:19:38 +02005904static void alc885_mbp3_automute(struct hda_codec *codec)
5905{
5906 unsigned int present;
5907
5908 present = snd_hda_codec_read(codec, 0x15, 0,
5909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5910 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5911 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5912 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5913 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5914
5915}
5916static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5917 unsigned int res)
5918{
5919 /* Headphone insertion or removal. */
5920 if ((res >> 26) == ALC880_HP_EVENT)
5921 alc885_mbp3_automute(codec);
5922}
5923
5924
Kailang Yang272a5272007-05-14 11:00:38 +02005925static struct hda_verb alc882_targa_verbs[] = {
5926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5928
5929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5931
5932 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5934 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5935
5936 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5937 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5938 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5939 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5940 { } /* end */
5941};
5942
5943/* toggle speaker-output according to the hp-jack state */
5944static void alc882_targa_automute(struct hda_codec *codec)
5945{
5946 unsigned int present;
5947
5948 present = snd_hda_codec_read(codec, 0x14, 0,
5949 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005950 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005952 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5953 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005954}
5955
5956static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5957{
5958 /* Looks like the unsol event is incompatible with the standard
5959 * definition. 4bit tag is placed at 26 bit!
5960 */
5961 if (((res >> 26) == ALC880_HP_EVENT)) {
5962 alc882_targa_automute(codec);
5963 }
5964}
5965
5966static struct hda_verb alc882_asus_a7j_verbs[] = {
5967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5969
5970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5973
5974 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5976 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5977
5978 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5979 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5980 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5981 { } /* end */
5982};
5983
Takashi Iwai914759b2007-09-06 14:52:04 +02005984static struct hda_verb alc882_asus_a7m_verbs[] = {
5985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5987
5988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5991
5992 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5994 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5995
5996 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5997 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5999 { } /* end */
6000};
6001
Tobin Davis9102cd12006-12-15 10:02:12 +01006002static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6003{
6004 unsigned int gpiostate, gpiomask, gpiodir;
6005
6006 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6007 AC_VERB_GET_GPIO_DATA, 0);
6008
6009 if (!muted)
6010 gpiostate |= (1 << pin);
6011 else
6012 gpiostate &= ~(1 << pin);
6013
6014 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6015 AC_VERB_GET_GPIO_MASK, 0);
6016 gpiomask |= (1 << pin);
6017
6018 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6019 AC_VERB_GET_GPIO_DIRECTION, 0);
6020 gpiodir |= (1 << pin);
6021
6022
6023 snd_hda_codec_write(codec, codec->afg, 0,
6024 AC_VERB_SET_GPIO_MASK, gpiomask);
6025 snd_hda_codec_write(codec, codec->afg, 0,
6026 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6027
6028 msleep(1);
6029
6030 snd_hda_codec_write(codec, codec->afg, 0,
6031 AC_VERB_SET_GPIO_DATA, gpiostate);
6032}
6033
Takashi Iwai7debbe52007-08-16 15:01:03 +02006034/* set up GPIO at initialization */
6035static void alc885_macpro_init_hook(struct hda_codec *codec)
6036{
6037 alc882_gpio_mute(codec, 0, 0);
6038 alc882_gpio_mute(codec, 1, 0);
6039}
6040
6041/* set up GPIO and update auto-muting at initialization */
6042static void alc885_imac24_init_hook(struct hda_codec *codec)
6043{
6044 alc885_macpro_init_hook(codec);
6045 alc885_imac24_automute(codec);
6046}
6047
Kailang Yangdf694da2005-12-05 19:42:22 +01006048/*
6049 * generic initialization of ADC, input mixers and output mixers
6050 */
6051static struct hda_verb alc882_auto_init_verbs[] = {
6052 /*
6053 * Unmute ADC0-2 and set the default input to mic-in
6054 */
6055 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6059 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6061
Takashi Iwaicb53c622007-08-10 17:21:45 +02006062 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006064 * Note: PASD motherboards uses the Line In 2 as the input for
6065 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 */
6067 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006073
6074 /*
6075 * Set up output mixers (0x0c - 0x0f)
6076 */
6077 /* set vol=0 to output mixers */
6078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6082 /* set up input amps for analog loopback */
6083 /* Amp Indices: DAC = 0, mixer = 1 */
6084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6092 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6093 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6094
6095 /* FIXME: use matrix-type input source selection */
6096 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6097 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6102 /* Input mixer2 */
6103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6107 /* Input mixer3 */
6108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6112
6113 { }
6114};
6115
6116/* capture mixer elements */
6117static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6122 {
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* The multiple "Capture Source" controls confuse alsamixer
6125 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006126 */
6127 /* .name = "Capture Source", */
6128 .name = "Input Source",
6129 .count = 2,
6130 .info = alc882_mux_enum_info,
6131 .get = alc882_mux_enum_get,
6132 .put = alc882_mux_enum_put,
6133 },
6134 { } /* end */
6135};
6136
6137static struct snd_kcontrol_new alc882_capture_mixer[] = {
6138 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6139 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6140 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6143 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6144 {
6145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6146 /* The multiple "Capture Source" controls confuse alsamixer
6147 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006148 */
6149 /* .name = "Capture Source", */
6150 .name = "Input Source",
6151 .count = 3,
6152 .info = alc882_mux_enum_info,
6153 .get = alc882_mux_enum_get,
6154 .put = alc882_mux_enum_put,
6155 },
6156 { } /* end */
6157};
6158
Takashi Iwaicb53c622007-08-10 17:21:45 +02006159#ifdef CONFIG_SND_HDA_POWER_SAVE
6160#define alc882_loopbacks alc880_loopbacks
6161#endif
6162
Kailang Yangdf694da2005-12-05 19:42:22 +01006163/* pcm configuration: identiacal with ALC880 */
6164#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6165#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6166#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6167#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6168
6169/*
6170 * configuration and preset
6171 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006172static const char *alc882_models[ALC882_MODEL_LAST] = {
6173 [ALC882_3ST_DIG] = "3stack-dig",
6174 [ALC882_6ST_DIG] = "6stack-dig",
6175 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006176 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006177 [ALC882_TARGA] = "targa",
6178 [ALC882_ASUS_A7J] = "asus-a7j",
6179 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006180 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006181 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006182 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006183 [ALC882_AUTO] = "auto",
6184};
6185
6186static struct snd_pci_quirk alc882_cfg_tbl[] = {
6187 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006188 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006189 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006190 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006191 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006192 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006193 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006194 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006195 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006196 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6197 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6198 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006199 {}
6200};
6201
6202static struct alc_config_preset alc882_presets[] = {
6203 [ALC882_3ST_DIG] = {
6204 .mixers = { alc882_base_mixer },
6205 .init_verbs = { alc882_init_verbs },
6206 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6207 .dac_nids = alc882_dac_nids,
6208 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006209 .dig_in_nid = ALC882_DIGIN_NID,
6210 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6211 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006212 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 .input_mux = &alc882_capture_source,
6214 },
6215 [ALC882_6ST_DIG] = {
6216 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6217 .init_verbs = { alc882_init_verbs },
6218 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6219 .dac_nids = alc882_dac_nids,
6220 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 .dig_in_nid = ALC882_DIGIN_NID,
6222 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6223 .channel_mode = alc882_sixstack_modes,
6224 .input_mux = &alc882_capture_source,
6225 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006226 [ALC882_ARIMA] = {
6227 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6228 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6229 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6230 .dac_nids = alc882_dac_nids,
6231 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6232 .channel_mode = alc882_sixstack_modes,
6233 .input_mux = &alc882_capture_source,
6234 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006235 [ALC882_W2JC] = {
6236 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6237 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6238 alc880_gpio1_init_verbs },
6239 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6240 .dac_nids = alc882_dac_nids,
6241 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6242 .channel_mode = alc880_threestack_modes,
6243 .need_dac_fix = 1,
6244 .input_mux = &alc882_capture_source,
6245 .dig_out_nid = ALC882_DIGOUT_NID,
6246 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006247 [ALC885_MBP3] = {
6248 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6249 .init_verbs = { alc885_mbp3_init_verbs,
6250 alc880_gpio1_init_verbs },
6251 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6252 .dac_nids = alc882_dac_nids,
6253 .channel_mode = alc885_mbp_6ch_modes,
6254 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6255 .input_mux = &alc882_capture_source,
6256 .dig_out_nid = ALC882_DIGOUT_NID,
6257 .dig_in_nid = ALC882_DIGIN_NID,
6258 .unsol_event = alc885_mbp3_unsol_event,
6259 .init_hook = alc885_mbp3_automute,
6260 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006261 [ALC885_MACPRO] = {
6262 .mixers = { alc882_macpro_mixer },
6263 .init_verbs = { alc882_macpro_init_verbs },
6264 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6265 .dac_nids = alc882_dac_nids,
6266 .dig_out_nid = ALC882_DIGOUT_NID,
6267 .dig_in_nid = ALC882_DIGIN_NID,
6268 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6269 .channel_mode = alc882_ch_modes,
6270 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006271 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006272 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006273 [ALC885_IMAC24] = {
6274 .mixers = { alc885_imac24_mixer },
6275 .init_verbs = { alc885_imac24_init_verbs },
6276 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6277 .dac_nids = alc882_dac_nids,
6278 .dig_out_nid = ALC882_DIGOUT_NID,
6279 .dig_in_nid = ALC882_DIGIN_NID,
6280 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6281 .channel_mode = alc882_ch_modes,
6282 .input_mux = &alc882_capture_source,
6283 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006284 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006285 },
Kailang Yang272a5272007-05-14 11:00:38 +02006286 [ALC882_TARGA] = {
6287 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6288 alc882_capture_mixer },
6289 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6290 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6291 .dac_nids = alc882_dac_nids,
6292 .dig_out_nid = ALC882_DIGOUT_NID,
6293 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6294 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006295 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006296 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6297 .channel_mode = alc882_3ST_6ch_modes,
6298 .need_dac_fix = 1,
6299 .input_mux = &alc882_capture_source,
6300 .unsol_event = alc882_targa_unsol_event,
6301 .init_hook = alc882_targa_automute,
6302 },
6303 [ALC882_ASUS_A7J] = {
6304 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6305 alc882_capture_mixer },
6306 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6307 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6308 .dac_nids = alc882_dac_nids,
6309 .dig_out_nid = ALC882_DIGOUT_NID,
6310 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6311 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006312 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006313 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6314 .channel_mode = alc882_3ST_6ch_modes,
6315 .need_dac_fix = 1,
6316 .input_mux = &alc882_capture_source,
6317 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006318 [ALC882_ASUS_A7M] = {
6319 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6320 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6321 alc880_gpio1_init_verbs,
6322 alc882_asus_a7m_verbs },
6323 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6324 .dac_nids = alc882_dac_nids,
6325 .dig_out_nid = ALC882_DIGOUT_NID,
6326 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6327 .channel_mode = alc880_threestack_modes,
6328 .need_dac_fix = 1,
6329 .input_mux = &alc882_capture_source,
6330 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006331};
6332
6333
6334/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006335 * Pin config fixes
6336 */
6337enum {
6338 PINFIX_ABIT_AW9D_MAX
6339};
6340
6341static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6342 { 0x15, 0x01080104 }, /* side */
6343 { 0x16, 0x01011012 }, /* rear */
6344 { 0x17, 0x01016011 }, /* clfe */
6345 { }
6346};
6347
6348static const struct alc_pincfg *alc882_pin_fixes[] = {
6349 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6350};
6351
6352static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6353 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6354 {}
6355};
6356
6357/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006358 * BIOS auto configuration
6359 */
6360static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6361 hda_nid_t nid, int pin_type,
6362 int dac_idx)
6363{
6364 /* set as output */
6365 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006366 int idx;
6367
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006368 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6370 idx = 4;
6371 else
6372 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006373 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6374
6375}
6376
6377static void alc882_auto_init_multi_out(struct hda_codec *codec)
6378{
6379 struct alc_spec *spec = codec->spec;
6380 int i;
6381
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006382 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006383 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006384 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006385 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006387 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006388 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 }
6390}
6391
6392static void alc882_auto_init_hp_out(struct hda_codec *codec)
6393{
6394 struct alc_spec *spec = codec->spec;
6395 hda_nid_t pin;
6396
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006397 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006398 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006399 /* use dac 0 */
6400 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006401 pin = spec->autocfg.speaker_pins[0];
6402 if (pin)
6403 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006404}
6405
6406#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6407#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6408
6409static void alc882_auto_init_analog_input(struct hda_codec *codec)
6410{
6411 struct alc_spec *spec = codec->spec;
6412 int i;
6413
6414 for (i = 0; i < AUTO_PIN_LAST; i++) {
6415 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006416 unsigned int vref;
6417 if (!nid)
6418 continue;
6419 vref = PIN_IN;
6420 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006421 unsigned int pincap;
6422 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6423 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006424 AC_PINCAP_VREF_80)
6425 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006427 snd_hda_codec_write(codec, nid, 0,
6428 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6429 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6430 snd_hda_codec_write(codec, nid, 0,
6431 AC_VERB_SET_AMP_GAIN_MUTE,
6432 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006433 }
6434}
6435
Takashi Iwai776e1842007-08-29 15:07:11 +02006436/* add mic boosts if needed */
6437static int alc_auto_add_mic_boost(struct hda_codec *codec)
6438{
6439 struct alc_spec *spec = codec->spec;
6440 int err;
6441 hda_nid_t nid;
6442
6443 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006444 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006445 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6446 "Mic Boost",
6447 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6448 if (err < 0)
6449 return err;
6450 }
6451 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006452 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006453 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6454 "Front Mic Boost",
6455 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6456 if (err < 0)
6457 return err;
6458 }
6459 return 0;
6460}
6461
Kailang Yangdf694da2005-12-05 19:42:22 +01006462/* almost identical with ALC880 parser... */
6463static int alc882_parse_auto_config(struct hda_codec *codec)
6464{
6465 struct alc_spec *spec = codec->spec;
6466 int err = alc880_parse_auto_config(codec);
6467
6468 if (err < 0)
6469 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006470 else if (!err)
6471 return 0; /* no config found */
6472
6473 err = alc_auto_add_mic_boost(codec);
6474 if (err < 0)
6475 return err;
6476
6477 /* hack - override the init verbs */
6478 spec->init_verbs[0] = alc882_auto_init_verbs;
6479
6480 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006481}
6482
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006483/* additional initialization for auto-configuration model */
6484static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006486 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 alc882_auto_init_multi_out(codec);
6488 alc882_auto_init_hp_out(codec);
6489 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006490 if (spec->unsol_event)
6491 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006492}
6493
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006494static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6495
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496static int patch_alc882(struct hda_codec *codec)
6497{
6498 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006499 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006500
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006501 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502 if (spec == NULL)
6503 return -ENOMEM;
6504
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505 codec->spec = spec;
6506
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006507 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6508 alc882_models,
6509 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006510
Kailang Yangdf694da2005-12-05 19:42:22 +01006511 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006512 /* Pick up systems that don't supply PCI SSID */
6513 switch (codec->subsystem_id) {
6514 case 0x106b0c00: /* Mac Pro */
6515 board_config = ALC885_MACPRO;
6516 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006517 case 0x106b1000: /* iMac 24 */
6518 board_config = ALC885_IMAC24;
6519 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006520 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006521 case 0x106b2c00: /* Macbook Pro rev3 */
6522 board_config = ALC885_MBP3;
6523 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006524 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006525 /* ALC889A is handled better as ALC888-compatible */
6526 if (codec->revision_id == 0x100103) {
6527 alc_free(codec);
6528 return patch_alc883(codec);
6529 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006530 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6531 "trying auto-probe from BIOS...\n");
6532 board_config = ALC882_AUTO;
6533 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006535
Takashi Iwaif95474e2007-07-10 00:47:43 +02006536 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6537
Kailang Yangdf694da2005-12-05 19:42:22 +01006538 if (board_config == ALC882_AUTO) {
6539 /* automatic parse from the BIOS config */
6540 err = alc882_parse_auto_config(codec);
6541 if (err < 0) {
6542 alc_free(codec);
6543 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006544 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006545 printk(KERN_INFO
6546 "hda_codec: Cannot set up configuration "
6547 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006548 board_config = ALC882_3ST_DIG;
6549 }
6550 }
6551
6552 if (board_config != ALC882_AUTO)
6553 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006554
Kailang Yang2f893282008-05-27 12:14:47 +02006555 if (codec->vendor_id == 0x10ec0885) {
6556 spec->stream_name_analog = "ALC885 Analog";
6557 spec->stream_name_digital = "ALC885 Digital";
6558 } else {
6559 spec->stream_name_analog = "ALC882 Analog";
6560 spec->stream_name_digital = "ALC882 Digital";
6561 }
6562
Kailang Yangdf694da2005-12-05 19:42:22 +01006563 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6564 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006565 /* FIXME: setup DAC5 */
6566 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6567 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006568
Kailang Yangdf694da2005-12-05 19:42:22 +01006569 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6570 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006572 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006574 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006575 /* get type */
6576 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006577 if (wcap != AC_WID_AUD_IN) {
6578 spec->adc_nids = alc882_adc_nids_alt;
6579 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006580 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006581 spec->mixers[spec->num_mixers] =
6582 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006583 spec->num_mixers++;
6584 } else {
6585 spec->adc_nids = alc882_adc_nids;
6586 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006587 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6589 spec->num_mixers++;
6590 }
6591 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006592
Takashi Iwai2134ea42008-01-10 16:53:55 +01006593 spec->vmaster_nid = 0x0c;
6594
Linus Torvalds1da177e2005-04-16 15:20:36 -07006595 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006596 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006597 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006598#ifdef CONFIG_SND_HDA_POWER_SAVE
6599 if (!spec->loopback.amplist)
6600 spec->loopback.amplist = alc882_loopbacks;
6601#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006602
6603 return 0;
6604}
6605
6606/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006607 * ALC883 support
6608 *
6609 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6610 * configuration. Each pin widget can choose any input DACs and a mixer.
6611 * Each ADC is connected from a mixer of all inputs. This makes possible
6612 * 6-channel independent captures.
6613 *
6614 * In addition, an independent DAC for the multi-playback (not used in this
6615 * driver yet).
6616 */
6617#define ALC883_DIGOUT_NID 0x06
6618#define ALC883_DIGIN_NID 0x0a
6619
6620static hda_nid_t alc883_dac_nids[4] = {
6621 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006622 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006623};
6624
6625static hda_nid_t alc883_adc_nids[2] = {
6626 /* ADC1-2 */
6627 0x08, 0x09,
6628};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006629
Takashi Iwaie1406342008-02-11 18:32:32 +01006630static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6631
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006632/* input MUX */
6633/* FIXME: should be a matrix-type input source selection */
6634
6635static struct hda_input_mux alc883_capture_source = {
6636 .num_items = 4,
6637 .items = {
6638 { "Mic", 0x0 },
6639 { "Front Mic", 0x1 },
6640 { "Line", 0x2 },
6641 { "CD", 0x4 },
6642 },
6643};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006644
Jiang zhe17bba1b2008-06-04 12:11:07 +02006645static struct hda_input_mux alc883_3stack_6ch_intel = {
6646 .num_items = 4,
6647 .items = {
6648 { "Mic", 0x1 },
6649 { "Front Mic", 0x0 },
6650 { "Line", 0x2 },
6651 { "CD", 0x4 },
6652 },
6653};
6654
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006655static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6656 .num_items = 2,
6657 .items = {
6658 { "Mic", 0x1 },
6659 { "Line", 0x2 },
6660 },
6661};
6662
Kailang Yang272a5272007-05-14 11:00:38 +02006663static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6664 .num_items = 4,
6665 .items = {
6666 { "Mic", 0x0 },
6667 { "iMic", 0x1 },
6668 { "Line", 0x2 },
6669 { "CD", 0x4 },
6670 },
6671};
6672
Jiang zhefb97dc62008-03-06 11:07:11 +01006673static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6674 .num_items = 2,
6675 .items = {
6676 { "Mic", 0x0 },
6677 { "Int Mic", 0x1 },
6678 },
6679};
6680
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006681#define alc883_mux_enum_info alc_mux_enum_info
6682#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006683/* ALC883 has the ALC882-type input selection */
6684#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006685
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006686/*
6687 * 2ch mode
6688 */
6689static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6690 { 2, NULL }
6691};
6692
6693/*
6694 * 2ch mode
6695 */
6696static struct hda_verb alc883_3ST_ch2_init[] = {
6697 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6698 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6701 { } /* end */
6702};
6703
6704/*
Tobin Davisb2011312007-09-17 12:45:11 +02006705 * 4ch mode
6706 */
6707static struct hda_verb alc883_3ST_ch4_init[] = {
6708 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6709 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6714};
6715
6716/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717 * 6ch mode
6718 */
6719static struct hda_verb alc883_3ST_ch6_init[] = {
6720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6722 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6723 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6724 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6725 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6726 { } /* end */
6727};
6728
Tobin Davisb2011312007-09-17 12:45:11 +02006729static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006730 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006731 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006732 { 6, alc883_3ST_ch6_init },
6733};
6734
6735/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006736 * 2ch mode
6737 */
6738static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6739 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6740 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6742 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6743 { } /* end */
6744};
6745
6746/*
6747 * 4ch mode
6748 */
6749static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6750 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6751 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6752 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6753 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6754 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6755 { } /* end */
6756};
6757
6758/*
6759 * 6ch mode
6760 */
6761static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6762 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6763 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6764 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6768 { } /* end */
6769};
6770
6771static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6772 { 2, alc883_3ST_ch2_intel_init },
6773 { 4, alc883_3ST_ch4_intel_init },
6774 { 6, alc883_3ST_ch6_intel_init },
6775};
6776
6777/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006778 * 6ch mode
6779 */
6780static struct hda_verb alc883_sixstack_ch6_init[] = {
6781 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6782 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6783 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6785 { } /* end */
6786};
6787
6788/*
6789 * 8ch mode
6790 */
6791static struct hda_verb alc883_sixstack_ch8_init[] = {
6792 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6793 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6795 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { } /* end */
6797};
6798
6799static struct hda_channel_mode alc883_sixstack_modes[2] = {
6800 { 6, alc883_sixstack_ch6_init },
6801 { 8, alc883_sixstack_ch8_init },
6802};
6803
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006804static struct hda_verb alc883_medion_eapd_verbs[] = {
6805 /* eanable EAPD on medion laptop */
6806 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6807 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6808 { }
6809};
6810
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006811/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6812 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6813 */
6814
6815static struct snd_kcontrol_new alc883_base_mixer[] = {
6816 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6817 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6819 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6822 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6823 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6824 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6825 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6834 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006835 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6837 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6838 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6841 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6843 {
6844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6845 /* .name = "Capture Source", */
6846 .name = "Input Source",
6847 .count = 2,
6848 .info = alc883_mux_enum_info,
6849 .get = alc883_mux_enum_get,
6850 .put = alc883_mux_enum_put,
6851 },
6852 { } /* end */
6853};
6854
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006855static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6858 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6860 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6861 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6870 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6871 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6872 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6873 {
6874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6875 /* .name = "Capture Source", */
6876 .name = "Input Source",
6877 .count = 2,
6878 .info = alc883_mux_enum_info,
6879 .get = alc883_mux_enum_get,
6880 .put = alc883_mux_enum_put,
6881 },
6882 { } /* end */
6883};
6884
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01006885static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01006886 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6887 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6888 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6889 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6893 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6894 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6895 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6896 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6897 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6899 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6900 {
6901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6902 /* .name = "Capture Source", */
6903 .name = "Input Source",
6904 .count = 2,
6905 .info = alc883_mux_enum_info,
6906 .get = alc883_mux_enum_get,
6907 .put = alc883_mux_enum_put,
6908 },
6909 { } /* end */
6910};
6911
Jiang zhefb97dc62008-03-06 11:07:11 +01006912static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6913 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6914 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6916 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6920 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6921 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6922 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6925 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6926 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6927 {
6928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6929 /* .name = "Capture Source", */
6930 .name = "Input Source",
6931 .count = 2,
6932 .info = alc883_mux_enum_info,
6933 .get = alc883_mux_enum_get,
6934 .put = alc883_mux_enum_put,
6935 },
6936 { } /* end */
6937};
6938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006939static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6941 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006948 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6953 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6954 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6955 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6956 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6957 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6958 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6959 {
6960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6961 /* .name = "Capture Source", */
6962 .name = "Input Source",
6963 .count = 2,
6964 .info = alc883_mux_enum_info,
6965 .get = alc883_mux_enum_get,
6966 .put = alc883_mux_enum_put,
6967 },
6968 { } /* end */
6969};
6970
6971static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6984 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006986 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006989 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6991 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6992 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6994 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6995 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6996 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6997 {
6998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6999 /* .name = "Capture Source", */
7000 .name = "Input Source",
7001 .count = 2,
7002 .info = alc883_mux_enum_info,
7003 .get = alc883_mux_enum_get,
7004 .put = alc883_mux_enum_put,
7005 },
7006 { } /* end */
7007};
7008
Jiang zhe17bba1b2008-06-04 12:11:07 +02007009static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7010 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7011 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7013 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7015 HDA_OUTPUT),
7016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7017 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7018 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7030 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7031 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7033 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7034 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7035 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7036 {
7037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7038 /* .name = "Capture Source", */
7039 .name = "Input Source",
7040 .count = 2,
7041 .info = alc883_mux_enum_info,
7042 .get = alc883_mux_enum_get,
7043 .put = alc883_mux_enum_put,
7044 },
7045 { } /* end */
7046};
7047
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007048static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7050 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7055 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
7056 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7058 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007066 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7068 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7069 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7071 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7072
7073 {
7074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7075 /* .name = "Capture Source", */
7076 .name = "Input Source",
7077 .count = 1,
7078 .info = alc883_mux_enum_info,
7079 .get = alc883_mux_enum_get,
7080 .put = alc883_mux_enum_put,
7081 },
7082 { } /* end */
7083};
7084
Kailang Yangccc656c2006-10-17 12:32:26 +02007085static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7090 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7102 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7103 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7104 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7105 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7106 {
7107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7108 /* .name = "Capture Source", */
7109 .name = "Input Source",
7110 .count = 2,
7111 .info = alc883_mux_enum_info,
7112 .get = alc883_mux_enum_get,
7113 .put = alc883_mux_enum_put,
7114 },
7115 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007116};
Kailang Yangccc656c2006-10-17 12:32:26 +02007117
7118static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7121 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007125 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007127 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7128 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7129 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007130 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7131 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7132 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7133 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7134 {
7135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7136 /* .name = "Capture Source", */
7137 .name = "Input Source",
7138 .count = 2,
7139 .info = alc883_mux_enum_info,
7140 .get = alc883_mux_enum_get,
7141 .put = alc883_mux_enum_put,
7142 },
7143 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007144};
Kailang Yangccc656c2006-10-17 12:32:26 +02007145
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007146static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007149 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7150 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007151 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7156 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7157 {
7158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7159 /* .name = "Capture Source", */
7160 .name = "Input Source",
7161 .count = 1,
7162 .info = alc883_mux_enum_info,
7163 .get = alc883_mux_enum_get,
7164 .put = alc883_mux_enum_put,
7165 },
7166 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007167};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007168
Kailang Yang272a5272007-05-14 11:00:38 +02007169static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7170 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7177 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7178 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7180 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7181 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7182 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7183 {
7184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7185 /* .name = "Capture Source", */
7186 .name = "Input Source",
7187 .count = 2,
7188 .info = alc883_mux_enum_info,
7189 .get = alc883_mux_enum_get,
7190 .put = alc883_mux_enum_put,
7191 },
7192 { } /* end */
7193};
7194
7195static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7198 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7199 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7200 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7205 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7206 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7207 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7208 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7209 {
7210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7211 /* .name = "Capture Source", */
7212 .name = "Input Source",
7213 .count = 2,
7214 .info = alc883_mux_enum_info,
7215 .get = alc883_mux_enum_get,
7216 .put = alc883_mux_enum_put,
7217 },
7218 { } /* end */
7219};
7220
Tobin Davis2880a862007-08-07 11:50:26 +02007221static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007230 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7231 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7233 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7234 {
7235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7236 /* .name = "Capture Source", */
7237 .name = "Input Source",
7238 .count = 2,
7239 .info = alc883_mux_enum_info,
7240 .get = alc883_mux_enum_get,
7241 .put = alc883_mux_enum_put,
7242 },
7243 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007244};
Tobin Davis2880a862007-08-07 11:50:26 +02007245
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007246static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7247 {
7248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7249 .name = "Channel Mode",
7250 .info = alc_ch_mode_info,
7251 .get = alc_ch_mode_get,
7252 .put = alc_ch_mode_put,
7253 },
7254 { } /* end */
7255};
7256
7257static struct hda_verb alc883_init_verbs[] = {
7258 /* ADC1: mute amp left and right */
7259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7260 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7261 /* ADC2: mute amp left and right */
7262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7264 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7268 /* Rear mixer */
7269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7272 /* CLFE mixer */
7273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7276 /* Side mixer */
7277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7280
Takashi Iwaicb53c622007-08-10 17:21:45 +02007281 /* mute analog input loopbacks */
7282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007287
7288 /* Front Pin: output 0 (0x0c) */
7289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7291 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7292 /* Rear Pin: output 1 (0x0d) */
7293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7296 /* CLFE Pin: output 2 (0x0e) */
7297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7299 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7300 /* Side Pin: output 3 (0x0f) */
7301 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7302 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7303 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7304 /* Mic (rear) pin: input vref at 80% */
7305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7307 /* Front Mic pin: input vref at 80% */
7308 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7310 /* Line In pin: input */
7311 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7313 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7317 /* CD pin widget for input */
7318 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7319
7320 /* FIXME: use matrix-type input source selection */
7321 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7322 /* Input mixer2 */
7323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7327 /* Input mixer3 */
7328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7332 { }
7333};
7334
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007335/* toggle speaker-output according to the hp-jack state */
7336static void alc883_mitac_hp_automute(struct hda_codec *codec)
7337{
7338 unsigned int present;
7339
7340 present = snd_hda_codec_read(codec, 0x15, 0,
7341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7342 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7343 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7344 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7345 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7346}
7347
7348/* auto-toggle front mic */
7349/*
7350static void alc883_mitac_mic_automute(struct hda_codec *codec)
7351{
7352 unsigned int present;
7353 unsigned char bits;
7354
7355 present = snd_hda_codec_read(codec, 0x18, 0,
7356 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7357 bits = present ? HDA_AMP_MUTE : 0;
7358 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7359}
7360*/
7361
7362static void alc883_mitac_automute(struct hda_codec *codec)
7363{
7364 alc883_mitac_hp_automute(codec);
7365 /* alc883_mitac_mic_automute(codec); */
7366}
7367
7368static void alc883_mitac_unsol_event(struct hda_codec *codec,
7369 unsigned int res)
7370{
7371 switch (res >> 26) {
7372 case ALC880_HP_EVENT:
7373 alc883_mitac_hp_automute(codec);
7374 break;
7375 case ALC880_MIC_EVENT:
7376 /* alc883_mitac_mic_automute(codec); */
7377 break;
7378 }
7379}
7380
7381static struct hda_verb alc883_mitac_verbs[] = {
7382 /* HP */
7383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7385 /* Subwoofer */
7386 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7388
7389 /* enable unsolicited event */
7390 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7391 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7392
7393 { } /* end */
7394};
7395
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007396static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007397 /* HP */
7398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7400 /* Int speaker */
7401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7403
7404 /* enable unsolicited event */
7405 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007407
7408 { } /* end */
7409};
7410
Jiang zhefb97dc62008-03-06 11:07:11 +01007411static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7412 /* HP */
7413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7415 /* Subwoofer */
7416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7418
7419 /* enable unsolicited event */
7420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7421
7422 { } /* end */
7423};
7424
Kailang Yangccc656c2006-10-17 12:32:26 +02007425static struct hda_verb alc883_tagra_verbs[] = {
7426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7428
7429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431
7432 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7433 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7434 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7435
7436 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007437 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7438 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7439 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007440
7441 { } /* end */
7442};
7443
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007444static struct hda_verb alc883_lenovo_101e_verbs[] = {
7445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7447 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7448 { } /* end */
7449};
7450
Kailang Yang272a5272007-05-14 11:00:38 +02007451static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7456 { } /* end */
7457};
7458
7459static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7464 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7465 { } /* end */
7466};
7467
Kailang Yang189609a2007-08-20 11:31:23 +02007468static struct hda_verb alc883_haier_w66_verbs[] = {
7469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7471
7472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7473
7474 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7476 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7478 { } /* end */
7479};
7480
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007481static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007482 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007483 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7484 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007485 { }
7486};
7487
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007488static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007489 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7490 { }
7491};
7492
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007493static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007494 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7495 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7496 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7497 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7498 { }
7499};
7500
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007501static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007502 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7503 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7505 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7506 { }
7507};
7508
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007509static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7510 { 2, alc888_3st_hp_2ch_init },
7511 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007512};
7513
Kailang Yang272a5272007-05-14 11:00:38 +02007514/* toggle front-jack and RCA according to the hp-jack state */
7515static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7516{
7517 unsigned int present;
7518
7519 present = snd_hda_codec_read(codec, 0x1b, 0,
7520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007521 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7522 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7523 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7524 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007525}
7526
7527/* toggle RCA according to the front-jack state */
7528static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7529{
7530 unsigned int present;
7531
7532 present = snd_hda_codec_read(codec, 0x14, 0,
7533 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007534 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7535 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007536}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007537
Kailang Yang272a5272007-05-14 11:00:38 +02007538static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7539 unsigned int res)
7540{
7541 if ((res >> 26) == ALC880_HP_EVENT)
7542 alc888_lenovo_ms7195_front_automute(codec);
7543 if ((res >> 26) == ALC880_FRONT_EVENT)
7544 alc888_lenovo_ms7195_rca_automute(codec);
7545}
7546
7547static struct hda_verb alc883_medion_md2_verbs[] = {
7548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7550
7551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7552
7553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7554 { } /* end */
7555};
7556
7557/* toggle speaker-output according to the hp-jack state */
7558static void alc883_medion_md2_automute(struct hda_codec *codec)
7559{
7560 unsigned int present;
7561
7562 present = snd_hda_codec_read(codec, 0x14, 0,
7563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007564 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7565 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007566}
7567
7568static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7569 unsigned int res)
7570{
7571 if ((res >> 26) == ALC880_HP_EVENT)
7572 alc883_medion_md2_automute(codec);
7573}
7574
Kailang Yangccc656c2006-10-17 12:32:26 +02007575/* toggle speaker-output according to the hp-jack state */
7576static void alc883_tagra_automute(struct hda_codec *codec)
7577{
7578 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007579 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007580
7581 present = snd_hda_codec_read(codec, 0x14, 0,
7582 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007583 bits = present ? HDA_AMP_MUTE : 0;
7584 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7585 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007586 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7587 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007588}
7589
7590static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7591{
7592 if ((res >> 26) == ALC880_HP_EVENT)
7593 alc883_tagra_automute(codec);
7594}
7595
Jiang zhe368c7a92008-03-04 11:20:33 +01007596/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007597static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007598{
7599 unsigned int present;
7600 unsigned char bits;
7601
7602 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7603 & AC_PINSENSE_PRESENCE;
7604 bits = present ? HDA_AMP_MUTE : 0;
7605 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7606 HDA_AMP_MUTE, bits);
7607}
7608
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007609static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7610{
7611 unsigned int present;
7612
7613 present = snd_hda_codec_read(codec, 0x18, 0,
7614 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7615 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7616 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7617}
7618
7619static void alc883_clevo_m720_automute(struct hda_codec *codec)
7620{
7621 alc883_clevo_m720_hp_automute(codec);
7622 alc883_clevo_m720_mic_automute(codec);
7623}
7624
7625static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007626 unsigned int res)
7627{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007628 switch (res >> 26) {
7629 case ALC880_HP_EVENT:
7630 alc883_clevo_m720_hp_automute(codec);
7631 break;
7632 case ALC880_MIC_EVENT:
7633 alc883_clevo_m720_mic_automute(codec);
7634 break;
7635 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007636}
7637
Jiang zhefb97dc62008-03-06 11:07:11 +01007638/* toggle speaker-output according to the hp-jack state */
7639static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7640{
7641 unsigned int present;
7642 unsigned char bits;
7643
7644 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7645 & AC_PINSENSE_PRESENCE;
7646 bits = present ? HDA_AMP_MUTE : 0;
7647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7648 HDA_AMP_MUTE, bits);
7649}
7650
7651static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7652 unsigned int res)
7653{
7654 if ((res >> 26) == ALC880_HP_EVENT)
7655 alc883_2ch_fujitsu_pi2515_automute(codec);
7656}
7657
Kailang Yang189609a2007-08-20 11:31:23 +02007658static void alc883_haier_w66_automute(struct hda_codec *codec)
7659{
7660 unsigned int present;
7661 unsigned char bits;
7662
7663 present = snd_hda_codec_read(codec, 0x1b, 0,
7664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7665 bits = present ? 0x80 : 0;
7666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7667 0x80, bits);
7668}
7669
7670static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7671 unsigned int res)
7672{
7673 if ((res >> 26) == ALC880_HP_EVENT)
7674 alc883_haier_w66_automute(codec);
7675}
7676
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007677static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7678{
7679 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007680 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007681
7682 present = snd_hda_codec_read(codec, 0x14, 0,
7683 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007684 bits = present ? HDA_AMP_MUTE : 0;
7685 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7686 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007687}
7688
7689static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7690{
7691 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007692 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007693
7694 present = snd_hda_codec_read(codec, 0x1b, 0,
7695 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007696 bits = present ? HDA_AMP_MUTE : 0;
7697 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7698 HDA_AMP_MUTE, bits);
7699 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7700 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007701}
7702
7703static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7704 unsigned int res)
7705{
7706 if ((res >> 26) == ALC880_HP_EVENT)
7707 alc883_lenovo_101e_all_automute(codec);
7708 if ((res >> 26) == ALC880_FRONT_EVENT)
7709 alc883_lenovo_101e_ispeaker_automute(codec);
7710}
7711
Takashi Iwai676a9b52007-08-16 15:23:35 +02007712/* toggle speaker-output according to the hp-jack state */
7713static void alc883_acer_aspire_automute(struct hda_codec *codec)
7714{
7715 unsigned int present;
7716
7717 present = snd_hda_codec_read(codec, 0x14, 0,
7718 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7720 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7721 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7722 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7723}
7724
7725static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7726 unsigned int res)
7727{
7728 if ((res >> 26) == ALC880_HP_EVENT)
7729 alc883_acer_aspire_automute(codec);
7730}
7731
Kailang Yangd1a991a2007-08-15 16:21:59 +02007732static struct hda_verb alc883_acer_eapd_verbs[] = {
7733 /* HP Pin: output 0 (0x0c) */
7734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7736 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7737 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007741 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7742 /* eanable EAPD on medion laptop */
7743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7744 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007745 /* enable unsolicited event */
7746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007747 { }
7748};
7749
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007750static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7751{
7752 unsigned int present;
7753
7754 present = snd_hda_codec_read(codec, 0x1b, 0,
7755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7756 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7757 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7758 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7759 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7760 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7761 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7762 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7764}
7765
7766static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7767 unsigned int res)
7768{
7769 switch (res >> 26) {
7770 case ALC880_HP_EVENT:
7771 printk("hp_event\n");
7772 alc888_6st_dell_front_automute(codec);
7773 break;
7774 }
7775}
7776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007777/*
7778 * generic initialization of ADC, input mixers and output mixers
7779 */
7780static struct hda_verb alc883_auto_init_verbs[] = {
7781 /*
7782 * Unmute ADC0-2 and set the default input to mic-in
7783 */
7784 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7786 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7788
Takashi Iwaicb53c622007-08-10 17:21:45 +02007789 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007790 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007791 * Note: PASD motherboards uses the Line In 2 as the input for
7792 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007793 */
7794 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007800
7801 /*
7802 * Set up output mixers (0x0c - 0x0f)
7803 */
7804 /* set vol=0 to output mixers */
7805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7808 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7809 /* set up input amps for analog loopback */
7810 /* Amp Indices: DAC = 0, mixer = 1 */
7811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7819 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7820 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7821
7822 /* FIXME: use matrix-type input source selection */
7823 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7824 /* Input mixer1 */
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007828 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7830 /* Input mixer2 */
7831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007834 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007836
7837 { }
7838};
7839
7840/* capture mixer elements */
7841static struct snd_kcontrol_new alc883_capture_mixer[] = {
7842 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7843 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7844 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7845 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7846 {
7847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7848 /* The multiple "Capture Source" controls confuse alsamixer
7849 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007850 */
7851 /* .name = "Capture Source", */
7852 .name = "Input Source",
7853 .count = 2,
7854 .info = alc882_mux_enum_info,
7855 .get = alc882_mux_enum_get,
7856 .put = alc882_mux_enum_put,
7857 },
7858 { } /* end */
7859};
7860
Takashi Iwaicb53c622007-08-10 17:21:45 +02007861#ifdef CONFIG_SND_HDA_POWER_SAVE
7862#define alc883_loopbacks alc880_loopbacks
7863#endif
7864
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007865/* pcm configuration: identiacal with ALC880 */
7866#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7867#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007868#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007869#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7870#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7871
7872/*
7873 * configuration and preset
7874 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007875static const char *alc883_models[ALC883_MODEL_LAST] = {
7876 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7877 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7878 [ALC883_3ST_6ch] = "3stack-6ch",
7879 [ALC883_6ST_DIG] = "6stack-dig",
7880 [ALC883_TARGA_DIG] = "targa-dig",
7881 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007882 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007883 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007884 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007885 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007886 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007887 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007888 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7889 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007890 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007891 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007892 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007893 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007894 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01007895 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02007896 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007897 [ALC883_AUTO] = "auto",
7898};
7899
7900static struct snd_pci_quirk alc883_cfg_tbl[] = {
7901 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007902 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7903 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7904 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7905 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007906 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007907 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007908 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7909 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01007910 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007911 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02007912 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007913 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007914 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7915 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7916 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007917 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007918 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7919 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7920 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02007921 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007922 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007923 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007924 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7925 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7926 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7927 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7928 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7929 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7930 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7931 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7932 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007933 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7934 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007935 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01007936 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007937 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007938 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007939 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007940 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007941 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7942 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007943 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007944 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007945 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007946 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007947 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007948 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007949 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7950 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007951 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007952 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007953 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007954 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7955 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007956 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007957 {}
7958};
7959
7960static struct alc_config_preset alc883_presets[] = {
7961 [ALC883_3ST_2ch_DIG] = {
7962 .mixers = { alc883_3ST_2ch_mixer },
7963 .init_verbs = { alc883_init_verbs },
7964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7965 .dac_nids = alc883_dac_nids,
7966 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967 .dig_in_nid = ALC883_DIGIN_NID,
7968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7969 .channel_mode = alc883_3ST_2ch_modes,
7970 .input_mux = &alc883_capture_source,
7971 },
7972 [ALC883_3ST_6ch_DIG] = {
7973 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7974 .init_verbs = { alc883_init_verbs },
7975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7976 .dac_nids = alc883_dac_nids,
7977 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007978 .dig_in_nid = ALC883_DIGIN_NID,
7979 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7980 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007981 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007982 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007983 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007984 [ALC883_3ST_6ch] = {
7985 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7986 .init_verbs = { alc883_init_verbs },
7987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7988 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007989 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7990 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007991 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007992 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007993 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02007994 [ALC883_3ST_6ch_INTEL] = {
7995 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
7996 .init_verbs = { alc883_init_verbs },
7997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7998 .dac_nids = alc883_dac_nids,
7999 .dig_out_nid = ALC883_DIGOUT_NID,
8000 .dig_in_nid = ALC883_DIGIN_NID,
8001 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8002 .channel_mode = alc883_3ST_6ch_intel_modes,
8003 .need_dac_fix = 1,
8004 .input_mux = &alc883_3stack_6ch_intel,
8005 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008006 [ALC883_6ST_DIG] = {
8007 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8008 .init_verbs = { alc883_init_verbs },
8009 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8010 .dac_nids = alc883_dac_nids,
8011 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008012 .dig_in_nid = ALC883_DIGIN_NID,
8013 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8014 .channel_mode = alc883_sixstack_modes,
8015 .input_mux = &alc883_capture_source,
8016 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008017 [ALC883_TARGA_DIG] = {
8018 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8019 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8021 .dac_nids = alc883_dac_nids,
8022 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008023 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8024 .channel_mode = alc883_3ST_6ch_modes,
8025 .need_dac_fix = 1,
8026 .input_mux = &alc883_capture_source,
8027 .unsol_event = alc883_tagra_unsol_event,
8028 .init_hook = alc883_tagra_automute,
8029 },
8030 [ALC883_TARGA_2ch_DIG] = {
8031 .mixers = { alc883_tagra_2ch_mixer},
8032 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8034 .dac_nids = alc883_dac_nids,
8035 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008036 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8037 .channel_mode = alc883_3ST_2ch_modes,
8038 .input_mux = &alc883_capture_source,
8039 .unsol_event = alc883_tagra_unsol_event,
8040 .init_hook = alc883_tagra_automute,
8041 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008042 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008043 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008044 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8045 * and the headphone jack. Turn this on and rely on the
8046 * standard mute methods whenever the user wants to turn
8047 * these outputs off.
8048 */
8049 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8050 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8051 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8053 .channel_mode = alc883_3ST_2ch_modes,
8054 .input_mux = &alc883_capture_source,
8055 },
Tobin Davis2880a862007-08-07 11:50:26 +02008056 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008057 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008058 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008059 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8060 .dac_nids = alc883_dac_nids,
8061 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008062 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8063 .channel_mode = alc883_3ST_2ch_modes,
8064 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008065 .unsol_event = alc883_acer_aspire_unsol_event,
8066 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008067 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008068 [ALC883_MEDION] = {
8069 .mixers = { alc883_fivestack_mixer,
8070 alc883_chmode_mixer },
8071 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008072 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8074 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008075 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8076 .channel_mode = alc883_sixstack_modes,
8077 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008078 },
Kailang Yang272a5272007-05-14 11:00:38 +02008079 [ALC883_MEDION_MD2] = {
8080 .mixers = { alc883_medion_md2_mixer},
8081 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8083 .dac_nids = alc883_dac_nids,
8084 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008085 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8086 .channel_mode = alc883_3ST_2ch_modes,
8087 .input_mux = &alc883_capture_source,
8088 .unsol_event = alc883_medion_md2_unsol_event,
8089 .init_hook = alc883_medion_md2_automute,
8090 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008091 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008092 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008093 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8095 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8097 .channel_mode = alc883_3ST_2ch_modes,
8098 .input_mux = &alc883_capture_source,
8099 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008100 [ALC883_CLEVO_M720] = {
8101 .mixers = { alc883_clevo_m720_mixer },
8102 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8104 .dac_nids = alc883_dac_nids,
8105 .dig_out_nid = ALC883_DIGOUT_NID,
8106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8107 .channel_mode = alc883_3ST_2ch_modes,
8108 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008109 .unsol_event = alc883_clevo_m720_unsol_event,
8110 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008111 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008112 [ALC883_LENOVO_101E_2ch] = {
8113 .mixers = { alc883_lenovo_101e_2ch_mixer},
8114 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8116 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008117 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8118 .channel_mode = alc883_3ST_2ch_modes,
8119 .input_mux = &alc883_lenovo_101e_capture_source,
8120 .unsol_event = alc883_lenovo_101e_unsol_event,
8121 .init_hook = alc883_lenovo_101e_all_automute,
8122 },
Kailang Yang272a5272007-05-14 11:00:38 +02008123 [ALC883_LENOVO_NB0763] = {
8124 .mixers = { alc883_lenovo_nb0763_mixer },
8125 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8127 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008128 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8129 .channel_mode = alc883_3ST_2ch_modes,
8130 .need_dac_fix = 1,
8131 .input_mux = &alc883_lenovo_nb0763_capture_source,
8132 .unsol_event = alc883_medion_md2_unsol_event,
8133 .init_hook = alc883_medion_md2_automute,
8134 },
8135 [ALC888_LENOVO_MS7195_DIG] = {
8136 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8137 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8139 .dac_nids = alc883_dac_nids,
8140 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8142 .channel_mode = alc883_3ST_6ch_modes,
8143 .need_dac_fix = 1,
8144 .input_mux = &alc883_capture_source,
8145 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8146 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008147 },
8148 [ALC883_HAIER_W66] = {
8149 .mixers = { alc883_tagra_2ch_mixer},
8150 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8151 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8152 .dac_nids = alc883_dac_nids,
8153 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8155 .channel_mode = alc883_3ST_2ch_modes,
8156 .input_mux = &alc883_capture_source,
8157 .unsol_event = alc883_haier_w66_unsol_event,
8158 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008159 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008160 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008161 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008162 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008163 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8164 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008165 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8166 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008167 .need_dac_fix = 1,
8168 .input_mux = &alc883_capture_source,
8169 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008170 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008171 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008172 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8173 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8174 .dac_nids = alc883_dac_nids,
8175 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008176 .dig_in_nid = ALC883_DIGIN_NID,
8177 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8178 .channel_mode = alc883_sixstack_modes,
8179 .input_mux = &alc883_capture_source,
8180 .unsol_event = alc888_6st_dell_unsol_event,
8181 .init_hook = alc888_6st_dell_front_automute,
8182 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008183 [ALC883_MITAC] = {
8184 .mixers = { alc883_mitac_mixer },
8185 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8187 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008188 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8189 .channel_mode = alc883_3ST_2ch_modes,
8190 .input_mux = &alc883_capture_source,
8191 .unsol_event = alc883_mitac_unsol_event,
8192 .init_hook = alc883_mitac_automute,
8193 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008194 [ALC883_FUJITSU_PI2515] = {
8195 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8196 .init_verbs = { alc883_init_verbs,
8197 alc883_2ch_fujitsu_pi2515_verbs},
8198 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8199 .dac_nids = alc883_dac_nids,
8200 .dig_out_nid = ALC883_DIGOUT_NID,
8201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8202 .channel_mode = alc883_3ST_2ch_modes,
8203 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8204 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8205 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8206 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008207};
8208
8209
8210/*
8211 * BIOS auto configuration
8212 */
8213static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8214 hda_nid_t nid, int pin_type,
8215 int dac_idx)
8216{
8217 /* set as output */
8218 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008219 int idx;
8220
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008221 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008222 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8223 idx = 4;
8224 else
8225 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008226 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8227
8228}
8229
8230static void alc883_auto_init_multi_out(struct hda_codec *codec)
8231{
8232 struct alc_spec *spec = codec->spec;
8233 int i;
8234
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008235 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008236 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008237 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008238 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008239 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008240 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008241 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008242 }
8243}
8244
8245static void alc883_auto_init_hp_out(struct hda_codec *codec)
8246{
8247 struct alc_spec *spec = codec->spec;
8248 hda_nid_t pin;
8249
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008250 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008251 if (pin) /* connect to front */
8252 /* use dac 0 */
8253 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008254 pin = spec->autocfg.speaker_pins[0];
8255 if (pin)
8256 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008257}
8258
8259#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8260#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8261
8262static void alc883_auto_init_analog_input(struct hda_codec *codec)
8263{
8264 struct alc_spec *spec = codec->spec;
8265 int i;
8266
8267 for (i = 0; i < AUTO_PIN_LAST; i++) {
8268 hda_nid_t nid = spec->autocfg.input_pins[i];
8269 if (alc883_is_input_pin(nid)) {
8270 snd_hda_codec_write(codec, nid, 0,
8271 AC_VERB_SET_PIN_WIDGET_CONTROL,
8272 (i <= AUTO_PIN_FRONT_MIC ?
8273 PIN_VREF80 : PIN_IN));
8274 if (nid != ALC883_PIN_CD_NID)
8275 snd_hda_codec_write(codec, nid, 0,
8276 AC_VERB_SET_AMP_GAIN_MUTE,
8277 AMP_OUT_MUTE);
8278 }
8279 }
8280}
8281
8282/* almost identical with ALC880 parser... */
8283static int alc883_parse_auto_config(struct hda_codec *codec)
8284{
8285 struct alc_spec *spec = codec->spec;
8286 int err = alc880_parse_auto_config(codec);
8287
8288 if (err < 0)
8289 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008290 else if (!err)
8291 return 0; /* no config found */
8292
8293 err = alc_auto_add_mic_boost(codec);
8294 if (err < 0)
8295 return err;
8296
8297 /* hack - override the init verbs */
8298 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008299 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8300 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008301
8302 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008303}
8304
8305/* additional initialization for auto-configuration model */
8306static void alc883_auto_init(struct hda_codec *codec)
8307{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008308 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008309 alc883_auto_init_multi_out(codec);
8310 alc883_auto_init_hp_out(codec);
8311 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008312 if (spec->unsol_event)
8313 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008314}
8315
8316static int patch_alc883(struct hda_codec *codec)
8317{
8318 struct alc_spec *spec;
8319 int err, board_config;
8320
8321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8322 if (spec == NULL)
8323 return -ENOMEM;
8324
8325 codec->spec = spec;
8326
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008327 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8328
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008329 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8330 alc883_models,
8331 alc883_cfg_tbl);
8332 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008333 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8334 "trying auto-probe from BIOS...\n");
8335 board_config = ALC883_AUTO;
8336 }
8337
8338 if (board_config == ALC883_AUTO) {
8339 /* automatic parse from the BIOS config */
8340 err = alc883_parse_auto_config(codec);
8341 if (err < 0) {
8342 alc_free(codec);
8343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008344 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008345 printk(KERN_INFO
8346 "hda_codec: Cannot set up configuration "
8347 "from BIOS. Using base mode...\n");
8348 board_config = ALC883_3ST_2ch_DIG;
8349 }
8350 }
8351
8352 if (board_config != ALC883_AUTO)
8353 setup_preset(spec, &alc883_presets[board_config]);
8354
Kailang Yang2f893282008-05-27 12:14:47 +02008355 switch (codec->vendor_id) {
8356 case 0x10ec0888:
8357 spec->stream_name_analog = "ALC888 Analog";
8358 spec->stream_name_digital = "ALC888 Digital";
8359 break;
8360 case 0x10ec0889:
8361 spec->stream_name_analog = "ALC889 Analog";
8362 spec->stream_name_digital = "ALC889 Digital";
8363 break;
8364 default:
8365 spec->stream_name_analog = "ALC883 Analog";
8366 spec->stream_name_digital = "ALC883 Digital";
8367 break;
8368 }
8369
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008370 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8371 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008372 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008374 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8375 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8376
Takashi Iwaie1406342008-02-11 18:32:32 +01008377 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8378 spec->adc_nids = alc883_adc_nids;
8379 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380
Takashi Iwai2134ea42008-01-10 16:53:55 +01008381 spec->vmaster_nid = 0x0c;
8382
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008383 codec->patch_ops = alc_patch_ops;
8384 if (board_config == ALC883_AUTO)
8385 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008386 else if (codec->vendor_id == 0x10ec0888)
8387 spec->init_hook = alc888_coef_init;
8388
Takashi Iwaicb53c622007-08-10 17:21:45 +02008389#ifdef CONFIG_SND_HDA_POWER_SAVE
8390 if (!spec->loopback.amplist)
8391 spec->loopback.amplist = alc883_loopbacks;
8392#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008393
8394 return 0;
8395}
8396
8397/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008398 * ALC262 support
8399 */
8400
8401#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8402#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8403
8404#define alc262_dac_nids alc260_dac_nids
8405#define alc262_adc_nids alc882_adc_nids
8406#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008407#define alc262_capsrc_nids alc882_capsrc_nids
8408#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008409
8410#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008411#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008412
8413static struct snd_kcontrol_new alc262_base_mixer[] = {
8414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8415 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8416 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8417 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008423 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008425 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008426 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008427 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008428 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8429 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8430 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8431 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008432 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008433};
8434
Kailang Yangccc656c2006-10-17 12:32:26 +02008435static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008445 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8446 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008447 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008448 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008449 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008450 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8452 { } /* end */
8453};
8454
Takashi Iwaice875f02008-01-28 18:17:43 +01008455/* update HP, line and mono-out pins according to the master switch */
8456static void alc262_hp_master_update(struct hda_codec *codec)
8457{
8458 struct alc_spec *spec = codec->spec;
8459 int val = spec->master_sw;
8460
8461 /* HP & line-out */
8462 snd_hda_codec_write_cache(codec, 0x1b, 0,
8463 AC_VERB_SET_PIN_WIDGET_CONTROL,
8464 val ? PIN_HP : 0);
8465 snd_hda_codec_write_cache(codec, 0x15, 0,
8466 AC_VERB_SET_PIN_WIDGET_CONTROL,
8467 val ? PIN_HP : 0);
8468 /* mono (speaker) depending on the HP jack sense */
8469 val = val && !spec->jack_present;
8470 snd_hda_codec_write_cache(codec, 0x16, 0,
8471 AC_VERB_SET_PIN_WIDGET_CONTROL,
8472 val ? PIN_OUT : 0);
8473}
8474
8475static void alc262_hp_bpc_automute(struct hda_codec *codec)
8476{
8477 struct alc_spec *spec = codec->spec;
8478 unsigned int presence;
8479 presence = snd_hda_codec_read(codec, 0x1b, 0,
8480 AC_VERB_GET_PIN_SENSE, 0);
8481 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8482 alc262_hp_master_update(codec);
8483}
8484
8485static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8486{
8487 if ((res >> 26) != ALC880_HP_EVENT)
8488 return;
8489 alc262_hp_bpc_automute(codec);
8490}
8491
8492static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8493{
8494 struct alc_spec *spec = codec->spec;
8495 unsigned int presence;
8496 presence = snd_hda_codec_read(codec, 0x15, 0,
8497 AC_VERB_GET_PIN_SENSE, 0);
8498 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8499 alc262_hp_master_update(codec);
8500}
8501
8502static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8503 unsigned int res)
8504{
8505 if ((res >> 26) != ALC880_HP_EVENT)
8506 return;
8507 alc262_hp_wildwest_automute(codec);
8508}
8509
8510static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8511 struct snd_ctl_elem_value *ucontrol)
8512{
8513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8514 struct alc_spec *spec = codec->spec;
8515 *ucontrol->value.integer.value = spec->master_sw;
8516 return 0;
8517}
8518
8519static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8520 struct snd_ctl_elem_value *ucontrol)
8521{
8522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8523 struct alc_spec *spec = codec->spec;
8524 int val = !!*ucontrol->value.integer.value;
8525
8526 if (val == spec->master_sw)
8527 return 0;
8528 spec->master_sw = val;
8529 alc262_hp_master_update(codec);
8530 return 1;
8531}
8532
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008533static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008534 {
8535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8536 .name = "Master Playback Switch",
8537 .info = snd_ctl_boolean_mono_info,
8538 .get = alc262_hp_master_sw_get,
8539 .put = alc262_hp_master_sw_put,
8540 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008541 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8542 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008544 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8545 HDA_OUTPUT),
8546 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8547 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008553 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8556 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8557 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8558 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8559 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8560 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8561 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8562 { } /* end */
8563};
8564
Kailang Yangcd7509a2007-01-26 18:33:17 +01008565static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008566 {
8567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8568 .name = "Master Playback Switch",
8569 .info = snd_ctl_boolean_mono_info,
8570 .get = alc262_hp_master_sw_get,
8571 .put = alc262_hp_master_sw_put,
8572 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008573 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8574 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008577 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8578 HDA_OUTPUT),
8579 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8580 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008583 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008584 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8585 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8588 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8589 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8590 { } /* end */
8591};
8592
8593static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8594 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8595 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008596 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008597 { } /* end */
8598};
8599
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008600/* mute/unmute internal speaker according to the hp jack and mute state */
8601static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8602{
8603 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008604
8605 if (force || !spec->sense_updated) {
8606 unsigned int present;
8607 present = snd_hda_codec_read(codec, 0x15, 0,
8608 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008609 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008610 spec->sense_updated = 1;
8611 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8613 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008614}
8615
8616static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8617 unsigned int res)
8618{
8619 if ((res >> 26) != ALC880_HP_EVENT)
8620 return;
8621 alc262_hp_t5735_automute(codec, 1);
8622}
8623
8624static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8625{
8626 alc262_hp_t5735_automute(codec, 1);
8627}
8628
8629static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8631 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8637 { } /* end */
8638};
8639
8640static struct hda_verb alc262_hp_t5735_verbs[] = {
8641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8643
8644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8645 { }
8646};
8647
Kailang Yang8c427222008-01-10 13:03:59 +01008648static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008649 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008651 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8652 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8655 { } /* end */
8656};
8657
8658static struct hda_verb alc262_hp_rp5700_verbs[] = {
8659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8661 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8664 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8669 {}
8670};
8671
8672static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8673 .num_items = 1,
8674 .items = {
8675 { "Line", 0x1 },
8676 },
8677};
8678
Takashi Iwai0724ea22007-08-23 00:31:43 +02008679/* bind hp and internal speaker mute (with plug check) */
8680static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8681 struct snd_ctl_elem_value *ucontrol)
8682{
8683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8684 long *valp = ucontrol->value.integer.value;
8685 int change;
8686
8687 /* change hp mute */
8688 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8689 HDA_AMP_MUTE,
8690 valp[0] ? 0 : HDA_AMP_MUTE);
8691 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8692 HDA_AMP_MUTE,
8693 valp[1] ? 0 : HDA_AMP_MUTE);
8694 if (change) {
8695 /* change speaker according to HP jack state */
8696 struct alc_spec *spec = codec->spec;
8697 unsigned int mute;
8698 if (spec->jack_present)
8699 mute = HDA_AMP_MUTE;
8700 else
8701 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8702 HDA_OUTPUT, 0);
8703 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8704 HDA_AMP_MUTE, mute);
8705 }
8706 return change;
8707}
Takashi Iwai5b319542007-07-26 11:49:22 +02008708
Kailang Yang272a5272007-05-14 11:00:38 +02008709static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008710 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8711 {
8712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8713 .name = "Master Playback Switch",
8714 .info = snd_hda_mixer_amp_switch_info,
8715 .get = snd_hda_mixer_amp_switch_get,
8716 .put = alc262_sony_master_sw_put,
8717 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8718 },
Kailang Yang272a5272007-05-14 11:00:38 +02008719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8721 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8722 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8723 { } /* end */
8724};
8725
Kailang Yang83c34212007-07-05 11:43:05 +02008726static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8728 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8734 { } /* end */
8735};
Kailang Yang272a5272007-05-14 11:00:38 +02008736
Kailang Yangdf694da2005-12-05 19:42:22 +01008737#define alc262_capture_mixer alc882_capture_mixer
8738#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8739
8740/*
8741 * generic initialization of ADC, input mixers and output mixers
8742 */
8743static struct hda_verb alc262_init_verbs[] = {
8744 /*
8745 * Unmute ADC0-2 and set the default input to mic-in
8746 */
8747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8753
Takashi Iwaicb53c622007-08-10 17:21:45 +02008754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008755 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008756 * Note: PASD motherboards uses the Line In 2 as the input for
8757 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008758 */
8759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008765
8766 /*
8767 * Set up output mixers (0x0c - 0x0e)
8768 */
8769 /* set vol=0 to output mixers */
8770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8773 /* set up input amps for analog loopback */
8774 /* Amp Indices: DAC = 0, mixer = 1 */
8775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8781
8782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8788
8789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8794
8795 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8797
8798 /* FIXME: use matrix-type input source selection */
8799 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8800 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8805 /* Input mixer2 */
8806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8810 /* Input mixer3 */
8811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008815
8816 { }
8817};
8818
Kailang Yangccc656c2006-10-17 12:32:26 +02008819static struct hda_verb alc262_hippo_unsol_verbs[] = {
8820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8822 {}
8823};
8824
8825static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8826 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8829
8830 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8832 {}
8833};
8834
Kailang Yang272a5272007-05-14 11:00:38 +02008835static struct hda_verb alc262_sony_unsol_verbs[] = {
8836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8839
8840 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008842 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008843};
8844
Kailang Yangccc656c2006-10-17 12:32:26 +02008845/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008846static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008847{
8848 struct alc_spec *spec = codec->spec;
8849 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008850 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008851
Takashi Iwai5b319542007-07-26 11:49:22 +02008852 /* need to execute and sync at first */
8853 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8854 present = snd_hda_codec_read(codec, 0x15, 0,
8855 AC_VERB_GET_PIN_SENSE, 0);
8856 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008857 if (spec->jack_present) {
8858 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008859 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8860 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008861 } else {
8862 /* unmute internal speaker if necessary */
8863 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008864 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8865 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008866 }
8867}
8868
8869/* unsolicited event for HP jack sensing */
8870static void alc262_hippo_unsol_event(struct hda_codec *codec,
8871 unsigned int res)
8872{
8873 if ((res >> 26) != ALC880_HP_EVENT)
8874 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008875 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008876}
8877
Takashi Iwai5b319542007-07-26 11:49:22 +02008878static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008879{
Kailang Yangccc656c2006-10-17 12:32:26 +02008880 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008881 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008882
Takashi Iwai5b319542007-07-26 11:49:22 +02008883 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8884 present = snd_hda_codec_read(codec, 0x1b, 0,
8885 AC_VERB_GET_PIN_SENSE, 0);
8886 present = (present & 0x80000000) != 0;
8887 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008888 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008889 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8890 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008891 } else {
8892 /* unmute internal speaker if necessary */
8893 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008894 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8895 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008896 }
8897}
8898
8899/* unsolicited event for HP jack sensing */
8900static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8901 unsigned int res)
8902{
8903 if ((res >> 26) != ALC880_HP_EVENT)
8904 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008905 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008906}
8907
Takashi Iwai834be882006-03-01 14:16:17 +01008908/*
8909 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008910 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8911 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008912 */
8913
8914#define ALC_HP_EVENT 0x37
8915
8916static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01008921 {}
8922};
8923
Jiang zhe0e31daf2008-03-20 12:12:39 +01008924static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8926 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8927 {}
8928};
8929
Takashi Iwai834be882006-03-01 14:16:17 +01008930static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008931 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008932 .items = {
8933 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008934 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008935 { "CD", 0x4 },
8936 },
8937};
8938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008939static struct hda_input_mux alc262_HP_capture_source = {
8940 .num_items = 5,
8941 .items = {
8942 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008943 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008944 { "Line", 0x2 },
8945 { "CD", 0x4 },
8946 { "AUX IN", 0x6 },
8947 },
8948};
8949
zhejiangaccbe492007-08-31 12:36:05 +02008950static struct hda_input_mux alc262_HP_D7000_capture_source = {
8951 .num_items = 4,
8952 .items = {
8953 { "Mic", 0x0 },
8954 { "Front Mic", 0x2 },
8955 { "Line", 0x1 },
8956 { "CD", 0x4 },
8957 },
8958};
8959
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008960/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01008961static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8962{
8963 struct alc_spec *spec = codec->spec;
8964 unsigned int mute;
8965
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008966 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008967 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01008968 /* need to execute and sync at first */
8969 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008970 /* check laptop HP jack */
8971 present = snd_hda_codec_read(codec, 0x14, 0,
8972 AC_VERB_GET_PIN_SENSE, 0);
8973 /* need to execute and sync at first */
8974 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8975 /* check docking HP jack */
8976 present |= snd_hda_codec_read(codec, 0x1b, 0,
8977 AC_VERB_GET_PIN_SENSE, 0);
8978 if (present & AC_PINSENSE_PRESENCE)
8979 spec->jack_present = 1;
8980 else
8981 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01008982 spec->sense_updated = 1;
8983 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008984 /* unmute internal speaker only if both HPs are unplugged and
8985 * master switch is on
8986 */
8987 if (spec->jack_present)
8988 mute = HDA_AMP_MUTE;
8989 else
Takashi Iwai834be882006-03-01 14:16:17 +01008990 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008991 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8992 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008993}
8994
8995/* unsolicited event for HP jack sensing */
8996static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8997 unsigned int res)
8998{
8999 if ((res >> 26) != ALC_HP_EVENT)
9000 return;
9001 alc262_fujitsu_automute(codec, 1);
9002}
9003
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009004static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9005{
9006 alc262_fujitsu_automute(codec, 1);
9007}
9008
Takashi Iwai834be882006-03-01 14:16:17 +01009009/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009010static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9011 .ops = &snd_hda_bind_vol,
9012 .values = {
9013 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9014 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9015 0
9016 },
9017};
Takashi Iwai834be882006-03-01 14:16:17 +01009018
Jiang zhe0e31daf2008-03-20 12:12:39 +01009019/* mute/unmute internal speaker according to the hp jack and mute state */
9020static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9021{
9022 struct alc_spec *spec = codec->spec;
9023 unsigned int mute;
9024
9025 if (force || !spec->sense_updated) {
9026 unsigned int present_int_hp;
9027 /* need to execute and sync at first */
9028 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9029 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9030 AC_VERB_GET_PIN_SENSE, 0);
9031 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9032 spec->sense_updated = 1;
9033 }
9034 if (spec->jack_present) {
9035 /* mute internal speaker */
9036 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9037 HDA_AMP_MUTE, HDA_AMP_MUTE);
9038 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9039 HDA_AMP_MUTE, HDA_AMP_MUTE);
9040 } else {
9041 /* unmute internal speaker if necessary */
9042 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9043 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9044 HDA_AMP_MUTE, mute);
9045 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9046 HDA_AMP_MUTE, mute);
9047 }
9048}
9049
9050/* unsolicited event for HP jack sensing */
9051static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9052 unsigned int res)
9053{
9054 if ((res >> 26) != ALC_HP_EVENT)
9055 return;
9056 alc262_lenovo_3000_automute(codec, 1);
9057}
9058
Takashi Iwai834be882006-03-01 14:16:17 +01009059/* bind hp and internal speaker mute (with plug check) */
9060static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9061 struct snd_ctl_elem_value *ucontrol)
9062{
9063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9064 long *valp = ucontrol->value.integer.value;
9065 int change;
9066
Tony Vroon5d9fab22008-03-14 17:09:18 +01009067 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9068 HDA_AMP_MUTE,
9069 valp ? 0 : HDA_AMP_MUTE);
9070 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9071 HDA_AMP_MUTE,
9072 valp ? 0 : HDA_AMP_MUTE);
9073
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009074 if (change)
9075 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009076 return change;
9077}
9078
9079static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009080 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009081 {
9082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9083 .name = "Master Playback Switch",
9084 .info = snd_hda_mixer_amp_switch_info,
9085 .get = snd_hda_mixer_amp_switch_get,
9086 .put = alc262_fujitsu_master_sw_put,
9087 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9088 },
9089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009091 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9092 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009096 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9097 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9098 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009099 { } /* end */
9100};
9101
Jiang zhe0e31daf2008-03-20 12:12:39 +01009102/* bind hp and internal speaker mute (with plug check) */
9103static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9104 struct snd_ctl_elem_value *ucontrol)
9105{
9106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9107 long *valp = ucontrol->value.integer.value;
9108 int change;
9109
9110 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9111 HDA_AMP_MUTE,
9112 valp ? 0 : HDA_AMP_MUTE);
9113
9114 if (change)
9115 alc262_lenovo_3000_automute(codec, 0);
9116 return change;
9117}
9118
9119static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9120 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9121 {
9122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9123 .name = "Master Playback Switch",
9124 .info = snd_hda_mixer_amp_switch_info,
9125 .get = snd_hda_mixer_amp_switch_get,
9126 .put = alc262_lenovo_3000_master_sw_put,
9127 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9128 },
9129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9134 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9135 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9136 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9137 { } /* end */
9138};
9139
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009140/* additional init verbs for Benq laptops */
9141static struct hda_verb alc262_EAPD_verbs[] = {
9142 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9143 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9144 {}
9145};
9146
Kailang Yang83c34212007-07-05 11:43:05 +02009147static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9148 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9150
9151 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9152 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9153 {}
9154};
9155
Tobin Davisf651b502007-10-26 12:40:47 +02009156/* Samsung Q1 Ultra Vista model setup */
9157static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009158 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9159 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9162 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009163 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009164 { } /* end */
9165};
9166
9167static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009168 /* output mixer */
9169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9172 /* speaker */
9173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9174 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9181 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9182 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9183 /* internal mic */
9184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9186 /* ADC, choose mic */
9187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009197 {}
9198};
9199
Tobin Davisf651b502007-10-26 12:40:47 +02009200/* mute/unmute internal speaker according to the hp jack and mute state */
9201static void alc262_ultra_automute(struct hda_codec *codec)
9202{
9203 struct alc_spec *spec = codec->spec;
9204 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009205
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009206 mute = 0;
9207 /* auto-mute only when HP is used as HP */
9208 if (!spec->cur_mux[0]) {
9209 unsigned int present;
9210 /* need to execute and sync at first */
9211 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9212 present = snd_hda_codec_read(codec, 0x15, 0,
9213 AC_VERB_GET_PIN_SENSE, 0);
9214 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9215 if (spec->jack_present)
9216 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009217 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009218 /* mute/unmute internal speaker */
9219 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9220 HDA_AMP_MUTE, mute);
9221 /* mute/unmute HP */
9222 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9223 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009224}
9225
9226/* unsolicited event for HP jack sensing */
9227static void alc262_ultra_unsol_event(struct hda_codec *codec,
9228 unsigned int res)
9229{
9230 if ((res >> 26) != ALC880_HP_EVENT)
9231 return;
9232 alc262_ultra_automute(codec);
9233}
9234
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009235static struct hda_input_mux alc262_ultra_capture_source = {
9236 .num_items = 2,
9237 .items = {
9238 { "Mic", 0x1 },
9239 { "Headphone", 0x7 },
9240 },
9241};
9242
9243static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9244 struct snd_ctl_elem_value *ucontrol)
9245{
9246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9247 struct alc_spec *spec = codec->spec;
9248 int ret;
9249
9250 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9251 if (!ret)
9252 return 0;
9253 /* reprogram the HP pin as mic or HP according to the input source */
9254 snd_hda_codec_write_cache(codec, 0x15, 0,
9255 AC_VERB_SET_PIN_WIDGET_CONTROL,
9256 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9257 alc262_ultra_automute(codec); /* mute/unmute HP */
9258 return ret;
9259}
9260
9261static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9262 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9263 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9264 {
9265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9266 .name = "Capture Source",
9267 .info = alc882_mux_enum_info,
9268 .get = alc882_mux_enum_get,
9269 .put = alc262_ultra_mux_enum_put,
9270 },
9271 { } /* end */
9272};
9273
Kailang Yangdf694da2005-12-05 19:42:22 +01009274/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009275static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9276 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009277{
9278 hda_nid_t nid;
9279 int err;
9280
9281 spec->multiout.num_dacs = 1; /* only use one dac */
9282 spec->multiout.dac_nids = spec->private_dac_nids;
9283 spec->multiout.dac_nids[0] = 2;
9284
9285 nid = cfg->line_out_pins[0];
9286 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009287 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9288 "Front Playback Volume",
9289 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9290 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009291 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009292 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9293 "Front Playback Switch",
9294 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9295 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009296 return err;
9297 }
9298
Takashi Iwai82bc9552006-03-21 11:24:42 +01009299 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009300 if (nid) {
9301 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9303 "Speaker Playback Volume",
9304 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9305 HDA_OUTPUT));
9306 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009307 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009308 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9309 "Speaker Playback Switch",
9310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9311 HDA_OUTPUT));
9312 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009313 return err;
9314 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009315 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9316 "Speaker Playback Switch",
9317 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9318 HDA_OUTPUT));
9319 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009320 return err;
9321 }
9322 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009323 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009324 if (nid) {
9325 /* spec->multiout.hp_nid = 2; */
9326 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009327 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9328 "Headphone Playback Volume",
9329 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9330 HDA_OUTPUT));
9331 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009332 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009333 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9334 "Headphone Playback Switch",
9335 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9336 HDA_OUTPUT));
9337 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009338 return err;
9339 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009340 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9341 "Headphone Playback Switch",
9342 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9343 HDA_OUTPUT));
9344 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009345 return err;
9346 }
9347 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009348 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009349}
9350
9351/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009352#define alc262_auto_create_analog_input_ctls \
9353 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009354
9355/*
9356 * generic initialization of ADC, input mixers and output mixers
9357 */
9358static struct hda_verb alc262_volume_init_verbs[] = {
9359 /*
9360 * Unmute ADC0-2 and set the default input to mic-in
9361 */
9362 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9364 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9366 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9368
Takashi Iwaicb53c622007-08-10 17:21:45 +02009369 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009370 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009371 * Note: PASD motherboards uses the Line In 2 as the input for
9372 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009373 */
9374 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009380
9381 /*
9382 * Set up output mixers (0x0c - 0x0f)
9383 */
9384 /* set vol=0 to output mixers */
9385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9388
9389 /* set up input amps for analog loopback */
9390 /* Amp Indices: DAC = 0, mixer = 1 */
9391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9397
9398 /* FIXME: use matrix-type input source selection */
9399 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9400 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9405 /* Input mixer2 */
9406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9410 /* Input mixer3 */
9411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9415
9416 { }
9417};
9418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009419static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9420 /*
9421 * Unmute ADC0-2 and set the default input to mic-in
9422 */
9423 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9425 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9427 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9429
Takashi Iwaicb53c622007-08-10 17:21:45 +02009430 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009431 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009432 * Note: PASD motherboards uses the Line In 2 as the input for
9433 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009434 */
9435 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009436 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009443
9444 /*
9445 * Set up output mixers (0x0c - 0x0e)
9446 */
9447 /* set vol=0 to output mixers */
9448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9451
9452 /* set up input amps for analog loopback */
9453 /* Amp Indices: DAC = 0, mixer = 1 */
9454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9460
Takashi Iwaice875f02008-01-28 18:17:43 +01009461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9464
9465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9467
9468 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9470
9471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9476
9477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9478 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9481 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9482 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9483
9484
9485 /* FIXME: use matrix-type input source selection */
9486 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9487 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9488 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9489 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9492 /* Input mixer2 */
9493 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9494 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9497 /* Input mixer3 */
9498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9502
Takashi Iwaice875f02008-01-28 18:17:43 +01009503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9504
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009505 { }
9506};
9507
Kailang Yangcd7509a2007-01-26 18:33:17 +01009508static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9509 /*
9510 * Unmute ADC0-2 and set the default input to mic-in
9511 */
9512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9514 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9518
Takashi Iwaicb53c622007-08-10 17:21:45 +02009519 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009520 * mixer widget
9521 * Note: PASD motherboards uses the Line In 2 as the input for front
9522 * panel mic (mic 2)
9523 */
9524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009533 /*
9534 * Set up output mixers (0x0c - 0x0e)
9535 */
9536 /* set vol=0 to output mixers */
9537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9540
9541 /* set up input amps for analog loopback */
9542 /* Amp Indices: DAC = 0, mixer = 1 */
9543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9549
9550
9551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9557 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9558
9559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9561
9562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9563 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9564
9565 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9568 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9569 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9570 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9571
9572 /* FIXME: use matrix-type input source selection */
9573 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9574 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9580 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9582 /* Input mixer2 */
9583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9584 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9588 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9590 /* Input mixer3 */
9591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9598
Takashi Iwaice875f02008-01-28 18:17:43 +01009599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9600
Kailang Yangcd7509a2007-01-26 18:33:17 +01009601 { }
9602};
9603
Takashi Iwaicb53c622007-08-10 17:21:45 +02009604#ifdef CONFIG_SND_HDA_POWER_SAVE
9605#define alc262_loopbacks alc880_loopbacks
9606#endif
9607
Kailang Yangdf694da2005-12-05 19:42:22 +01009608/* pcm configuration: identiacal with ALC880 */
9609#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9610#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9611#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9612#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9613
9614/*
9615 * BIOS auto configuration
9616 */
9617static int alc262_parse_auto_config(struct hda_codec *codec)
9618{
9619 struct alc_spec *spec = codec->spec;
9620 int err;
9621 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009623 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9624 alc262_ignore);
9625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009626 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009627 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009628 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9630 if (err < 0)
9631 return err;
9632 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9633 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009634 return err;
9635
9636 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9637
9638 if (spec->autocfg.dig_out_pin)
9639 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9640 if (spec->autocfg.dig_in_pin)
9641 spec->dig_in_nid = ALC262_DIGIN_NID;
9642
9643 if (spec->kctl_alloc)
9644 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9645
9646 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009647 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009648 spec->input_mux = &spec->private_imux;
9649
Takashi Iwai776e1842007-08-29 15:07:11 +02009650 err = alc_auto_add_mic_boost(codec);
9651 if (err < 0)
9652 return err;
9653
Kailang Yangdf694da2005-12-05 19:42:22 +01009654 return 1;
9655}
9656
9657#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9658#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9659#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9660
9661
9662/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009663static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009664{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009665 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009666 alc262_auto_init_multi_out(codec);
9667 alc262_auto_init_hp_out(codec);
9668 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009669 if (spec->unsol_event)
9670 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009671}
9672
9673/*
9674 * configuration and preset
9675 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009676static const char *alc262_models[ALC262_MODEL_LAST] = {
9677 [ALC262_BASIC] = "basic",
9678 [ALC262_HIPPO] = "hippo",
9679 [ALC262_HIPPO_1] = "hippo_1",
9680 [ALC262_FUJITSU] = "fujitsu",
9681 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009682 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009683 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009684 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009685 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009686 [ALC262_BENQ_T31] = "benq-t31",
9687 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009688 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009689 [ALC262_LENOVO_3000] = "lenovo-3000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009690 [ALC262_AUTO] = "auto",
9691};
9692
9693static struct snd_pci_quirk alc262_cfg_tbl[] = {
9694 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9695 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009696 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009697 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9698 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009699 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009700 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009701 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009702 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009703 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009704 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009705 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009706 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009707 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009708 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009709 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009710 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009711 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9712 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9713 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009714 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9715 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009716 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009717 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009718 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009719 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9720 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9721 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009722 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9723 ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009724 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009725 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009726 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009727 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009728 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009729 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009730 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009731 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009732 {}
9733};
9734
9735static struct alc_config_preset alc262_presets[] = {
9736 [ALC262_BASIC] = {
9737 .mixers = { alc262_base_mixer },
9738 .init_verbs = { alc262_init_verbs },
9739 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9740 .dac_nids = alc262_dac_nids,
9741 .hp_nid = 0x03,
9742 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9743 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009744 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009745 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009746 [ALC262_HIPPO] = {
9747 .mixers = { alc262_base_mixer },
9748 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9749 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9750 .dac_nids = alc262_dac_nids,
9751 .hp_nid = 0x03,
9752 .dig_out_nid = ALC262_DIGOUT_NID,
9753 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9754 .channel_mode = alc262_modes,
9755 .input_mux = &alc262_capture_source,
9756 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009757 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009758 },
9759 [ALC262_HIPPO_1] = {
9760 .mixers = { alc262_hippo1_mixer },
9761 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9762 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9763 .dac_nids = alc262_dac_nids,
9764 .hp_nid = 0x02,
9765 .dig_out_nid = ALC262_DIGOUT_NID,
9766 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9767 .channel_mode = alc262_modes,
9768 .input_mux = &alc262_capture_source,
9769 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009770 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009771 },
Takashi Iwai834be882006-03-01 14:16:17 +01009772 [ALC262_FUJITSU] = {
9773 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009774 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9775 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009776 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9777 .dac_nids = alc262_dac_nids,
9778 .hp_nid = 0x03,
9779 .dig_out_nid = ALC262_DIGOUT_NID,
9780 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9781 .channel_mode = alc262_modes,
9782 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009783 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009784 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009785 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009786 [ALC262_HP_BPC] = {
9787 .mixers = { alc262_HP_BPC_mixer },
9788 .init_verbs = { alc262_HP_BPC_init_verbs },
9789 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9790 .dac_nids = alc262_dac_nids,
9791 .hp_nid = 0x03,
9792 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9793 .channel_mode = alc262_modes,
9794 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009795 .unsol_event = alc262_hp_bpc_unsol_event,
9796 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009797 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009798 [ALC262_HP_BPC_D7000_WF] = {
9799 .mixers = { alc262_HP_BPC_WildWest_mixer },
9800 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9801 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9802 .dac_nids = alc262_dac_nids,
9803 .hp_nid = 0x03,
9804 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9805 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009806 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009807 .unsol_event = alc262_hp_wildwest_unsol_event,
9808 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009809 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009810 [ALC262_HP_BPC_D7000_WL] = {
9811 .mixers = { alc262_HP_BPC_WildWest_mixer,
9812 alc262_HP_BPC_WildWest_option_mixer },
9813 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9815 .dac_nids = alc262_dac_nids,
9816 .hp_nid = 0x03,
9817 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9818 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009819 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009820 .unsol_event = alc262_hp_wildwest_unsol_event,
9821 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009822 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009823 [ALC262_HP_TC_T5735] = {
9824 .mixers = { alc262_hp_t5735_mixer },
9825 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9826 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9827 .dac_nids = alc262_dac_nids,
9828 .hp_nid = 0x03,
9829 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9830 .channel_mode = alc262_modes,
9831 .input_mux = &alc262_capture_source,
9832 .unsol_event = alc262_hp_t5735_unsol_event,
9833 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009834 },
9835 [ALC262_HP_RP5700] = {
9836 .mixers = { alc262_hp_rp5700_mixer },
9837 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9838 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9839 .dac_nids = alc262_dac_nids,
9840 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9841 .channel_mode = alc262_modes,
9842 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009843 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009844 [ALC262_BENQ_ED8] = {
9845 .mixers = { alc262_base_mixer },
9846 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9847 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9848 .dac_nids = alc262_dac_nids,
9849 .hp_nid = 0x03,
9850 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9851 .channel_mode = alc262_modes,
9852 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009853 },
Kailang Yang272a5272007-05-14 11:00:38 +02009854 [ALC262_SONY_ASSAMD] = {
9855 .mixers = { alc262_sony_mixer },
9856 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9857 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9858 .dac_nids = alc262_dac_nids,
9859 .hp_nid = 0x02,
9860 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9861 .channel_mode = alc262_modes,
9862 .input_mux = &alc262_capture_source,
9863 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009864 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009865 },
9866 [ALC262_BENQ_T31] = {
9867 .mixers = { alc262_benq_t31_mixer },
9868 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9869 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9870 .dac_nids = alc262_dac_nids,
9871 .hp_nid = 0x03,
9872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9873 .channel_mode = alc262_modes,
9874 .input_mux = &alc262_capture_source,
9875 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009876 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009877 },
Tobin Davisf651b502007-10-26 12:40:47 +02009878 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009879 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9880 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009881 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9882 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009883 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9884 .channel_mode = alc262_modes,
9885 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009886 .adc_nids = alc262_adc_nids, /* ADC0 */
9887 .capsrc_nids = alc262_capsrc_nids,
9888 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009889 .unsol_event = alc262_ultra_unsol_event,
9890 .init_hook = alc262_ultra_automute,
9891 },
Jiang zhe0e31daf2008-03-20 12:12:39 +01009892 [ALC262_LENOVO_3000] = {
9893 .mixers = { alc262_lenovo_3000_mixer },
9894 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9895 alc262_lenovo_3000_unsol_verbs },
9896 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9897 .dac_nids = alc262_dac_nids,
9898 .hp_nid = 0x03,
9899 .dig_out_nid = ALC262_DIGOUT_NID,
9900 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9901 .channel_mode = alc262_modes,
9902 .input_mux = &alc262_fujitsu_capture_source,
9903 .unsol_event = alc262_lenovo_3000_unsol_event,
9904 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009905};
9906
9907static int patch_alc262(struct hda_codec *codec)
9908{
9909 struct alc_spec *spec;
9910 int board_config;
9911 int err;
9912
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009913 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009914 if (spec == NULL)
9915 return -ENOMEM;
9916
9917 codec->spec = spec;
9918#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009919 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9920 * under-run
9921 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009922 {
9923 int tmp;
9924 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9925 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9926 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9927 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9928 }
9929#endif
9930
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009931 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9932
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009933 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9934 alc262_models,
9935 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009936
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009937 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009938 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9939 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009940 board_config = ALC262_AUTO;
9941 }
9942
9943 if (board_config == ALC262_AUTO) {
9944 /* automatic parse from the BIOS config */
9945 err = alc262_parse_auto_config(codec);
9946 if (err < 0) {
9947 alc_free(codec);
9948 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009949 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950 printk(KERN_INFO
9951 "hda_codec: Cannot set up configuration "
9952 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009953 board_config = ALC262_BASIC;
9954 }
9955 }
9956
9957 if (board_config != ALC262_AUTO)
9958 setup_preset(spec, &alc262_presets[board_config]);
9959
9960 spec->stream_name_analog = "ALC262 Analog";
9961 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9962 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9963
9964 spec->stream_name_digital = "ALC262 Digital";
9965 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9966 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9967
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009968 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009969 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009970 unsigned int wcap = get_wcaps(codec, 0x07);
9971
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009972 /* get type */
9973 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009974 if (wcap != AC_WID_AUD_IN) {
9975 spec->adc_nids = alc262_adc_nids_alt;
9976 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009977 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009978 spec->mixers[spec->num_mixers] =
9979 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009980 spec->num_mixers++;
9981 } else {
9982 spec->adc_nids = alc262_adc_nids;
9983 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009984 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009985 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9986 spec->num_mixers++;
9987 }
9988 }
9989
Takashi Iwai2134ea42008-01-10 16:53:55 +01009990 spec->vmaster_nid = 0x0c;
9991
Kailang Yangdf694da2005-12-05 19:42:22 +01009992 codec->patch_ops = alc_patch_ops;
9993 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009994 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009995#ifdef CONFIG_SND_HDA_POWER_SAVE
9996 if (!spec->loopback.amplist)
9997 spec->loopback.amplist = alc262_loopbacks;
9998#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009999
Kailang Yangdf694da2005-12-05 19:42:22 +010010000 return 0;
10001}
10002
Kailang Yangdf694da2005-12-05 19:42:22 +010010003/*
Kailang Yanga361d842007-06-05 12:30:55 +020010004 * ALC268 channel source setting (2 channel)
10005 */
10006#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10007#define alc268_modes alc260_modes
10008
10009static hda_nid_t alc268_dac_nids[2] = {
10010 /* front, hp */
10011 0x02, 0x03
10012};
10013
10014static hda_nid_t alc268_adc_nids[2] = {
10015 /* ADC0-1 */
10016 0x08, 0x07
10017};
10018
10019static hda_nid_t alc268_adc_nids_alt[1] = {
10020 /* ADC0 */
10021 0x08
10022};
10023
Takashi Iwaie1406342008-02-11 18:32:32 +010010024static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10025
Kailang Yanga361d842007-06-05 12:30:55 +020010026static struct snd_kcontrol_new alc268_base_mixer[] = {
10027 /* output mixer control */
10028 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10029 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10030 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10033 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10034 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010035 { }
10036};
10037
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010038/* bind Beep switches of both NID 0x0f and 0x10 */
10039static struct hda_bind_ctls alc268_bind_beep_sw = {
10040 .ops = &snd_hda_bind_sw,
10041 .values = {
10042 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10043 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10044 0
10045 },
10046};
10047
10048static struct snd_kcontrol_new alc268_beep_mixer[] = {
10049 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10050 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10051 { }
10052};
10053
Kailang Yangd1a991a2007-08-15 16:21:59 +020010054static struct hda_verb alc268_eapd_verbs[] = {
10055 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10056 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10057 { }
10058};
10059
Takashi Iwaid2738092007-08-16 14:59:45 +020010060/* Toshiba specific */
10061#define alc268_toshiba_automute alc262_hippo_automute
10062
10063static struct hda_verb alc268_toshiba_verbs[] = {
10064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10065 { } /* end */
10066};
10067
10068/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010069/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010070static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10071 .ops = &snd_hda_bind_vol,
10072 .values = {
10073 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10074 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10075 0
10076 },
10077};
10078
Takashi Iwai889c4392007-08-23 18:56:52 +020010079/* mute/unmute internal speaker according to the hp jack and mute state */
10080static void alc268_acer_automute(struct hda_codec *codec, int force)
10081{
10082 struct alc_spec *spec = codec->spec;
10083 unsigned int mute;
10084
10085 if (force || !spec->sense_updated) {
10086 unsigned int present;
10087 present = snd_hda_codec_read(codec, 0x14, 0,
10088 AC_VERB_GET_PIN_SENSE, 0);
10089 spec->jack_present = (present & 0x80000000) != 0;
10090 spec->sense_updated = 1;
10091 }
10092 if (spec->jack_present)
10093 mute = HDA_AMP_MUTE; /* mute internal speaker */
10094 else /* unmute internal speaker if necessary */
10095 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10096 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10097 HDA_AMP_MUTE, mute);
10098}
10099
10100
10101/* bind hp and internal speaker mute (with plug check) */
10102static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10103 struct snd_ctl_elem_value *ucontrol)
10104{
10105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10106 long *valp = ucontrol->value.integer.value;
10107 int change;
10108
10109 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10110 HDA_AMP_MUTE,
10111 valp[0] ? 0 : HDA_AMP_MUTE);
10112 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10113 HDA_AMP_MUTE,
10114 valp[1] ? 0 : HDA_AMP_MUTE);
10115 if (change)
10116 alc268_acer_automute(codec, 0);
10117 return change;
10118}
Takashi Iwaid2738092007-08-16 14:59:45 +020010119
10120static struct snd_kcontrol_new alc268_acer_mixer[] = {
10121 /* output mixer control */
10122 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10123 {
10124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10125 .name = "Master Playback Switch",
10126 .info = snd_hda_mixer_amp_switch_info,
10127 .get = snd_hda_mixer_amp_switch_get,
10128 .put = alc268_acer_master_sw_put,
10129 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10130 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10132 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10133 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010134 { }
10135};
10136
10137static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010138 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10139 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010142 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10143 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010144
10145 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10146 { }
10147};
10148
10149/* unsolicited event for HP jack sensing */
10150static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10151 unsigned int res)
10152{
Takashi Iwai889c4392007-08-23 18:56:52 +020010153 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010154 return;
10155 alc268_toshiba_automute(codec);
10156}
10157
10158static void alc268_acer_unsol_event(struct hda_codec *codec,
10159 unsigned int res)
10160{
Takashi Iwai889c4392007-08-23 18:56:52 +020010161 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010162 return;
10163 alc268_acer_automute(codec, 1);
10164}
10165
Takashi Iwai889c4392007-08-23 18:56:52 +020010166static void alc268_acer_init_hook(struct hda_codec *codec)
10167{
10168 alc268_acer_automute(codec, 1);
10169}
10170
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010171static struct snd_kcontrol_new alc268_dell_mixer[] = {
10172 /* output mixer control */
10173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10175 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10178 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10179 { }
10180};
10181
10182static struct hda_verb alc268_dell_verbs[] = {
10183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10186 { }
10187};
10188
10189/* mute/unmute internal speaker according to the hp jack and mute state */
10190static void alc268_dell_automute(struct hda_codec *codec)
10191{
10192 unsigned int present;
10193 unsigned int mute;
10194
10195 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10196 if (present & 0x80000000)
10197 mute = HDA_AMP_MUTE;
10198 else
10199 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10200 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10201 HDA_AMP_MUTE, mute);
10202}
10203
10204static void alc268_dell_unsol_event(struct hda_codec *codec,
10205 unsigned int res)
10206{
10207 if ((res >> 26) != ALC880_HP_EVENT)
10208 return;
10209 alc268_dell_automute(codec);
10210}
10211
10212#define alc268_dell_init_hook alc268_dell_automute
10213
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010214static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10215 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10216 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10220 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10221 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10222 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10223 { }
10224};
10225
10226static struct hda_verb alc267_quanta_il1_verbs[] = {
10227 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10228 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10229 { }
10230};
10231
10232static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10233{
10234 unsigned int present;
10235
10236 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10237 & AC_PINSENSE_PRESENCE;
10238 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10239 present ? 0 : PIN_OUT);
10240}
10241
10242static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10243{
10244 unsigned int present;
10245
10246 present = snd_hda_codec_read(codec, 0x18, 0,
10247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10248 snd_hda_codec_write(codec, 0x23, 0,
10249 AC_VERB_SET_CONNECT_SEL,
10250 present ? 0x00 : 0x01);
10251}
10252
10253static void alc267_quanta_il1_automute(struct hda_codec *codec)
10254{
10255 alc267_quanta_il1_hp_automute(codec);
10256 alc267_quanta_il1_mic_automute(codec);
10257}
10258
10259static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10260 unsigned int res)
10261{
10262 switch (res >> 26) {
10263 case ALC880_HP_EVENT:
10264 alc267_quanta_il1_hp_automute(codec);
10265 break;
10266 case ALC880_MIC_EVENT:
10267 alc267_quanta_il1_mic_automute(codec);
10268 break;
10269 }
10270}
10271
Kailang Yanga361d842007-06-05 12:30:55 +020010272/*
10273 * generic initialization of ADC, input mixers and output mixers
10274 */
10275static struct hda_verb alc268_base_init_verbs[] = {
10276 /* Unmute DAC0-1 and set vol = 0 */
10277 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10278 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10279 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10280 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10281 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10283
10284 /*
10285 * Set up output mixers (0x0c - 0x0e)
10286 */
10287 /* set vol=0 to output mixers */
10288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10291 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10292
10293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10294 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10295
10296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10303 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10304
10305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10311 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010312
10313 /* set PCBEEP vol = 0, mute connections */
10314 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10316 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010317
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010318 /* Unmute Selector 23h,24h and set the default input to mic-in */
10319
10320 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10322 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010324
Kailang Yanga361d842007-06-05 12:30:55 +020010325 { }
10326};
10327
10328/*
10329 * generic initialization of ADC, input mixers and output mixers
10330 */
10331static struct hda_verb alc268_volume_init_verbs[] = {
10332 /* set output DAC */
10333 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10334 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10335 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10336 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10337
10338 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10341 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10342 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10343
10344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10349
10350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10353 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10354
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010355 /* set PCBEEP vol = 0, mute connections */
10356 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10357 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10358 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010359
10360 { }
10361};
10362
10363#define alc268_mux_enum_info alc_mux_enum_info
10364#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010365#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010366
10367static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10368 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10369 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10370 {
10371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10372 /* The multiple "Capture Source" controls confuse alsamixer
10373 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010374 */
10375 /* .name = "Capture Source", */
10376 .name = "Input Source",
10377 .count = 1,
10378 .info = alc268_mux_enum_info,
10379 .get = alc268_mux_enum_get,
10380 .put = alc268_mux_enum_put,
10381 },
10382 { } /* end */
10383};
10384
10385static struct snd_kcontrol_new alc268_capture_mixer[] = {
10386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10390 {
10391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10392 /* The multiple "Capture Source" controls confuse alsamixer
10393 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010394 */
10395 /* .name = "Capture Source", */
10396 .name = "Input Source",
10397 .count = 2,
10398 .info = alc268_mux_enum_info,
10399 .get = alc268_mux_enum_get,
10400 .put = alc268_mux_enum_put,
10401 },
10402 { } /* end */
10403};
10404
10405static struct hda_input_mux alc268_capture_source = {
10406 .num_items = 4,
10407 .items = {
10408 { "Mic", 0x0 },
10409 { "Front Mic", 0x1 },
10410 { "Line", 0x2 },
10411 { "CD", 0x3 },
10412 },
10413};
10414
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010415static struct hda_input_mux alc268_acer_capture_source = {
10416 .num_items = 3,
10417 .items = {
10418 { "Mic", 0x0 },
10419 { "Internal Mic", 0x6 },
10420 { "Line", 0x2 },
10421 },
10422};
10423
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010424#ifdef CONFIG_SND_DEBUG
10425static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010426 /* Volume widgets */
10427 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10428 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10429 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10430 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10431 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10432 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10433 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10434 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10435 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10436 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10437 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10438 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10439 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010440 /* The below appears problematic on some hardwares */
10441 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010442 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10443 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10444 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10445 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10446
10447 /* Modes for retasking pin widgets */
10448 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10449 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10450 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10451 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10452
10453 /* Controls for GPIO pins, assuming they are configured as outputs */
10454 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10455 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10456 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10457 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10458
10459 /* Switches to allow the digital SPDIF output pin to be enabled.
10460 * The ALC268 does not have an SPDIF input.
10461 */
10462 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10463
10464 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10465 * this output to turn on an external amplifier.
10466 */
10467 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10468 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10469
10470 { } /* end */
10471};
10472#endif
10473
Kailang Yanga361d842007-06-05 12:30:55 +020010474/* create input playback/capture controls for the given pin */
10475static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10476 const char *ctlname, int idx)
10477{
10478 char name[32];
10479 int err;
10480
10481 sprintf(name, "%s Playback Volume", ctlname);
10482 if (nid == 0x14) {
10483 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10484 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10485 HDA_OUTPUT));
10486 if (err < 0)
10487 return err;
10488 } else if (nid == 0x15) {
10489 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10490 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10491 HDA_OUTPUT));
10492 if (err < 0)
10493 return err;
10494 } else
10495 return -1;
10496 sprintf(name, "%s Playback Switch", ctlname);
10497 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10498 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10499 if (err < 0)
10500 return err;
10501 return 0;
10502}
10503
10504/* add playback controls from the parsed DAC table */
10505static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10506 const struct auto_pin_cfg *cfg)
10507{
10508 hda_nid_t nid;
10509 int err;
10510
10511 spec->multiout.num_dacs = 2; /* only use one dac */
10512 spec->multiout.dac_nids = spec->private_dac_nids;
10513 spec->multiout.dac_nids[0] = 2;
10514 spec->multiout.dac_nids[1] = 3;
10515
10516 nid = cfg->line_out_pins[0];
10517 if (nid)
10518 alc268_new_analog_output(spec, nid, "Front", 0);
10519
10520 nid = cfg->speaker_pins[0];
10521 if (nid == 0x1d) {
10522 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10523 "Speaker Playback Volume",
10524 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10525 if (err < 0)
10526 return err;
10527 }
10528 nid = cfg->hp_pins[0];
10529 if (nid)
10530 alc268_new_analog_output(spec, nid, "Headphone", 0);
10531
10532 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10533 if (nid == 0x16) {
10534 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10535 "Mono Playback Switch",
10536 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10537 if (err < 0)
10538 return err;
10539 }
10540 return 0;
10541}
10542
10543/* create playback/capture controls for input pins */
10544static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10545 const struct auto_pin_cfg *cfg)
10546{
10547 struct hda_input_mux *imux = &spec->private_imux;
10548 int i, idx1;
10549
10550 for (i = 0; i < AUTO_PIN_LAST; i++) {
10551 switch(cfg->input_pins[i]) {
10552 case 0x18:
10553 idx1 = 0; /* Mic 1 */
10554 break;
10555 case 0x19:
10556 idx1 = 1; /* Mic 2 */
10557 break;
10558 case 0x1a:
10559 idx1 = 2; /* Line In */
10560 break;
10561 case 0x1c:
10562 idx1 = 3; /* CD */
10563 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010564 case 0x12:
10565 case 0x13:
10566 idx1 = 6; /* digital mics */
10567 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010568 default:
10569 continue;
10570 }
10571 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10572 imux->items[imux->num_items].index = idx1;
10573 imux->num_items++;
10574 }
10575 return 0;
10576}
10577
10578static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10579{
10580 struct alc_spec *spec = codec->spec;
10581 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10582 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10583 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10584 unsigned int dac_vol1, dac_vol2;
10585
10586 if (speaker_nid) {
10587 snd_hda_codec_write(codec, speaker_nid, 0,
10588 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10589 snd_hda_codec_write(codec, 0x0f, 0,
10590 AC_VERB_SET_AMP_GAIN_MUTE,
10591 AMP_IN_UNMUTE(1));
10592 snd_hda_codec_write(codec, 0x10, 0,
10593 AC_VERB_SET_AMP_GAIN_MUTE,
10594 AMP_IN_UNMUTE(1));
10595 } else {
10596 snd_hda_codec_write(codec, 0x0f, 0,
10597 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10598 snd_hda_codec_write(codec, 0x10, 0,
10599 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10600 }
10601
10602 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10603 if (line_nid == 0x14)
10604 dac_vol2 = AMP_OUT_ZERO;
10605 else if (line_nid == 0x15)
10606 dac_vol1 = AMP_OUT_ZERO;
10607 if (hp_nid == 0x14)
10608 dac_vol2 = AMP_OUT_ZERO;
10609 else if (hp_nid == 0x15)
10610 dac_vol1 = AMP_OUT_ZERO;
10611 if (line_nid != 0x16 || hp_nid != 0x16 ||
10612 spec->autocfg.line_out_pins[1] != 0x16 ||
10613 spec->autocfg.line_out_pins[2] != 0x16)
10614 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10615
10616 snd_hda_codec_write(codec, 0x02, 0,
10617 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10618 snd_hda_codec_write(codec, 0x03, 0,
10619 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10620}
10621
10622/* pcm configuration: identiacal with ALC880 */
10623#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10624#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010625#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010626#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10627
10628/*
10629 * BIOS auto configuration
10630 */
10631static int alc268_parse_auto_config(struct hda_codec *codec)
10632{
10633 struct alc_spec *spec = codec->spec;
10634 int err;
10635 static hda_nid_t alc268_ignore[] = { 0 };
10636
10637 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10638 alc268_ignore);
10639 if (err < 0)
10640 return err;
10641 if (!spec->autocfg.line_outs)
10642 return 0; /* can't find valid BIOS pin config */
10643
10644 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10645 if (err < 0)
10646 return err;
10647 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10648 if (err < 0)
10649 return err;
10650
10651 spec->multiout.max_channels = 2;
10652
10653 /* digital only support output */
10654 if (spec->autocfg.dig_out_pin)
10655 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10656
10657 if (spec->kctl_alloc)
10658 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10659
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010660 if (spec->autocfg.speaker_pins[0] != 0x1d)
10661 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10662
Kailang Yanga361d842007-06-05 12:30:55 +020010663 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10664 spec->num_mux_defs = 1;
10665 spec->input_mux = &spec->private_imux;
10666
Takashi Iwai776e1842007-08-29 15:07:11 +020010667 err = alc_auto_add_mic_boost(codec);
10668 if (err < 0)
10669 return err;
10670
Kailang Yanga361d842007-06-05 12:30:55 +020010671 return 1;
10672}
10673
10674#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10675#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10676#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10677
10678/* init callback for auto-configuration model -- overriding the default init */
10679static void alc268_auto_init(struct hda_codec *codec)
10680{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010681 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010682 alc268_auto_init_multi_out(codec);
10683 alc268_auto_init_hp_out(codec);
10684 alc268_auto_init_mono_speaker_out(codec);
10685 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010686 if (spec->unsol_event)
10687 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010688}
10689
10690/*
10691 * configuration and preset
10692 */
10693static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010694 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010695 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010696 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010697 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010698 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010699 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010700#ifdef CONFIG_SND_DEBUG
10701 [ALC268_TEST] = "test",
10702#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010703 [ALC268_AUTO] = "auto",
10704};
10705
10706static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010707 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010708 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010709 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010710 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010711 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010712 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010713 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010714 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010715 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010716 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010717 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010718 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010719 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010720 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010721 {}
10722};
10723
10724static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010725 [ALC267_QUANTA_IL1] = {
10726 .mixers = { alc267_quanta_il1_mixer },
10727 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10728 alc267_quanta_il1_verbs },
10729 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10730 .dac_nids = alc268_dac_nids,
10731 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10732 .adc_nids = alc268_adc_nids_alt,
10733 .hp_nid = 0x03,
10734 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10735 .channel_mode = alc268_modes,
10736 .input_mux = &alc268_capture_source,
10737 .unsol_event = alc267_quanta_il1_unsol_event,
10738 .init_hook = alc267_quanta_il1_automute,
10739 },
Kailang Yanga361d842007-06-05 12:30:55 +020010740 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010741 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10742 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010743 .init_verbs = { alc268_base_init_verbs },
10744 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10745 .dac_nids = alc268_dac_nids,
10746 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10747 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010748 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010749 .hp_nid = 0x03,
10750 .dig_out_nid = ALC268_DIGOUT_NID,
10751 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10752 .channel_mode = alc268_modes,
10753 .input_mux = &alc268_capture_source,
10754 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010755 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010756 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10757 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010758 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10759 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010760 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10761 .dac_nids = alc268_dac_nids,
10762 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10763 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010764 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010765 .hp_nid = 0x03,
10766 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10767 .channel_mode = alc268_modes,
10768 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010769 .unsol_event = alc268_toshiba_unsol_event,
10770 .init_hook = alc268_toshiba_automute,
10771 },
10772 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010773 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10774 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010775 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10776 alc268_acer_verbs },
10777 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10778 .dac_nids = alc268_dac_nids,
10779 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10780 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010781 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010782 .hp_nid = 0x02,
10783 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10784 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010785 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010786 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010787 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010788 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010789 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010790 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010791 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10792 alc268_dell_verbs },
10793 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10794 .dac_nids = alc268_dac_nids,
10795 .hp_nid = 0x02,
10796 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10797 .channel_mode = alc268_modes,
10798 .unsol_event = alc268_dell_unsol_event,
10799 .init_hook = alc268_dell_init_hook,
10800 .input_mux = &alc268_capture_source,
10801 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010802 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010803 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10804 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010805 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10806 alc268_toshiba_verbs },
10807 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10808 .dac_nids = alc268_dac_nids,
10809 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10810 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010811 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010812 .hp_nid = 0x03,
10813 .dig_out_nid = ALC268_DIGOUT_NID,
10814 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10815 .channel_mode = alc268_modes,
10816 .input_mux = &alc268_capture_source,
10817 .unsol_event = alc268_toshiba_unsol_event,
10818 .init_hook = alc268_toshiba_automute
10819 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010820#ifdef CONFIG_SND_DEBUG
10821 [ALC268_TEST] = {
10822 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10823 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10824 alc268_volume_init_verbs },
10825 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10826 .dac_nids = alc268_dac_nids,
10827 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10828 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010829 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010830 .hp_nid = 0x03,
10831 .dig_out_nid = ALC268_DIGOUT_NID,
10832 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10833 .channel_mode = alc268_modes,
10834 .input_mux = &alc268_capture_source,
10835 },
10836#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010837};
10838
10839static int patch_alc268(struct hda_codec *codec)
10840{
10841 struct alc_spec *spec;
10842 int board_config;
10843 int err;
10844
10845 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10846 if (spec == NULL)
10847 return -ENOMEM;
10848
10849 codec->spec = spec;
10850
10851 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10852 alc268_models,
10853 alc268_cfg_tbl);
10854
10855 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10856 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10857 "trying auto-probe from BIOS...\n");
10858 board_config = ALC268_AUTO;
10859 }
10860
10861 if (board_config == ALC268_AUTO) {
10862 /* automatic parse from the BIOS config */
10863 err = alc268_parse_auto_config(codec);
10864 if (err < 0) {
10865 alc_free(codec);
10866 return err;
10867 } else if (!err) {
10868 printk(KERN_INFO
10869 "hda_codec: Cannot set up configuration "
10870 "from BIOS. Using base mode...\n");
10871 board_config = ALC268_3ST;
10872 }
10873 }
10874
10875 if (board_config != ALC268_AUTO)
10876 setup_preset(spec, &alc268_presets[board_config]);
10877
Kailang Yang2f893282008-05-27 12:14:47 +020010878 if (codec->vendor_id == 0x10ec0267) {
10879 spec->stream_name_analog = "ALC267 Analog";
10880 spec->stream_name_digital = "ALC267 Digital";
10881 } else {
10882 spec->stream_name_analog = "ALC268 Analog";
10883 spec->stream_name_digital = "ALC268 Digital";
10884 }
10885
Kailang Yanga361d842007-06-05 12:30:55 +020010886 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10887 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010888 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010889
Kailang Yanga361d842007-06-05 12:30:55 +020010890 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10891
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010892 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10893 /* override the amp caps for beep generator */
10894 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10895 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10896 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10897 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10898 (0 << AC_AMPCAP_MUTE_SHIFT));
10899
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010900 if (!spec->adc_nids && spec->input_mux) {
10901 /* check whether NID 0x07 is valid */
10902 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010903 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010904
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010905 /* get type */
10906 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010907 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010908 spec->adc_nids = alc268_adc_nids_alt;
10909 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10910 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010911 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010912 spec->num_mixers++;
10913 } else {
10914 spec->adc_nids = alc268_adc_nids;
10915 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10916 spec->mixers[spec->num_mixers] =
10917 alc268_capture_mixer;
10918 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010919 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010920 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010921 /* set default input source */
10922 for (i = 0; i < spec->num_adc_nids; i++)
10923 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10924 0, AC_VERB_SET_CONNECT_SEL,
10925 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010926 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010927
10928 spec->vmaster_nid = 0x02;
10929
Kailang Yanga361d842007-06-05 12:30:55 +020010930 codec->patch_ops = alc_patch_ops;
10931 if (board_config == ALC268_AUTO)
10932 spec->init_hook = alc268_auto_init;
10933
10934 return 0;
10935}
10936
10937/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010938 * ALC269 channel source setting (2 channel)
10939 */
10940#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10941
10942#define alc269_dac_nids alc260_dac_nids
10943
10944static hda_nid_t alc269_adc_nids[1] = {
10945 /* ADC1 */
10946 0x07,
10947};
10948
10949#define alc269_modes alc260_modes
10950#define alc269_capture_source alc880_lg_lw_capture_source
10951
10952static struct snd_kcontrol_new alc269_base_mixer[] = {
10953 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10954 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10960 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10964 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10965 { } /* end */
10966};
10967
10968/* capture mixer elements */
10969static struct snd_kcontrol_new alc269_capture_mixer[] = {
10970 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10971 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10972 {
10973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10974 /* The multiple "Capture Source" controls confuse alsamixer
10975 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010976 */
10977 /* .name = "Capture Source", */
10978 .name = "Input Source",
10979 .count = 1,
10980 .info = alc_mux_enum_info,
10981 .get = alc_mux_enum_get,
10982 .put = alc_mux_enum_put,
10983 },
10984 { } /* end */
10985};
10986
10987/*
10988 * generic initialization of ADC, input mixers and output mixers
10989 */
10990static struct hda_verb alc269_init_verbs[] = {
10991 /*
10992 * Unmute ADC0 and set the default input to mic-in
10993 */
10994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10995
10996 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10997 * analog-loopback mixer widget
10998 * Note: PASD motherboards uses the Line In 2 as the input for
10999 * front panel mic (mic 2)
11000 */
11001 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11007
11008 /*
11009 * Set up output mixers (0x0c - 0x0e)
11010 */
11011 /* set vol=0 to output mixers */
11012 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11013 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11014
11015 /* set up input amps for analog loopback */
11016 /* Amp Indices: DAC = 0, mixer = 1 */
11017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11023
11024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11026 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11027 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11028 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11031
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11034 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11038 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11039
11040 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11041 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11042
11043 /* FIXME: use matrix-type input source selection */
11044 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11045 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11050
11051 /* set EAPD */
11052 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11053 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11054 { }
11055};
11056
11057/* add playback controls from the parsed DAC table */
11058static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11059 const struct auto_pin_cfg *cfg)
11060{
11061 hda_nid_t nid;
11062 int err;
11063
11064 spec->multiout.num_dacs = 1; /* only use one dac */
11065 spec->multiout.dac_nids = spec->private_dac_nids;
11066 spec->multiout.dac_nids[0] = 2;
11067
11068 nid = cfg->line_out_pins[0];
11069 if (nid) {
11070 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11071 "Front Playback Volume",
11072 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11073 if (err < 0)
11074 return err;
11075 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11076 "Front Playback Switch",
11077 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11078 if (err < 0)
11079 return err;
11080 }
11081
11082 nid = cfg->speaker_pins[0];
11083 if (nid) {
11084 if (!cfg->line_out_pins[0]) {
11085 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11086 "Speaker Playback Volume",
11087 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11088 HDA_OUTPUT));
11089 if (err < 0)
11090 return err;
11091 }
11092 if (nid == 0x16) {
11093 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11094 "Speaker Playback Switch",
11095 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11096 HDA_OUTPUT));
11097 if (err < 0)
11098 return err;
11099 } else {
11100 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11101 "Speaker Playback Switch",
11102 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11103 HDA_OUTPUT));
11104 if (err < 0)
11105 return err;
11106 }
11107 }
11108 nid = cfg->hp_pins[0];
11109 if (nid) {
11110 /* spec->multiout.hp_nid = 2; */
11111 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11112 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11113 "Headphone Playback Volume",
11114 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11115 HDA_OUTPUT));
11116 if (err < 0)
11117 return err;
11118 }
11119 if (nid == 0x16) {
11120 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11121 "Headphone Playback Switch",
11122 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11123 HDA_OUTPUT));
11124 if (err < 0)
11125 return err;
11126 } else {
11127 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11128 "Headphone Playback Switch",
11129 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11130 HDA_OUTPUT));
11131 if (err < 0)
11132 return err;
11133 }
11134 }
11135 return 0;
11136}
11137
11138#define alc269_auto_create_analog_input_ctls \
11139 alc880_auto_create_analog_input_ctls
11140
11141#ifdef CONFIG_SND_HDA_POWER_SAVE
11142#define alc269_loopbacks alc880_loopbacks
11143#endif
11144
11145/* pcm configuration: identiacal with ALC880 */
11146#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11147#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11148#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11149#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11150
11151/*
11152 * BIOS auto configuration
11153 */
11154static int alc269_parse_auto_config(struct hda_codec *codec)
11155{
11156 struct alc_spec *spec = codec->spec;
11157 int err;
11158 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11159
11160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11161 alc269_ignore);
11162 if (err < 0)
11163 return err;
11164
11165 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11166 if (err < 0)
11167 return err;
11168 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11169 if (err < 0)
11170 return err;
11171
11172 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11173
11174 if (spec->autocfg.dig_out_pin)
11175 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11176
11177 if (spec->kctl_alloc)
11178 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11179
11180 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11181 spec->num_mux_defs = 1;
11182 spec->input_mux = &spec->private_imux;
11183
11184 err = alc_auto_add_mic_boost(codec);
11185 if (err < 0)
11186 return err;
11187
11188 return 1;
11189}
11190
11191#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11192#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11193#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11194
11195
11196/* init callback for auto-configuration model -- overriding the default init */
11197static void alc269_auto_init(struct hda_codec *codec)
11198{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011199 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011200 alc269_auto_init_multi_out(codec);
11201 alc269_auto_init_hp_out(codec);
11202 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011203 if (spec->unsol_event)
11204 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011205}
11206
11207/*
11208 * configuration and preset
11209 */
11210static const char *alc269_models[ALC269_MODEL_LAST] = {
11211 [ALC269_BASIC] = "basic",
11212};
11213
11214static struct snd_pci_quirk alc269_cfg_tbl[] = {
11215 {}
11216};
11217
11218static struct alc_config_preset alc269_presets[] = {
11219 [ALC269_BASIC] = {
11220 .mixers = { alc269_base_mixer },
11221 .init_verbs = { alc269_init_verbs },
11222 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11223 .dac_nids = alc269_dac_nids,
11224 .hp_nid = 0x03,
11225 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11226 .channel_mode = alc269_modes,
11227 .input_mux = &alc269_capture_source,
11228 },
11229};
11230
11231static int patch_alc269(struct hda_codec *codec)
11232{
11233 struct alc_spec *spec;
11234 int board_config;
11235 int err;
11236
11237 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11238 if (spec == NULL)
11239 return -ENOMEM;
11240
11241 codec->spec = spec;
11242
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011243 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11244
Kailang Yangf6a92242007-12-13 16:52:54 +010011245 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11246 alc269_models,
11247 alc269_cfg_tbl);
11248
11249 if (board_config < 0) {
11250 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11251 "trying auto-probe from BIOS...\n");
11252 board_config = ALC269_AUTO;
11253 }
11254
11255 if (board_config == ALC269_AUTO) {
11256 /* automatic parse from the BIOS config */
11257 err = alc269_parse_auto_config(codec);
11258 if (err < 0) {
11259 alc_free(codec);
11260 return err;
11261 } else if (!err) {
11262 printk(KERN_INFO
11263 "hda_codec: Cannot set up configuration "
11264 "from BIOS. Using base mode...\n");
11265 board_config = ALC269_BASIC;
11266 }
11267 }
11268
11269 if (board_config != ALC269_AUTO)
11270 setup_preset(spec, &alc269_presets[board_config]);
11271
11272 spec->stream_name_analog = "ALC269 Analog";
11273 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11274 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11275
11276 spec->stream_name_digital = "ALC269 Digital";
11277 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11278 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11279
11280 spec->adc_nids = alc269_adc_nids;
11281 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11282 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11283 spec->num_mixers++;
11284
11285 codec->patch_ops = alc_patch_ops;
11286 if (board_config == ALC269_AUTO)
11287 spec->init_hook = alc269_auto_init;
11288#ifdef CONFIG_SND_HDA_POWER_SAVE
11289 if (!spec->loopback.amplist)
11290 spec->loopback.amplist = alc269_loopbacks;
11291#endif
11292
11293 return 0;
11294}
11295
11296/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011297 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11298 */
11299
11300/*
11301 * set the path ways for 2 channel output
11302 * need to set the codec line out and mic 1 pin widgets to inputs
11303 */
11304static struct hda_verb alc861_threestack_ch2_init[] = {
11305 /* set pin widget 1Ah (line in) for input */
11306 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011307 /* set pin widget 18h (mic1/2) for input, for mic also enable
11308 * the vref
11309 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011310 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11311
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011312 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11313#if 0
11314 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11315 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11316#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011317 { } /* end */
11318};
11319/*
11320 * 6ch mode
11321 * need to set the codec line out and mic 1 pin widgets to outputs
11322 */
11323static struct hda_verb alc861_threestack_ch6_init[] = {
11324 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11325 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11326 /* set pin widget 18h (mic1) for output (CLFE)*/
11327 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11328
11329 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011331
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011332 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11333#if 0
11334 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11335 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11336#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011337 { } /* end */
11338};
11339
11340static struct hda_channel_mode alc861_threestack_modes[2] = {
11341 { 2, alc861_threestack_ch2_init },
11342 { 6, alc861_threestack_ch6_init },
11343};
Takashi Iwai22309c32006-08-09 16:57:28 +020011344/* Set mic1 as input and unmute the mixer */
11345static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11346 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11348 { } /* end */
11349};
11350/* Set mic1 as output and mute mixer */
11351static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11352 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11353 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11354 { } /* end */
11355};
11356
11357static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11358 { 2, alc861_uniwill_m31_ch2_init },
11359 { 4, alc861_uniwill_m31_ch4_init },
11360};
Kailang Yangdf694da2005-12-05 19:42:22 +010011361
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011362/* Set mic1 and line-in as input and unmute the mixer */
11363static struct hda_verb alc861_asus_ch2_init[] = {
11364 /* set pin widget 1Ah (line in) for input */
11365 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011366 /* set pin widget 18h (mic1/2) for input, for mic also enable
11367 * the vref
11368 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011369 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11370
11371 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11372#if 0
11373 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11375#endif
11376 { } /* end */
11377};
11378/* Set mic1 nad line-in as output and mute mixer */
11379static struct hda_verb alc861_asus_ch6_init[] = {
11380 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11381 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11382 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11383 /* set pin widget 18h (mic1) for output (CLFE)*/
11384 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11385 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11386 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11387 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11388
11389 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11390#if 0
11391 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11392 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11393#endif
11394 { } /* end */
11395};
11396
11397static struct hda_channel_mode alc861_asus_modes[2] = {
11398 { 2, alc861_asus_ch2_init },
11399 { 6, alc861_asus_ch6_init },
11400};
11401
Kailang Yangdf694da2005-12-05 19:42:22 +010011402/* patch-ALC861 */
11403
11404static struct snd_kcontrol_new alc861_base_mixer[] = {
11405 /* output mixer control */
11406 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11411
11412 /*Input mixer control */
11413 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11415 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11416 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11417 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11418 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11420 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11421 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011423
Kailang Yangdf694da2005-12-05 19:42:22 +010011424 /* Capture mixer control */
11425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11427 {
11428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11429 .name = "Capture Source",
11430 .count = 1,
11431 .info = alc_mux_enum_info,
11432 .get = alc_mux_enum_get,
11433 .put = alc_mux_enum_put,
11434 },
11435 { } /* end */
11436};
11437
11438static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11439 /* output mixer control */
11440 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11441 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11442 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11443 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11444 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11445
11446 /* Input mixer control */
11447 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11448 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11449 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11450 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11451 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11452 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11454 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11455 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011457
Kailang Yangdf694da2005-12-05 19:42:22 +010011458 /* Capture mixer control */
11459 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11460 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11461 {
11462 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11463 .name = "Capture Source",
11464 .count = 1,
11465 .info = alc_mux_enum_info,
11466 .get = alc_mux_enum_get,
11467 .put = alc_mux_enum_put,
11468 },
11469 {
11470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11471 .name = "Channel Mode",
11472 .info = alc_ch_mode_info,
11473 .get = alc_ch_mode_get,
11474 .put = alc_ch_mode_put,
11475 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11476 },
11477 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011478};
11479
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011480static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011481 /* output mixer control */
11482 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11484 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11485
11486 /*Capture mixer control */
11487 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11488 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11489 {
11490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11491 .name = "Capture Source",
11492 .count = 1,
11493 .info = alc_mux_enum_info,
11494 .get = alc_mux_enum_get,
11495 .put = alc_mux_enum_put,
11496 },
11497
11498 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011499};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011500
Takashi Iwai22309c32006-08-09 16:57:28 +020011501static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11502 /* output mixer control */
11503 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11504 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11505 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11506 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11507 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11508
11509 /* Input mixer control */
11510 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11511 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11512 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11513 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11514 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11515 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11517 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11518 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520
Takashi Iwai22309c32006-08-09 16:57:28 +020011521 /* Capture mixer control */
11522 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11523 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11524 {
11525 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11526 .name = "Capture Source",
11527 .count = 1,
11528 .info = alc_mux_enum_info,
11529 .get = alc_mux_enum_get,
11530 .put = alc_mux_enum_put,
11531 },
11532 {
11533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11534 .name = "Channel Mode",
11535 .info = alc_ch_mode_info,
11536 .get = alc_ch_mode_get,
11537 .put = alc_ch_mode_put,
11538 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11539 },
11540 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011541};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011542
11543static struct snd_kcontrol_new alc861_asus_mixer[] = {
11544 /* output mixer control */
11545 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11547 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11548 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11549 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11550
11551 /* Input mixer control */
11552 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11553 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11554 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11555 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11556 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11557 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11559 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11562
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011563 /* Capture mixer control */
11564 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11565 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11566 {
11567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11568 .name = "Capture Source",
11569 .count = 1,
11570 .info = alc_mux_enum_info,
11571 .get = alc_mux_enum_get,
11572 .put = alc_mux_enum_put,
11573 },
11574 {
11575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11576 .name = "Channel Mode",
11577 .info = alc_ch_mode_info,
11578 .get = alc_ch_mode_get,
11579 .put = alc_ch_mode_put,
11580 .private_value = ARRAY_SIZE(alc861_asus_modes),
11581 },
11582 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011583};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011584
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011585/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011586static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011587 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11588 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11589 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11590 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11591 { }
11592};
11593
Kailang Yangdf694da2005-12-05 19:42:22 +010011594/*
11595 * generic initialization of ADC, input mixers and output mixers
11596 */
11597static struct hda_verb alc861_base_init_verbs[] = {
11598 /*
11599 * Unmute ADC0 and set the default input to mic-in
11600 */
11601 /* port-A for surround (rear panel) */
11602 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11603 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11604 /* port-B for mic-in (rear panel) with vref */
11605 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11606 /* port-C for line-in (rear panel) */
11607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11608 /* port-D for Front */
11609 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11610 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11611 /* port-E for HP out (front panel) */
11612 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11613 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011614 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011615 /* port-F for mic-in (front panel) with vref */
11616 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11617 /* port-G for CLFE (rear panel) */
11618 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11619 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11620 /* port-H for side (rear panel) */
11621 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11622 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11623 /* CD-in */
11624 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11625 /* route front mic to ADC1*/
11626 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11628
11629 /* Unmute DAC0~3 & spdif out*/
11630 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11631 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11632 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11633 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11635
11636 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11637 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11638 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11639 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11640 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11641
11642 /* Unmute Stereo Mixer 15 */
11643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011647
11648 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11651 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11653 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011656 /* hp used DAC 3 (Front) */
11657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011658 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11659
11660 { }
11661};
11662
11663static struct hda_verb alc861_threestack_init_verbs[] = {
11664 /*
11665 * Unmute ADC0 and set the default input to mic-in
11666 */
11667 /* port-A for surround (rear panel) */
11668 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11669 /* port-B for mic-in (rear panel) with vref */
11670 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11671 /* port-C for line-in (rear panel) */
11672 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11673 /* port-D for Front */
11674 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11675 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11676 /* port-E for HP out (front panel) */
11677 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11678 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011679 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011680 /* port-F for mic-in (front panel) with vref */
11681 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11682 /* port-G for CLFE (rear panel) */
11683 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11684 /* port-H for side (rear panel) */
11685 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11686 /* CD-in */
11687 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11688 /* route front mic to ADC1*/
11689 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11691 /* Unmute DAC0~3 & spdif out*/
11692 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11693 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11695 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11697
11698 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11699 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11700 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11701 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11702 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11703
11704 /* Unmute Stereo Mixer 15 */
11705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011709
11710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11711 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011718 /* hp used DAC 3 (Front) */
11719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011720 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11721 { }
11722};
Takashi Iwai22309c32006-08-09 16:57:28 +020011723
11724static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11725 /*
11726 * Unmute ADC0 and set the default input to mic-in
11727 */
11728 /* port-A for surround (rear panel) */
11729 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11730 /* port-B for mic-in (rear panel) with vref */
11731 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11732 /* port-C for line-in (rear panel) */
11733 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11734 /* port-D for Front */
11735 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11736 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11737 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011738 /* this has to be set to VREF80 */
11739 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011740 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011742 /* port-F for mic-in (front panel) with vref */
11743 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11744 /* port-G for CLFE (rear panel) */
11745 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11746 /* port-H for side (rear panel) */
11747 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11748 /* CD-in */
11749 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11750 /* route front mic to ADC1*/
11751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11753 /* Unmute DAC0~3 & spdif out*/
11754 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11755 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11756 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11757 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11759
11760 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11761 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11762 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11763 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11764 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11765
11766 /* Unmute Stereo Mixer 15 */
11767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011771
11772 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11779 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011780 /* hp used DAC 3 (Front) */
11781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11783 { }
11784};
11785
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011786static struct hda_verb alc861_asus_init_verbs[] = {
11787 /*
11788 * Unmute ADC0 and set the default input to mic-in
11789 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011790 /* port-A for surround (rear panel)
11791 * according to codec#0 this is the HP jack
11792 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011793 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11794 /* route front PCM to HP */
11795 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11796 /* port-B for mic-in (rear panel) with vref */
11797 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11798 /* port-C for line-in (rear panel) */
11799 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11800 /* port-D for Front */
11801 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11802 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11803 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011804 /* this has to be set to VREF80 */
11805 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011806 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011807 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011808 /* port-F for mic-in (front panel) with vref */
11809 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11810 /* port-G for CLFE (rear panel) */
11811 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11812 /* port-H for side (rear panel) */
11813 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11814 /* CD-in */
11815 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11816 /* route front mic to ADC1*/
11817 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11819 /* Unmute DAC0~3 & spdif out*/
11820 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11821 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11823 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11825 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11826 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11827 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11828 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11829 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11830
11831 /* Unmute Stereo Mixer 15 */
11832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011836
11837 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11839 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011845 /* hp used DAC 3 (Front) */
11846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11848 { }
11849};
11850
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011851/* additional init verbs for ASUS laptops */
11852static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11853 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11854 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11855 { }
11856};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011857
Kailang Yangdf694da2005-12-05 19:42:22 +010011858/*
11859 * generic initialization of ADC, input mixers and output mixers
11860 */
11861static struct hda_verb alc861_auto_init_verbs[] = {
11862 /*
11863 * Unmute ADC0 and set the default input to mic-in
11864 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011865 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11867
11868 /* Unmute DAC0~3 & spdif out*/
11869 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11870 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11871 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11872 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11874
11875 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11877 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11879 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11880
11881 /* Unmute Stereo Mixer 15 */
11882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11886
11887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11895
11896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011900 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11901 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011902 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011906
11907 { }
11908};
11909
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011910static struct hda_verb alc861_toshiba_init_verbs[] = {
11911 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011912
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011913 { }
11914};
11915
11916/* toggle speaker-output according to the hp-jack state */
11917static void alc861_toshiba_automute(struct hda_codec *codec)
11918{
11919 unsigned int present;
11920
11921 present = snd_hda_codec_read(codec, 0x0f, 0,
11922 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011923 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11924 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11925 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11926 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011927}
11928
11929static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11930 unsigned int res)
11931{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011932 if ((res >> 26) == ALC880_HP_EVENT)
11933 alc861_toshiba_automute(codec);
11934}
11935
Kailang Yangdf694da2005-12-05 19:42:22 +010011936/* pcm configuration: identiacal with ALC880 */
11937#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11938#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11939#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11940#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11941
11942
11943#define ALC861_DIGOUT_NID 0x07
11944
11945static struct hda_channel_mode alc861_8ch_modes[1] = {
11946 { 8, NULL }
11947};
11948
11949static hda_nid_t alc861_dac_nids[4] = {
11950 /* front, surround, clfe, side */
11951 0x03, 0x06, 0x05, 0x04
11952};
11953
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011954static hda_nid_t alc660_dac_nids[3] = {
11955 /* front, clfe, surround */
11956 0x03, 0x05, 0x06
11957};
11958
Kailang Yangdf694da2005-12-05 19:42:22 +010011959static hda_nid_t alc861_adc_nids[1] = {
11960 /* ADC0-2 */
11961 0x08,
11962};
11963
11964static struct hda_input_mux alc861_capture_source = {
11965 .num_items = 5,
11966 .items = {
11967 { "Mic", 0x0 },
11968 { "Front Mic", 0x3 },
11969 { "Line", 0x1 },
11970 { "CD", 0x4 },
11971 { "Mixer", 0x5 },
11972 },
11973};
11974
11975/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011976static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11977 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011978{
11979 int i;
11980 hda_nid_t nid;
11981
11982 spec->multiout.dac_nids = spec->private_dac_nids;
11983 for (i = 0; i < cfg->line_outs; i++) {
11984 nid = cfg->line_out_pins[i];
11985 if (nid) {
11986 if (i >= ARRAY_SIZE(alc861_dac_nids))
11987 continue;
11988 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11989 }
11990 }
11991 spec->multiout.num_dacs = cfg->line_outs;
11992 return 0;
11993}
11994
11995/* add playback controls from the parsed DAC table */
11996static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11997 const struct auto_pin_cfg *cfg)
11998{
11999 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012000 static const char *chname[4] = {
12001 "Front", "Surround", NULL /*CLFE*/, "Side"
12002 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012003 hda_nid_t nid;
12004 int i, idx, err;
12005
12006 for (i = 0; i < cfg->line_outs; i++) {
12007 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012008 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012009 continue;
12010 if (nid == 0x05) {
12011 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012012 err = add_control(spec, ALC_CTL_BIND_MUTE,
12013 "Center Playback Switch",
12014 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12015 HDA_OUTPUT));
12016 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012017 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012018 err = add_control(spec, ALC_CTL_BIND_MUTE,
12019 "LFE Playback Switch",
12020 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12021 HDA_OUTPUT));
12022 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012023 return err;
12024 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012025 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12026 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012027 if (nid == alc861_dac_nids[idx])
12028 break;
12029 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012030 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12031 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12032 HDA_OUTPUT));
12033 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012034 return err;
12035 }
12036 }
12037 return 0;
12038}
12039
12040static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12041{
12042 int err;
12043 hda_nid_t nid;
12044
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012045 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012046 return 0;
12047
12048 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12049 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012050 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12051 "Headphone Playback Switch",
12052 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12053 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012054 return err;
12055 spec->multiout.hp_nid = nid;
12056 }
12057 return 0;
12058}
12059
12060/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012061static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12062 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012063{
Kailang Yangdf694da2005-12-05 19:42:22 +010012064 struct hda_input_mux *imux = &spec->private_imux;
12065 int i, err, idx, idx1;
12066
12067 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012068 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012069 case 0x0c:
12070 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012071 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012072 break;
12073 case 0x0f:
12074 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012075 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012076 break;
12077 case 0x0d:
12078 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012079 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012080 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012081 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012082 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012083 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012084 break;
12085 case 0x11:
12086 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012087 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012088 break;
12089 default:
12090 continue;
12091 }
12092
Takashi Iwai4a471b72005-12-07 13:56:29 +010012093 err = new_analog_input(spec, cfg->input_pins[i],
12094 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012095 if (err < 0)
12096 return err;
12097
Takashi Iwai4a471b72005-12-07 13:56:29 +010012098 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012099 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012100 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012101 }
12102 return 0;
12103}
12104
12105static struct snd_kcontrol_new alc861_capture_mixer[] = {
12106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12108
12109 {
12110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12111 /* The multiple "Capture Source" controls confuse alsamixer
12112 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012113 */
12114 /* .name = "Capture Source", */
12115 .name = "Input Source",
12116 .count = 1,
12117 .info = alc_mux_enum_info,
12118 .get = alc_mux_enum_get,
12119 .put = alc_mux_enum_put,
12120 },
12121 { } /* end */
12122};
12123
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012124static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12125 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012126 int pin_type, int dac_idx)
12127{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012128 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12129 pin_type);
12130 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12131 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012132}
12133
12134static void alc861_auto_init_multi_out(struct hda_codec *codec)
12135{
12136 struct alc_spec *spec = codec->spec;
12137 int i;
12138
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012139 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012140 for (i = 0; i < spec->autocfg.line_outs; i++) {
12141 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012142 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012143 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012144 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012145 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012146 }
12147}
12148
12149static void alc861_auto_init_hp_out(struct hda_codec *codec)
12150{
12151 struct alc_spec *spec = codec->spec;
12152 hda_nid_t pin;
12153
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012154 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012155 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012156 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12157 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012158 pin = spec->autocfg.speaker_pins[0];
12159 if (pin)
12160 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012161}
12162
12163static void alc861_auto_init_analog_input(struct hda_codec *codec)
12164{
12165 struct alc_spec *spec = codec->spec;
12166 int i;
12167
12168 for (i = 0; i < AUTO_PIN_LAST; i++) {
12169 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012170 if (nid >= 0x0c && nid <= 0x11) {
12171 snd_hda_codec_write(codec, nid, 0,
12172 AC_VERB_SET_PIN_WIDGET_CONTROL,
12173 i <= AUTO_PIN_FRONT_MIC ?
12174 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012175 }
12176 }
12177}
12178
12179/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012180/* return 1 if successful, 0 if the proper config is not found,
12181 * or a negative error code
12182 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012183static int alc861_parse_auto_config(struct hda_codec *codec)
12184{
12185 struct alc_spec *spec = codec->spec;
12186 int err;
12187 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12188
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012189 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12190 alc861_ignore);
12191 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012192 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012193 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012194 return 0; /* can't find valid BIOS pin config */
12195
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012196 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12197 if (err < 0)
12198 return err;
12199 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12200 if (err < 0)
12201 return err;
12202 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12203 if (err < 0)
12204 return err;
12205 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12206 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012207 return err;
12208
12209 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12210
12211 if (spec->autocfg.dig_out_pin)
12212 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12213
12214 if (spec->kctl_alloc)
12215 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12216
12217 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12218
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012219 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012220 spec->input_mux = &spec->private_imux;
12221
12222 spec->adc_nids = alc861_adc_nids;
12223 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12224 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12225 spec->num_mixers++;
12226
12227 return 1;
12228}
12229
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012230/* additional initialization for auto-configuration model */
12231static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012232{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012233 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012234 alc861_auto_init_multi_out(codec);
12235 alc861_auto_init_hp_out(codec);
12236 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012237 if (spec->unsol_event)
12238 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012239}
12240
Takashi Iwaicb53c622007-08-10 17:21:45 +020012241#ifdef CONFIG_SND_HDA_POWER_SAVE
12242static struct hda_amp_list alc861_loopbacks[] = {
12243 { 0x15, HDA_INPUT, 0 },
12244 { 0x15, HDA_INPUT, 1 },
12245 { 0x15, HDA_INPUT, 2 },
12246 { 0x15, HDA_INPUT, 3 },
12247 { } /* end */
12248};
12249#endif
12250
Kailang Yangdf694da2005-12-05 19:42:22 +010012251
12252/*
12253 * configuration and preset
12254 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012255static const char *alc861_models[ALC861_MODEL_LAST] = {
12256 [ALC861_3ST] = "3stack",
12257 [ALC660_3ST] = "3stack-660",
12258 [ALC861_3ST_DIG] = "3stack-dig",
12259 [ALC861_6ST_DIG] = "6stack-dig",
12260 [ALC861_UNIWILL_M31] = "uniwill-m31",
12261 [ALC861_TOSHIBA] = "toshiba",
12262 [ALC861_ASUS] = "asus",
12263 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12264 [ALC861_AUTO] = "auto",
12265};
12266
12267static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012268 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012269 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12270 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12271 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012272 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012273 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012274 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012275 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12276 * Any other models that need this preset?
12277 */
12278 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012279 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12280 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012281 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12282 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12283 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12284 /* FIXME: the below seems conflict */
12285 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12286 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12287 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012288 {}
12289};
12290
12291static struct alc_config_preset alc861_presets[] = {
12292 [ALC861_3ST] = {
12293 .mixers = { alc861_3ST_mixer },
12294 .init_verbs = { alc861_threestack_init_verbs },
12295 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12296 .dac_nids = alc861_dac_nids,
12297 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12298 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012299 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012300 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12301 .adc_nids = alc861_adc_nids,
12302 .input_mux = &alc861_capture_source,
12303 },
12304 [ALC861_3ST_DIG] = {
12305 .mixers = { alc861_base_mixer },
12306 .init_verbs = { alc861_threestack_init_verbs },
12307 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12308 .dac_nids = alc861_dac_nids,
12309 .dig_out_nid = ALC861_DIGOUT_NID,
12310 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12311 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012312 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012313 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12314 .adc_nids = alc861_adc_nids,
12315 .input_mux = &alc861_capture_source,
12316 },
12317 [ALC861_6ST_DIG] = {
12318 .mixers = { alc861_base_mixer },
12319 .init_verbs = { alc861_base_init_verbs },
12320 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12321 .dac_nids = alc861_dac_nids,
12322 .dig_out_nid = ALC861_DIGOUT_NID,
12323 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12324 .channel_mode = alc861_8ch_modes,
12325 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12326 .adc_nids = alc861_adc_nids,
12327 .input_mux = &alc861_capture_source,
12328 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012329 [ALC660_3ST] = {
12330 .mixers = { alc861_3ST_mixer },
12331 .init_verbs = { alc861_threestack_init_verbs },
12332 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12333 .dac_nids = alc660_dac_nids,
12334 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12335 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012336 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012337 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12338 .adc_nids = alc861_adc_nids,
12339 .input_mux = &alc861_capture_source,
12340 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012341 [ALC861_UNIWILL_M31] = {
12342 .mixers = { alc861_uniwill_m31_mixer },
12343 .init_verbs = { alc861_uniwill_m31_init_verbs },
12344 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12345 .dac_nids = alc861_dac_nids,
12346 .dig_out_nid = ALC861_DIGOUT_NID,
12347 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12348 .channel_mode = alc861_uniwill_m31_modes,
12349 .need_dac_fix = 1,
12350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12351 .adc_nids = alc861_adc_nids,
12352 .input_mux = &alc861_capture_source,
12353 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012354 [ALC861_TOSHIBA] = {
12355 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012356 .init_verbs = { alc861_base_init_verbs,
12357 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012358 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12359 .dac_nids = alc861_dac_nids,
12360 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12361 .channel_mode = alc883_3ST_2ch_modes,
12362 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12363 .adc_nids = alc861_adc_nids,
12364 .input_mux = &alc861_capture_source,
12365 .unsol_event = alc861_toshiba_unsol_event,
12366 .init_hook = alc861_toshiba_automute,
12367 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012368 [ALC861_ASUS] = {
12369 .mixers = { alc861_asus_mixer },
12370 .init_verbs = { alc861_asus_init_verbs },
12371 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12372 .dac_nids = alc861_dac_nids,
12373 .dig_out_nid = ALC861_DIGOUT_NID,
12374 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12375 .channel_mode = alc861_asus_modes,
12376 .need_dac_fix = 1,
12377 .hp_nid = 0x06,
12378 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12379 .adc_nids = alc861_adc_nids,
12380 .input_mux = &alc861_capture_source,
12381 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012382 [ALC861_ASUS_LAPTOP] = {
12383 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12384 .init_verbs = { alc861_asus_init_verbs,
12385 alc861_asus_laptop_init_verbs },
12386 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12387 .dac_nids = alc861_dac_nids,
12388 .dig_out_nid = ALC861_DIGOUT_NID,
12389 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12390 .channel_mode = alc883_3ST_2ch_modes,
12391 .need_dac_fix = 1,
12392 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12393 .adc_nids = alc861_adc_nids,
12394 .input_mux = &alc861_capture_source,
12395 },
12396};
Kailang Yangdf694da2005-12-05 19:42:22 +010012397
12398
12399static int patch_alc861(struct hda_codec *codec)
12400{
12401 struct alc_spec *spec;
12402 int board_config;
12403 int err;
12404
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012405 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012406 if (spec == NULL)
12407 return -ENOMEM;
12408
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012409 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012410
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012411 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12412 alc861_models,
12413 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012414
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012415 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012416 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12417 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012418 board_config = ALC861_AUTO;
12419 }
12420
12421 if (board_config == ALC861_AUTO) {
12422 /* automatic parse from the BIOS config */
12423 err = alc861_parse_auto_config(codec);
12424 if (err < 0) {
12425 alc_free(codec);
12426 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012427 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012428 printk(KERN_INFO
12429 "hda_codec: Cannot set up configuration "
12430 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012431 board_config = ALC861_3ST_DIG;
12432 }
12433 }
12434
12435 if (board_config != ALC861_AUTO)
12436 setup_preset(spec, &alc861_presets[board_config]);
12437
12438 spec->stream_name_analog = "ALC861 Analog";
12439 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12440 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12441
12442 spec->stream_name_digital = "ALC861 Digital";
12443 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12444 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12445
Takashi Iwai2134ea42008-01-10 16:53:55 +010012446 spec->vmaster_nid = 0x03;
12447
Kailang Yangdf694da2005-12-05 19:42:22 +010012448 codec->patch_ops = alc_patch_ops;
12449 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012450 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012451#ifdef CONFIG_SND_HDA_POWER_SAVE
12452 if (!spec->loopback.amplist)
12453 spec->loopback.amplist = alc861_loopbacks;
12454#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012455
12456 return 0;
12457}
12458
12459/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012460 * ALC861-VD support
12461 *
12462 * Based on ALC882
12463 *
12464 * In addition, an independent DAC
12465 */
12466#define ALC861VD_DIGOUT_NID 0x06
12467
12468static hda_nid_t alc861vd_dac_nids[4] = {
12469 /* front, surr, clfe, side surr */
12470 0x02, 0x03, 0x04, 0x05
12471};
12472
12473/* dac_nids for ALC660vd are in a different order - according to
12474 * Realtek's driver.
12475 * This should probably tesult in a different mixer for 6stack models
12476 * of ALC660vd codecs, but for now there is only 3stack mixer
12477 * - and it is the same as in 861vd.
12478 * adc_nids in ALC660vd are (is) the same as in 861vd
12479 */
12480static hda_nid_t alc660vd_dac_nids[3] = {
12481 /* front, rear, clfe, rear_surr */
12482 0x02, 0x04, 0x03
12483};
12484
12485static hda_nid_t alc861vd_adc_nids[1] = {
12486 /* ADC0 */
12487 0x09,
12488};
12489
Takashi Iwaie1406342008-02-11 18:32:32 +010012490static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12491
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012492/* input MUX */
12493/* FIXME: should be a matrix-type input source selection */
12494static struct hda_input_mux alc861vd_capture_source = {
12495 .num_items = 4,
12496 .items = {
12497 { "Mic", 0x0 },
12498 { "Front Mic", 0x1 },
12499 { "Line", 0x2 },
12500 { "CD", 0x4 },
12501 },
12502};
12503
Kailang Yang272a5272007-05-14 11:00:38 +020012504static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012505 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012506 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012507 { "Ext Mic", 0x0 },
12508 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012509 },
12510};
12511
Kailang Yangd1a991a2007-08-15 16:21:59 +020012512static struct hda_input_mux alc861vd_hp_capture_source = {
12513 .num_items = 2,
12514 .items = {
12515 { "Front Mic", 0x0 },
12516 { "ATAPI Mic", 0x1 },
12517 },
12518};
12519
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012520#define alc861vd_mux_enum_info alc_mux_enum_info
12521#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012522/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12523#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012524
12525/*
12526 * 2ch mode
12527 */
12528static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12529 { 2, NULL }
12530};
12531
12532/*
12533 * 6ch mode
12534 */
12535static struct hda_verb alc861vd_6stack_ch6_init[] = {
12536 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12537 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12538 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12539 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12540 { } /* end */
12541};
12542
12543/*
12544 * 8ch mode
12545 */
12546static struct hda_verb alc861vd_6stack_ch8_init[] = {
12547 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12548 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12549 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12550 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12551 { } /* end */
12552};
12553
12554static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12555 { 6, alc861vd_6stack_ch6_init },
12556 { 8, alc861vd_6stack_ch8_init },
12557};
12558
12559static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12560 {
12561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12562 .name = "Channel Mode",
12563 .info = alc_ch_mode_info,
12564 .get = alc_ch_mode_get,
12565 .put = alc_ch_mode_put,
12566 },
12567 { } /* end */
12568};
12569
12570static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12571 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12572 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12573
12574 {
12575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12576 /* The multiple "Capture Source" controls confuse alsamixer
12577 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012578 */
12579 /* .name = "Capture Source", */
12580 .name = "Input Source",
12581 .count = 1,
12582 .info = alc861vd_mux_enum_info,
12583 .get = alc861vd_mux_enum_get,
12584 .put = alc861vd_mux_enum_put,
12585 },
12586 { } /* end */
12587};
12588
12589/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12590 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12591 */
12592static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12593 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12594 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12595
12596 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12597 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12598
12599 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12600 HDA_OUTPUT),
12601 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12602 HDA_OUTPUT),
12603 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12604 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12605
12606 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12607 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12608
12609 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12610
12611 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12614
12615 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12616 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12617 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12618
12619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12621
12622 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12623 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12624
12625 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12626 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12627
12628 { } /* end */
12629};
12630
12631static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12632 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12634
12635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12636
12637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12640
12641 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12644
12645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12647
12648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12650
12651 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12652 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12653
12654 { } /* end */
12655};
12656
Kailang Yangbdd148a2007-05-08 15:19:08 +020012657static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12658 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12659 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12660 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12661
12662 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12663
12664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12667
12668 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12671
12672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12674
12675 { } /* end */
12676};
12677
Tobin Davisb419f342008-03-07 11:57:51 +010012678/* Pin assignment: Speaker=0x14, HP = 0x15,
12679 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012680 */
12681static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12683 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12685 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012686 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12687 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12688 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12689 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12690 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12691 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12692 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12693 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012694 { } /* end */
12695};
12696
Kailang Yangd1a991a2007-08-15 16:21:59 +020012697/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12698 * Front Mic=0x18, ATAPI Mic = 0x19,
12699 */
12700static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12701 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12702 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12703 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12704 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12705 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12707 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12708 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12709
12710 { } /* end */
12711};
12712
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012713/*
12714 * generic initialization of ADC, input mixers and output mixers
12715 */
12716static struct hda_verb alc861vd_volume_init_verbs[] = {
12717 /*
12718 * Unmute ADC0 and set the default input to mic-in
12719 */
12720 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12721 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12722
12723 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12724 * the analog-loopback mixer widget
12725 */
12726 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012732
12733 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012738
12739 /*
12740 * Set up output mixers (0x02 - 0x05)
12741 */
12742 /* set vol=0 to output mixers */
12743 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12744 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12745 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12746 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12747
12748 /* set up input amps for analog loopback */
12749 /* Amp Indices: DAC = 0, mixer = 1 */
12750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12757 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12758
12759 { }
12760};
12761
12762/*
12763 * 3-stack pin configuration:
12764 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12765 */
12766static struct hda_verb alc861vd_3stack_init_verbs[] = {
12767 /*
12768 * Set pin mode and muting
12769 */
12770 /* set front pin widgets 0x14 for output */
12771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12773 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12774
12775 /* Mic (rear) pin: input vref at 80% */
12776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12778 /* Front Mic pin: input vref at 80% */
12779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12781 /* Line In pin: input */
12782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12784 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12785 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12786 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12787 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12788 /* CD pin widget for input */
12789 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12790
12791 { }
12792};
12793
12794/*
12795 * 6-stack pin configuration:
12796 */
12797static struct hda_verb alc861vd_6stack_init_verbs[] = {
12798 /*
12799 * Set pin mode and muting
12800 */
12801 /* set front pin widgets 0x14 for output */
12802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12803 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12804 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12805
12806 /* Rear Pin: output 1 (0x0d) */
12807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12809 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12810 /* CLFE Pin: output 2 (0x0e) */
12811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12813 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12814 /* Side Pin: output 3 (0x0f) */
12815 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12817 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12818
12819 /* Mic (rear) pin: input vref at 80% */
12820 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12821 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12822 /* Front Mic pin: input vref at 80% */
12823 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12824 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12825 /* Line In pin: input */
12826 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12828 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12831 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12832 /* CD pin widget for input */
12833 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12834
12835 { }
12836};
12837
Kailang Yangbdd148a2007-05-08 15:19:08 +020012838static struct hda_verb alc861vd_eapd_verbs[] = {
12839 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12840 { }
12841};
12842
Kailang Yangf9423e72008-05-27 12:32:25 +020012843static struct hda_verb alc660vd_eapd_verbs[] = {
12844 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12845 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12846 { }
12847};
12848
Kailang Yangbdd148a2007-05-08 15:19:08 +020012849static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12850 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12853 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12855 {}
12856};
12857
12858/* toggle speaker-output according to the hp-jack state */
12859static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12860{
12861 unsigned int present;
12862 unsigned char bits;
12863
12864 present = snd_hda_codec_read(codec, 0x1b, 0,
12865 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012866 bits = present ? HDA_AMP_MUTE : 0;
12867 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12868 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012869}
12870
12871static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12872{
12873 unsigned int present;
12874 unsigned char bits;
12875
12876 present = snd_hda_codec_read(codec, 0x18, 0,
12877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012878 bits = present ? HDA_AMP_MUTE : 0;
12879 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12880 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012881}
12882
12883static void alc861vd_lenovo_automute(struct hda_codec *codec)
12884{
12885 alc861vd_lenovo_hp_automute(codec);
12886 alc861vd_lenovo_mic_automute(codec);
12887}
12888
12889static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12890 unsigned int res)
12891{
12892 switch (res >> 26) {
12893 case ALC880_HP_EVENT:
12894 alc861vd_lenovo_hp_automute(codec);
12895 break;
12896 case ALC880_MIC_EVENT:
12897 alc861vd_lenovo_mic_automute(codec);
12898 break;
12899 }
12900}
12901
Kailang Yang272a5272007-05-14 11:00:38 +020012902static struct hda_verb alc861vd_dallas_verbs[] = {
12903 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12904 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12905 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12906 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12907
12908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12911 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12912 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12913 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12914 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12915 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12916
12917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12925
12926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12930 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12933 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12934
12935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12939
12940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12941 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12943
12944 { } /* end */
12945};
12946
12947/* toggle speaker-output according to the hp-jack state */
12948static void alc861vd_dallas_automute(struct hda_codec *codec)
12949{
12950 unsigned int present;
12951
12952 present = snd_hda_codec_read(codec, 0x15, 0,
12953 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012954 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12955 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012956}
12957
12958static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12959{
12960 if ((res >> 26) == ALC880_HP_EVENT)
12961 alc861vd_dallas_automute(codec);
12962}
12963
Takashi Iwaicb53c622007-08-10 17:21:45 +020012964#ifdef CONFIG_SND_HDA_POWER_SAVE
12965#define alc861vd_loopbacks alc880_loopbacks
12966#endif
12967
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012968/* pcm configuration: identiacal with ALC880 */
12969#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12970#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12971#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12972#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12973
12974/*
12975 * configuration and preset
12976 */
12977static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12978 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012979 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012980 [ALC861VD_3ST] = "3stack",
12981 [ALC861VD_3ST_DIG] = "3stack-digout",
12982 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012983 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012984 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012985 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012986 [ALC861VD_AUTO] = "auto",
12987};
12988
12989static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012990 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12991 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012992 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012993 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012994 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012995 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012996 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012997 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012998 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012999 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013000 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013001 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013002 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13003 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013004 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013005 {}
13006};
13007
13008static struct alc_config_preset alc861vd_presets[] = {
13009 [ALC660VD_3ST] = {
13010 .mixers = { alc861vd_3st_mixer },
13011 .init_verbs = { alc861vd_volume_init_verbs,
13012 alc861vd_3stack_init_verbs },
13013 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13014 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013015 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13016 .channel_mode = alc861vd_3stack_2ch_modes,
13017 .input_mux = &alc861vd_capture_source,
13018 },
Mike Crash6963f842007-06-25 12:12:51 +020013019 [ALC660VD_3ST_DIG] = {
13020 .mixers = { alc861vd_3st_mixer },
13021 .init_verbs = { alc861vd_volume_init_verbs,
13022 alc861vd_3stack_init_verbs },
13023 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13024 .dac_nids = alc660vd_dac_nids,
13025 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013026 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13027 .channel_mode = alc861vd_3stack_2ch_modes,
13028 .input_mux = &alc861vd_capture_source,
13029 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013030 [ALC861VD_3ST] = {
13031 .mixers = { alc861vd_3st_mixer },
13032 .init_verbs = { alc861vd_volume_init_verbs,
13033 alc861vd_3stack_init_verbs },
13034 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13035 .dac_nids = alc861vd_dac_nids,
13036 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13037 .channel_mode = alc861vd_3stack_2ch_modes,
13038 .input_mux = &alc861vd_capture_source,
13039 },
13040 [ALC861VD_3ST_DIG] = {
13041 .mixers = { alc861vd_3st_mixer },
13042 .init_verbs = { alc861vd_volume_init_verbs,
13043 alc861vd_3stack_init_verbs },
13044 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13045 .dac_nids = alc861vd_dac_nids,
13046 .dig_out_nid = ALC861VD_DIGOUT_NID,
13047 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13048 .channel_mode = alc861vd_3stack_2ch_modes,
13049 .input_mux = &alc861vd_capture_source,
13050 },
13051 [ALC861VD_6ST_DIG] = {
13052 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13053 .init_verbs = { alc861vd_volume_init_verbs,
13054 alc861vd_6stack_init_verbs },
13055 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13056 .dac_nids = alc861vd_dac_nids,
13057 .dig_out_nid = ALC861VD_DIGOUT_NID,
13058 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13059 .channel_mode = alc861vd_6stack_modes,
13060 .input_mux = &alc861vd_capture_source,
13061 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013062 [ALC861VD_LENOVO] = {
13063 .mixers = { alc861vd_lenovo_mixer },
13064 .init_verbs = { alc861vd_volume_init_verbs,
13065 alc861vd_3stack_init_verbs,
13066 alc861vd_eapd_verbs,
13067 alc861vd_lenovo_unsol_verbs },
13068 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13069 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013070 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13071 .channel_mode = alc861vd_3stack_2ch_modes,
13072 .input_mux = &alc861vd_capture_source,
13073 .unsol_event = alc861vd_lenovo_unsol_event,
13074 .init_hook = alc861vd_lenovo_automute,
13075 },
Kailang Yang272a5272007-05-14 11:00:38 +020013076 [ALC861VD_DALLAS] = {
13077 .mixers = { alc861vd_dallas_mixer },
13078 .init_verbs = { alc861vd_dallas_verbs },
13079 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13080 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013081 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13082 .channel_mode = alc861vd_3stack_2ch_modes,
13083 .input_mux = &alc861vd_dallas_capture_source,
13084 .unsol_event = alc861vd_dallas_unsol_event,
13085 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013086 },
13087 [ALC861VD_HP] = {
13088 .mixers = { alc861vd_hp_mixer },
13089 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13090 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13091 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013092 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013093 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13094 .channel_mode = alc861vd_3stack_2ch_modes,
13095 .input_mux = &alc861vd_hp_capture_source,
13096 .unsol_event = alc861vd_dallas_unsol_event,
13097 .init_hook = alc861vd_dallas_automute,
13098 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013099};
13100
13101/*
13102 * BIOS auto configuration
13103 */
13104static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13105 hda_nid_t nid, int pin_type, int dac_idx)
13106{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013107 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013108}
13109
13110static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13111{
13112 struct alc_spec *spec = codec->spec;
13113 int i;
13114
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013115 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013116 for (i = 0; i <= HDA_SIDE; i++) {
13117 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013118 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013119 if (nid)
13120 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013121 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013122 }
13123}
13124
13125
13126static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13127{
13128 struct alc_spec *spec = codec->spec;
13129 hda_nid_t pin;
13130
13131 pin = spec->autocfg.hp_pins[0];
13132 if (pin) /* connect to front and use dac 0 */
13133 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013134 pin = spec->autocfg.speaker_pins[0];
13135 if (pin)
13136 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013137}
13138
13139#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13140#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13141
13142static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13143{
13144 struct alc_spec *spec = codec->spec;
13145 int i;
13146
13147 for (i = 0; i < AUTO_PIN_LAST; i++) {
13148 hda_nid_t nid = spec->autocfg.input_pins[i];
13149 if (alc861vd_is_input_pin(nid)) {
13150 snd_hda_codec_write(codec, nid, 0,
13151 AC_VERB_SET_PIN_WIDGET_CONTROL,
13152 i <= AUTO_PIN_FRONT_MIC ?
13153 PIN_VREF80 : PIN_IN);
13154 if (nid != ALC861VD_PIN_CD_NID)
13155 snd_hda_codec_write(codec, nid, 0,
13156 AC_VERB_SET_AMP_GAIN_MUTE,
13157 AMP_OUT_MUTE);
13158 }
13159 }
13160}
13161
13162#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13163#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13164
13165/* add playback controls from the parsed DAC table */
13166/* Based on ALC880 version. But ALC861VD has separate,
13167 * different NIDs for mute/unmute switch and volume control */
13168static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13169 const struct auto_pin_cfg *cfg)
13170{
13171 char name[32];
13172 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13173 hda_nid_t nid_v, nid_s;
13174 int i, err;
13175
13176 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013177 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013178 continue;
13179 nid_v = alc861vd_idx_to_mixer_vol(
13180 alc880_dac_to_idx(
13181 spec->multiout.dac_nids[i]));
13182 nid_s = alc861vd_idx_to_mixer_switch(
13183 alc880_dac_to_idx(
13184 spec->multiout.dac_nids[i]));
13185
13186 if (i == 2) {
13187 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013188 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13189 "Center Playback Volume",
13190 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13191 HDA_OUTPUT));
13192 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013193 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013194 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13195 "LFE Playback Volume",
13196 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13197 HDA_OUTPUT));
13198 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013199 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013200 err = add_control(spec, ALC_CTL_BIND_MUTE,
13201 "Center Playback Switch",
13202 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13203 HDA_INPUT));
13204 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013205 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013206 err = add_control(spec, ALC_CTL_BIND_MUTE,
13207 "LFE Playback Switch",
13208 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13209 HDA_INPUT));
13210 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013211 return err;
13212 } else {
13213 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013214 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13215 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13216 HDA_OUTPUT));
13217 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013218 return err;
13219 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013220 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013221 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222 HDA_INPUT));
13223 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013224 return err;
13225 }
13226 }
13227 return 0;
13228}
13229
13230/* add playback controls for speaker and HP outputs */
13231/* Based on ALC880 version. But ALC861VD has separate,
13232 * different NIDs for mute/unmute switch and volume control */
13233static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13234 hda_nid_t pin, const char *pfx)
13235{
13236 hda_nid_t nid_v, nid_s;
13237 int err;
13238 char name[32];
13239
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013240 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013241 return 0;
13242
13243 if (alc880_is_fixed_pin(pin)) {
13244 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13245 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013246 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013247 spec->multiout.hp_nid = nid_v;
13248 else
13249 spec->multiout.extra_out_nid[0] = nid_v;
13250 /* control HP volume/switch on the output mixer amp */
13251 nid_v = alc861vd_idx_to_mixer_vol(
13252 alc880_fixed_pin_idx(pin));
13253 nid_s = alc861vd_idx_to_mixer_switch(
13254 alc880_fixed_pin_idx(pin));
13255
13256 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013257 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13258 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13259 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013260 return err;
13261 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013262 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13263 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13264 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013265 return err;
13266 } else if (alc880_is_multi_pin(pin)) {
13267 /* set manual connection */
13268 /* we have only a switch on HP-out PIN */
13269 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013270 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13271 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13272 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013273 return err;
13274 }
13275 return 0;
13276}
13277
13278/* parse the BIOS configuration and set up the alc_spec
13279 * return 1 if successful, 0 if the proper config is not found,
13280 * or a negative error code
13281 * Based on ALC880 version - had to change it to override
13282 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13283static int alc861vd_parse_auto_config(struct hda_codec *codec)
13284{
13285 struct alc_spec *spec = codec->spec;
13286 int err;
13287 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013289 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13290 alc861vd_ignore);
13291 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013292 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013293 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013294 return 0; /* can't find valid BIOS pin config */
13295
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013296 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13297 if (err < 0)
13298 return err;
13299 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13300 if (err < 0)
13301 return err;
13302 err = alc861vd_auto_create_extra_out(spec,
13303 spec->autocfg.speaker_pins[0],
13304 "Speaker");
13305 if (err < 0)
13306 return err;
13307 err = alc861vd_auto_create_extra_out(spec,
13308 spec->autocfg.hp_pins[0],
13309 "Headphone");
13310 if (err < 0)
13311 return err;
13312 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13313 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013314 return err;
13315
13316 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13317
13318 if (spec->autocfg.dig_out_pin)
13319 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13320
13321 if (spec->kctl_alloc)
13322 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13323
13324 spec->init_verbs[spec->num_init_verbs++]
13325 = alc861vd_volume_init_verbs;
13326
13327 spec->num_mux_defs = 1;
13328 spec->input_mux = &spec->private_imux;
13329
Takashi Iwai776e1842007-08-29 15:07:11 +020013330 err = alc_auto_add_mic_boost(codec);
13331 if (err < 0)
13332 return err;
13333
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013334 return 1;
13335}
13336
13337/* additional initialization for auto-configuration model */
13338static void alc861vd_auto_init(struct hda_codec *codec)
13339{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013340 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013341 alc861vd_auto_init_multi_out(codec);
13342 alc861vd_auto_init_hp_out(codec);
13343 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013344 if (spec->unsol_event)
13345 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013346}
13347
13348static int patch_alc861vd(struct hda_codec *codec)
13349{
13350 struct alc_spec *spec;
13351 int err, board_config;
13352
13353 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13354 if (spec == NULL)
13355 return -ENOMEM;
13356
13357 codec->spec = spec;
13358
13359 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13360 alc861vd_models,
13361 alc861vd_cfg_tbl);
13362
13363 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13364 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13365 "ALC861VD, trying auto-probe from BIOS...\n");
13366 board_config = ALC861VD_AUTO;
13367 }
13368
13369 if (board_config == ALC861VD_AUTO) {
13370 /* automatic parse from the BIOS config */
13371 err = alc861vd_parse_auto_config(codec);
13372 if (err < 0) {
13373 alc_free(codec);
13374 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013375 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013376 printk(KERN_INFO
13377 "hda_codec: Cannot set up configuration "
13378 "from BIOS. Using base mode...\n");
13379 board_config = ALC861VD_3ST;
13380 }
13381 }
13382
13383 if (board_config != ALC861VD_AUTO)
13384 setup_preset(spec, &alc861vd_presets[board_config]);
13385
Kailang Yang2f893282008-05-27 12:14:47 +020013386 if (codec->vendor_id == 0x10ec0660) {
13387 spec->stream_name_analog = "ALC660-VD Analog";
13388 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013389 /* always turn on EAPD */
13390 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013391 } else {
13392 spec->stream_name_analog = "ALC861VD Analog";
13393 spec->stream_name_digital = "ALC861VD Digital";
13394 }
13395
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013396 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13397 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13398
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013399 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13400 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13401
13402 spec->adc_nids = alc861vd_adc_nids;
13403 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013404 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013405
13406 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13407 spec->num_mixers++;
13408
Takashi Iwai2134ea42008-01-10 16:53:55 +010013409 spec->vmaster_nid = 0x02;
13410
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013411 codec->patch_ops = alc_patch_ops;
13412
13413 if (board_config == ALC861VD_AUTO)
13414 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013415#ifdef CONFIG_SND_HDA_POWER_SAVE
13416 if (!spec->loopback.amplist)
13417 spec->loopback.amplist = alc861vd_loopbacks;
13418#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013419
13420 return 0;
13421}
13422
13423/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013424 * ALC662 support
13425 *
13426 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13427 * configuration. Each pin widget can choose any input DACs and a mixer.
13428 * Each ADC is connected from a mixer of all inputs. This makes possible
13429 * 6-channel independent captures.
13430 *
13431 * In addition, an independent DAC for the multi-playback (not used in this
13432 * driver yet).
13433 */
13434#define ALC662_DIGOUT_NID 0x06
13435#define ALC662_DIGIN_NID 0x0a
13436
13437static hda_nid_t alc662_dac_nids[4] = {
13438 /* front, rear, clfe, rear_surr */
13439 0x02, 0x03, 0x04
13440};
13441
13442static hda_nid_t alc662_adc_nids[1] = {
13443 /* ADC1-2 */
13444 0x09,
13445};
Takashi Iwaie1406342008-02-11 18:32:32 +010013446
Kailang Yang77a261b2008-02-19 11:38:05 +010013447static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013448
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013449/* input MUX */
13450/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013451static struct hda_input_mux alc662_capture_source = {
13452 .num_items = 4,
13453 .items = {
13454 { "Mic", 0x0 },
13455 { "Front Mic", 0x1 },
13456 { "Line", 0x2 },
13457 { "CD", 0x4 },
13458 },
13459};
13460
13461static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13462 .num_items = 2,
13463 .items = {
13464 { "Mic", 0x1 },
13465 { "Line", 0x2 },
13466 },
13467};
Kailang Yang291702f2007-10-16 14:28:03 +020013468
13469static struct hda_input_mux alc662_eeepc_capture_source = {
13470 .num_items = 2,
13471 .items = {
13472 { "i-Mic", 0x1 },
13473 { "e-Mic", 0x0 },
13474 },
13475};
13476
Kailang Yang6dda9f42008-05-27 12:05:31 +020013477static struct hda_input_mux alc663_capture_source = {
13478 .num_items = 3,
13479 .items = {
13480 { "Mic", 0x0 },
13481 { "Front Mic", 0x1 },
13482 { "Line", 0x2 },
13483 },
13484};
13485
13486static struct hda_input_mux alc663_m51va_capture_source = {
13487 .num_items = 2,
13488 .items = {
13489 { "Ext-Mic", 0x0 },
13490 { "D-Mic", 0x9 },
13491 },
13492};
13493
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013494#define alc662_mux_enum_info alc_mux_enum_info
13495#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013496#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013497
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013498/*
13499 * 2ch mode
13500 */
13501static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13502 { 2, NULL }
13503};
13504
13505/*
13506 * 2ch mode
13507 */
13508static struct hda_verb alc662_3ST_ch2_init[] = {
13509 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13510 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13511 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13512 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13513 { } /* end */
13514};
13515
13516/*
13517 * 6ch mode
13518 */
13519static struct hda_verb alc662_3ST_ch6_init[] = {
13520 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13521 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13522 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13523 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13524 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13525 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13526 { } /* end */
13527};
13528
13529static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13530 { 2, alc662_3ST_ch2_init },
13531 { 6, alc662_3ST_ch6_init },
13532};
13533
13534/*
13535 * 2ch mode
13536 */
13537static struct hda_verb alc662_sixstack_ch6_init[] = {
13538 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13539 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13540 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13541 { } /* end */
13542};
13543
13544/*
13545 * 6ch mode
13546 */
13547static struct hda_verb alc662_sixstack_ch8_init[] = {
13548 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13549 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13550 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13551 { } /* end */
13552};
13553
13554static struct hda_channel_mode alc662_5stack_modes[2] = {
13555 { 2, alc662_sixstack_ch6_init },
13556 { 6, alc662_sixstack_ch8_init },
13557};
13558
13559/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13560 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13561 */
13562
13563static struct snd_kcontrol_new alc662_base_mixer[] = {
13564 /* output mixer control */
13565 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013566 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013567 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013568 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013569 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13570 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013571 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13572 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13574
13575 /*Input mixer control */
13576 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13577 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13578 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13579 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13580 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13581 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13582 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13583 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013584 { } /* end */
13585};
13586
13587static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13588 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013589 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13591 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13592 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13593 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13594 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13595 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13596 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13597 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13599 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13600 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013601 { } /* end */
13602};
13603
13604static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13605 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013606 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013607 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013608 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013609 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13610 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013611 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13612 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13614 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13615 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13616 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13617 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13620 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13621 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13622 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13623 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013624 { } /* end */
13625};
13626
13627static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13628 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13629 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13631 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013632 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13633 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13634 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013637 { } /* end */
13638};
13639
Kailang Yang291702f2007-10-16 14:28:03 +020013640static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013641 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013642
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013643 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13644 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013645
13646 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13647 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13648 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13649
13650 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13651 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13652 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13653 { } /* end */
13654};
13655
Kailang Yang8c427222008-01-10 13:03:59 +010013656static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013657 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13658 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013659 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13660 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13661 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13662 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13663 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13664 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013665 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013666 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13668 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13671 { } /* end */
13672};
13673
Kailang Yang6dda9f42008-05-27 12:05:31 +020013674static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13680 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13681 { } /* end */
13682};
13683
13684static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13686 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13688 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13690
13691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13693 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13694 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13695 { } /* end */
13696};
13697
13698static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13699 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13700 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13701 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13702
13703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13705 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13706 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13709 { } /* end */
13710};
13711
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013712static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13713 {
13714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13715 .name = "Channel Mode",
13716 .info = alc_ch_mode_info,
13717 .get = alc_ch_mode_get,
13718 .put = alc_ch_mode_put,
13719 },
13720 { } /* end */
13721};
13722
13723static struct hda_verb alc662_init_verbs[] = {
13724 /* ADC: mute amp left and right */
13725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13726 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13727 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13728
Takashi Iwaicb53c622007-08-10 17:21:45 +020013729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013734
Kailang Yangb60dd392007-09-20 12:50:29 +020013735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13739 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013741
13742 /* Front Pin: output 0 (0x0c) */
13743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13745
13746 /* Rear Pin: output 1 (0x0d) */
13747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13749
13750 /* CLFE Pin: output 2 (0x0e) */
13751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13753
13754 /* Mic (rear) pin: input vref at 80% */
13755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13757 /* Front Mic pin: input vref at 80% */
13758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13760 /* Line In pin: input */
13761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13763 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13764 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13765 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13767 /* CD pin widget for input */
13768 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13769
13770 /* FIXME: use matrix-type input source selection */
13771 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13772 /* Input mixer */
13773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013777
13778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020013782
13783 /* always trun on EAPD */
13784 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13785 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13786
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013787 { }
13788};
13789
13790static struct hda_verb alc662_sue_init_verbs[] = {
13791 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13792 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013793 {}
13794};
13795
13796static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13797 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13798 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13799 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013800};
13801
Kailang Yang8c427222008-01-10 13:03:59 +010013802/* Set Unsolicited Event*/
13803static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13804 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13805 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13806 {}
13807};
13808
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013809/*
13810 * generic initialization of ADC, input mixers and output mixers
13811 */
13812static struct hda_verb alc662_auto_init_verbs[] = {
13813 /*
13814 * Unmute ADC and set the default input to mic-in
13815 */
13816 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13818
13819 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13820 * mixer widget
13821 * Note: PASD motherboards uses the Line In 2 as the input for front
13822 * panel mic (mic 2)
13823 */
13824 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013830
13831 /*
13832 * Set up output mixers (0x0c - 0x0f)
13833 */
13834 /* set vol=0 to output mixers */
13835 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13836 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13837 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13838
13839 /* set up input amps for analog loopback */
13840 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013847
13848
13849 /* FIXME: use matrix-type input source selection */
13850 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13851 /* Input mixer */
13852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013854 { }
13855};
13856
Kailang Yang6dda9f42008-05-27 12:05:31 +020013857static struct hda_verb alc663_m51va_init_verbs[] = {
13858 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13859 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13860 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13861
13862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
13863
13864 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13865 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13866 {}
13867};
13868
13869static struct hda_verb alc663_g71v_init_verbs[] = {
13870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13871 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
13872 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
13873
13874 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13875 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13876 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13877
13878 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13879 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
13880 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13881 {}
13882};
13883
13884static struct hda_verb alc663_g50v_init_verbs[] = {
13885 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13886 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13887 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13888
13889 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13890 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13891 {}
13892};
13893
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013894/* capture mixer elements */
13895static struct snd_kcontrol_new alc662_capture_mixer[] = {
13896 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13897 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13898 {
13899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13900 /* The multiple "Capture Source" controls confuse alsamixer
13901 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013902 */
13903 /* .name = "Capture Source", */
13904 .name = "Input Source",
13905 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013906 .info = alc662_mux_enum_info,
13907 .get = alc662_mux_enum_get,
13908 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013909 },
13910 { } /* end */
13911};
13912
13913static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13914{
13915 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013916 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013917
13918 present = snd_hda_codec_read(codec, 0x14, 0,
13919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013920 bits = present ? HDA_AMP_MUTE : 0;
13921 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13922 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013923}
13924
13925static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13926{
13927 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013928 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013929
13930 present = snd_hda_codec_read(codec, 0x1b, 0,
13931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013932 bits = present ? HDA_AMP_MUTE : 0;
13933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13934 HDA_AMP_MUTE, bits);
13935 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13936 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013937}
13938
13939static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13940 unsigned int res)
13941{
13942 if ((res >> 26) == ALC880_HP_EVENT)
13943 alc662_lenovo_101e_all_automute(codec);
13944 if ((res >> 26) == ALC880_FRONT_EVENT)
13945 alc662_lenovo_101e_ispeaker_automute(codec);
13946}
13947
Kailang Yang291702f2007-10-16 14:28:03 +020013948static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13949{
13950 unsigned int present;
13951
13952 present = snd_hda_codec_read(codec, 0x18, 0,
13953 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13954 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13955 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13956 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13957 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13958 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13959 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13960 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13961 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13962}
13963
13964/* unsolicited event for HP jack sensing */
13965static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13966 unsigned int res)
13967{
13968 if ((res >> 26) == ALC880_HP_EVENT)
13969 alc262_hippo1_automute( codec );
13970
13971 if ((res >> 26) == ALC880_MIC_EVENT)
13972 alc662_eeepc_mic_automute(codec);
13973}
13974
13975static void alc662_eeepc_inithook(struct hda_codec *codec)
13976{
13977 alc262_hippo1_automute( codec );
13978 alc662_eeepc_mic_automute(codec);
13979}
13980
Kailang Yang8c427222008-01-10 13:03:59 +010013981static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13982{
13983 unsigned int mute;
13984 unsigned int present;
13985
13986 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13987 present = snd_hda_codec_read(codec, 0x14, 0,
13988 AC_VERB_GET_PIN_SENSE, 0);
13989 present = (present & 0x80000000) != 0;
13990 if (present) {
13991 /* mute internal speaker */
13992 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13993 HDA_AMP_MUTE, HDA_AMP_MUTE);
13994 } else {
13995 /* unmute internal speaker if necessary */
13996 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13997 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13998 HDA_AMP_MUTE, mute);
13999 }
14000}
14001
14002/* unsolicited event for HP jack sensing */
14003static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14004 unsigned int res)
14005{
14006 if ((res >> 26) == ALC880_HP_EVENT)
14007 alc662_eeepc_ep20_automute(codec);
14008}
14009
14010static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14011{
14012 alc662_eeepc_ep20_automute(codec);
14013}
14014
Kailang Yang6dda9f42008-05-27 12:05:31 +020014015static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14016{
14017 unsigned int present;
14018 unsigned char bits;
14019
14020 present = snd_hda_codec_read(codec, 0x21, 0,
14021 AC_VERB_GET_PIN_SENSE, 0)
14022 & AC_PINSENSE_PRESENCE;
14023 bits = present ? HDA_AMP_MUTE : 0;
14024 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14025 HDA_AMP_MUTE, bits);
14026}
14027
14028static void alc663_m51va_mic_automute(struct hda_codec *codec)
14029{
14030 unsigned int present;
14031
14032 present = snd_hda_codec_read(codec, 0x18, 0,
14033 AC_VERB_GET_PIN_SENSE, 0)
14034 & AC_PINSENSE_PRESENCE;
14035 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14036 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14037 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14038 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14039 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14040 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14041 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14042 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14043}
14044
14045static void alc663_m51va_unsol_event(struct hda_codec *codec,
14046 unsigned int res)
14047{
14048 switch (res >> 26) {
14049 case ALC880_HP_EVENT:
14050 alc663_m51va_speaker_automute(codec);
14051 break;
14052 case ALC880_MIC_EVENT:
14053 alc663_m51va_mic_automute(codec);
14054 break;
14055 }
14056}
14057
14058static void alc663_m51va_inithook(struct hda_codec *codec)
14059{
14060 alc663_m51va_speaker_automute(codec);
14061 alc663_m51va_mic_automute(codec);
14062}
14063
14064static void alc663_g71v_hp_automute(struct hda_codec *codec)
14065{
14066 unsigned int present;
14067 unsigned char bits;
14068
14069 present = snd_hda_codec_read(codec, 0x21, 0,
14070 AC_VERB_GET_PIN_SENSE, 0)
14071 & AC_PINSENSE_PRESENCE;
14072 bits = present ? HDA_AMP_MUTE : 0;
14073 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14074 HDA_AMP_MUTE, bits);
14075 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14076 HDA_AMP_MUTE, bits);
14077}
14078
14079static void alc663_g71v_front_automute(struct hda_codec *codec)
14080{
14081 unsigned int present;
14082 unsigned char bits;
14083
14084 present = snd_hda_codec_read(codec, 0x15, 0,
14085 AC_VERB_GET_PIN_SENSE, 0)
14086 & AC_PINSENSE_PRESENCE;
14087 bits = present ? HDA_AMP_MUTE : 0;
14088 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14089 HDA_AMP_MUTE, bits);
14090}
14091
14092static void alc663_g71v_unsol_event(struct hda_codec *codec,
14093 unsigned int res)
14094{
14095 switch (res >> 26) {
14096 case ALC880_HP_EVENT:
14097 alc663_g71v_hp_automute(codec);
14098 break;
14099 case ALC880_FRONT_EVENT:
14100 alc663_g71v_front_automute(codec);
14101 break;
14102 case ALC880_MIC_EVENT:
14103 alc662_eeepc_mic_automute(codec);
14104 break;
14105 }
14106}
14107
14108static void alc663_g71v_inithook(struct hda_codec *codec)
14109{
14110 alc663_g71v_front_automute(codec);
14111 alc663_g71v_hp_automute(codec);
14112 alc662_eeepc_mic_automute(codec);
14113}
14114
14115static void alc663_g50v_unsol_event(struct hda_codec *codec,
14116 unsigned int res)
14117{
14118 switch (res >> 26) {
14119 case ALC880_HP_EVENT:
14120 alc663_m51va_speaker_automute(codec);
14121 break;
14122 case ALC880_MIC_EVENT:
14123 alc662_eeepc_mic_automute(codec);
14124 break;
14125 }
14126}
14127
14128static void alc663_g50v_inithook(struct hda_codec *codec)
14129{
14130 alc663_m51va_speaker_automute(codec);
14131 alc662_eeepc_mic_automute(codec);
14132}
14133
Takashi Iwaicb53c622007-08-10 17:21:45 +020014134#ifdef CONFIG_SND_HDA_POWER_SAVE
14135#define alc662_loopbacks alc880_loopbacks
14136#endif
14137
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014138
14139/* pcm configuration: identiacal with ALC880 */
14140#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14141#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14142#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14143#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14144
14145/*
14146 * configuration and preset
14147 */
14148static const char *alc662_models[ALC662_MODEL_LAST] = {
14149 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14150 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14151 [ALC662_3ST_6ch] = "3stack-6ch",
14152 [ALC662_5ST_DIG] = "6stack-dig",
14153 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014154 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014155 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014156 [ALC663_ASUS_M51VA] = "m51va",
14157 [ALC663_ASUS_G71V] = "g71v",
14158 [ALC663_ASUS_H13] = "h13",
14159 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014160 [ALC662_AUTO] = "auto",
14161};
14162
14163static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014164 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14165 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14166 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014167 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014168 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014169 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014170 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014171 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14172 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14173 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014174 {}
14175};
14176
14177static struct alc_config_preset alc662_presets[] = {
14178 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014179 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014180 .init_verbs = { alc662_init_verbs },
14181 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14182 .dac_nids = alc662_dac_nids,
14183 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014184 .dig_in_nid = ALC662_DIGIN_NID,
14185 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14186 .channel_mode = alc662_3ST_2ch_modes,
14187 .input_mux = &alc662_capture_source,
14188 },
14189 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014190 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14191 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014192 .init_verbs = { alc662_init_verbs },
14193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14194 .dac_nids = alc662_dac_nids,
14195 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014196 .dig_in_nid = ALC662_DIGIN_NID,
14197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14198 .channel_mode = alc662_3ST_6ch_modes,
14199 .need_dac_fix = 1,
14200 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014201 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014202 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014203 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14204 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014205 .init_verbs = { alc662_init_verbs },
14206 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14207 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014208 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14209 .channel_mode = alc662_3ST_6ch_modes,
14210 .need_dac_fix = 1,
14211 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014213 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014214 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14215 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014216 .init_verbs = { alc662_init_verbs },
14217 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14218 .dac_nids = alc662_dac_nids,
14219 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014220 .dig_in_nid = ALC662_DIGIN_NID,
14221 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14222 .channel_mode = alc662_5stack_modes,
14223 .input_mux = &alc662_capture_source,
14224 },
14225 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014226 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014227 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14229 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014230 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14231 .channel_mode = alc662_3ST_2ch_modes,
14232 .input_mux = &alc662_lenovo_101e_capture_source,
14233 .unsol_event = alc662_lenovo_101e_unsol_event,
14234 .init_hook = alc662_lenovo_101e_all_automute,
14235 },
Kailang Yang291702f2007-10-16 14:28:03 +020014236 [ALC662_ASUS_EEEPC_P701] = {
14237 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14238 .init_verbs = { alc662_init_verbs,
14239 alc662_eeepc_sue_init_verbs },
14240 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14241 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014242 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14243 .channel_mode = alc662_3ST_2ch_modes,
14244 .input_mux = &alc662_eeepc_capture_source,
14245 .unsol_event = alc662_eeepc_unsol_event,
14246 .init_hook = alc662_eeepc_inithook,
14247 },
Kailang Yang8c427222008-01-10 13:03:59 +010014248 [ALC662_ASUS_EEEPC_EP20] = {
14249 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14250 alc662_chmode_mixer },
14251 .init_verbs = { alc662_init_verbs,
14252 alc662_eeepc_ep20_sue_init_verbs },
14253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14254 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014255 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14256 .channel_mode = alc662_3ST_6ch_modes,
14257 .input_mux = &alc662_lenovo_101e_capture_source,
14258 .unsol_event = alc662_eeepc_ep20_unsol_event,
14259 .init_hook = alc662_eeepc_ep20_inithook,
14260 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014261 [ALC663_ASUS_M51VA] = {
14262 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14263 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14264 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14265 .dac_nids = alc662_dac_nids,
14266 .dig_out_nid = ALC662_DIGOUT_NID,
14267 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14268 .channel_mode = alc662_3ST_2ch_modes,
14269 .input_mux = &alc663_m51va_capture_source,
14270 .unsol_event = alc663_m51va_unsol_event,
14271 .init_hook = alc663_m51va_inithook,
14272 },
14273 [ALC663_ASUS_G71V] = {
14274 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14275 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14276 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14277 .dac_nids = alc662_dac_nids,
14278 .dig_out_nid = ALC662_DIGOUT_NID,
14279 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14280 .channel_mode = alc662_3ST_2ch_modes,
14281 .input_mux = &alc662_eeepc_capture_source,
14282 .unsol_event = alc663_g71v_unsol_event,
14283 .init_hook = alc663_g71v_inithook,
14284 },
14285 [ALC663_ASUS_H13] = {
14286 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14287 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14288 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14289 .dac_nids = alc662_dac_nids,
14290 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14291 .channel_mode = alc662_3ST_2ch_modes,
14292 .input_mux = &alc663_m51va_capture_source,
14293 .unsol_event = alc663_m51va_unsol_event,
14294 .init_hook = alc663_m51va_inithook,
14295 },
14296 [ALC663_ASUS_G50V] = {
14297 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14298 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14299 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14300 .dac_nids = alc662_dac_nids,
14301 .dig_out_nid = ALC662_DIGOUT_NID,
14302 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14303 .channel_mode = alc662_3ST_6ch_modes,
14304 .input_mux = &alc663_capture_source,
14305 .unsol_event = alc663_g50v_unsol_event,
14306 .init_hook = alc663_g50v_inithook,
14307 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014308};
14309
14310
14311/*
14312 * BIOS auto configuration
14313 */
14314
14315/* add playback controls from the parsed DAC table */
14316static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14317 const struct auto_pin_cfg *cfg)
14318{
14319 char name[32];
14320 static const char *chname[4] = {
14321 "Front", "Surround", NULL /*CLFE*/, "Side"
14322 };
14323 hda_nid_t nid;
14324 int i, err;
14325
14326 for (i = 0; i < cfg->line_outs; i++) {
14327 if (!spec->multiout.dac_nids[i])
14328 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014329 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014330 if (i == 2) {
14331 /* Center/LFE */
14332 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14333 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014334 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14335 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014336 if (err < 0)
14337 return err;
14338 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14339 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014340 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14341 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014342 if (err < 0)
14343 return err;
14344 err = add_control(spec, ALC_CTL_BIND_MUTE,
14345 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014346 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14347 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014348 if (err < 0)
14349 return err;
14350 err = add_control(spec, ALC_CTL_BIND_MUTE,
14351 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014352 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14353 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014354 if (err < 0)
14355 return err;
14356 } else {
14357 sprintf(name, "%s Playback Volume", chname[i]);
14358 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014359 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14360 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014361 if (err < 0)
14362 return err;
14363 sprintf(name, "%s Playback Switch", chname[i]);
14364 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014365 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14366 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014367 if (err < 0)
14368 return err;
14369 }
14370 }
14371 return 0;
14372}
14373
14374/* add playback controls for speaker and HP outputs */
14375static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14376 const char *pfx)
14377{
14378 hda_nid_t nid;
14379 int err;
14380 char name[32];
14381
14382 if (!pin)
14383 return 0;
14384
14385 if (alc880_is_fixed_pin(pin)) {
14386 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14387 /* printk("DAC nid=%x\n",nid); */
14388 /* specify the DAC as the extra output */
14389 if (!spec->multiout.hp_nid)
14390 spec->multiout.hp_nid = nid;
14391 else
14392 spec->multiout.extra_out_nid[0] = nid;
14393 /* control HP volume/switch on the output mixer amp */
14394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14395 sprintf(name, "%s Playback Volume", pfx);
14396 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14397 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14398 if (err < 0)
14399 return err;
14400 sprintf(name, "%s Playback Switch", pfx);
14401 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14402 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14403 if (err < 0)
14404 return err;
14405 } else if (alc880_is_multi_pin(pin)) {
14406 /* set manual connection */
14407 /* we have only a switch on HP-out PIN */
14408 sprintf(name, "%s Playback Switch", pfx);
14409 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14410 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14411 if (err < 0)
14412 return err;
14413 }
14414 return 0;
14415}
14416
14417/* create playback/capture controls for input pins */
14418static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14419 const struct auto_pin_cfg *cfg)
14420{
14421 struct hda_input_mux *imux = &spec->private_imux;
14422 int i, err, idx;
14423
14424 for (i = 0; i < AUTO_PIN_LAST; i++) {
14425 if (alc880_is_input_pin(cfg->input_pins[i])) {
14426 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14427 err = new_analog_input(spec, cfg->input_pins[i],
14428 auto_pin_cfg_labels[i],
14429 idx, 0x0b);
14430 if (err < 0)
14431 return err;
14432 imux->items[imux->num_items].label =
14433 auto_pin_cfg_labels[i];
14434 imux->items[imux->num_items].index =
14435 alc880_input_pin_idx(cfg->input_pins[i]);
14436 imux->num_items++;
14437 }
14438 }
14439 return 0;
14440}
14441
14442static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14443 hda_nid_t nid, int pin_type,
14444 int dac_idx)
14445{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014446 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014447 /* need the manual connection? */
14448 if (alc880_is_multi_pin(nid)) {
14449 struct alc_spec *spec = codec->spec;
14450 int idx = alc880_multi_pin_idx(nid);
14451 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14452 AC_VERB_SET_CONNECT_SEL,
14453 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14454 }
14455}
14456
14457static void alc662_auto_init_multi_out(struct hda_codec *codec)
14458{
14459 struct alc_spec *spec = codec->spec;
14460 int i;
14461
Kailang Yang8c427222008-01-10 13:03:59 +010014462 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014463 for (i = 0; i <= HDA_SIDE; i++) {
14464 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014465 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014466 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014467 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014468 i);
14469 }
14470}
14471
14472static void alc662_auto_init_hp_out(struct hda_codec *codec)
14473{
14474 struct alc_spec *spec = codec->spec;
14475 hda_nid_t pin;
14476
14477 pin = spec->autocfg.hp_pins[0];
14478 if (pin) /* connect to front */
14479 /* use dac 0 */
14480 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014481 pin = spec->autocfg.speaker_pins[0];
14482 if (pin)
14483 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014484}
14485
14486#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14487#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14488
14489static void alc662_auto_init_analog_input(struct hda_codec *codec)
14490{
14491 struct alc_spec *spec = codec->spec;
14492 int i;
14493
14494 for (i = 0; i < AUTO_PIN_LAST; i++) {
14495 hda_nid_t nid = spec->autocfg.input_pins[i];
14496 if (alc662_is_input_pin(nid)) {
14497 snd_hda_codec_write(codec, nid, 0,
14498 AC_VERB_SET_PIN_WIDGET_CONTROL,
14499 (i <= AUTO_PIN_FRONT_MIC ?
14500 PIN_VREF80 : PIN_IN));
14501 if (nid != ALC662_PIN_CD_NID)
14502 snd_hda_codec_write(codec, nid, 0,
14503 AC_VERB_SET_AMP_GAIN_MUTE,
14504 AMP_OUT_MUTE);
14505 }
14506 }
14507}
14508
14509static int alc662_parse_auto_config(struct hda_codec *codec)
14510{
14511 struct alc_spec *spec = codec->spec;
14512 int err;
14513 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14514
14515 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14516 alc662_ignore);
14517 if (err < 0)
14518 return err;
14519 if (!spec->autocfg.line_outs)
14520 return 0; /* can't find valid BIOS pin config */
14521
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014522 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14523 if (err < 0)
14524 return err;
14525 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14526 if (err < 0)
14527 return err;
14528 err = alc662_auto_create_extra_out(spec,
14529 spec->autocfg.speaker_pins[0],
14530 "Speaker");
14531 if (err < 0)
14532 return err;
14533 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14534 "Headphone");
14535 if (err < 0)
14536 return err;
14537 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14538 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014539 return err;
14540
14541 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14542
14543 if (spec->autocfg.dig_out_pin)
14544 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14545
14546 if (spec->kctl_alloc)
14547 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14548
14549 spec->num_mux_defs = 1;
14550 spec->input_mux = &spec->private_imux;
14551
Takashi Iwai8c872862007-06-19 12:11:16 +020014552 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014553 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14554 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020014555 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014556}
14557
14558/* additional initialization for auto-configuration model */
14559static void alc662_auto_init(struct hda_codec *codec)
14560{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014561 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014562 alc662_auto_init_multi_out(codec);
14563 alc662_auto_init_hp_out(codec);
14564 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014565 if (spec->unsol_event)
14566 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014567}
14568
14569static int patch_alc662(struct hda_codec *codec)
14570{
14571 struct alc_spec *spec;
14572 int err, board_config;
14573
14574 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14575 if (!spec)
14576 return -ENOMEM;
14577
14578 codec->spec = spec;
14579
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014580 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14581
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014582 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14583 alc662_models,
14584 alc662_cfg_tbl);
14585 if (board_config < 0) {
14586 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14587 "trying auto-probe from BIOS...\n");
14588 board_config = ALC662_AUTO;
14589 }
14590
14591 if (board_config == ALC662_AUTO) {
14592 /* automatic parse from the BIOS config */
14593 err = alc662_parse_auto_config(codec);
14594 if (err < 0) {
14595 alc_free(codec);
14596 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020014597 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014598 printk(KERN_INFO
14599 "hda_codec: Cannot set up configuration "
14600 "from BIOS. Using base mode...\n");
14601 board_config = ALC662_3ST_2ch_DIG;
14602 }
14603 }
14604
14605 if (board_config != ALC662_AUTO)
14606 setup_preset(spec, &alc662_presets[board_config]);
14607
Kailang Yang6dda9f42008-05-27 12:05:31 +020014608 if (codec->vendor_id == 0x10ec0663) {
14609 spec->stream_name_analog = "ALC663 Analog";
14610 spec->stream_name_digital = "ALC663 Digital";
14611 } else {
14612 spec->stream_name_analog = "ALC662 Analog";
14613 spec->stream_name_digital = "ALC662 Digital";
14614 }
14615
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014616 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14617 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14618
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014619 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14620 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14621
Takashi Iwaie1406342008-02-11 18:32:32 +010014622 spec->adc_nids = alc662_adc_nids;
14623 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14624 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014625
Takashi Iwai2134ea42008-01-10 16:53:55 +010014626 spec->vmaster_nid = 0x02;
14627
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014628 codec->patch_ops = alc_patch_ops;
14629 if (board_config == ALC662_AUTO)
14630 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014631#ifdef CONFIG_SND_HDA_POWER_SAVE
14632 if (!spec->loopback.amplist)
14633 spec->loopback.amplist = alc662_loopbacks;
14634#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014635
14636 return 0;
14637}
14638
14639/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070014640 * patch entries
14641 */
14642struct hda_codec_preset snd_hda_preset_realtek[] = {
14643 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014644 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014645 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020014646 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014647 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014648 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014649 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014650 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14651 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14652 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014653 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14654 .patch = patch_alc883 },
14655 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14656 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014657 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014658 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014659 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014660 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020014661 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020014662 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010014663 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014664 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014665 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014666 {} /* terminator */
14667};