blob: 7e5422f64caf9d834eef20161d200f44b49b6984 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200103 ALC262_NEC,
Kailang Yangdf694da2005-12-05 19:42:22 +0100104 ALC262_AUTO,
105 ALC262_MODEL_LAST /* last tag */
106};
107
Kailang Yanga361d842007-06-05 12:30:55 +0200108/* ALC268 models */
109enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200110 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200111 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200112 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200113 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100114 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100115 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100116#ifdef CONFIG_SND_DEBUG
117 ALC268_TEST,
118#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200119 ALC268_AUTO,
120 ALC268_MODEL_LAST /* last tag */
121};
122
Kailang Yangf6a92242007-12-13 16:52:54 +0100123/* ALC269 models */
124enum {
125 ALC269_BASIC,
Kailang Yangf53281e2008-07-18 12:36:43 +0200126 ALC269_ASUS_EEEPC_P703,
127 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100128 ALC269_AUTO,
129 ALC269_MODEL_LAST /* last tag */
130};
131
Kailang Yangdf694da2005-12-05 19:42:22 +0100132/* ALC861 models */
133enum {
134 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200135 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100136 ALC861_3ST_DIG,
137 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200138 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200139 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200140 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100141 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100142 ALC861_AUTO,
143 ALC861_MODEL_LAST,
144};
145
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100146/* ALC861-VD models */
147enum {
148 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200149 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100150 ALC861VD_3ST,
151 ALC861VD_3ST_DIG,
152 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200153 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200154 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200155 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156 ALC861VD_AUTO,
157 ALC861VD_MODEL_LAST,
158};
159
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200160/* ALC662 models */
161enum {
162 ALC662_3ST_2ch_DIG,
163 ALC662_3ST_6ch_DIG,
164 ALC662_3ST_6ch,
165 ALC662_5ST_DIG,
166 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200167 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100168 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200169 ALC663_ASUS_M51VA,
170 ALC663_ASUS_G71V,
171 ALC663_ASUS_H13,
172 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173 ALC662_AUTO,
174 ALC662_MODEL_LAST,
175};
176
Kailang Yangdf694da2005-12-05 19:42:22 +0100177/* ALC882 models */
178enum {
179 ALC882_3ST_DIG,
180 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200181 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200182 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200183 ALC882_TARGA,
184 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200185 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100186 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200187 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200188 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200189 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100190 ALC882_MODEL_LAST,
191};
192
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200193/* ALC883 models */
194enum {
195 ALC883_3ST_2ch_DIG,
196 ALC883_3ST_6ch_DIG,
197 ALC883_3ST_6ch,
198 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200199 ALC883_TARGA_DIG,
200 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200201 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200202 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200203 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100205 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200206 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200207 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200208 ALC888_LENOVO_MS7195_DIG,
209 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200210 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100211 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100212 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100213 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100214 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200215 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200216 ALC883_AUTO,
217 ALC883_MODEL_LAST,
218};
219
Kailang Yangdf694da2005-12-05 19:42:22 +0100220/* for GPIO Poll */
221#define GPIO_MASK 0x03
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223struct alc_spec {
224 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100225 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 unsigned int num_mixers;
227
Kailang Yangdf694da2005-12-05 19:42:22 +0100228 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200229 * don't forget NULL
230 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200231 */
232 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Takashi Iwai16ded522005-06-10 19:58:24 +0200234 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 struct hda_pcm_stream *stream_analog_playback;
236 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100237 struct hda_pcm_stream *stream_analog_alt_playback;
238 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200240 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 struct hda_pcm_stream *stream_digital_playback;
242 struct hda_pcm_stream *stream_digital_capture;
243
244 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200245 struct hda_multi_out multiout; /* playback set-up
246 * max_channels, dacs must be set
247 * dig_out_nid and hp_nid are optional
248 */
Takashi Iwai63300792008-01-24 15:31:36 +0100249 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
251 /* capture */
252 unsigned int num_adc_nids;
253 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100254 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200255 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200258 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 const struct hda_input_mux *input_mux;
260 unsigned int cur_mux[3];
261
262 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100263 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200265 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100268 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200269
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200270 /* dynamic controls, init_verbs and input_mux */
271 struct auto_pin_cfg autocfg;
272 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100273 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200274 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200275 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100276
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100277 /* hooks */
278 void (*init_hook)(struct hda_codec *codec);
279 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
280
Takashi Iwai834be882006-03-01 14:16:17 +0100281 /* for pin sensing */
282 unsigned int sense_updated: 1;
283 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100284 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200285
Takashi Iwai2134ea42008-01-10 16:53:55 +0100286 /* for virtual master */
287 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200288#ifdef CONFIG_SND_HDA_POWER_SAVE
289 struct hda_loopback_check loopback;
290#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200291
292 /* for PLL fix */
293 hda_nid_t pll_nid;
294 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100295};
296
297/*
298 * configuration template - to be copied to the spec instance
299 */
300struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200301 struct snd_kcontrol_new *mixers[5]; /* should be identical size
302 * with spec
303 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 const struct hda_verb *init_verbs[5];
305 unsigned int num_dacs;
306 hda_nid_t *dac_nids;
307 hda_nid_t dig_out_nid; /* optional */
308 hda_nid_t hp_nid; /* optional */
309 unsigned int num_adc_nids;
310 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100311 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100312 hda_nid_t dig_in_nid;
313 unsigned int num_channel_mode;
314 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200315 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200316 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100317 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100318 void (*unsol_event)(struct hda_codec *, unsigned int);
319 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200320#ifdef CONFIG_SND_HDA_POWER_SAVE
321 struct hda_amp_list *loopbacks;
322#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323};
324
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326/*
327 * input MUX handling
328 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200329static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
333 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200334 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
335 if (mux_idx >= spec->num_mux_defs)
336 mux_idx = 0;
337 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200340static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342{
343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
344 struct alc_spec *spec = codec->spec;
345 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
346
347 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
348 return 0;
349}
350
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200351static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353{
354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
355 struct alc_spec *spec = codec->spec;
356 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200357 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100358 hda_nid_t nid = spec->capsrc_nids ?
359 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200360 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100361 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362}
363
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365/*
366 * channel mode setting
367 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200368static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100373 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
374 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375}
376
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200377static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
378 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
380 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
381 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100382 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200383 spec->num_channel_mode,
384 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
391 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200392 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
393 spec->num_channel_mode,
394 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200395 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200396 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
397 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398}
399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100401 * Control the mode of pin widget settings via the mixer. "pc" is used
402 * instead of "%" to avoid consequences of accidently treating the % as
403 * being part of a format specifier. Maximum allowed length of a value is
404 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100405 *
406 * Note: some retasking pin complexes seem to ignore requests for input
407 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
408 * are requested. Therefore order this list so that this behaviour will not
409 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200410 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
411 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200412 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100413static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100414 "Mic 50pc bias", "Mic 80pc bias",
415 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416};
417static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100418 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419};
420/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200421 * in the pin being assumed to be exclusively an input or an output pin. In
422 * addition, "input" pins may or may not process the mic bias option
423 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
424 * accept requests for bias as of chip versions up to March 2006) and/or
425 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200427#define ALC_PIN_DIR_IN 0x00
428#define ALC_PIN_DIR_OUT 0x01
429#define ALC_PIN_DIR_INOUT 0x02
430#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
431#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200433/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 * For each direction the minimum and maximum values are given.
435 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200436static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 { 0, 2 }, /* ALC_PIN_DIR_IN */
438 { 3, 4 }, /* ALC_PIN_DIR_OUT */
439 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200440 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
441 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100442};
443#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
444#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
445#define alc_pin_mode_n_items(_dir) \
446 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
447
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200450{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 unsigned int item_num = uinfo->value.enumerated.item;
452 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
453
454 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200455 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
457
458 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
459 item_num = alc_pin_mode_min(dir);
460 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200461 return 0;
462}
463
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200466{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100470 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200471 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_PIN_WIDGET_CONTROL,
474 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200475
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100476 /* Find enumerated value for current pinctl setting */
477 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200478 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 return 0;
482}
483
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100486{
487 signed int change;
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 hda_nid_t nid = kcontrol->private_value & 0xffff;
490 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
491 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200492 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
493 AC_VERB_GET_PIN_WIDGET_CONTROL,
494 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200496 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 val = alc_pin_mode_min(dir);
498
499 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100500 if (change) {
501 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200502 snd_hda_codec_write_cache(codec, nid, 0,
503 AC_VERB_SET_PIN_WIDGET_CONTROL,
504 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100505
506 /* Also enable the retasking pin's input/output as required
507 * for the requested pin mode. Enum values of 2 or less are
508 * input modes.
509 *
510 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200511 * reduces noise slightly (particularly on input) so we'll
512 * do it. However, having both input and output buffers
513 * enabled simultaneously doesn't seem to be problematic if
514 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100515 */
516 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200517 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
518 HDA_AMP_MUTE, HDA_AMP_MUTE);
519 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
520 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100521 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200522 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
523 HDA_AMP_MUTE, HDA_AMP_MUTE);
524 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
525 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100526 }
527 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200528 return change;
529}
530
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 .info = alc_pin_mode_info, \
534 .get = alc_pin_mode_get, \
535 .put = alc_pin_mode_put, \
536 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100537
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100538/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
539 * together using a mask with more than one bit set. This control is
540 * currently used only by the ALC260 test model. At this stage they are not
541 * needed for any "production" models.
542 */
543#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200544#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200545
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100548{
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 hda_nid_t nid = kcontrol->private_value & 0xffff;
551 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
552 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 unsigned int val = snd_hda_codec_read(codec, nid, 0,
554 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100555
556 *valp = (val & mask) != 0;
557 return 0;
558}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100561{
562 signed int change;
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
565 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
566 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_GPIO_DATA,
569 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100570
571 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
573 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100574 gpio_data &= ~mask;
575 else
576 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200577 snd_hda_codec_write_cache(codec, nid, 0,
578 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100579
580 return change;
581}
582#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
583 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
584 .info = alc_gpio_data_info, \
585 .get = alc_gpio_data_get, \
586 .put = alc_gpio_data_put, \
587 .private_value = nid | (mask<<16) }
588#endif /* CONFIG_SND_DEBUG */
589
Jonathan Woithe92621f12006-02-28 11:47:47 +0100590/* A switch control to allow the enabling of the digital IO pins on the
591 * ALC260. This is incredibly simplistic; the intention of this control is
592 * to provide something in the test model allowing digital outputs to be
593 * identified if present. If models are found which can utilise these
594 * outputs a more complete mixer control can be devised for those models if
595 * necessary.
596 */
597#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200598#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200599
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200600static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100602{
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 hda_nid_t nid = kcontrol->private_value & 0xffff;
605 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
606 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100608 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100609
610 *valp = (val & mask) != 0;
611 return 0;
612}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100615{
616 signed int change;
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
619 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
620 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100622 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100624
625 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100627 if (val==0)
628 ctrl_data &= ~mask;
629 else
630 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200631 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
632 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100633
634 return change;
635}
636#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
637 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
638 .info = alc_spdif_ctrl_info, \
639 .get = alc_spdif_ctrl_get, \
640 .put = alc_spdif_ctrl_put, \
641 .private_value = nid | (mask<<16) }
642#endif /* CONFIG_SND_DEBUG */
643
Jonathan Woithef8225f62008-01-08 12:16:54 +0100644/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
645 * Again, this is only used in the ALC26x test models to help identify when
646 * the EAPD line must be asserted for features to work.
647 */
648#ifdef CONFIG_SND_DEBUG
649#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
650
651static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 hda_nid_t nid = kcontrol->private_value & 0xffff;
656 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
657 long *valp = ucontrol->value.integer.value;
658 unsigned int val = snd_hda_codec_read(codec, nid, 0,
659 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
660
661 *valp = (val & mask) != 0;
662 return 0;
663}
664
665static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_value *ucontrol)
667{
668 int change;
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long val = *ucontrol->value.integer.value;
673 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
674 AC_VERB_GET_EAPD_BTLENABLE,
675 0x00);
676
677 /* Set/unset the masked control bit(s) as needed */
678 change = (!val ? 0 : mask) != (ctrl_data & mask);
679 if (!val)
680 ctrl_data &= ~mask;
681 else
682 ctrl_data |= mask;
683 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
684 ctrl_data);
685
686 return change;
687}
688
689#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
690 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
691 .info = alc_eapd_ctrl_info, \
692 .get = alc_eapd_ctrl_get, \
693 .put = alc_eapd_ctrl_put, \
694 .private_value = nid | (mask<<16) }
695#endif /* CONFIG_SND_DEBUG */
696
Kailang Yangdf694da2005-12-05 19:42:22 +0100697/*
698 * set up from the preset table
699 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700static void setup_preset(struct alc_spec *spec,
701 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100702{
703 int i;
704
705 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
706 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
708 i++)
709 spec->init_verbs[spec->num_init_verbs++] =
710 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100711
712 spec->channel_mode = preset->channel_mode;
713 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200714 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100715
716 spec->multiout.max_channels = spec->channel_mode[0].channels;
717
718 spec->multiout.num_dacs = preset->num_dacs;
719 spec->multiout.dac_nids = preset->dac_nids;
720 spec->multiout.dig_out_nid = preset->dig_out_nid;
721 spec->multiout.hp_nid = preset->hp_nid;
722
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200723 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200724 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200725 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100726 spec->input_mux = preset->input_mux;
727
728 spec->num_adc_nids = preset->num_adc_nids;
729 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100730 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100731 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100732
733 spec->unsol_event = preset->unsol_event;
734 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200735#ifdef CONFIG_SND_HDA_POWER_SAVE
736 spec->loopback.amplist = preset->loopbacks;
737#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100738}
739
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200740/* Enable GPIO mask and set output */
741static struct hda_verb alc_gpio1_init_verbs[] = {
742 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
743 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
744 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
745 { }
746};
747
748static struct hda_verb alc_gpio2_init_verbs[] = {
749 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
750 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
751 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
752 { }
753};
754
Kailang Yangbdd148a2007-05-08 15:19:08 +0200755static struct hda_verb alc_gpio3_init_verbs[] = {
756 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
757 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
758 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
759 { }
760};
761
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200762/*
763 * Fix hardware PLL issue
764 * On some codecs, the analog PLL gating control must be off while
765 * the default value is 1.
766 */
767static void alc_fix_pll(struct hda_codec *codec)
768{
769 struct alc_spec *spec = codec->spec;
770 unsigned int val;
771
772 if (!spec->pll_nid)
773 return;
774 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
775 spec->pll_coef_idx);
776 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
777 AC_VERB_GET_PROC_COEF, 0);
778 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
779 spec->pll_coef_idx);
780 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
781 val & ~(1 << spec->pll_coef_bit));
782}
783
784static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
785 unsigned int coef_idx, unsigned int coef_bit)
786{
787 struct alc_spec *spec = codec->spec;
788 spec->pll_nid = nid;
789 spec->pll_coef_idx = coef_idx;
790 spec->pll_coef_bit = coef_bit;
791 alc_fix_pll(codec);
792}
793
Kailang Yangc9b58002007-10-16 14:30:01 +0200794static void alc_sku_automute(struct hda_codec *codec)
795{
796 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200797 unsigned int present;
798 unsigned int hp_nid = spec->autocfg.hp_pins[0];
799 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
800
801 /* need to execute and sync at first */
802 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
803 present = snd_hda_codec_read(codec, hp_nid, 0,
804 AC_VERB_GET_PIN_SENSE, 0);
805 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100806 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
807 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200808}
809
810/* unsolicited event for HP jack sensing */
811static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
812{
813 if (codec->vendor_id == 0x10ec0880)
814 res >>= 28;
815 else
816 res >>= 26;
817 if (res != ALC880_HP_EVENT)
818 return;
819
820 alc_sku_automute(codec);
821}
822
Kailang Yangf9423e72008-05-27 12:32:25 +0200823/* additional initialization for ALC888 variants */
824static void alc888_coef_init(struct hda_codec *codec)
825{
826 unsigned int tmp;
827
828 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
829 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
830 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
831 if ((tmp & 0xf0) == 2)
832 /* alc888S-VC */
833 snd_hda_codec_read(codec, 0x20, 0,
834 AC_VERB_SET_PROC_COEF, 0x830);
835 else
836 /* alc888-VB */
837 snd_hda_codec_read(codec, 0x20, 0,
838 AC_VERB_SET_PROC_COEF, 0x3030);
839}
840
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200841/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
842 * 31 ~ 16 : Manufacture ID
843 * 15 ~ 8 : SKU ID
844 * 7 ~ 0 : Assembly ID
845 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
846 */
847static void alc_subsystem_id(struct hda_codec *codec,
848 unsigned int porta, unsigned int porte,
849 unsigned int portd)
850{
Kailang Yangc9b58002007-10-16 14:30:01 +0200851 unsigned int ass, tmp, i;
852 unsigned nid;
853 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200854
Kailang Yangc9b58002007-10-16 14:30:01 +0200855 ass = codec->subsystem_id & 0xffff;
856 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
857 goto do_sku;
858
859 /*
860 * 31~30 : port conetcivity
861 * 29~21 : reserve
862 * 20 : PCBEEP input
863 * 19~16 : Check sum (15:1)
864 * 15~1 : Custom
865 * 0 : override
866 */
867 nid = 0x1d;
868 if (codec->vendor_id == 0x10ec0260)
869 nid = 0x17;
870 ass = snd_hda_codec_read(codec, nid, 0,
871 AC_VERB_GET_CONFIG_DEFAULT, 0);
872 if (!(ass & 1) && !(ass & 0x100000))
873 return;
874 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200875 return;
876
Kailang Yangc9b58002007-10-16 14:30:01 +0200877 /* check sum */
878 tmp = 0;
879 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100880 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200881 tmp++;
882 }
883 if (((ass >> 16) & 0xf) != tmp)
884 return;
885do_sku:
886 /*
887 * 0 : override
888 * 1 : Swap Jack
889 * 2 : 0 --> Desktop, 1 --> Laptop
890 * 3~5 : External Amplifier control
891 * 7~6 : Reserved
892 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200893 tmp = (ass & 0x38) >> 3; /* external Amp control */
894 switch (tmp) {
895 case 1:
896 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
897 break;
898 case 3:
899 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
900 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200901 case 7:
902 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
903 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200904 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200905 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 case 0x10ec0260:
907 snd_hda_codec_write(codec, 0x0f, 0,
908 AC_VERB_SET_EAPD_BTLENABLE, 2);
909 snd_hda_codec_write(codec, 0x10, 0,
910 AC_VERB_SET_EAPD_BTLENABLE, 2);
911 break;
912 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200913 case 0x10ec0267:
914 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200915 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200916 case 0x10ec0660:
917 case 0x10ec0662:
918 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200920 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200921 snd_hda_codec_write(codec, 0x14, 0,
922 AC_VERB_SET_EAPD_BTLENABLE, 2);
923 snd_hda_codec_write(codec, 0x15, 0,
924 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200925 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200926 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200927 switch (codec->vendor_id) {
928 case 0x10ec0260:
929 snd_hda_codec_write(codec, 0x1a, 0,
930 AC_VERB_SET_COEF_INDEX, 7);
931 tmp = snd_hda_codec_read(codec, 0x1a, 0,
932 AC_VERB_GET_PROC_COEF, 0);
933 snd_hda_codec_write(codec, 0x1a, 0,
934 AC_VERB_SET_COEF_INDEX, 7);
935 snd_hda_codec_write(codec, 0x1a, 0,
936 AC_VERB_SET_PROC_COEF,
937 tmp | 0x2010);
938 break;
939 case 0x10ec0262:
940 case 0x10ec0880:
941 case 0x10ec0882:
942 case 0x10ec0883:
943 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200944 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200945 snd_hda_codec_write(codec, 0x20, 0,
946 AC_VERB_SET_COEF_INDEX, 7);
947 tmp = snd_hda_codec_read(codec, 0x20, 0,
948 AC_VERB_GET_PROC_COEF, 0);
949 snd_hda_codec_write(codec, 0x20, 0,
950 AC_VERB_SET_COEF_INDEX, 7);
951 snd_hda_codec_write(codec, 0x20, 0,
952 AC_VERB_SET_PROC_COEF,
953 tmp | 0x2010);
954 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200955 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200956 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200957 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200958 case 0x10ec0267:
959 case 0x10ec0268:
960 snd_hda_codec_write(codec, 0x20, 0,
961 AC_VERB_SET_COEF_INDEX, 7);
962 tmp = snd_hda_codec_read(codec, 0x20, 0,
963 AC_VERB_GET_PROC_COEF, 0);
964 snd_hda_codec_write(codec, 0x20, 0,
965 AC_VERB_SET_COEF_INDEX, 7);
966 snd_hda_codec_write(codec, 0x20, 0,
967 AC_VERB_SET_PROC_COEF,
968 tmp | 0x3000);
969 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200970 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200971 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200972 break;
973 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200974
Kailang Yang8c427222008-01-10 13:03:59 +0100975 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200976 * when the external headphone out jack is plugged"
977 */
Kailang Yang8c427222008-01-10 13:03:59 +0100978 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200979 return;
980 /*
981 * 10~8 : Jack location
982 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
983 * 14~13: Resvered
984 * 15 : 1 --> enable the function "Mute internal speaker
985 * when the external headphone out jack is plugged"
986 */
987 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100988 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200989 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100990 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200991 else
992 return;
993 }
994
995 if (!spec->autocfg.hp_pins[0]) {
996 tmp = (ass >> 11) & 0x3; /* HP to chassis */
997 if (tmp == 0)
998 spec->autocfg.hp_pins[0] = porta;
999 else if (tmp == 1)
1000 spec->autocfg.hp_pins[0] = porte;
1001 else if (tmp == 2)
1002 spec->autocfg.hp_pins[0] = portd;
1003 else
1004 return;
1005 }
1006
1007 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1008 AC_VERB_SET_UNSOLICITED_ENABLE,
1009 AC_USRSP_EN | ALC880_HP_EVENT);
1010 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001011}
1012
Takashi Iwai41e41f12005-06-08 14:48:49 +02001013/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001014 * Fix-up pin default configurations
1015 */
1016
1017struct alc_pincfg {
1018 hda_nid_t nid;
1019 u32 val;
1020};
1021
1022static void alc_fix_pincfg(struct hda_codec *codec,
1023 const struct snd_pci_quirk *quirk,
1024 const struct alc_pincfg **pinfix)
1025{
1026 const struct alc_pincfg *cfg;
1027
1028 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1029 if (!quirk)
1030 return;
1031
1032 cfg = pinfix[quirk->value];
1033 for (; cfg->nid; cfg++) {
1034 int i;
1035 u32 val = cfg->val;
1036 for (i = 0; i < 4; i++) {
1037 snd_hda_codec_write(codec, cfg->nid, 0,
1038 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1039 val & 0xff);
1040 val >>= 8;
1041 }
1042 }
1043}
1044
1045/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001046 * ALC880 3-stack model
1047 *
1048 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001049 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1050 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 */
1052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001053static hda_nid_t alc880_dac_nids[4] = {
1054 /* front, rear, clfe, rear_surr */
1055 0x02, 0x05, 0x04, 0x03
1056};
1057
1058static hda_nid_t alc880_adc_nids[3] = {
1059 /* ADC0-2 */
1060 0x07, 0x08, 0x09,
1061};
1062
1063/* The datasheet says the node 0x07 is connected from inputs,
1064 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001065 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067static hda_nid_t alc880_adc_nids_alt[2] = {
1068 /* ADC1-2 */
1069 0x08, 0x09,
1070};
1071
1072#define ALC880_DIGOUT_NID 0x06
1073#define ALC880_DIGIN_NID 0x0a
1074
1075static struct hda_input_mux alc880_capture_source = {
1076 .num_items = 4,
1077 .items = {
1078 { "Mic", 0x0 },
1079 { "Front Mic", 0x3 },
1080 { "Line", 0x2 },
1081 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083};
1084
1085/* channel source setting (2/6 channel selection for 3-stack) */
1086/* 2ch mode */
1087static struct hda_verb alc880_threestack_ch2_init[] = {
1088 /* set line-in to input, mute it */
1089 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1090 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1091 /* set mic-in to input vref 80%, mute it */
1092 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1093 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 { } /* end */
1095};
1096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001097/* 6ch mode */
1098static struct hda_verb alc880_threestack_ch6_init[] = {
1099 /* set line-in to output, unmute it */
1100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1102 /* set mic-in to output, unmute it */
1103 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1104 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1105 { } /* end */
1106};
1107
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001108static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001109 { 2, alc880_threestack_ch2_init },
1110 { 6, alc880_threestack_ch6_init },
1111};
1112
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001113static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001114 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001115 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001116 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001117 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001118 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1119 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001120 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1121 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1129 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1130 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1131 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001133 {
1134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1135 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001136 .info = alc_ch_mode_info,
1137 .get = alc_ch_mode_get,
1138 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001139 },
1140 { } /* end */
1141};
1142
1143/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001144static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001145 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1151 {
1152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1153 /* The multiple "Capture Source" controls confuse alsamixer
1154 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155 */
1156 /* .name = "Capture Source", */
1157 .name = "Input Source",
1158 .count = 3,
1159 .info = alc_mux_enum_info,
1160 .get = alc_mux_enum_get,
1161 .put = alc_mux_enum_put,
1162 },
1163 { } /* end */
1164};
1165
1166/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001167static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 {
1173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1174 /* The multiple "Capture Source" controls confuse alsamixer
1175 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 */
1177 /* .name = "Capture Source", */
1178 .name = "Input Source",
1179 .count = 2,
1180 .info = alc_mux_enum_info,
1181 .get = alc_mux_enum_get,
1182 .put = alc_mux_enum_put,
1183 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 { } /* end */
1185};
1186
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001187
1188
1189/*
1190 * ALC880 5-stack model
1191 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001192 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1193 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001194 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1195 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1196 */
1197
1198/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001199static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001200 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001201 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 { } /* end */
1203};
1204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001205/* channel source setting (6/8 channel selection for 5-stack) */
1206/* 6ch mode */
1207static struct hda_verb alc880_fivestack_ch6_init[] = {
1208 /* set line-in to input, mute it */
1209 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1210 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001211 { } /* end */
1212};
1213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214/* 8ch mode */
1215static struct hda_verb alc880_fivestack_ch8_init[] = {
1216 /* set line-in to output, unmute it */
1217 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1218 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1219 { } /* end */
1220};
1221
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001222static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001223 { 6, alc880_fivestack_ch6_init },
1224 { 8, alc880_fivestack_ch8_init },
1225};
1226
1227
1228/*
1229 * ALC880 6-stack model
1230 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001231 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1232 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001233 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1234 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1235 */
1236
1237static hda_nid_t alc880_6st_dac_nids[4] = {
1238 /* front, rear, clfe, rear_surr */
1239 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001240};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001241
1242static struct hda_input_mux alc880_6stack_capture_source = {
1243 .num_items = 4,
1244 .items = {
1245 { "Mic", 0x0 },
1246 { "Front Mic", 0x1 },
1247 { "Line", 0x2 },
1248 { "CD", 0x4 },
1249 },
1250};
1251
1252/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001253static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254 { 8, NULL },
1255};
1256
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001257static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001260 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001261 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001262 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001266 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001267 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1274 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1275 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1276 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1277 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001278 {
1279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1280 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001281 .info = alc_ch_mode_info,
1282 .get = alc_ch_mode_get,
1283 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001284 },
1285 { } /* end */
1286};
1287
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001288
1289/*
1290 * ALC880 W810 model
1291 *
1292 * W810 has rear IO for:
1293 * Front (DAC 02)
1294 * Surround (DAC 03)
1295 * Center/LFE (DAC 04)
1296 * Digital out (06)
1297 *
1298 * The system also has a pair of internal speakers, and a headphone jack.
1299 * These are both connected to Line2 on the codec, hence to DAC 02.
1300 *
1301 * There is a variable resistor to control the speaker or headphone
1302 * volume. This is a hardware-only device without a software API.
1303 *
1304 * Plugging headphones in will disable the internal speakers. This is
1305 * implemented in hardware, not via the driver using jack sense. In
1306 * a similar fashion, plugging into the rear socket marked "front" will
1307 * disable both the speakers and headphones.
1308 *
1309 * For input, there's a microphone jack, and an "audio in" jack.
1310 * These may not do anything useful with this driver yet, because I
1311 * haven't setup any initialization verbs for these yet...
1312 */
1313
1314static hda_nid_t alc880_w810_dac_nids[3] = {
1315 /* front, rear/surround, clfe */
1316 0x02, 0x03, 0x04
1317};
1318
1319/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001320static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001321 { 6, NULL }
1322};
1323
1324/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001325static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001327 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001328 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001329 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1331 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001332 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1333 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1335 { } /* end */
1336};
1337
1338
1339/*
1340 * Z710V model
1341 *
1342 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001343 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1344 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001345 */
1346
1347static hda_nid_t alc880_z71v_dac_nids[1] = {
1348 0x02
1349};
1350#define ALC880_Z71V_HP_DAC 0x03
1351
1352/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001353static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001354 { 2, NULL }
1355};
1356
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001357static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001359 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001360 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001361 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1366 { } /* end */
1367};
1368
1369
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001370/*
1371 * ALC880 F1734 model
1372 *
1373 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1374 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1375 */
1376
1377static hda_nid_t alc880_f1734_dac_nids[1] = {
1378 0x03
1379};
1380#define ALC880_F1734_HP_DAC 0x02
1381
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001382static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001383 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001384 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001385 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1386 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001391 { } /* end */
1392};
1393
Takashi Iwai937b4162008-02-11 14:52:36 +01001394static struct hda_input_mux alc880_f1734_capture_source = {
1395 .num_items = 2,
1396 .items = {
1397 { "Mic", 0x1 },
1398 { "CD", 0x4 },
1399 },
1400};
1401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001403/*
1404 * ALC880 ASUS model
1405 *
1406 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1407 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1408 * Mic = 0x18, Line = 0x1a
1409 */
1410
1411#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1412#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1413
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001414static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001418 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001419 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001423 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1428 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001429 {
1430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1431 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001432 .info = alc_ch_mode_info,
1433 .get = alc_ch_mode_get,
1434 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001435 },
1436 { } /* end */
1437};
1438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439/*
1440 * ALC880 ASUS W1V model
1441 *
1442 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1443 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1444 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1445 */
1446
1447/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001448static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1450 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 { } /* end */
1452};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001453
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001454/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001455static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001456 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1457 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1458 { } /* end */
1459};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460
Kailang Yangdf694da2005-12-05 19:42:22 +01001461/* TCL S700 */
1462static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1463 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1464 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1467 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1470 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1471 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1472 {
1473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1474 /* The multiple "Capture Source" controls confuse alsamixer
1475 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001476 */
1477 /* .name = "Capture Source", */
1478 .name = "Input Source",
1479 .count = 1,
1480 .info = alc_mux_enum_info,
1481 .get = alc_mux_enum_get,
1482 .put = alc_mux_enum_put,
1483 },
1484 { } /* end */
1485};
1486
Kailang Yangccc656c2006-10-17 12:32:26 +02001487/* Uniwill */
1488static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1490 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1491 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1494 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1495 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1496 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1505 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1506 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1507 {
1508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1509 .name = "Channel Mode",
1510 .info = alc_ch_mode_info,
1511 .get = alc_ch_mode_get,
1512 .put = alc_ch_mode_put,
1513 },
1514 { } /* end */
1515};
1516
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001517static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1518 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1519 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1520 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1521 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1522 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1523 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1524 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1525 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1526 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1527 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1528 { } /* end */
1529};
1530
Kailang Yangccc656c2006-10-17 12:32:26 +02001531static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001532 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1533 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1534 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1535 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1538 { } /* end */
1539};
1540
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001542 * virtual master controls
1543 */
1544
1545/*
1546 * slave controls for virtual master
1547 */
1548static const char *alc_slave_vols[] = {
1549 "Front Playback Volume",
1550 "Surround Playback Volume",
1551 "Center Playback Volume",
1552 "LFE Playback Volume",
1553 "Side Playback Volume",
1554 "Headphone Playback Volume",
1555 "Speaker Playback Volume",
1556 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001557 "Line-Out Playback Volume",
1558 NULL,
1559};
1560
1561static const char *alc_slave_sws[] = {
1562 "Front Playback Switch",
1563 "Surround Playback Switch",
1564 "Center Playback Switch",
1565 "LFE Playback Switch",
1566 "Side Playback Switch",
1567 "Headphone Playback Switch",
1568 "Speaker Playback Switch",
1569 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001570 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001571 NULL,
1572};
1573
1574/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001575 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 */
1577static int alc_build_controls(struct hda_codec *codec)
1578{
1579 struct alc_spec *spec = codec->spec;
1580 int err;
1581 int i;
1582
1583 for (i = 0; i < spec->num_mixers; i++) {
1584 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1585 if (err < 0)
1586 return err;
1587 }
1588
1589 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001590 err = snd_hda_create_spdif_out_ctls(codec,
1591 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 if (err < 0)
1593 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001594 err = snd_hda_create_spdif_share_sw(codec,
1595 &spec->multiout);
1596 if (err < 0)
1597 return err;
1598 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 }
1600 if (spec->dig_in_nid) {
1601 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1602 if (err < 0)
1603 return err;
1604 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001605
1606 /* if we have no master control, let's create it */
1607 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001608 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001609 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001610 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001611 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001612 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001613 if (err < 0)
1614 return err;
1615 }
1616 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1617 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1618 NULL, alc_slave_sws);
1619 if (err < 0)
1620 return err;
1621 }
1622
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 return 0;
1624}
1625
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001626
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627/*
1628 * initialize the codec volumes, etc
1629 */
1630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001631/*
1632 * generic initialization of ADC, input mixers and output mixers
1633 */
1634static struct hda_verb alc880_volume_init_verbs[] = {
1635 /*
1636 * Unmute ADC0-2 and set the default input to mic-in
1637 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001638 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001642 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001643 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1646 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001647 * Note: PASD motherboards uses the Line In 2 as the input for front
1648 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001650 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659 /*
1660 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 /* set vol=0 to output mixers */
1663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1666 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1667 /* set up input amps for analog loopback */
1668 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001671 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1672 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1674 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001675 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1676 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677
1678 { }
1679};
1680
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681/*
1682 * 3-stack pin configuration:
1683 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1684 */
1685static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1686 /*
1687 * preset connection lists of input pins
1688 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1689 */
1690 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1691 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1692 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1693
1694 /*
1695 * Set pin mode and muting
1696 */
1697 /* set front pin widgets 0x14 for output */
1698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1700 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1701 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1703 /* Mic2 (as headphone out) for HP output */
1704 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1705 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 /* Line In pin widget for input */
1707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1709 /* Line2 (as front mic) pin widget for input and vref at 80% */
1710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1712 /* CD pin widget for input */
1713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1714
1715 { }
1716};
1717
1718/*
1719 * 5-stack pin configuration:
1720 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1721 * line-in/side = 0x1a, f-mic = 0x1b
1722 */
1723static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1724 /*
1725 * preset connection lists of input pins
1726 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1727 */
1728 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1729 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1730
1731 /*
1732 * Set pin mode and muting
1733 */
1734 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1738 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 /* unmute pins for output (no gain on this amp) */
1740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001747 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1748 /* Mic2 (as headphone out) for HP output */
1749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 /* Line In pin widget for input */
1752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1754 /* Line2 (as front mic) pin widget for input and vref at 80% */
1755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1757 /* CD pin widget for input */
1758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759
1760 { }
1761};
1762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763/*
1764 * W810 pin configuration:
1765 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1766 */
1767static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 /* hphone/speaker input selector: front DAC */
1769 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1770
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1775 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777
1778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001779 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781 { }
1782};
1783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001784/*
1785 * Z71V pin configuration:
1786 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1787 */
1788static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001793
Takashi Iwai16ded522005-06-10 19:58:24 +02001794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001796 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001798
1799 { }
1800};
1801
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802/*
1803 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001804 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1805 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 */
1807static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1808 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1809
Takashi Iwai16ded522005-06-10 19:58:24 +02001810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1818
Takashi Iwai16ded522005-06-10 19:58:24 +02001819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001824 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001826 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 { }
1830};
Takashi Iwai16ded522005-06-10 19:58:24 +02001831
Kailang Yangccc656c2006-10-17 12:32:26 +02001832/*
1833 * Uniwill pin configuration:
1834 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1835 * line = 0x1a
1836 */
1837static struct hda_verb alc880_uniwill_init_verbs[] = {
1838 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1839
1840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1854
1855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1861 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1862 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1863 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1864
1865 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1867
1868 { }
1869};
1870
1871/*
1872* Uniwill P53
1873* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1874 */
1875static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1876 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1877
1878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1880 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1890
1891 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1897
1898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1899 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1900
1901 { }
1902};
1903
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001904static struct hda_verb alc880_beep_init_verbs[] = {
1905 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1906 { }
1907};
1908
Kailang Yangccc656c2006-10-17 12:32:26 +02001909/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001910static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001911{
1912 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001913 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001914
1915 present = snd_hda_codec_read(codec, 0x14, 0,
1916 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001917 bits = present ? HDA_AMP_MUTE : 0;
1918 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1919 HDA_AMP_MUTE, bits);
1920 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1921 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001922}
1923
1924/* auto-toggle front mic */
1925static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1926{
1927 unsigned int present;
1928 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001929
1930 present = snd_hda_codec_read(codec, 0x18, 0,
1931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001932 bits = present ? HDA_AMP_MUTE : 0;
1933 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001934}
1935
1936static void alc880_uniwill_automute(struct hda_codec *codec)
1937{
1938 alc880_uniwill_hp_automute(codec);
1939 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001940}
1941
1942static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1943 unsigned int res)
1944{
1945 /* Looks like the unsol event is incompatible with the standard
1946 * definition. 4bit tag is placed at 28 bit!
1947 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001948 switch (res >> 28) {
1949 case ALC880_HP_EVENT:
1950 alc880_uniwill_hp_automute(codec);
1951 break;
1952 case ALC880_MIC_EVENT:
1953 alc880_uniwill_mic_automute(codec);
1954 break;
1955 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001956}
1957
1958static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1959{
1960 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001961 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001962
1963 present = snd_hda_codec_read(codec, 0x14, 0,
1964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001965 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001966 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001967}
1968
1969static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1970{
1971 unsigned int present;
1972
1973 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001974 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1975 present &= HDA_AMP_VOLMASK;
1976 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1977 HDA_AMP_VOLMASK, present);
1978 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1979 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001980}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001981
Kailang Yangccc656c2006-10-17 12:32:26 +02001982static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1983 unsigned int res)
1984{
1985 /* Looks like the unsol event is incompatible with the standard
1986 * definition. 4bit tag is placed at 28 bit!
1987 */
1988 if ((res >> 28) == ALC880_HP_EVENT)
1989 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001990 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001991 alc880_uniwill_p53_dcvol_automute(codec);
1992}
1993
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001994/*
1995 * F1734 pin configuration:
1996 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1997 */
1998static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01001999 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002000 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2001 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2002 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2003 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2004
2005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009
2010 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2011 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002012 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2018 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002019
Takashi Iwai937b4162008-02-11 14:52:36 +01002020 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2021 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2022
Takashi Iwai16ded522005-06-10 19:58:24 +02002023 { }
2024};
2025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002026/*
2027 * ASUS pin configuration:
2028 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2029 */
2030static struct hda_verb alc880_pin_asus_init_verbs[] = {
2031 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2032 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2033 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2034 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2035
2036 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2037 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2039 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044
2045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2046 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2047 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2053 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2054
2055 { }
2056};
2057
2058/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002059#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2060#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061
Kailang Yangdf694da2005-12-05 19:42:22 +01002062/* Clevo m520g init */
2063static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2064 /* headphone output */
2065 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2066 /* line-out */
2067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 /* Line-in */
2070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 /* CD */
2073 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2074 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2075 /* Mic1 (rear panel) */
2076 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2077 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 /* Mic2 (front panel) */
2079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 /* headphone */
2082 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2084 /* change to EAPD mode */
2085 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2086 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2087
2088 { }
2089};
2090
2091static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002092 /* change to EAPD mode */
2093 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2094 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2095
Kailang Yangdf694da2005-12-05 19:42:22 +01002096 /* Headphone output */
2097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2098 /* Front output*/
2099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2100 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2101
2102 /* Line In pin widget for input */
2103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2104 /* CD pin widget for input */
2105 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2106 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2108
2109 /* change to EAPD mode */
2110 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2111 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2112
2113 { }
2114};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002115
2116/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002117 * LG m1 express dual
2118 *
2119 * Pin assignment:
2120 * Rear Line-In/Out (blue): 0x14
2121 * Build-in Mic-In: 0x15
2122 * Speaker-out: 0x17
2123 * HP-Out (green): 0x1b
2124 * Mic-In/Out (red): 0x19
2125 * SPDIF-Out: 0x1e
2126 */
2127
2128/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2129static hda_nid_t alc880_lg_dac_nids[3] = {
2130 0x05, 0x02, 0x03
2131};
2132
2133/* seems analog CD is not working */
2134static struct hda_input_mux alc880_lg_capture_source = {
2135 .num_items = 3,
2136 .items = {
2137 { "Mic", 0x1 },
2138 { "Line", 0x5 },
2139 { "Internal Mic", 0x6 },
2140 },
2141};
2142
2143/* 2,4,6 channel modes */
2144static struct hda_verb alc880_lg_ch2_init[] = {
2145 /* set line-in and mic-in to input */
2146 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2147 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2148 { }
2149};
2150
2151static struct hda_verb alc880_lg_ch4_init[] = {
2152 /* set line-in to out and mic-in to input */
2153 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2154 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2155 { }
2156};
2157
2158static struct hda_verb alc880_lg_ch6_init[] = {
2159 /* set line-in and mic-in to output */
2160 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2161 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2162 { }
2163};
2164
2165static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2166 { 2, alc880_lg_ch2_init },
2167 { 4, alc880_lg_ch4_init },
2168 { 6, alc880_lg_ch6_init },
2169};
2170
2171static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2173 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002174 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2175 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2176 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2177 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2179 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2184 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2185 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2186 {
2187 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2188 .name = "Channel Mode",
2189 .info = alc_ch_mode_info,
2190 .get = alc_ch_mode_get,
2191 .put = alc_ch_mode_put,
2192 },
2193 { } /* end */
2194};
2195
2196static struct hda_verb alc880_lg_init_verbs[] = {
2197 /* set capture source to mic-in */
2198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2201 /* mute all amp mixer inputs */
2202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002205 /* line-in to input */
2206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2208 /* built-in mic */
2209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2211 /* speaker-out */
2212 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2213 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2214 /* mic-in to input */
2215 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2217 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2218 /* HP-out */
2219 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2221 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 /* jack sense */
2223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2224 { }
2225};
2226
2227/* toggle speaker-output according to the hp-jack state */
2228static void alc880_lg_automute(struct hda_codec *codec)
2229{
2230 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002231 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002232
2233 present = snd_hda_codec_read(codec, 0x1b, 0,
2234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002235 bits = present ? HDA_AMP_MUTE : 0;
2236 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2237 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002238}
2239
2240static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2241{
2242 /* Looks like the unsol event is incompatible with the standard
2243 * definition. 4bit tag is placed at 28 bit!
2244 */
2245 if ((res >> 28) == 0x01)
2246 alc880_lg_automute(codec);
2247}
2248
2249/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002250 * LG LW20
2251 *
2252 * Pin assignment:
2253 * Speaker-out: 0x14
2254 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002255 * Built-in Mic-In: 0x19
2256 * Line-In: 0x1b
2257 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002258 * SPDIF-Out: 0x1e
2259 */
2260
Takashi Iwaid6815182006-03-23 16:06:23 +01002261static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002262 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002263 .items = {
2264 { "Mic", 0x0 },
2265 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002266 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002267 },
2268};
2269
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002270#define alc880_lg_lw_modes alc880_threestack_modes
2271
Takashi Iwaid6815182006-03-23 16:06:23 +01002272static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2276 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2277 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2278 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2279 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2280 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002283 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2284 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2285 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2286 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002287 {
2288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2289 .name = "Channel Mode",
2290 .info = alc_ch_mode_info,
2291 .get = alc_ch_mode_get,
2292 .put = alc_ch_mode_put,
2293 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002294 { } /* end */
2295};
2296
2297static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002298 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2299 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2300 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2301
Takashi Iwaid6815182006-03-23 16:06:23 +01002302 /* set capture source to mic-in */
2303 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002307 /* speaker-out */
2308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2312 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 /* mic-in to input */
2314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 /* built-in mic */
2317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2319 /* jack sense */
2320 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2321 { }
2322};
2323
2324/* toggle speaker-output according to the hp-jack state */
2325static void alc880_lg_lw_automute(struct hda_codec *codec)
2326{
2327 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002328 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002329
2330 present = snd_hda_codec_read(codec, 0x1b, 0,
2331 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002332 bits = present ? HDA_AMP_MUTE : 0;
2333 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2334 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002335}
2336
2337static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2338{
2339 /* Looks like the unsol event is incompatible with the standard
2340 * definition. 4bit tag is placed at 28 bit!
2341 */
2342 if ((res >> 28) == 0x01)
2343 alc880_lg_lw_automute(codec);
2344}
2345
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002346static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2347 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2352 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2353 { } /* end */
2354};
2355
2356static struct hda_input_mux alc880_medion_rim_capture_source = {
2357 .num_items = 2,
2358 .items = {
2359 { "Mic", 0x0 },
2360 { "Internal Mic", 0x1 },
2361 },
2362};
2363
2364static struct hda_verb alc880_medion_rim_init_verbs[] = {
2365 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2366
2367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2368 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2369
2370 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2373 /* Mic2 (as headphone out) for HP output */
2374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2376 /* Internal Speaker */
2377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2378 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2379
2380 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2381 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2382
2383 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2384 { }
2385};
2386
2387/* toggle speaker-output according to the hp-jack state */
2388static void alc880_medion_rim_automute(struct hda_codec *codec)
2389{
2390 unsigned int present;
2391 unsigned char bits;
2392
2393 present = snd_hda_codec_read(codec, 0x14, 0,
2394 AC_VERB_GET_PIN_SENSE, 0)
2395 & AC_PINSENSE_PRESENCE;
2396 bits = present ? HDA_AMP_MUTE : 0;
2397 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2398 HDA_AMP_MUTE, bits);
2399 if (present)
2400 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2401 else
2402 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2403}
2404
2405static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2406 unsigned int res)
2407{
2408 /* Looks like the unsol event is incompatible with the standard
2409 * definition. 4bit tag is placed at 28 bit!
2410 */
2411 if ((res >> 28) == ALC880_HP_EVENT)
2412 alc880_medion_rim_automute(codec);
2413}
2414
Takashi Iwaicb53c622007-08-10 17:21:45 +02002415#ifdef CONFIG_SND_HDA_POWER_SAVE
2416static struct hda_amp_list alc880_loopbacks[] = {
2417 { 0x0b, HDA_INPUT, 0 },
2418 { 0x0b, HDA_INPUT, 1 },
2419 { 0x0b, HDA_INPUT, 2 },
2420 { 0x0b, HDA_INPUT, 3 },
2421 { 0x0b, HDA_INPUT, 4 },
2422 { } /* end */
2423};
2424
2425static struct hda_amp_list alc880_lg_loopbacks[] = {
2426 { 0x0b, HDA_INPUT, 1 },
2427 { 0x0b, HDA_INPUT, 6 },
2428 { 0x0b, HDA_INPUT, 7 },
2429 { } /* end */
2430};
2431#endif
2432
Takashi Iwaid6815182006-03-23 16:06:23 +01002433/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002434 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002435 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002436
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437static int alc_init(struct hda_codec *codec)
2438{
2439 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002440 unsigned int i;
2441
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002442 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002443 if (codec->vendor_id == 0x10ec0888)
2444 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002445
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002446 for (i = 0; i < spec->num_init_verbs; i++)
2447 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002448
2449 if (spec->init_hook)
2450 spec->init_hook(codec);
2451
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 return 0;
2453}
2454
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002455static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2456{
2457 struct alc_spec *spec = codec->spec;
2458
2459 if (spec->unsol_event)
2460 spec->unsol_event(codec, res);
2461}
2462
Takashi Iwaicb53c622007-08-10 17:21:45 +02002463#ifdef CONFIG_SND_HDA_POWER_SAVE
2464static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2465{
2466 struct alc_spec *spec = codec->spec;
2467 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2468}
2469#endif
2470
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471/*
2472 * Analog playback callbacks
2473 */
2474static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2475 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002476 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477{
2478 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002479 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2480 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481}
2482
2483static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2484 struct hda_codec *codec,
2485 unsigned int stream_tag,
2486 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002487 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488{
2489 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002490 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2491 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492}
2493
2494static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2495 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002496 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497{
2498 struct alc_spec *spec = codec->spec;
2499 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2500}
2501
2502/*
2503 * Digital out
2504 */
2505static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2506 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002507 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508{
2509 struct alc_spec *spec = codec->spec;
2510 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2511}
2512
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002513static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2514 struct hda_codec *codec,
2515 unsigned int stream_tag,
2516 unsigned int format,
2517 struct snd_pcm_substream *substream)
2518{
2519 struct alc_spec *spec = codec->spec;
2520 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2521 stream_tag, format, substream);
2522}
2523
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2525 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002526 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527{
2528 struct alc_spec *spec = codec->spec;
2529 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2530}
2531
2532/*
2533 * Analog capture
2534 */
Takashi Iwai63300792008-01-24 15:31:36 +01002535static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536 struct hda_codec *codec,
2537 unsigned int stream_tag,
2538 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002539 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540{
2541 struct alc_spec *spec = codec->spec;
2542
Takashi Iwai63300792008-01-24 15:31:36 +01002543 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 stream_tag, 0, format);
2545 return 0;
2546}
2547
Takashi Iwai63300792008-01-24 15:31:36 +01002548static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002550 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551{
2552 struct alc_spec *spec = codec->spec;
2553
Takashi Iwai888afa12008-03-18 09:57:50 +01002554 snd_hda_codec_cleanup_stream(codec,
2555 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 return 0;
2557}
2558
2559
2560/*
2561 */
2562static struct hda_pcm_stream alc880_pcm_analog_playback = {
2563 .substreams = 1,
2564 .channels_min = 2,
2565 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567 .ops = {
2568 .open = alc880_playback_pcm_open,
2569 .prepare = alc880_playback_pcm_prepare,
2570 .cleanup = alc880_playback_pcm_cleanup
2571 },
2572};
2573
2574static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002575 .substreams = 1,
2576 .channels_min = 2,
2577 .channels_max = 2,
2578 /* NID is set in alc_build_pcms */
2579};
2580
2581static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2582 .substreams = 1,
2583 .channels_min = 2,
2584 .channels_max = 2,
2585 /* NID is set in alc_build_pcms */
2586};
2587
2588static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2589 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 .channels_min = 2,
2591 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002592 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002594 .prepare = alc880_alt_capture_pcm_prepare,
2595 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 },
2597};
2598
2599static struct hda_pcm_stream alc880_pcm_digital_playback = {
2600 .substreams = 1,
2601 .channels_min = 2,
2602 .channels_max = 2,
2603 /* NID is set in alc_build_pcms */
2604 .ops = {
2605 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002606 .close = alc880_dig_playback_pcm_close,
2607 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 },
2609};
2610
2611static struct hda_pcm_stream alc880_pcm_digital_capture = {
2612 .substreams = 1,
2613 .channels_min = 2,
2614 .channels_max = 2,
2615 /* NID is set in alc_build_pcms */
2616};
2617
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002618/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002619static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002620 .substreams = 0,
2621 .channels_min = 0,
2622 .channels_max = 0,
2623};
2624
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625static int alc_build_pcms(struct hda_codec *codec)
2626{
2627 struct alc_spec *spec = codec->spec;
2628 struct hda_pcm *info = spec->pcm_rec;
2629 int i;
2630
2631 codec->num_pcms = 1;
2632 codec->pcm_info = info;
2633
2634 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002635 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002636 if (snd_BUG_ON(!spec->multiout.dac_nids))
2637 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002638 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2639 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2640 }
2641 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002642 if (snd_BUG_ON(!spec->adc_nids))
2643 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002644 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2645 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2646 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647
Takashi Iwai4a471b72005-12-07 13:56:29 +01002648 if (spec->channel_mode) {
2649 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2650 for (i = 0; i < spec->num_channel_mode; i++) {
2651 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2652 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2653 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 }
2655 }
2656
Takashi Iwaie08a0072006-09-07 17:52:14 +02002657 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002659 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002660 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002662 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002663 if (spec->multiout.dig_out_nid &&
2664 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2666 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2667 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002668 if (spec->dig_in_nid &&
2669 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2671 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2672 }
2673 }
2674
Takashi Iwaie08a0072006-09-07 17:52:14 +02002675 /* If the use of more than one ADC is requested for the current
2676 * model, configure a second analog capture-only PCM.
2677 */
2678 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002679 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2680 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002681 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002682 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002683 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002684 if (spec->alt_dac_nid) {
2685 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2686 *spec->stream_analog_alt_playback;
2687 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2688 spec->alt_dac_nid;
2689 } else {
2690 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2691 alc_pcm_null_stream;
2692 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2693 }
2694 if (spec->num_adc_nids > 1) {
2695 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2696 *spec->stream_analog_alt_capture;
2697 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2698 spec->adc_nids[1];
2699 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2700 spec->num_adc_nids - 1;
2701 } else {
2702 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2703 alc_pcm_null_stream;
2704 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002705 }
2706 }
2707
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708 return 0;
2709}
2710
2711static void alc_free(struct hda_codec *codec)
2712{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 struct alc_spec *spec = codec->spec;
2714 unsigned int i;
2715
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002716 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 return;
2718
2719 if (spec->kctl_alloc) {
2720 for (i = 0; i < spec->num_kctl_used; i++)
2721 kfree(spec->kctl_alloc[i].name);
2722 kfree(spec->kctl_alloc);
2723 }
2724 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002725 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726}
2727
2728/*
2729 */
2730static struct hda_codec_ops alc_patch_ops = {
2731 .build_controls = alc_build_controls,
2732 .build_pcms = alc_build_pcms,
2733 .init = alc_init,
2734 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002735 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002736#ifdef CONFIG_SND_HDA_POWER_SAVE
2737 .check_power_status = alc_check_power_status,
2738#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002739};
2740
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002741
2742/*
2743 * Test configuration for debugging
2744 *
2745 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2746 * enum controls.
2747 */
2748#ifdef CONFIG_SND_DEBUG
2749static hda_nid_t alc880_test_dac_nids[4] = {
2750 0x02, 0x03, 0x04, 0x05
2751};
2752
2753static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002754 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002755 .items = {
2756 { "In-1", 0x0 },
2757 { "In-2", 0x1 },
2758 { "In-3", 0x2 },
2759 { "In-4", 0x3 },
2760 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002761 { "Front", 0x5 },
2762 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002763 },
2764};
2765
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002766static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002767 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002768 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002769 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002770 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002771};
2772
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002773static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2774 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002775{
2776 static char *texts[] = {
2777 "N/A", "Line Out", "HP Out",
2778 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2779 };
2780 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2781 uinfo->count = 1;
2782 uinfo->value.enumerated.items = 8;
2783 if (uinfo->value.enumerated.item >= 8)
2784 uinfo->value.enumerated.item = 7;
2785 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2786 return 0;
2787}
2788
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002789static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2790 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002791{
2792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2793 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2794 unsigned int pin_ctl, item = 0;
2795
2796 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2797 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2798 if (pin_ctl & AC_PINCTL_OUT_EN) {
2799 if (pin_ctl & AC_PINCTL_HP_EN)
2800 item = 2;
2801 else
2802 item = 1;
2803 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2804 switch (pin_ctl & AC_PINCTL_VREFEN) {
2805 case AC_PINCTL_VREF_HIZ: item = 3; break;
2806 case AC_PINCTL_VREF_50: item = 4; break;
2807 case AC_PINCTL_VREF_GRD: item = 5; break;
2808 case AC_PINCTL_VREF_80: item = 6; break;
2809 case AC_PINCTL_VREF_100: item = 7; break;
2810 }
2811 }
2812 ucontrol->value.enumerated.item[0] = item;
2813 return 0;
2814}
2815
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002816static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2817 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002818{
2819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2820 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2821 static unsigned int ctls[] = {
2822 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2823 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2824 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2825 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2826 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2827 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2828 };
2829 unsigned int old_ctl, new_ctl;
2830
2831 old_ctl = snd_hda_codec_read(codec, nid, 0,
2832 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2833 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2834 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002835 int val;
2836 snd_hda_codec_write_cache(codec, nid, 0,
2837 AC_VERB_SET_PIN_WIDGET_CONTROL,
2838 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002839 val = ucontrol->value.enumerated.item[0] >= 3 ?
2840 HDA_AMP_MUTE : 0;
2841 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2842 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002843 return 1;
2844 }
2845 return 0;
2846}
2847
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002848static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2849 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002850{
2851 static char *texts[] = {
2852 "Front", "Surround", "CLFE", "Side"
2853 };
2854 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2855 uinfo->count = 1;
2856 uinfo->value.enumerated.items = 4;
2857 if (uinfo->value.enumerated.item >= 4)
2858 uinfo->value.enumerated.item = 3;
2859 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2860 return 0;
2861}
2862
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002863static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2864 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002865{
2866 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2867 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2868 unsigned int sel;
2869
2870 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2871 ucontrol->value.enumerated.item[0] = sel & 3;
2872 return 0;
2873}
2874
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002875static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2876 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002877{
2878 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2879 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2880 unsigned int sel;
2881
2882 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2883 if (ucontrol->value.enumerated.item[0] != sel) {
2884 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002885 snd_hda_codec_write_cache(codec, nid, 0,
2886 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002887 return 1;
2888 }
2889 return 0;
2890}
2891
2892#define PIN_CTL_TEST(xname,nid) { \
2893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2894 .name = xname, \
2895 .info = alc_test_pin_ctl_info, \
2896 .get = alc_test_pin_ctl_get, \
2897 .put = alc_test_pin_ctl_put, \
2898 .private_value = nid \
2899 }
2900
2901#define PIN_SRC_TEST(xname,nid) { \
2902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2903 .name = xname, \
2904 .info = alc_test_pin_src_info, \
2905 .get = alc_test_pin_src_get, \
2906 .put = alc_test_pin_src_put, \
2907 .private_value = nid \
2908 }
2909
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002910static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2912 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2913 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2914 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002915 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2916 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2917 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2918 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002919 PIN_CTL_TEST("Front Pin Mode", 0x14),
2920 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2921 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2922 PIN_CTL_TEST("Side Pin Mode", 0x17),
2923 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2924 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2925 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2926 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2927 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2928 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2929 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2930 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2931 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2932 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2933 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2934 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2935 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2936 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2937 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2938 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002941 {
2942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2943 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002944 .info = alc_ch_mode_info,
2945 .get = alc_ch_mode_get,
2946 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002947 },
2948 { } /* end */
2949};
2950
2951static struct hda_verb alc880_test_init_verbs[] = {
2952 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2955 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2959 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2960 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002961 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002966 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2970 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002971 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2974 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002976 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002977 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2981 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002982 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2984 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2986 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002987 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002989 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002993 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002994 /* Analog input/passthru */
2995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2997 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003000 { }
3001};
3002#endif
3003
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004/*
3005 */
3006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003007static const char *alc880_models[ALC880_MODEL_LAST] = {
3008 [ALC880_3ST] = "3stack",
3009 [ALC880_TCL_S700] = "tcl",
3010 [ALC880_3ST_DIG] = "3stack-digout",
3011 [ALC880_CLEVO] = "clevo",
3012 [ALC880_5ST] = "5stack",
3013 [ALC880_5ST_DIG] = "5stack-digout",
3014 [ALC880_W810] = "w810",
3015 [ALC880_Z71V] = "z71v",
3016 [ALC880_6ST] = "6stack",
3017 [ALC880_6ST_DIG] = "6stack-digout",
3018 [ALC880_ASUS] = "asus",
3019 [ALC880_ASUS_W1V] = "asus-w1v",
3020 [ALC880_ASUS_DIG] = "asus-dig",
3021 [ALC880_ASUS_DIG2] = "asus-dig2",
3022 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003023 [ALC880_UNIWILL_P53] = "uniwill-p53",
3024 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003025 [ALC880_F1734] = "F1734",
3026 [ALC880_LG] = "lg",
3027 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003028 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003029#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003030 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003031#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003032 [ALC880_AUTO] = "auto",
3033};
3034
3035static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003036 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003037 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3038 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3039 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3040 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3041 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3042 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3043 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3044 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003045 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3046 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003047 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3048 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3049 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3050 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3051 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3052 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3053 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3054 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3055 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003057 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003058 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3059 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3060 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003061 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003062 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003063 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3064 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003065 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3066 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003067 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3068 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3069 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3070 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003071 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3072 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003073 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003074 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003075 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003076 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003077 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3078 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003079 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003080 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003081 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003083 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003084 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003085 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003086 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003087 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003088 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3089 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003090 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3092 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3093 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3094 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003095 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3096 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003097 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003098 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003099 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3100 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003101 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3102 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3103 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003104 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3105 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3106 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 {}
3108};
3109
Takashi Iwai16ded522005-06-10 19:58:24 +02003110/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003111 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003113static struct alc_config_preset alc880_presets[] = {
3114 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003116 .init_verbs = { alc880_volume_init_verbs,
3117 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003118 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003120 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3121 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003122 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .input_mux = &alc880_capture_source,
3124 },
3125 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 .dac_nids = alc880_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003134 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .input_mux = &alc880_capture_source,
3136 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003137 [ALC880_TCL_S700] = {
3138 .mixers = { alc880_tcl_s700_mixer },
3139 .init_verbs = { alc880_volume_init_verbs,
3140 alc880_pin_tcl_S700_init_verbs,
3141 alc880_gpio2_init_verbs },
3142 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3143 .dac_nids = alc880_dac_nids,
3144 .hp_nid = 0x03,
3145 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3146 .channel_mode = alc880_2_jack_modes,
3147 .input_mux = &alc880_capture_source,
3148 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003149 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003150 .mixers = { alc880_three_stack_mixer,
3151 alc880_five_stack_mixer},
3152 .init_verbs = { alc880_volume_init_verbs,
3153 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003154 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3155 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003156 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3157 .channel_mode = alc880_fivestack_modes,
3158 .input_mux = &alc880_capture_source,
3159 },
3160 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003161 .mixers = { alc880_three_stack_mixer,
3162 alc880_five_stack_mixer },
3163 .init_verbs = { alc880_volume_init_verbs,
3164 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003165 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3166 .dac_nids = alc880_dac_nids,
3167 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003168 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3169 .channel_mode = alc880_fivestack_modes,
3170 .input_mux = &alc880_capture_source,
3171 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003172 [ALC880_6ST] = {
3173 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003174 .init_verbs = { alc880_volume_init_verbs,
3175 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003176 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3177 .dac_nids = alc880_6st_dac_nids,
3178 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3179 .channel_mode = alc880_sixstack_modes,
3180 .input_mux = &alc880_6stack_capture_source,
3181 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003183 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003184 .init_verbs = { alc880_volume_init_verbs,
3185 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003186 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3187 .dac_nids = alc880_6st_dac_nids,
3188 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003189 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3190 .channel_mode = alc880_sixstack_modes,
3191 .input_mux = &alc880_6stack_capture_source,
3192 },
3193 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003194 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003195 .init_verbs = { alc880_volume_init_verbs,
3196 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003197 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003198 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3199 .dac_nids = alc880_w810_dac_nids,
3200 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003201 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3202 .channel_mode = alc880_w810_modes,
3203 .input_mux = &alc880_capture_source,
3204 },
3205 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003206 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003207 .init_verbs = { alc880_volume_init_verbs,
3208 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003209 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3210 .dac_nids = alc880_z71v_dac_nids,
3211 .dig_out_nid = ALC880_DIGOUT_NID,
3212 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3214 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .input_mux = &alc880_capture_source,
3216 },
3217 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003218 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003219 .init_verbs = { alc880_volume_init_verbs,
3220 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003221 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3222 .dac_nids = alc880_f1734_dac_nids,
3223 .hp_nid = 0x02,
3224 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3225 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003226 .input_mux = &alc880_f1734_capture_source,
3227 .unsol_event = alc880_uniwill_p53_unsol_event,
3228 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003229 },
3230 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003231 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003232 .init_verbs = { alc880_volume_init_verbs,
3233 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003234 alc880_gpio1_init_verbs },
3235 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3236 .dac_nids = alc880_asus_dac_nids,
3237 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3238 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003239 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 .input_mux = &alc880_capture_source,
3241 },
3242 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003244 .init_verbs = { alc880_volume_init_verbs,
3245 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003246 alc880_gpio1_init_verbs },
3247 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3248 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003249 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3251 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003252 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003253 .input_mux = &alc880_capture_source,
3254 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003255 [ALC880_ASUS_DIG2] = {
3256 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003257 .init_verbs = { alc880_volume_init_verbs,
3258 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003259 alc880_gpio2_init_verbs }, /* use GPIO2 */
3260 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3261 .dac_nids = alc880_asus_dac_nids,
3262 .dig_out_nid = ALC880_DIGOUT_NID,
3263 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3264 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003265 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003266 .input_mux = &alc880_capture_source,
3267 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003268 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003270 .init_verbs = { alc880_volume_init_verbs,
3271 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 alc880_gpio1_init_verbs },
3273 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3274 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003275 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3277 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003278 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003279 .input_mux = &alc880_capture_source,
3280 },
3281 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003282 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003283 .init_verbs = { alc880_volume_init_verbs,
3284 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3286 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003287 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3289 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003290 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003291 .input_mux = &alc880_capture_source,
3292 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003293 [ALC880_UNIWILL] = {
3294 .mixers = { alc880_uniwill_mixer },
3295 .init_verbs = { alc880_volume_init_verbs,
3296 alc880_uniwill_init_verbs },
3297 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3298 .dac_nids = alc880_asus_dac_nids,
3299 .dig_out_nid = ALC880_DIGOUT_NID,
3300 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3301 .channel_mode = alc880_threestack_modes,
3302 .need_dac_fix = 1,
3303 .input_mux = &alc880_capture_source,
3304 .unsol_event = alc880_uniwill_unsol_event,
3305 .init_hook = alc880_uniwill_automute,
3306 },
3307 [ALC880_UNIWILL_P53] = {
3308 .mixers = { alc880_uniwill_p53_mixer },
3309 .init_verbs = { alc880_volume_init_verbs,
3310 alc880_uniwill_p53_init_verbs },
3311 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3312 .dac_nids = alc880_asus_dac_nids,
3313 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003314 .channel_mode = alc880_threestack_modes,
3315 .input_mux = &alc880_capture_source,
3316 .unsol_event = alc880_uniwill_p53_unsol_event,
3317 .init_hook = alc880_uniwill_p53_hp_automute,
3318 },
3319 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003320 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003321 alc880_pcbeep_mixer, },
3322 .init_verbs = { alc880_volume_init_verbs,
3323 alc880_uniwill_p53_init_verbs,
3324 alc880_beep_init_verbs },
3325 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3326 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003327 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003328 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3329 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003330 .input_mux = &alc880_capture_source,
3331 .unsol_event = alc880_uniwill_p53_unsol_event,
3332 .init_hook = alc880_uniwill_p53_hp_automute,
3333 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003334 [ALC880_CLEVO] = {
3335 .mixers = { alc880_three_stack_mixer },
3336 .init_verbs = { alc880_volume_init_verbs,
3337 alc880_pin_clevo_init_verbs },
3338 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3339 .dac_nids = alc880_dac_nids,
3340 .hp_nid = 0x03,
3341 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3342 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003343 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003344 .input_mux = &alc880_capture_source,
3345 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003346 [ALC880_LG] = {
3347 .mixers = { alc880_lg_mixer },
3348 .init_verbs = { alc880_volume_init_verbs,
3349 alc880_lg_init_verbs },
3350 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3351 .dac_nids = alc880_lg_dac_nids,
3352 .dig_out_nid = ALC880_DIGOUT_NID,
3353 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3354 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003355 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003356 .input_mux = &alc880_lg_capture_source,
3357 .unsol_event = alc880_lg_unsol_event,
3358 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003359#ifdef CONFIG_SND_HDA_POWER_SAVE
3360 .loopbacks = alc880_lg_loopbacks,
3361#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003362 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003363 [ALC880_LG_LW] = {
3364 .mixers = { alc880_lg_lw_mixer },
3365 .init_verbs = { alc880_volume_init_verbs,
3366 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003367 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003368 .dac_nids = alc880_dac_nids,
3369 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003370 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3371 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003372 .input_mux = &alc880_lg_lw_capture_source,
3373 .unsol_event = alc880_lg_lw_unsol_event,
3374 .init_hook = alc880_lg_lw_automute,
3375 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003376 [ALC880_MEDION_RIM] = {
3377 .mixers = { alc880_medion_rim_mixer },
3378 .init_verbs = { alc880_volume_init_verbs,
3379 alc880_medion_rim_init_verbs,
3380 alc_gpio2_init_verbs },
3381 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3382 .dac_nids = alc880_dac_nids,
3383 .dig_out_nid = ALC880_DIGOUT_NID,
3384 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3385 .channel_mode = alc880_2_jack_modes,
3386 .input_mux = &alc880_medion_rim_capture_source,
3387 .unsol_event = alc880_medion_rim_unsol_event,
3388 .init_hook = alc880_medion_rim_automute,
3389 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003390#ifdef CONFIG_SND_DEBUG
3391 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003392 .mixers = { alc880_test_mixer },
3393 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003394 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3395 .dac_nids = alc880_test_dac_nids,
3396 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003397 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3398 .channel_mode = alc880_test_modes,
3399 .input_mux = &alc880_test_capture_source,
3400 },
3401#endif
3402};
3403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404/*
3405 * Automatic parse of I/O pins from the BIOS configuration
3406 */
3407
3408#define NUM_CONTROL_ALLOC 32
3409#define NUM_VERB_ALLOC 32
3410
3411enum {
3412 ALC_CTL_WIDGET_VOL,
3413 ALC_CTL_WIDGET_MUTE,
3414 ALC_CTL_BIND_MUTE,
3415};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003416static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003417 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3418 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003419 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420};
3421
3422/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423static int add_control(struct alc_spec *spec, int type, const char *name,
3424 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003425{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003426 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427
3428 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3429 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3430
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003431 /* array + terminator */
3432 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3433 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 return -ENOMEM;
3435 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003436 memcpy(knew, spec->kctl_alloc,
3437 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 kfree(spec->kctl_alloc);
3439 }
3440 spec->kctl_alloc = knew;
3441 spec->num_kctl_alloc = num;
3442 }
3443
3444 knew = &spec->kctl_alloc[spec->num_kctl_used];
3445 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003446 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003447 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448 return -ENOMEM;
3449 knew->private_value = val;
3450 spec->num_kctl_used++;
3451 return 0;
3452}
3453
3454#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3455#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3456#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3457#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3458#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3459#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3460#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3461#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3462#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3463#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3464#define ALC880_PIN_CD_NID 0x1c
3465
3466/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003467static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3468 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003469{
3470 hda_nid_t nid;
3471 int assigned[4];
3472 int i, j;
3473
3474 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003475 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476
3477 /* check the pins hardwired to audio widget */
3478 for (i = 0; i < cfg->line_outs; i++) {
3479 nid = cfg->line_out_pins[i];
3480 if (alc880_is_fixed_pin(nid)) {
3481 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003482 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 assigned[idx] = 1;
3484 }
3485 }
3486 /* left pins can be connect to any audio widget */
3487 for (i = 0; i < cfg->line_outs; i++) {
3488 nid = cfg->line_out_pins[i];
3489 if (alc880_is_fixed_pin(nid))
3490 continue;
3491 /* search for an empty channel */
3492 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003493 if (!assigned[j]) {
3494 spec->multiout.dac_nids[i] =
3495 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003496 assigned[j] = 1;
3497 break;
3498 }
3499 }
3500 }
3501 spec->multiout.num_dacs = cfg->line_outs;
3502 return 0;
3503}
3504
3505/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003506static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3507 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003508{
3509 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003510 static const char *chname[4] = {
3511 "Front", "Surround", NULL /*CLFE*/, "Side"
3512 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 hda_nid_t nid;
3514 int i, err;
3515
3516 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003517 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003518 continue;
3519 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3520 if (i == 2) {
3521 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003522 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3523 "Center Playback Volume",
3524 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3525 HDA_OUTPUT));
3526 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003527 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3529 "LFE Playback Volume",
3530 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3531 HDA_OUTPUT));
3532 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003534 err = add_control(spec, ALC_CTL_BIND_MUTE,
3535 "Center Playback Switch",
3536 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3537 HDA_INPUT));
3538 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003539 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003540 err = add_control(spec, ALC_CTL_BIND_MUTE,
3541 "LFE Playback Switch",
3542 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3543 HDA_INPUT));
3544 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 return err;
3546 } else {
3547 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003548 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3549 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3550 HDA_OUTPUT));
3551 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552 return err;
3553 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003554 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3555 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3556 HDA_INPUT));
3557 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003558 return err;
3559 }
3560 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003561 return 0;
3562}
3563
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003564/* add playback controls for speaker and HP outputs */
3565static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3566 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567{
3568 hda_nid_t nid;
3569 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003570 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003572 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003573 return 0;
3574
3575 if (alc880_is_fixed_pin(pin)) {
3576 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003577 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003578 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003580 else
3581 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003582 /* control HP volume/switch on the output mixer amp */
3583 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003584 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003585 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3586 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3587 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 return err;
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_BIND_MUTE, name,
3591 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 return err;
3594 } else if (alc880_is_multi_pin(pin)) {
3595 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003597 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003598 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3599 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3600 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003601 return err;
3602 }
3603 return 0;
3604}
3605
3606/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003607static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3608 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003609 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003610{
3611 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003612 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613
3614 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003615 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3616 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3617 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618 return err;
3619 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003620 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3621 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3622 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 return err;
3624 return 0;
3625}
3626
3627/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003628static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3629 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003631 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003632 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003633
3634 for (i = 0; i < AUTO_PIN_LAST; i++) {
3635 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003636 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003637 err = new_analog_input(spec, cfg->input_pins[i],
3638 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003639 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640 if (err < 0)
3641 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003642 imux->items[imux->num_items].label =
3643 auto_pin_cfg_labels[i];
3644 imux->items[imux->num_items].index =
3645 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003646 imux->num_items++;
3647 }
3648 }
3649 return 0;
3650}
3651
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003652static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3653 unsigned int pin_type)
3654{
3655 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3656 pin_type);
3657 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003658 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3659 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003660}
3661
Kailang Yangdf694da2005-12-05 19:42:22 +01003662static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3663 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003664 int dac_idx)
3665{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003666 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003667 /* need the manual connection? */
3668 if (alc880_is_multi_pin(nid)) {
3669 struct alc_spec *spec = codec->spec;
3670 int idx = alc880_multi_pin_idx(nid);
3671 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3672 AC_VERB_SET_CONNECT_SEL,
3673 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3674 }
3675}
3676
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003677static int get_pin_type(int line_out_type)
3678{
3679 if (line_out_type == AUTO_PIN_HP_OUT)
3680 return PIN_HP;
3681 else
3682 return PIN_OUT;
3683}
3684
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003685static void alc880_auto_init_multi_out(struct hda_codec *codec)
3686{
3687 struct alc_spec *spec = codec->spec;
3688 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003689
3690 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 for (i = 0; i < spec->autocfg.line_outs; i++) {
3692 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003693 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3694 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003695 }
3696}
3697
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003698static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699{
3700 struct alc_spec *spec = codec->spec;
3701 hda_nid_t pin;
3702
Takashi Iwai82bc9552006-03-21 11:24:42 +01003703 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003704 if (pin) /* connect to front */
3705 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003706 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 if (pin) /* connect to front */
3708 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3709}
3710
3711static void alc880_auto_init_analog_input(struct hda_codec *codec)
3712{
3713 struct alc_spec *spec = codec->spec;
3714 int i;
3715
3716 for (i = 0; i < AUTO_PIN_LAST; i++) {
3717 hda_nid_t nid = spec->autocfg.input_pins[i];
3718 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003719 snd_hda_codec_write(codec, nid, 0,
3720 AC_VERB_SET_PIN_WIDGET_CONTROL,
3721 i <= AUTO_PIN_FRONT_MIC ?
3722 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003723 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724 snd_hda_codec_write(codec, nid, 0,
3725 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726 AMP_OUT_MUTE);
3727 }
3728 }
3729}
3730
3731/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003732/* return 1 if successful, 0 if the proper config is not found,
3733 * or a negative error code
3734 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003735static int alc880_parse_auto_config(struct hda_codec *codec)
3736{
3737 struct alc_spec *spec = codec->spec;
3738 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003739 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003741 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3742 alc880_ignore);
3743 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003745 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003746 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003747
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3749 if (err < 0)
3750 return err;
3751 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3752 if (err < 0)
3753 return err;
3754 err = alc880_auto_create_extra_out(spec,
3755 spec->autocfg.speaker_pins[0],
3756 "Speaker");
3757 if (err < 0)
3758 return err;
3759 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3760 "Headphone");
3761 if (err < 0)
3762 return err;
3763 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3764 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003765 return err;
3766
3767 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3768
3769 if (spec->autocfg.dig_out_pin)
3770 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3771 if (spec->autocfg.dig_in_pin)
3772 spec->dig_in_nid = ALC880_DIGIN_NID;
3773
3774 if (spec->kctl_alloc)
3775 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3776
3777 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3778
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003779 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003780 spec->input_mux = &spec->private_imux;
3781
3782 return 1;
3783}
3784
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003785/* additional initialization for auto-configuration model */
3786static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003788 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003789 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003790 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003792 if (spec->unsol_event)
3793 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003794}
3795
3796/*
3797 * OK, here we have finally the patch for ALC880
3798 */
3799
Linus Torvalds1da177e2005-04-16 15:20:36 -07003800static int patch_alc880(struct hda_codec *codec)
3801{
3802 struct alc_spec *spec;
3803 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003804 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003805
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003806 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807 if (spec == NULL)
3808 return -ENOMEM;
3809
3810 codec->spec = spec;
3811
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003812 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3813 alc880_models,
3814 alc880_cfg_tbl);
3815 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003816 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3817 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003818 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003819 }
3820
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003821 if (board_config == ALC880_AUTO) {
3822 /* automatic parse from the BIOS config */
3823 err = alc880_parse_auto_config(codec);
3824 if (err < 0) {
3825 alc_free(codec);
3826 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003827 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003828 printk(KERN_INFO
3829 "hda_codec: Cannot set up configuration "
3830 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003831 board_config = ALC880_3ST;
3832 }
3833 }
3834
Kailang Yangdf694da2005-12-05 19:42:22 +01003835 if (board_config != ALC880_AUTO)
3836 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003837
3838 spec->stream_name_analog = "ALC880 Analog";
3839 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3840 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003841 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842
3843 spec->stream_name_digital = "ALC880 Digital";
3844 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3845 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3846
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003847 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003849 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003850 /* get type */
3851 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 if (wcap != AC_WID_AUD_IN) {
3853 spec->adc_nids = alc880_adc_nids_alt;
3854 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003855 spec->mixers[spec->num_mixers] =
3856 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 spec->num_mixers++;
3858 } else {
3859 spec->adc_nids = alc880_adc_nids;
3860 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3861 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3862 spec->num_mixers++;
3863 }
3864 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003865
Takashi Iwai2134ea42008-01-10 16:53:55 +01003866 spec->vmaster_nid = 0x0c;
3867
Linus Torvalds1da177e2005-04-16 15:20:36 -07003868 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003869 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003871#ifdef CONFIG_SND_HDA_POWER_SAVE
3872 if (!spec->loopback.amplist)
3873 spec->loopback.amplist = alc880_loopbacks;
3874#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875
3876 return 0;
3877}
3878
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003879
Linus Torvalds1da177e2005-04-16 15:20:36 -07003880/*
3881 * ALC260 support
3882 */
3883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003884static hda_nid_t alc260_dac_nids[1] = {
3885 /* front */
3886 0x02,
3887};
3888
3889static hda_nid_t alc260_adc_nids[1] = {
3890 /* ADC0 */
3891 0x04,
3892};
3893
Kailang Yangdf694da2005-12-05 19:42:22 +01003894static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003895 /* ADC1 */
3896 0x05,
3897};
3898
Kailang Yangdf694da2005-12-05 19:42:22 +01003899static hda_nid_t alc260_hp_adc_nids[2] = {
3900 /* ADC1, 0 */
3901 0x05, 0x04
3902};
3903
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003904/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3905 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3906 */
3907static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003908 /* ADC0, ADC1 */
3909 0x04, 0x05
3910};
3911
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003912#define ALC260_DIGOUT_NID 0x03
3913#define ALC260_DIGIN_NID 0x06
3914
3915static struct hda_input_mux alc260_capture_source = {
3916 .num_items = 4,
3917 .items = {
3918 { "Mic", 0x0 },
3919 { "Front Mic", 0x1 },
3920 { "Line", 0x2 },
3921 { "CD", 0x4 },
3922 },
3923};
3924
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003925/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003926 * headphone jack and the internal CD lines since these are the only pins at
3927 * which audio can appear. For flexibility, also allow the option of
3928 * recording the mixer output on the second ADC (ADC0 doesn't have a
3929 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003930 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003931static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3932 {
3933 .num_items = 3,
3934 .items = {
3935 { "Mic/Line", 0x0 },
3936 { "CD", 0x4 },
3937 { "Headphone", 0x2 },
3938 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003939 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003940 {
3941 .num_items = 4,
3942 .items = {
3943 { "Mic/Line", 0x0 },
3944 { "CD", 0x4 },
3945 { "Headphone", 0x2 },
3946 { "Mixer", 0x5 },
3947 },
3948 },
3949
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003950};
3951
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003952/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3953 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003954 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003955static struct hda_input_mux alc260_acer_capture_sources[2] = {
3956 {
3957 .num_items = 4,
3958 .items = {
3959 { "Mic", 0x0 },
3960 { "Line", 0x2 },
3961 { "CD", 0x4 },
3962 { "Headphone", 0x5 },
3963 },
3964 },
3965 {
3966 .num_items = 5,
3967 .items = {
3968 { "Mic", 0x0 },
3969 { "Line", 0x2 },
3970 { "CD", 0x4 },
3971 { "Headphone", 0x6 },
3972 { "Mixer", 0x5 },
3973 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003974 },
3975};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003976/*
3977 * This is just place-holder, so there's something for alc_build_pcms to look
3978 * at when it calculates the maximum number of channels. ALC260 has no mixer
3979 * element which allows changing the channel mode, so the verb list is
3980 * never used.
3981 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003982static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003983 { 2, NULL },
3984};
3985
Kailang Yangdf694da2005-12-05 19:42:22 +01003986
3987/* Mixer combinations
3988 *
3989 * basic: base_output + input + pc_beep + capture
3990 * HP: base_output + input + capture_alt
3991 * HP_3013: hp_3013 + input + capture
3992 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003993 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003994 */
3995
3996static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003997 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003998 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4000 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4001 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4002 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4003 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004004};
Kailang Yangdf694da2005-12-05 19:42:22 +01004005
4006static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4008 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4009 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4010 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004015 { } /* end */
4016};
4017
Kailang Yangdf694da2005-12-05 19:42:22 +01004018static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4019 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4020 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4021 { } /* end */
4022};
4023
Takashi Iwaibec15c32008-01-28 18:16:30 +01004024/* update HP, line and mono out pins according to the master switch */
4025static void alc260_hp_master_update(struct hda_codec *codec,
4026 hda_nid_t hp, hda_nid_t line,
4027 hda_nid_t mono)
4028{
4029 struct alc_spec *spec = codec->spec;
4030 unsigned int val = spec->master_sw ? PIN_HP : 0;
4031 /* change HP and line-out pins */
4032 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4033 val);
4034 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4035 val);
4036 /* mono (speaker) depending on the HP jack sense */
4037 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4038 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4039 val);
4040}
4041
4042static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4043 struct snd_ctl_elem_value *ucontrol)
4044{
4045 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4046 struct alc_spec *spec = codec->spec;
4047 *ucontrol->value.integer.value = spec->master_sw;
4048 return 0;
4049}
4050
4051static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4052 struct snd_ctl_elem_value *ucontrol)
4053{
4054 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4055 struct alc_spec *spec = codec->spec;
4056 int val = !!*ucontrol->value.integer.value;
4057 hda_nid_t hp, line, mono;
4058
4059 if (val == spec->master_sw)
4060 return 0;
4061 spec->master_sw = val;
4062 hp = (kcontrol->private_value >> 16) & 0xff;
4063 line = (kcontrol->private_value >> 8) & 0xff;
4064 mono = kcontrol->private_value & 0xff;
4065 alc260_hp_master_update(codec, hp, line, mono);
4066 return 1;
4067}
4068
4069static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4070 {
4071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4072 .name = "Master Playback Switch",
4073 .info = snd_ctl_boolean_mono_info,
4074 .get = alc260_hp_master_sw_get,
4075 .put = alc260_hp_master_sw_put,
4076 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4077 },
4078 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4079 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4080 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4081 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4082 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4083 HDA_OUTPUT),
4084 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4085 { } /* end */
4086};
4087
4088static struct hda_verb alc260_hp_unsol_verbs[] = {
4089 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4090 {},
4091};
4092
4093static void alc260_hp_automute(struct hda_codec *codec)
4094{
4095 struct alc_spec *spec = codec->spec;
4096 unsigned int present;
4097
4098 present = snd_hda_codec_read(codec, 0x10, 0,
4099 AC_VERB_GET_PIN_SENSE, 0);
4100 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4101 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4102}
4103
4104static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4105{
4106 if ((res >> 26) == ALC880_HP_EVENT)
4107 alc260_hp_automute(codec);
4108}
4109
Kailang Yangdf694da2005-12-05 19:42:22 +01004110static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004111 {
4112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4113 .name = "Master Playback Switch",
4114 .info = snd_ctl_boolean_mono_info,
4115 .get = alc260_hp_master_sw_get,
4116 .put = alc260_hp_master_sw_put,
4117 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4118 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004119 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4120 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4121 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4122 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4123 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004125 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4126 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004127 { } /* end */
4128};
4129
Takashi Iwaibec15c32008-01-28 18:16:30 +01004130static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4131 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4132 {},
4133};
4134
4135static void alc260_hp_3013_automute(struct hda_codec *codec)
4136{
4137 struct alc_spec *spec = codec->spec;
4138 unsigned int present;
4139
4140 present = snd_hda_codec_read(codec, 0x15, 0,
4141 AC_VERB_GET_PIN_SENSE, 0);
4142 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4143 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4144}
4145
4146static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4147 unsigned int res)
4148{
4149 if ((res >> 26) == ALC880_HP_EVENT)
4150 alc260_hp_3013_automute(codec);
4151}
4152
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004153/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4154 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4155 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004156static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004157 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004158 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004159 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004160 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4161 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4162 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4163 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004164 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004165 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4166 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4168 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004169 { } /* end */
4170};
4171
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004172/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4173 * versions of the ALC260 don't act on requests to enable mic bias from NID
4174 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4175 * datasheet doesn't mention this restriction. At this stage it's not clear
4176 * whether this behaviour is intentional or is a hardware bug in chip
4177 * revisions available in early 2006. Therefore for now allow the
4178 * "Headphone Jack Mode" control to span all choices, but if it turns out
4179 * that the lack of mic bias for this NID is intentional we could change the
4180 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4181 *
4182 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4183 * don't appear to make the mic bias available from the "line" jack, even
4184 * though the NID used for this jack (0x14) can supply it. The theory is
4185 * that perhaps Acer have included blocking capacitors between the ALC260
4186 * and the output jack. If this turns out to be the case for all such
4187 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4188 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004189 *
4190 * The C20x Tablet series have a mono internal speaker which is controlled
4191 * via the chip's Mono sum widget and pin complex, so include the necessary
4192 * controls for such models. On models without a "mono speaker" the control
4193 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004194 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004195static struct snd_kcontrol_new alc260_acer_mixer[] = {
4196 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4197 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004198 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004199 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004200 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004201 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004202 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004203 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4204 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4206 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4207 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4208 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4209 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4210 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4211 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4212 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4213 { } /* end */
4214};
4215
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004216/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4217 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4218 */
4219static struct snd_kcontrol_new alc260_will_mixer[] = {
4220 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4221 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4223 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4224 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4225 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4226 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4227 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4228 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4229 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4230 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4231 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4232 { } /* end */
4233};
4234
4235/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4236 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4237 */
4238static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4239 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4240 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4242 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4243 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4244 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4245 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4246 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4247 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4248 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4249 { } /* end */
4250};
4251
Kailang Yangdf694da2005-12-05 19:42:22 +01004252/* capture mixer elements */
4253static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004254 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4255 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004256 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4257 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004258 {
4259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004260 /* The multiple "Capture Source" controls confuse alsamixer
4261 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004262 */
4263 /* .name = "Capture Source", */
4264 .name = "Input Source",
4265 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004266 .info = alc_mux_enum_info,
4267 .get = alc_mux_enum_get,
4268 .put = alc_mux_enum_put,
4269 },
4270 { } /* end */
4271};
4272
Kailang Yangdf694da2005-12-05 19:42:22 +01004273static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4274 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4275 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4276 {
4277 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4278 /* The multiple "Capture Source" controls confuse alsamixer
4279 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004280 */
4281 /* .name = "Capture Source", */
4282 .name = "Input Source",
4283 .count = 1,
4284 .info = alc_mux_enum_info,
4285 .get = alc_mux_enum_get,
4286 .put = alc_mux_enum_put,
4287 },
4288 { } /* end */
4289};
4290
4291/*
4292 * initialization verbs
4293 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004294static struct hda_verb alc260_init_verbs[] = {
4295 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004297 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004299 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004300 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004302 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004305 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004306 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004308 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004309 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004310 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004311 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004312 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4313 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004315 /* set connection select to line in (default select for this ADC) */
4316 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004317 /* mute capture amp left and right */
4318 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4319 /* set connection select to line in (default select for this ADC) */
4320 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004321 /* set vol=0 Line-Out mixer amp left and right */
4322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4323 /* unmute pin widget amp left and right (no gain on this amp) */
4324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4325 /* set vol=0 HP mixer amp left and right */
4326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4327 /* unmute pin widget amp left and right (no gain on this amp) */
4328 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4329 /* set vol=0 Mono mixer amp left and right */
4330 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4331 /* unmute pin widget amp left and right (no gain on this amp) */
4332 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4333 /* unmute LINE-2 out pin */
4334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004335 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4336 * Line In 2 = 0x03
4337 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004338 /* mute analog inputs */
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004344 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004345 /* mute Front out path */
4346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4348 /* mute Headphone out path */
4349 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4351 /* mute Mono out path */
4352 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4353 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354 { }
4355};
4356
Takashi Iwai474167d2006-05-17 17:17:43 +02004357#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004358static struct hda_verb alc260_hp_init_verbs[] = {
4359 /* Headphone and output */
4360 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4361 /* mono output */
4362 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4363 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4364 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4365 /* Mic2 (front panel) pin widget for input and vref at 80% */
4366 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4367 /* Line In pin widget for input */
4368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4369 /* Line-2 pin widget for output */
4370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4371 /* CD pin widget for input */
4372 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4373 /* unmute amp left and right */
4374 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4375 /* set connection select to line in (default select for this ADC) */
4376 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4377 /* unmute Line-Out mixer amp left and right (volume = 0) */
4378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4379 /* mute pin widget amp left and right (no gain on this amp) */
4380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4381 /* unmute HP mixer amp left and right (volume = 0) */
4382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4383 /* mute pin widget amp left and right (no gain on this amp) */
4384 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4386 * Line In 2 = 0x03
4387 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004388 /* mute analog inputs */
4389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004394 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4395 /* Unmute Front out path */
4396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4398 /* Unmute Headphone out path */
4399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4401 /* Unmute Mono out path */
4402 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4404 { }
4405};
Takashi Iwai474167d2006-05-17 17:17:43 +02004406#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004407
4408static struct hda_verb alc260_hp_3013_init_verbs[] = {
4409 /* Line out and output */
4410 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4411 /* mono output */
4412 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4413 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4414 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4415 /* Mic2 (front panel) pin widget for input and vref at 80% */
4416 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4417 /* Line In pin widget for input */
4418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4419 /* Headphone pin widget for output */
4420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4421 /* CD pin widget for input */
4422 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4423 /* unmute amp left and right */
4424 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4425 /* set connection select to line in (default select for this ADC) */
4426 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4427 /* unmute Line-Out mixer amp left and right (volume = 0) */
4428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4429 /* mute pin widget amp left and right (no gain on this amp) */
4430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4431 /* unmute HP mixer amp left and right (volume = 0) */
4432 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4433 /* mute pin widget amp left and right (no gain on this amp) */
4434 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004435 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4436 * Line In 2 = 0x03
4437 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004438 /* mute analog inputs */
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004444 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4445 /* Unmute Front out path */
4446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4448 /* Unmute Headphone out path */
4449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4451 /* Unmute Mono out path */
4452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4454 { }
4455};
4456
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004457/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004458 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4459 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004460 */
4461static struct hda_verb alc260_fujitsu_init_verbs[] = {
4462 /* Disable all GPIOs */
4463 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4464 /* Internal speaker is connected to headphone pin */
4465 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4466 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004468 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4469 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4470 /* Ensure all other unused pins are disabled and muted. */
4471 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004473 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004474 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004475 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004476 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004479
Jonathan Woithef7ace402006-02-28 11:46:14 +01004480 /* Disable digital (SPDIF) pins */
4481 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4482 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004483
Jonathan Woithef7ace402006-02-28 11:46:14 +01004484 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4485 * when acting as an output.
4486 */
4487 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4488
4489 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4496 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4497 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4498 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004499
Jonathan Woithef7ace402006-02-28 11:46:14 +01004500 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4501 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4502 /* Unmute Line1 pin widget output buffer since it starts as an output.
4503 * If the pin mode is changed by the user the pin mode control will
4504 * take care of enabling the pin's input/output buffers as needed.
4505 * Therefore there's no need to enable the input buffer at this
4506 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004507 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004509 /* Unmute input buffer of pin widget used for Line-in (no equiv
4510 * mixer ctrl)
4511 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004512 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004513
Jonathan Woithef7ace402006-02-28 11:46:14 +01004514 /* Mute capture amp left and right */
4515 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4516 /* Set ADC connection select to match default mixer setting - line
4517 * in (on mic1 pin)
4518 */
4519 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004520
Jonathan Woithef7ace402006-02-28 11:46:14 +01004521 /* Do the same for the second ADC: mute capture input amp and
4522 * set ADC connection to line in (on mic1 pin)
4523 */
4524 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4525 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004526
Jonathan Woithef7ace402006-02-28 11:46:14 +01004527 /* Mute all inputs to mixer widget (even unconnected ones) */
4528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004536
4537 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004538};
4539
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004540/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4541 * similar laptops (adapted from Fujitsu init verbs).
4542 */
4543static struct hda_verb alc260_acer_init_verbs[] = {
4544 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4545 * the headphone jack. Turn this on and rely on the standard mute
4546 * methods whenever the user wants to turn these outputs off.
4547 */
4548 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4549 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4550 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4551 /* Internal speaker/Headphone jack is connected to Line-out pin */
4552 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4553 /* Internal microphone/Mic jack is connected to Mic1 pin */
4554 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4555 /* Line In jack is connected to Line1 pin */
4556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004557 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4558 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004559 /* Ensure all other unused pins are disabled and muted. */
4560 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4561 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004562 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4563 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4564 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4566 /* Disable digital (SPDIF) pins */
4567 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4568 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4569
4570 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4571 * bus when acting as outputs.
4572 */
4573 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4574 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4575
4576 /* Start with output sum widgets muted and their output gains at min */
4577 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4579 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4582 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4583 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4584 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4585 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4586
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004587 /* Unmute Line-out pin widget amp left and right
4588 * (no equiv mixer ctrl)
4589 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004591 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4592 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004593 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4594 * inputs. If the pin mode is changed by the user the pin mode control
4595 * will take care of enabling the pin's input/output buffers as needed.
4596 * Therefore there's no need to enable the input buffer at this
4597 * stage.
4598 */
4599 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4601
4602 /* Mute capture amp left and right */
4603 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4604 /* Set ADC connection select to match default mixer setting - mic
4605 * (on mic1 pin)
4606 */
4607 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4608
4609 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004610 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004611 */
4612 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004613 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004614
4615 /* Mute all inputs to mixer widget (even unconnected ones) */
4616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4624
4625 { }
4626};
4627
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004628static struct hda_verb alc260_will_verbs[] = {
4629 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4630 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4631 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4632 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4633 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4634 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4635 {}
4636};
4637
4638static struct hda_verb alc260_replacer_672v_verbs[] = {
4639 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4640 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4641 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4642
4643 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4645 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4646
4647 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4648 {}
4649};
4650
4651/* toggle speaker-output according to the hp-jack state */
4652static void alc260_replacer_672v_automute(struct hda_codec *codec)
4653{
4654 unsigned int present;
4655
4656 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4657 present = snd_hda_codec_read(codec, 0x0f, 0,
4658 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4659 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004660 snd_hda_codec_write_cache(codec, 0x01, 0,
4661 AC_VERB_SET_GPIO_DATA, 1);
4662 snd_hda_codec_write_cache(codec, 0x0f, 0,
4663 AC_VERB_SET_PIN_WIDGET_CONTROL,
4664 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004665 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004666 snd_hda_codec_write_cache(codec, 0x01, 0,
4667 AC_VERB_SET_GPIO_DATA, 0);
4668 snd_hda_codec_write_cache(codec, 0x0f, 0,
4669 AC_VERB_SET_PIN_WIDGET_CONTROL,
4670 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004671 }
4672}
4673
4674static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4675 unsigned int res)
4676{
4677 if ((res >> 26) == ALC880_HP_EVENT)
4678 alc260_replacer_672v_automute(codec);
4679}
4680
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004681/* Test configuration for debugging, modelled after the ALC880 test
4682 * configuration.
4683 */
4684#ifdef CONFIG_SND_DEBUG
4685static hda_nid_t alc260_test_dac_nids[1] = {
4686 0x02,
4687};
4688static hda_nid_t alc260_test_adc_nids[2] = {
4689 0x04, 0x05,
4690};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004691/* For testing the ALC260, each input MUX needs its own definition since
4692 * the signal assignments are different. This assumes that the first ADC
4693 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004694 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004695static struct hda_input_mux alc260_test_capture_sources[2] = {
4696 {
4697 .num_items = 7,
4698 .items = {
4699 { "MIC1 pin", 0x0 },
4700 { "MIC2 pin", 0x1 },
4701 { "LINE1 pin", 0x2 },
4702 { "LINE2 pin", 0x3 },
4703 { "CD pin", 0x4 },
4704 { "LINE-OUT pin", 0x5 },
4705 { "HP-OUT pin", 0x6 },
4706 },
4707 },
4708 {
4709 .num_items = 8,
4710 .items = {
4711 { "MIC1 pin", 0x0 },
4712 { "MIC2 pin", 0x1 },
4713 { "LINE1 pin", 0x2 },
4714 { "LINE2 pin", 0x3 },
4715 { "CD pin", 0x4 },
4716 { "Mixer", 0x5 },
4717 { "LINE-OUT pin", 0x6 },
4718 { "HP-OUT pin", 0x7 },
4719 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004720 },
4721};
4722static struct snd_kcontrol_new alc260_test_mixer[] = {
4723 /* Output driver widgets */
4724 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4725 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4726 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4727 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4728 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4729 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4730
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004731 /* Modes for retasking pin widgets
4732 * Note: the ALC260 doesn't seem to act on requests to enable mic
4733 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4734 * mention this restriction. At this stage it's not clear whether
4735 * this behaviour is intentional or is a hardware bug in chip
4736 * revisions available at least up until early 2006. Therefore for
4737 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4738 * choices, but if it turns out that the lack of mic bias for these
4739 * NIDs is intentional we could change their modes from
4740 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4741 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004742 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4743 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4744 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4745 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4746 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4747 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4748
4749 /* Loopback mixer controls */
4750 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4751 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4752 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4753 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4754 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4755 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4756 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4757 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4758 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4759 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4760 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4761 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4762 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4763 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4764 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4765 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004766
4767 /* Controls for GPIO pins, assuming they are configured as outputs */
4768 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4769 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4770 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4771 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4772
Jonathan Woithe92621f12006-02-28 11:47:47 +01004773 /* Switches to allow the digital IO pins to be enabled. The datasheet
4774 * is ambigious as to which NID is which; testing on laptops which
4775 * make this output available should provide clarification.
4776 */
4777 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4778 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4779
Jonathan Woithef8225f62008-01-08 12:16:54 +01004780 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4781 * this output to turn on an external amplifier.
4782 */
4783 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4784 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4785
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004786 { } /* end */
4787};
4788static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004789 /* Enable all GPIOs as outputs with an initial value of 0 */
4790 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4791 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4792 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4793
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004794 /* Enable retasking pins as output, initially without power amp */
4795 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4796 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4799 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4800 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4801
Jonathan Woithe92621f12006-02-28 11:47:47 +01004802 /* Disable digital (SPDIF) pins initially, but users can enable
4803 * them via a mixer switch. In the case of SPDIF-out, this initverb
4804 * payload also sets the generation to 0, output to be in "consumer"
4805 * PCM format, copyright asserted, no pre-emphasis and no validity
4806 * control.
4807 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004808 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4809 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4810
Jonathan Woithef7ace402006-02-28 11:46:14 +01004811 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004812 * OUT1 sum bus when acting as an output.
4813 */
4814 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4815 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4816 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4817 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4818
4819 /* Start with output sum widgets muted and their output gains at min */
4820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4823 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4826 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4827 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4828 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4829
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004830 /* Unmute retasking pin widget output buffers since the default
4831 * state appears to be output. As the pin mode is changed by the
4832 * user the pin mode control will take care of enabling the pin's
4833 * input/output buffers as needed.
4834 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004835 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4839 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4840 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4841 /* Also unmute the mono-out pin widget */
4842 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4843
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004844 /* Mute capture amp left and right */
4845 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004846 /* Set ADC connection select to match default mixer setting (mic1
4847 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004848 */
4849 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4850
4851 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004852 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004853 */
4854 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4855 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4856
4857 /* Mute all inputs to mixer widget (even unconnected ones) */
4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4862 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4866
4867 { }
4868};
4869#endif
4870
Takashi Iwai63300792008-01-24 15:31:36 +01004871#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4872#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004873
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004874#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4875#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4876
Kailang Yangdf694da2005-12-05 19:42:22 +01004877/*
4878 * for BIOS auto-configuration
4879 */
4880
4881static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4882 const char *pfx)
4883{
4884 hda_nid_t nid_vol;
4885 unsigned long vol_val, sw_val;
4886 char name[32];
4887 int err;
4888
4889 if (nid >= 0x0f && nid < 0x11) {
4890 nid_vol = nid - 0x7;
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 if (nid == 0x11) {
4894 nid_vol = nid - 0x7;
4895 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4896 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4897 } else if (nid >= 0x12 && nid <= 0x15) {
4898 nid_vol = 0x08;
4899 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4900 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4901 } else
4902 return 0; /* N/A */
4903
4904 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004905 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4906 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004907 return err;
4908 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004909 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4910 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004911 return err;
4912 return 1;
4913}
4914
4915/* add playback controls from the parsed DAC table */
4916static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4917 const struct auto_pin_cfg *cfg)
4918{
4919 hda_nid_t nid;
4920 int err;
4921
4922 spec->multiout.num_dacs = 1;
4923 spec->multiout.dac_nids = spec->private_dac_nids;
4924 spec->multiout.dac_nids[0] = 0x02;
4925
4926 nid = cfg->line_out_pins[0];
4927 if (nid) {
4928 err = alc260_add_playback_controls(spec, nid, "Front");
4929 if (err < 0)
4930 return err;
4931 }
4932
Takashi Iwai82bc9552006-03-21 11:24:42 +01004933 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 if (nid) {
4935 err = alc260_add_playback_controls(spec, nid, "Speaker");
4936 if (err < 0)
4937 return err;
4938 }
4939
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004940 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004941 if (nid) {
4942 err = alc260_add_playback_controls(spec, nid, "Headphone");
4943 if (err < 0)
4944 return err;
4945 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004946 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004947}
4948
4949/* create playback/capture controls for input pins */
4950static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4951 const struct auto_pin_cfg *cfg)
4952{
Kailang Yangdf694da2005-12-05 19:42:22 +01004953 struct hda_input_mux *imux = &spec->private_imux;
4954 int i, err, idx;
4955
4956 for (i = 0; i < AUTO_PIN_LAST; i++) {
4957 if (cfg->input_pins[i] >= 0x12) {
4958 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004959 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004960 auto_pin_cfg_labels[i], idx,
4961 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004962 if (err < 0)
4963 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004964 imux->items[imux->num_items].label =
4965 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004966 imux->items[imux->num_items].index = idx;
4967 imux->num_items++;
4968 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004969 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004970 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004971 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004972 auto_pin_cfg_labels[i], idx,
4973 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004974 if (err < 0)
4975 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004976 imux->items[imux->num_items].label =
4977 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004978 imux->items[imux->num_items].index = idx;
4979 imux->num_items++;
4980 }
4981 }
4982 return 0;
4983}
4984
4985static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4986 hda_nid_t nid, int pin_type,
4987 int sel_idx)
4988{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004989 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004990 /* need the manual connection? */
4991 if (nid >= 0x12) {
4992 int idx = nid - 0x12;
4993 snd_hda_codec_write(codec, idx + 0x0b, 0,
4994 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004995 }
4996}
4997
4998static void alc260_auto_init_multi_out(struct hda_codec *codec)
4999{
5000 struct alc_spec *spec = codec->spec;
5001 hda_nid_t nid;
5002
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005003 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005004 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005005 if (nid) {
5006 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5007 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5008 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005009
Takashi Iwai82bc9552006-03-21 11:24:42 +01005010 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005011 if (nid)
5012 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5013
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005014 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005015 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005016 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005017}
Kailang Yangdf694da2005-12-05 19:42:22 +01005018
5019#define ALC260_PIN_CD_NID 0x16
5020static void alc260_auto_init_analog_input(struct hda_codec *codec)
5021{
5022 struct alc_spec *spec = codec->spec;
5023 int i;
5024
5025 for (i = 0; i < AUTO_PIN_LAST; i++) {
5026 hda_nid_t nid = spec->autocfg.input_pins[i];
5027 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005028 snd_hda_codec_write(codec, nid, 0,
5029 AC_VERB_SET_PIN_WIDGET_CONTROL,
5030 i <= AUTO_PIN_FRONT_MIC ?
5031 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005032 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005033 snd_hda_codec_write(codec, nid, 0,
5034 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005035 AMP_OUT_MUTE);
5036 }
5037 }
5038}
5039
5040/*
5041 * generic initialization of ADC, input mixers and output mixers
5042 */
5043static struct hda_verb alc260_volume_init_verbs[] = {
5044 /*
5045 * Unmute ADC0-1 and set the default input to mic-in
5046 */
5047 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5048 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5049 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5050 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5051
5052 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5053 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005054 * Note: PASD motherboards uses the Line In 2 as the input for
5055 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005056 */
5057 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005058 /* mute analog inputs */
5059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005064
5065 /*
5066 * Set up output mixers (0x08 - 0x0a)
5067 */
5068 /* set vol=0 to output mixers */
5069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5072 /* set up input amps for analog loopback */
5073 /* Amp Indices: DAC = 0, mixer = 1 */
5074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5077 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5080
5081 { }
5082};
5083
5084static int alc260_parse_auto_config(struct hda_codec *codec)
5085{
5086 struct alc_spec *spec = codec->spec;
5087 unsigned int wcap;
5088 int err;
5089 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5090
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005091 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5092 alc260_ignore);
5093 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005094 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5096 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005097 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005098 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005099 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005100 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5101 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005102 return err;
5103
5104 spec->multiout.max_channels = 2;
5105
5106 if (spec->autocfg.dig_out_pin)
5107 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5108 if (spec->kctl_alloc)
5109 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5110
5111 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5112
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005113 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005114 spec->input_mux = &spec->private_imux;
5115
5116 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005117 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005118 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005119 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005120 spec->adc_nids = alc260_adc_nids_alt;
5121 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5122 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005123 } else {
5124 spec->adc_nids = alc260_adc_nids;
5125 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5126 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005127 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005128 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005129
5130 return 1;
5131}
5132
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005133/* additional initialization for auto-configuration model */
5134static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005135{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005136 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005137 alc260_auto_init_multi_out(codec);
5138 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005139 if (spec->unsol_event)
5140 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005141}
5142
Takashi Iwaicb53c622007-08-10 17:21:45 +02005143#ifdef CONFIG_SND_HDA_POWER_SAVE
5144static struct hda_amp_list alc260_loopbacks[] = {
5145 { 0x07, HDA_INPUT, 0 },
5146 { 0x07, HDA_INPUT, 1 },
5147 { 0x07, HDA_INPUT, 2 },
5148 { 0x07, HDA_INPUT, 3 },
5149 { 0x07, HDA_INPUT, 4 },
5150 { } /* end */
5151};
5152#endif
5153
Kailang Yangdf694da2005-12-05 19:42:22 +01005154/*
5155 * ALC260 configurations
5156 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005157static const char *alc260_models[ALC260_MODEL_LAST] = {
5158 [ALC260_BASIC] = "basic",
5159 [ALC260_HP] = "hp",
5160 [ALC260_HP_3013] = "hp-3013",
5161 [ALC260_FUJITSU_S702X] = "fujitsu",
5162 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005163 [ALC260_WILL] = "will",
5164 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005165#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005166 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005167#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005168 [ALC260_AUTO] = "auto",
5169};
5170
5171static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005172 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005173 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005174 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005175 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005176 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005177 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005178 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5179 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5180 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5181 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5182 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5183 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5184 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5185 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5186 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5187 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005188 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005189 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005190 {}
5191};
5192
Kailang Yangdf694da2005-12-05 19:42:22 +01005193static struct alc_config_preset alc260_presets[] = {
5194 [ALC260_BASIC] = {
5195 .mixers = { alc260_base_output_mixer,
5196 alc260_input_mixer,
5197 alc260_pc_beep_mixer,
5198 alc260_capture_mixer },
5199 .init_verbs = { alc260_init_verbs },
5200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5201 .dac_nids = alc260_dac_nids,
5202 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5203 .adc_nids = alc260_adc_nids,
5204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5205 .channel_mode = alc260_modes,
5206 .input_mux = &alc260_capture_source,
5207 },
5208 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005209 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005210 alc260_input_mixer,
5211 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005212 .init_verbs = { alc260_init_verbs,
5213 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005214 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5215 .dac_nids = alc260_dac_nids,
5216 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5217 .adc_nids = alc260_hp_adc_nids,
5218 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5219 .channel_mode = alc260_modes,
5220 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005221 .unsol_event = alc260_hp_unsol_event,
5222 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005223 },
5224 [ALC260_HP_3013] = {
5225 .mixers = { alc260_hp_3013_mixer,
5226 alc260_input_mixer,
5227 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005228 .init_verbs = { alc260_hp_3013_init_verbs,
5229 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005230 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5231 .dac_nids = alc260_dac_nids,
5232 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5233 .adc_nids = alc260_hp_adc_nids,
5234 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5235 .channel_mode = alc260_modes,
5236 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005237 .unsol_event = alc260_hp_3013_unsol_event,
5238 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005239 },
5240 [ALC260_FUJITSU_S702X] = {
5241 .mixers = { alc260_fujitsu_mixer,
5242 alc260_capture_mixer },
5243 .init_verbs = { alc260_fujitsu_init_verbs },
5244 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5245 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005246 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5247 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005248 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5249 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005250 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5251 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005252 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005253 [ALC260_ACER] = {
5254 .mixers = { alc260_acer_mixer,
5255 alc260_capture_mixer },
5256 .init_verbs = { alc260_acer_init_verbs },
5257 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5258 .dac_nids = alc260_dac_nids,
5259 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5260 .adc_nids = alc260_dual_adc_nids,
5261 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5262 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005263 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5264 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005265 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005266 [ALC260_WILL] = {
5267 .mixers = { alc260_will_mixer,
5268 alc260_capture_mixer },
5269 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5270 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5271 .dac_nids = alc260_dac_nids,
5272 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5273 .adc_nids = alc260_adc_nids,
5274 .dig_out_nid = ALC260_DIGOUT_NID,
5275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5276 .channel_mode = alc260_modes,
5277 .input_mux = &alc260_capture_source,
5278 },
5279 [ALC260_REPLACER_672V] = {
5280 .mixers = { alc260_replacer_672v_mixer,
5281 alc260_capture_mixer },
5282 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5283 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5284 .dac_nids = alc260_dac_nids,
5285 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5286 .adc_nids = alc260_adc_nids,
5287 .dig_out_nid = ALC260_DIGOUT_NID,
5288 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5289 .channel_mode = alc260_modes,
5290 .input_mux = &alc260_capture_source,
5291 .unsol_event = alc260_replacer_672v_unsol_event,
5292 .init_hook = alc260_replacer_672v_automute,
5293 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005294#ifdef CONFIG_SND_DEBUG
5295 [ALC260_TEST] = {
5296 .mixers = { alc260_test_mixer,
5297 alc260_capture_mixer },
5298 .init_verbs = { alc260_test_init_verbs },
5299 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5300 .dac_nids = alc260_test_dac_nids,
5301 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5302 .adc_nids = alc260_test_adc_nids,
5303 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5304 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005305 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5306 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005307 },
5308#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005309};
5310
Linus Torvalds1da177e2005-04-16 15:20:36 -07005311static int patch_alc260(struct hda_codec *codec)
5312{
5313 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005315
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005316 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005317 if (spec == NULL)
5318 return -ENOMEM;
5319
5320 codec->spec = spec;
5321
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005322 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5323 alc260_models,
5324 alc260_cfg_tbl);
5325 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005326 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5327 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005328 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005329 }
5330
Kailang Yangdf694da2005-12-05 19:42:22 +01005331 if (board_config == ALC260_AUTO) {
5332 /* automatic parse from the BIOS config */
5333 err = alc260_parse_auto_config(codec);
5334 if (err < 0) {
5335 alc_free(codec);
5336 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005337 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005338 printk(KERN_INFO
5339 "hda_codec: Cannot set up configuration "
5340 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005341 board_config = ALC260_BASIC;
5342 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005344
Kailang Yangdf694da2005-12-05 19:42:22 +01005345 if (board_config != ALC260_AUTO)
5346 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005347
5348 spec->stream_name_analog = "ALC260 Analog";
5349 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5350 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5351
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005352 spec->stream_name_digital = "ALC260 Digital";
5353 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5354 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5355
Takashi Iwai2134ea42008-01-10 16:53:55 +01005356 spec->vmaster_nid = 0x08;
5357
Linus Torvalds1da177e2005-04-16 15:20:36 -07005358 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005359 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005360 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005361#ifdef CONFIG_SND_HDA_POWER_SAVE
5362 if (!spec->loopback.amplist)
5363 spec->loopback.amplist = alc260_loopbacks;
5364#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365
5366 return 0;
5367}
5368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005369
Linus Torvalds1da177e2005-04-16 15:20:36 -07005370/*
5371 * ALC882 support
5372 *
5373 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5374 * configuration. Each pin widget can choose any input DACs and a mixer.
5375 * Each ADC is connected from a mixer of all inputs. This makes possible
5376 * 6-channel independent captures.
5377 *
5378 * In addition, an independent DAC for the multi-playback (not used in this
5379 * driver yet).
5380 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005381#define ALC882_DIGOUT_NID 0x06
5382#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005383
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005384static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005385 { 8, NULL }
5386};
5387
5388static hda_nid_t alc882_dac_nids[4] = {
5389 /* front, rear, clfe, rear_surr */
5390 0x02, 0x03, 0x04, 0x05
5391};
5392
Kailang Yangdf694da2005-12-05 19:42:22 +01005393/* identical with ALC880 */
5394#define alc882_adc_nids alc880_adc_nids
5395#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005396
Takashi Iwaie1406342008-02-11 18:32:32 +01005397static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5398static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5399
Linus Torvalds1da177e2005-04-16 15:20:36 -07005400/* input MUX */
5401/* FIXME: should be a matrix-type input source selection */
5402
5403static struct hda_input_mux alc882_capture_source = {
5404 .num_items = 4,
5405 .items = {
5406 { "Mic", 0x0 },
5407 { "Front Mic", 0x1 },
5408 { "Line", 0x2 },
5409 { "CD", 0x4 },
5410 },
5411};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005412#define alc882_mux_enum_info alc_mux_enum_info
5413#define alc882_mux_enum_get alc_mux_enum_get
5414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005415static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5416 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005417{
5418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5419 struct alc_spec *spec = codec->spec;
5420 const struct hda_input_mux *imux = spec->input_mux;
5421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005422 hda_nid_t nid = spec->capsrc_nids ?
5423 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005424 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5425 unsigned int i, idx;
5426
5427 idx = ucontrol->value.enumerated.item[0];
5428 if (idx >= imux->num_items)
5429 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005430 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005431 return 0;
5432 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005433 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5434 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005435 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005436 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005437 }
5438 *cur_val = idx;
5439 return 1;
5440}
5441
Kailang Yangdf694da2005-12-05 19:42:22 +01005442/*
Kailang Yang272a5272007-05-14 11:00:38 +02005443 * 2ch mode
5444 */
5445static struct hda_verb alc882_3ST_ch2_init[] = {
5446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5450 { } /* end */
5451};
5452
5453/*
5454 * 6ch mode
5455 */
5456static struct hda_verb alc882_3ST_ch6_init[] = {
5457 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5458 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5459 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5462 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5463 { } /* end */
5464};
5465
5466static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5467 { 2, alc882_3ST_ch2_init },
5468 { 6, alc882_3ST_ch6_init },
5469};
5470
5471/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005472 * 6ch mode
5473 */
5474static struct hda_verb alc882_sixstack_ch6_init[] = {
5475 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5476 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5477 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5478 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5479 { } /* end */
5480};
5481
5482/*
5483 * 8ch mode
5484 */
5485static struct hda_verb alc882_sixstack_ch8_init[] = {
5486 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5487 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5488 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5489 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5490 { } /* end */
5491};
5492
5493static struct hda_channel_mode alc882_sixstack_modes[2] = {
5494 { 6, alc882_sixstack_ch6_init },
5495 { 8, alc882_sixstack_ch8_init },
5496};
5497
Takashi Iwai87350ad2007-08-16 18:19:38 +02005498/*
5499 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5500 */
5501
5502/*
5503 * 2ch mode
5504 */
5505static struct hda_verb alc885_mbp_ch2_init[] = {
5506 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5507 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 { } /* end */
5510};
5511
5512/*
5513 * 6ch mode
5514 */
5515static struct hda_verb alc885_mbp_ch6_init[] = {
5516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5517 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5518 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5519 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5520 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5521 { } /* end */
5522};
5523
5524static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5525 { 2, alc885_mbp_ch2_init },
5526 { 6, alc885_mbp_ch6_init },
5527};
5528
5529
Linus Torvalds1da177e2005-04-16 15:20:36 -07005530/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5531 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5532 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005533static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005534 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005535 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005536 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005537 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005538 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5539 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005540 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5541 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005542 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005543 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5547 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5548 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5552 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005553 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005554 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5555 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5556 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557 { } /* end */
5558};
5559
Takashi Iwai87350ad2007-08-16 18:19:38 +02005560static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005561 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5562 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5563 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5564 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5565 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5566 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5568 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005569 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005570 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5571 { } /* end */
5572};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005573static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5574 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5575 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5581 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5582 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5583 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5584 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5585 { } /* end */
5586};
5587
Kailang Yang272a5272007-05-14 11:00:38 +02005588static struct snd_kcontrol_new alc882_targa_mixer[] = {
5589 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5590 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5592 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5593 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5594 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5595 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005598 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005601 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005602 { } /* end */
5603};
5604
5605/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5606 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5607 */
5608static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5610 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5612 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5615 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5616 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5617 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5618 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005621 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005622 { } /* end */
5623};
5624
Takashi Iwai914759b2007-09-06 14:52:04 +02005625static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5636 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5637 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5638 { } /* end */
5639};
5640
Kailang Yangdf694da2005-12-05 19:42:22 +01005641static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5642 {
5643 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5644 .name = "Channel Mode",
5645 .info = alc_ch_mode_info,
5646 .get = alc_ch_mode_get,
5647 .put = alc_ch_mode_put,
5648 },
5649 { } /* end */
5650};
5651
Linus Torvalds1da177e2005-04-16 15:20:36 -07005652static struct hda_verb alc882_init_verbs[] = {
5653 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005661 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005665 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005666 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5667 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5668 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005670 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005674 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005677 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005678 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005681 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005682 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005685 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005687 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005688 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5689 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005690 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005691 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5692 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005693 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5695 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5698 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005700 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005701
5702 /* FIXME: use matrix-type input source selection */
5703 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5704 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005709 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5711 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5712 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005714 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5719 /* ADC1: mute amp left and right */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005721 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005722 /* ADC2: mute amp left and right */
5723 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005724 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005725 /* ADC3: mute amp left and right */
5726 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005727 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005728
5729 { }
5730};
5731
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005732static struct hda_verb alc882_eapd_verbs[] = {
5733 /* change to EAPD mode */
5734 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005735 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005736 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005737};
5738
Tobin Davis9102cd12006-12-15 10:02:12 +01005739/* Mac Pro test */
5740static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5742 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5744 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5745 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5746 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5747 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5748 { } /* end */
5749};
5750
5751static struct hda_verb alc882_macpro_init_verbs[] = {
5752 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5756 /* Front Pin: output 0 (0x0c) */
5757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5759 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5760 /* Front Mic pin: input vref at 80% */
5761 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5763 /* Speaker: output */
5764 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5765 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5766 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5767 /* Headphone output (output 0 - 0x0c) */
5768 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5769 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5770 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5771
5772 /* FIXME: use matrix-type input source selection */
5773 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5774 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5779 /* Input mixer2 */
5780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5784 /* Input mixer3 */
5785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5789 /* ADC1: mute amp left and right */
5790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5791 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5792 /* ADC2: mute amp left and right */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5794 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5795 /* ADC3: mute amp left and right */
5796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5797 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5798
5799 { }
5800};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005801
Takashi Iwai87350ad2007-08-16 18:19:38 +02005802/* Macbook Pro rev3 */
5803static struct hda_verb alc885_mbp3_init_verbs[] = {
5804 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5808 /* Rear mixer */
5809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5812 /* Front Pin: output 0 (0x0c) */
5813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5814 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5815 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5816 /* HP Pin: output 0 (0x0d) */
5817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5821 /* Mic (rear) pin: input vref at 80% */
5822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5824 /* Front Mic pin: input vref at 80% */
5825 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5827 /* Line In pin: use output 1 when in LineOut mode */
5828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5830 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5831
5832 /* FIXME: use matrix-type input source selection */
5833 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5834 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5839 /* Input mixer2 */
5840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5844 /* Input mixer3 */
5845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5849 /* ADC1: mute amp left and right */
5850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5851 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5852 /* ADC2: mute amp left and right */
5853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5854 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5855 /* ADC3: mute amp left and right */
5856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5857 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5858
5859 { }
5860};
5861
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005862/* iMac 24 mixer. */
5863static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5864 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5865 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5866 { } /* end */
5867};
5868
5869/* iMac 24 init verbs. */
5870static struct hda_verb alc885_imac24_init_verbs[] = {
5871 /* Internal speakers: output 0 (0x0c) */
5872 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5874 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5875 /* Internal speakers: output 0 (0x0c) */
5876 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5878 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5879 /* Headphone: output 0 (0x0c) */
5880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5882 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5884 /* Front Mic: input vref at 80% */
5885 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5886 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5887 { }
5888};
5889
5890/* Toggle speaker-output according to the hp-jack state */
5891static void alc885_imac24_automute(struct hda_codec *codec)
5892{
5893 unsigned int present;
5894
5895 present = snd_hda_codec_read(codec, 0x14, 0,
5896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005897 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5898 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5899 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5900 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005901}
5902
5903/* Processes unsolicited events. */
5904static void alc885_imac24_unsol_event(struct hda_codec *codec,
5905 unsigned int res)
5906{
5907 /* Headphone insertion or removal. */
5908 if ((res >> 26) == ALC880_HP_EVENT)
5909 alc885_imac24_automute(codec);
5910}
5911
Takashi Iwai87350ad2007-08-16 18:19:38 +02005912static void alc885_mbp3_automute(struct hda_codec *codec)
5913{
5914 unsigned int present;
5915
5916 present = snd_hda_codec_read(codec, 0x15, 0,
5917 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5918 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5919 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5920 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5921 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5922
5923}
5924static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5925 unsigned int res)
5926{
5927 /* Headphone insertion or removal. */
5928 if ((res >> 26) == ALC880_HP_EVENT)
5929 alc885_mbp3_automute(codec);
5930}
5931
5932
Kailang Yang272a5272007-05-14 11:00:38 +02005933static struct hda_verb alc882_targa_verbs[] = {
5934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5936
5937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5939
5940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5941 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5943
5944 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5945 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5946 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5947 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5948 { } /* end */
5949};
5950
5951/* toggle speaker-output according to the hp-jack state */
5952static void alc882_targa_automute(struct hda_codec *codec)
5953{
5954 unsigned int present;
5955
5956 present = snd_hda_codec_read(codec, 0x14, 0,
5957 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005958 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5959 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005960 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5961 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005962}
5963
5964static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5965{
5966 /* Looks like the unsol event is incompatible with the standard
5967 * definition. 4bit tag is placed at 26 bit!
5968 */
5969 if (((res >> 26) == ALC880_HP_EVENT)) {
5970 alc882_targa_automute(codec);
5971 }
5972}
5973
5974static struct hda_verb alc882_asus_a7j_verbs[] = {
5975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5977
5978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5980 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5981
5982 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5984 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5985
5986 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5987 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5988 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5989 { } /* end */
5990};
5991
Takashi Iwai914759b2007-09-06 14:52:04 +02005992static struct hda_verb alc882_asus_a7m_verbs[] = {
5993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5995
5996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5999
6000 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6001 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6002 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6003
6004 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6005 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6006 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6007 { } /* end */
6008};
6009
Tobin Davis9102cd12006-12-15 10:02:12 +01006010static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6011{
6012 unsigned int gpiostate, gpiomask, gpiodir;
6013
6014 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6015 AC_VERB_GET_GPIO_DATA, 0);
6016
6017 if (!muted)
6018 gpiostate |= (1 << pin);
6019 else
6020 gpiostate &= ~(1 << pin);
6021
6022 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6023 AC_VERB_GET_GPIO_MASK, 0);
6024 gpiomask |= (1 << pin);
6025
6026 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6027 AC_VERB_GET_GPIO_DIRECTION, 0);
6028 gpiodir |= (1 << pin);
6029
6030
6031 snd_hda_codec_write(codec, codec->afg, 0,
6032 AC_VERB_SET_GPIO_MASK, gpiomask);
6033 snd_hda_codec_write(codec, codec->afg, 0,
6034 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6035
6036 msleep(1);
6037
6038 snd_hda_codec_write(codec, codec->afg, 0,
6039 AC_VERB_SET_GPIO_DATA, gpiostate);
6040}
6041
Takashi Iwai7debbe52007-08-16 15:01:03 +02006042/* set up GPIO at initialization */
6043static void alc885_macpro_init_hook(struct hda_codec *codec)
6044{
6045 alc882_gpio_mute(codec, 0, 0);
6046 alc882_gpio_mute(codec, 1, 0);
6047}
6048
6049/* set up GPIO and update auto-muting at initialization */
6050static void alc885_imac24_init_hook(struct hda_codec *codec)
6051{
6052 alc885_macpro_init_hook(codec);
6053 alc885_imac24_automute(codec);
6054}
6055
Kailang Yangdf694da2005-12-05 19:42:22 +01006056/*
6057 * generic initialization of ADC, input mixers and output mixers
6058 */
6059static struct hda_verb alc882_auto_init_verbs[] = {
6060 /*
6061 * Unmute ADC0-2 and set the default input to mic-in
6062 */
6063 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6065 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6067 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6068 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6069
Takashi Iwaicb53c622007-08-10 17:21:45 +02006070 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006071 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006072 * Note: PASD motherboards uses the Line In 2 as the input for
6073 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 */
6075 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6078 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6079 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006081
6082 /*
6083 * Set up output mixers (0x0c - 0x0f)
6084 */
6085 /* set vol=0 to output mixers */
6086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6090 /* set up input amps for analog loopback */
6091 /* Amp Indices: DAC = 0, mixer = 1 */
6092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6094 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6096 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6098 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6100 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6101 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6102
6103 /* FIXME: use matrix-type input source selection */
6104 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6105 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6110 /* Input mixer2 */
6111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6115 /* Input mixer3 */
6116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6120
6121 { }
6122};
6123
6124/* capture mixer elements */
6125static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6126 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6127 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6128 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6129 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6130 {
6131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6132 /* The multiple "Capture Source" controls confuse alsamixer
6133 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006134 */
6135 /* .name = "Capture Source", */
6136 .name = "Input Source",
6137 .count = 2,
6138 .info = alc882_mux_enum_info,
6139 .get = alc882_mux_enum_get,
6140 .put = alc882_mux_enum_put,
6141 },
6142 { } /* end */
6143};
6144
6145static struct snd_kcontrol_new alc882_capture_mixer[] = {
6146 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6148 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6149 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6150 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6152 {
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 /* The multiple "Capture Source" controls confuse alsamixer
6155 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006156 */
6157 /* .name = "Capture Source", */
6158 .name = "Input Source",
6159 .count = 3,
6160 .info = alc882_mux_enum_info,
6161 .get = alc882_mux_enum_get,
6162 .put = alc882_mux_enum_put,
6163 },
6164 { } /* end */
6165};
6166
Takashi Iwaicb53c622007-08-10 17:21:45 +02006167#ifdef CONFIG_SND_HDA_POWER_SAVE
6168#define alc882_loopbacks alc880_loopbacks
6169#endif
6170
Kailang Yangdf694da2005-12-05 19:42:22 +01006171/* pcm configuration: identiacal with ALC880 */
6172#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6173#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6174#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6175#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6176
6177/*
6178 * configuration and preset
6179 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006180static const char *alc882_models[ALC882_MODEL_LAST] = {
6181 [ALC882_3ST_DIG] = "3stack-dig",
6182 [ALC882_6ST_DIG] = "6stack-dig",
6183 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006184 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006185 [ALC882_TARGA] = "targa",
6186 [ALC882_ASUS_A7J] = "asus-a7j",
6187 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006188 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006189 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006190 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006191 [ALC882_AUTO] = "auto",
6192};
6193
6194static struct snd_pci_quirk alc882_cfg_tbl[] = {
6195 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006196 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006197 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006198 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006199 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006200 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006201 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006202 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006203 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006204 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6205 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6206 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006207 {}
6208};
6209
6210static struct alc_config_preset alc882_presets[] = {
6211 [ALC882_3ST_DIG] = {
6212 .mixers = { alc882_base_mixer },
6213 .init_verbs = { alc882_init_verbs },
6214 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6215 .dac_nids = alc882_dac_nids,
6216 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006217 .dig_in_nid = ALC882_DIGIN_NID,
6218 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6219 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006220 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 .input_mux = &alc882_capture_source,
6222 },
6223 [ALC882_6ST_DIG] = {
6224 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6225 .init_verbs = { alc882_init_verbs },
6226 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6227 .dac_nids = alc882_dac_nids,
6228 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 .dig_in_nid = ALC882_DIGIN_NID,
6230 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6231 .channel_mode = alc882_sixstack_modes,
6232 .input_mux = &alc882_capture_source,
6233 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006234 [ALC882_ARIMA] = {
6235 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6236 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6237 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6238 .dac_nids = alc882_dac_nids,
6239 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6240 .channel_mode = alc882_sixstack_modes,
6241 .input_mux = &alc882_capture_source,
6242 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006243 [ALC882_W2JC] = {
6244 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6245 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6246 alc880_gpio1_init_verbs },
6247 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6248 .dac_nids = alc882_dac_nids,
6249 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6250 .channel_mode = alc880_threestack_modes,
6251 .need_dac_fix = 1,
6252 .input_mux = &alc882_capture_source,
6253 .dig_out_nid = ALC882_DIGOUT_NID,
6254 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006255 [ALC885_MBP3] = {
6256 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6257 .init_verbs = { alc885_mbp3_init_verbs,
6258 alc880_gpio1_init_verbs },
6259 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6260 .dac_nids = alc882_dac_nids,
6261 .channel_mode = alc885_mbp_6ch_modes,
6262 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6263 .input_mux = &alc882_capture_source,
6264 .dig_out_nid = ALC882_DIGOUT_NID,
6265 .dig_in_nid = ALC882_DIGIN_NID,
6266 .unsol_event = alc885_mbp3_unsol_event,
6267 .init_hook = alc885_mbp3_automute,
6268 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006269 [ALC885_MACPRO] = {
6270 .mixers = { alc882_macpro_mixer },
6271 .init_verbs = { alc882_macpro_init_verbs },
6272 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6273 .dac_nids = alc882_dac_nids,
6274 .dig_out_nid = ALC882_DIGOUT_NID,
6275 .dig_in_nid = ALC882_DIGIN_NID,
6276 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6277 .channel_mode = alc882_ch_modes,
6278 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006279 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006280 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006281 [ALC885_IMAC24] = {
6282 .mixers = { alc885_imac24_mixer },
6283 .init_verbs = { alc885_imac24_init_verbs },
6284 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6285 .dac_nids = alc882_dac_nids,
6286 .dig_out_nid = ALC882_DIGOUT_NID,
6287 .dig_in_nid = ALC882_DIGIN_NID,
6288 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6289 .channel_mode = alc882_ch_modes,
6290 .input_mux = &alc882_capture_source,
6291 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006292 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006293 },
Kailang Yang272a5272007-05-14 11:00:38 +02006294 [ALC882_TARGA] = {
6295 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6296 alc882_capture_mixer },
6297 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6298 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6299 .dac_nids = alc882_dac_nids,
6300 .dig_out_nid = ALC882_DIGOUT_NID,
6301 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6302 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006303 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006304 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6305 .channel_mode = alc882_3ST_6ch_modes,
6306 .need_dac_fix = 1,
6307 .input_mux = &alc882_capture_source,
6308 .unsol_event = alc882_targa_unsol_event,
6309 .init_hook = alc882_targa_automute,
6310 },
6311 [ALC882_ASUS_A7J] = {
6312 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6313 alc882_capture_mixer },
6314 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6315 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6316 .dac_nids = alc882_dac_nids,
6317 .dig_out_nid = ALC882_DIGOUT_NID,
6318 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6319 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006320 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006321 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6322 .channel_mode = alc882_3ST_6ch_modes,
6323 .need_dac_fix = 1,
6324 .input_mux = &alc882_capture_source,
6325 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006326 [ALC882_ASUS_A7M] = {
6327 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6328 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6329 alc880_gpio1_init_verbs,
6330 alc882_asus_a7m_verbs },
6331 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6332 .dac_nids = alc882_dac_nids,
6333 .dig_out_nid = ALC882_DIGOUT_NID,
6334 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6335 .channel_mode = alc880_threestack_modes,
6336 .need_dac_fix = 1,
6337 .input_mux = &alc882_capture_source,
6338 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006339};
6340
6341
6342/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006343 * Pin config fixes
6344 */
6345enum {
6346 PINFIX_ABIT_AW9D_MAX
6347};
6348
6349static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6350 { 0x15, 0x01080104 }, /* side */
6351 { 0x16, 0x01011012 }, /* rear */
6352 { 0x17, 0x01016011 }, /* clfe */
6353 { }
6354};
6355
6356static const struct alc_pincfg *alc882_pin_fixes[] = {
6357 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6358};
6359
6360static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6361 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6362 {}
6363};
6364
6365/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006366 * BIOS auto configuration
6367 */
6368static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6369 hda_nid_t nid, int pin_type,
6370 int dac_idx)
6371{
6372 /* set as output */
6373 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006374 int idx;
6375
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006376 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006377 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6378 idx = 4;
6379 else
6380 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006381 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6382
6383}
6384
6385static void alc882_auto_init_multi_out(struct hda_codec *codec)
6386{
6387 struct alc_spec *spec = codec->spec;
6388 int i;
6389
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006390 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006391 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006392 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006393 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006394 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006395 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006396 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 }
6398}
6399
6400static void alc882_auto_init_hp_out(struct hda_codec *codec)
6401{
6402 struct alc_spec *spec = codec->spec;
6403 hda_nid_t pin;
6404
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006405 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006406 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006407 /* use dac 0 */
6408 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006409 pin = spec->autocfg.speaker_pins[0];
6410 if (pin)
6411 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006412}
6413
6414#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6415#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6416
6417static void alc882_auto_init_analog_input(struct hda_codec *codec)
6418{
6419 struct alc_spec *spec = codec->spec;
6420 int i;
6421
6422 for (i = 0; i < AUTO_PIN_LAST; i++) {
6423 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006424 unsigned int vref;
6425 if (!nid)
6426 continue;
6427 vref = PIN_IN;
6428 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006429 unsigned int pincap;
6430 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6431 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006432 AC_PINCAP_VREF_80)
6433 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006434 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006435 snd_hda_codec_write(codec, nid, 0,
6436 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6437 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6438 snd_hda_codec_write(codec, nid, 0,
6439 AC_VERB_SET_AMP_GAIN_MUTE,
6440 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006441 }
6442}
6443
Takashi Iwaif511b012008-08-15 16:46:42 +02006444static void alc882_auto_init_input_src(struct hda_codec *codec)
6445{
6446 struct alc_spec *spec = codec->spec;
6447 const struct hda_input_mux *imux = spec->input_mux;
6448 int c;
6449
6450 for (c = 0; c < spec->num_adc_nids; c++) {
6451 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6452 hda_nid_t nid = spec->capsrc_nids[c];
6453 int conns, mute, idx, item;
6454
6455 conns = snd_hda_get_connections(codec, nid, conn_list,
6456 ARRAY_SIZE(conn_list));
6457 if (conns < 0)
6458 continue;
6459 for (idx = 0; idx < conns; idx++) {
6460 /* if the current connection is the selected one,
6461 * unmute it as default - otherwise mute it
6462 */
6463 mute = AMP_IN_MUTE(idx);
6464 for (item = 0; item < imux->num_items; item++) {
6465 if (imux->items[item].index == idx) {
6466 if (spec->cur_mux[c] == item)
6467 mute = AMP_IN_UNMUTE(idx);
6468 break;
6469 }
6470 }
6471 snd_hda_codec_write(codec, nid, 0,
6472 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6473 }
6474 }
6475}
6476
Takashi Iwai776e1842007-08-29 15:07:11 +02006477/* add mic boosts if needed */
6478static int alc_auto_add_mic_boost(struct hda_codec *codec)
6479{
6480 struct alc_spec *spec = codec->spec;
6481 int err;
6482 hda_nid_t nid;
6483
6484 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006485 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006486 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6487 "Mic Boost",
6488 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6489 if (err < 0)
6490 return err;
6491 }
6492 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006493 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006494 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6495 "Front Mic Boost",
6496 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6497 if (err < 0)
6498 return err;
6499 }
6500 return 0;
6501}
6502
Kailang Yangdf694da2005-12-05 19:42:22 +01006503/* almost identical with ALC880 parser... */
6504static int alc882_parse_auto_config(struct hda_codec *codec)
6505{
6506 struct alc_spec *spec = codec->spec;
6507 int err = alc880_parse_auto_config(codec);
6508
6509 if (err < 0)
6510 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006511 else if (!err)
6512 return 0; /* no config found */
6513
6514 err = alc_auto_add_mic_boost(codec);
6515 if (err < 0)
6516 return err;
6517
6518 /* hack - override the init verbs */
6519 spec->init_verbs[0] = alc882_auto_init_verbs;
6520
6521 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006522}
6523
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006524/* additional initialization for auto-configuration model */
6525static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006526{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006527 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006528 alc882_auto_init_multi_out(codec);
6529 alc882_auto_init_hp_out(codec);
6530 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006531 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006532 if (spec->unsol_event)
6533 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006534}
6535
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006536static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6537
Linus Torvalds1da177e2005-04-16 15:20:36 -07006538static int patch_alc882(struct hda_codec *codec)
6539{
6540 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006542
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006543 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006544 if (spec == NULL)
6545 return -ENOMEM;
6546
Linus Torvalds1da177e2005-04-16 15:20:36 -07006547 codec->spec = spec;
6548
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006549 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6550 alc882_models,
6551 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006552
Kailang Yangdf694da2005-12-05 19:42:22 +01006553 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006554 /* Pick up systems that don't supply PCI SSID */
6555 switch (codec->subsystem_id) {
6556 case 0x106b0c00: /* Mac Pro */
6557 board_config = ALC885_MACPRO;
6558 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006559 case 0x106b1000: /* iMac 24 */
6560 board_config = ALC885_IMAC24;
6561 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006562 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006563 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006564 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006565 board_config = ALC885_MBP3;
6566 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006567 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006568 /* ALC889A is handled better as ALC888-compatible */
6569 if (codec->revision_id == 0x100103) {
6570 alc_free(codec);
6571 return patch_alc883(codec);
6572 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006573 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6574 "trying auto-probe from BIOS...\n");
6575 board_config = ALC882_AUTO;
6576 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006577 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006578
Takashi Iwaif95474e2007-07-10 00:47:43 +02006579 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6580
Kailang Yangdf694da2005-12-05 19:42:22 +01006581 if (board_config == ALC882_AUTO) {
6582 /* automatic parse from the BIOS config */
6583 err = alc882_parse_auto_config(codec);
6584 if (err < 0) {
6585 alc_free(codec);
6586 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006587 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006588 printk(KERN_INFO
6589 "hda_codec: Cannot set up configuration "
6590 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006591 board_config = ALC882_3ST_DIG;
6592 }
6593 }
6594
6595 if (board_config != ALC882_AUTO)
6596 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006597
Kailang Yang2f893282008-05-27 12:14:47 +02006598 if (codec->vendor_id == 0x10ec0885) {
6599 spec->stream_name_analog = "ALC885 Analog";
6600 spec->stream_name_digital = "ALC885 Digital";
6601 } else {
6602 spec->stream_name_analog = "ALC882 Analog";
6603 spec->stream_name_digital = "ALC882 Digital";
6604 }
6605
Kailang Yangdf694da2005-12-05 19:42:22 +01006606 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6607 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006608 /* FIXME: setup DAC5 */
6609 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6610 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006611
Kailang Yangdf694da2005-12-05 19:42:22 +01006612 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6613 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006614
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006615 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006616 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006617 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006618 /* get type */
6619 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006620 if (wcap != AC_WID_AUD_IN) {
6621 spec->adc_nids = alc882_adc_nids_alt;
6622 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006623 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006624 spec->mixers[spec->num_mixers] =
6625 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 spec->num_mixers++;
6627 } else {
6628 spec->adc_nids = alc882_adc_nids;
6629 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006630 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006631 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6632 spec->num_mixers++;
6633 }
6634 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006635
Takashi Iwai2134ea42008-01-10 16:53:55 +01006636 spec->vmaster_nid = 0x0c;
6637
Linus Torvalds1da177e2005-04-16 15:20:36 -07006638 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006639 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006640 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006641#ifdef CONFIG_SND_HDA_POWER_SAVE
6642 if (!spec->loopback.amplist)
6643 spec->loopback.amplist = alc882_loopbacks;
6644#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006645
6646 return 0;
6647}
6648
6649/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006650 * ALC883 support
6651 *
6652 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6653 * configuration. Each pin widget can choose any input DACs and a mixer.
6654 * Each ADC is connected from a mixer of all inputs. This makes possible
6655 * 6-channel independent captures.
6656 *
6657 * In addition, an independent DAC for the multi-playback (not used in this
6658 * driver yet).
6659 */
6660#define ALC883_DIGOUT_NID 0x06
6661#define ALC883_DIGIN_NID 0x0a
6662
6663static hda_nid_t alc883_dac_nids[4] = {
6664 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006665 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006666};
6667
6668static hda_nid_t alc883_adc_nids[2] = {
6669 /* ADC1-2 */
6670 0x08, 0x09,
6671};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006672
Takashi Iwaie1406342008-02-11 18:32:32 +01006673static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6674
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006675/* input MUX */
6676/* FIXME: should be a matrix-type input source selection */
6677
6678static struct hda_input_mux alc883_capture_source = {
6679 .num_items = 4,
6680 .items = {
6681 { "Mic", 0x0 },
6682 { "Front Mic", 0x1 },
6683 { "Line", 0x2 },
6684 { "CD", 0x4 },
6685 },
6686};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006687
Jiang zhe17bba1b2008-06-04 12:11:07 +02006688static struct hda_input_mux alc883_3stack_6ch_intel = {
6689 .num_items = 4,
6690 .items = {
6691 { "Mic", 0x1 },
6692 { "Front Mic", 0x0 },
6693 { "Line", 0x2 },
6694 { "CD", 0x4 },
6695 },
6696};
6697
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006698static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6699 .num_items = 2,
6700 .items = {
6701 { "Mic", 0x1 },
6702 { "Line", 0x2 },
6703 },
6704};
6705
Kailang Yang272a5272007-05-14 11:00:38 +02006706static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6707 .num_items = 4,
6708 .items = {
6709 { "Mic", 0x0 },
6710 { "iMic", 0x1 },
6711 { "Line", 0x2 },
6712 { "CD", 0x4 },
6713 },
6714};
6715
Jiang zhefb97dc62008-03-06 11:07:11 +01006716static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6717 .num_items = 2,
6718 .items = {
6719 { "Mic", 0x0 },
6720 { "Int Mic", 0x1 },
6721 },
6722};
6723
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006724#define alc883_mux_enum_info alc_mux_enum_info
6725#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006726/* ALC883 has the ALC882-type input selection */
6727#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006729/*
6730 * 2ch mode
6731 */
6732static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6733 { 2, NULL }
6734};
6735
6736/*
6737 * 2ch mode
6738 */
6739static struct hda_verb alc883_3ST_ch2_init[] = {
6740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6744 { } /* end */
6745};
6746
6747/*
Tobin Davisb2011312007-09-17 12:45:11 +02006748 * 4ch mode
6749 */
6750static struct hda_verb alc883_3ST_ch4_init[] = {
6751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6755 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6756 { } /* end */
6757};
6758
6759/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006760 * 6ch mode
6761 */
6762static struct hda_verb alc883_3ST_ch6_init[] = {
6763 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6764 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6765 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6766 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6767 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6768 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6769 { } /* end */
6770};
6771
Tobin Davisb2011312007-09-17 12:45:11 +02006772static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006773 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006774 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006775 { 6, alc883_3ST_ch6_init },
6776};
6777
6778/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006779 * 2ch mode
6780 */
6781static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6782 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6783 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6784 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6785 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6786 { } /* end */
6787};
6788
6789/*
6790 * 4ch mode
6791 */
6792static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6793 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6794 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6795 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6797 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6798 { } /* end */
6799};
6800
6801/*
6802 * 6ch mode
6803 */
6804static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6805 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6806 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6807 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6810 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6811 { } /* end */
6812};
6813
6814static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6815 { 2, alc883_3ST_ch2_intel_init },
6816 { 4, alc883_3ST_ch4_intel_init },
6817 { 6, alc883_3ST_ch6_intel_init },
6818};
6819
6820/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006821 * 6ch mode
6822 */
6823static struct hda_verb alc883_sixstack_ch6_init[] = {
6824 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6825 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6826 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6827 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { } /* end */
6829};
6830
6831/*
6832 * 8ch mode
6833 */
6834static struct hda_verb alc883_sixstack_ch8_init[] = {
6835 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6836 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6837 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6838 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6839 { } /* end */
6840};
6841
6842static struct hda_channel_mode alc883_sixstack_modes[2] = {
6843 { 6, alc883_sixstack_ch6_init },
6844 { 8, alc883_sixstack_ch8_init },
6845};
6846
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006847static struct hda_verb alc883_medion_eapd_verbs[] = {
6848 /* eanable EAPD on medion laptop */
6849 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6850 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6851 { }
6852};
6853
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006854/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6855 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6856 */
6857
6858static struct snd_kcontrol_new alc883_base_mixer[] = {
6859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6868 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6869 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6870 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6871 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6872 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6873 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006875 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006878 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006879 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6880 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6881 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6882 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6883 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6884 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6885 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6886 {
6887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6888 /* .name = "Capture Source", */
6889 .name = "Input Source",
6890 .count = 2,
6891 .info = alc883_mux_enum_info,
6892 .get = alc883_mux_enum_get,
6893 .put = alc883_mux_enum_put,
6894 },
6895 { } /* end */
6896};
6897
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006898static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6900 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6902 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6905 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6911 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6912 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6913 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6914 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6915 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6916 {
6917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6918 /* .name = "Capture Source", */
6919 .name = "Input Source",
6920 .count = 2,
6921 .info = alc883_mux_enum_info,
6922 .get = alc883_mux_enum_get,
6923 .put = alc883_mux_enum_put,
6924 },
6925 { } /* end */
6926};
6927
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01006928static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01006929 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6930 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6931 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6932 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6937 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6938 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6941 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6942 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6943 {
6944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6945 /* .name = "Capture Source", */
6946 .name = "Input Source",
6947 .count = 2,
6948 .info = alc883_mux_enum_info,
6949 .get = alc883_mux_enum_get,
6950 .put = alc883_mux_enum_put,
6951 },
6952 { } /* end */
6953};
6954
Jiang zhefb97dc62008-03-06 11:07:11 +01006955static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6957 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6958 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6959 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6964 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6965 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6966 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6967 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6968 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6969 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6970 {
6971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6972 /* .name = "Capture Source", */
6973 .name = "Input Source",
6974 .count = 2,
6975 .info = alc883_mux_enum_info,
6976 .get = alc883_mux_enum_get,
6977 .put = alc883_mux_enum_put,
6978 },
6979 { } /* end */
6980};
6981
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006982static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006994 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7000 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7001 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7002 {
7003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7004 /* .name = "Capture Source", */
7005 .name = "Input Source",
7006 .count = 2,
7007 .info = alc883_mux_enum_info,
7008 .get = alc883_mux_enum_get,
7009 .put = alc883_mux_enum_put,
7010 },
7011 { } /* end */
7012};
7013
7014static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7018 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7019 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7020 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7021 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7022 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7023 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7024 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7025 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007029 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007032 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007033 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7034 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7035 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7036 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7037 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7038 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7039 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7040 {
7041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7042 /* .name = "Capture Source", */
7043 .name = "Input Source",
7044 .count = 2,
7045 .info = alc883_mux_enum_info,
7046 .get = alc883_mux_enum_get,
7047 .put = alc883_mux_enum_put,
7048 },
7049 { } /* end */
7050};
7051
Jiang zhe17bba1b2008-06-04 12:11:07 +02007052static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7055 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7056 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7057 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7058 HDA_OUTPUT),
7059 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7060 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7061 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7063 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7064 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7066 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7068 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7069 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7071 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7072 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7073 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7074 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7076 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7077 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7078 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7079 {
7080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7081 /* .name = "Capture Source", */
7082 .name = "Input Source",
7083 .count = 2,
7084 .info = alc883_mux_enum_info,
7085 .get = alc883_mux_enum_get,
7086 .put = alc883_mux_enum_put,
7087 },
7088 { } /* end */
7089};
7090
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007091static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007094 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007095 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007096 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7097 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007098 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7099 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007106 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007109 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007110 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7111 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7112 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7114 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7115
7116 {
7117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7118 /* .name = "Capture Source", */
7119 .name = "Input Source",
7120 .count = 1,
7121 .info = alc883_mux_enum_info,
7122 .get = alc883_mux_enum_get,
7123 .put = alc883_mux_enum_put,
7124 },
7125 { } /* end */
7126};
7127
Kailang Yangccc656c2006-10-17 12:32:26 +02007128static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7131 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7145 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7146 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7147 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7148 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7149 {
7150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7151 /* .name = "Capture Source", */
7152 .name = "Input Source",
7153 .count = 2,
7154 .info = alc883_mux_enum_info,
7155 .get = alc883_mux_enum_get,
7156 .put = alc883_mux_enum_put,
7157 },
7158 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007159};
Kailang Yangccc656c2006-10-17 12:32:26 +02007160
7161static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7164 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7165 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7166 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007170 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7171 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7172 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007173 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7175 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7176 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7177 {
7178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7179 /* .name = "Capture Source", */
7180 .name = "Input Source",
7181 .count = 2,
7182 .info = alc883_mux_enum_info,
7183 .get = alc883_mux_enum_get,
7184 .put = alc883_mux_enum_put,
7185 },
7186 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007187};
Kailang Yangccc656c2006-10-17 12:32:26 +02007188
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007189static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007192 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7193 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7196 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7199 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7200 {
7201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7202 /* .name = "Capture Source", */
7203 .name = "Input Source",
7204 .count = 1,
7205 .info = alc883_mux_enum_info,
7206 .get = alc883_mux_enum_get,
7207 .put = alc883_mux_enum_put,
7208 },
7209 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007210};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007211
Kailang Yang272a5272007-05-14 11:00:38 +02007212static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7213 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7214 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7217 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7220 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7221 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7224 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7225 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7226 {
7227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7228 /* .name = "Capture Source", */
7229 .name = "Input Source",
7230 .count = 2,
7231 .info = alc883_mux_enum_info,
7232 .get = alc883_mux_enum_get,
7233 .put = alc883_mux_enum_put,
7234 },
7235 { } /* end */
7236};
7237
7238static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7239 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7241 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7248 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7249 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7250 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7251 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7252 {
7253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7254 /* .name = "Capture Source", */
7255 .name = "Input Source",
7256 .count = 2,
7257 .info = alc883_mux_enum_info,
7258 .get = alc883_mux_enum_get,
7259 .put = alc883_mux_enum_put,
7260 },
7261 { } /* end */
7262};
7263
Tobin Davis2880a862007-08-07 11:50:26 +02007264static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7266 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7271 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007273 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7274 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7275 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7276 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7277 {
7278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7279 /* .name = "Capture Source", */
7280 .name = "Input Source",
7281 .count = 2,
7282 .info = alc883_mux_enum_info,
7283 .get = alc883_mux_enum_get,
7284 .put = alc883_mux_enum_put,
7285 },
7286 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007287};
Tobin Davis2880a862007-08-07 11:50:26 +02007288
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007289static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7290 {
7291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7292 .name = "Channel Mode",
7293 .info = alc_ch_mode_info,
7294 .get = alc_ch_mode_get,
7295 .put = alc_ch_mode_put,
7296 },
7297 { } /* end */
7298};
7299
7300static struct hda_verb alc883_init_verbs[] = {
7301 /* ADC1: mute amp left and right */
7302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7303 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7304 /* ADC2: mute amp left and right */
7305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7306 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7311 /* Rear mixer */
7312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7315 /* CLFE mixer */
7316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7319 /* Side mixer */
7320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7322 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7323
Takashi Iwaicb53c622007-08-10 17:21:45 +02007324 /* mute analog input loopbacks */
7325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007330
7331 /* Front Pin: output 0 (0x0c) */
7332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7333 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7334 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7335 /* Rear Pin: output 1 (0x0d) */
7336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7337 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7338 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7339 /* CLFE Pin: output 2 (0x0e) */
7340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7342 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7343 /* Side Pin: output 3 (0x0f) */
7344 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7346 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7347 /* Mic (rear) pin: input vref at 80% */
7348 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7349 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7350 /* Front Mic pin: input vref at 80% */
7351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7353 /* Line In pin: input */
7354 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7358 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7359 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7360 /* CD pin widget for input */
7361 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7362
7363 /* FIXME: use matrix-type input source selection */
7364 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7365 /* Input mixer2 */
7366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7370 /* Input mixer3 */
7371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7375 { }
7376};
7377
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007378/* toggle speaker-output according to the hp-jack state */
7379static void alc883_mitac_hp_automute(struct hda_codec *codec)
7380{
7381 unsigned int present;
7382
7383 present = snd_hda_codec_read(codec, 0x15, 0,
7384 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7385 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7386 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7387 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7388 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7389}
7390
7391/* auto-toggle front mic */
7392/*
7393static void alc883_mitac_mic_automute(struct hda_codec *codec)
7394{
7395 unsigned int present;
7396 unsigned char bits;
7397
7398 present = snd_hda_codec_read(codec, 0x18, 0,
7399 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7400 bits = present ? HDA_AMP_MUTE : 0;
7401 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7402}
7403*/
7404
7405static void alc883_mitac_automute(struct hda_codec *codec)
7406{
7407 alc883_mitac_hp_automute(codec);
7408 /* alc883_mitac_mic_automute(codec); */
7409}
7410
7411static void alc883_mitac_unsol_event(struct hda_codec *codec,
7412 unsigned int res)
7413{
7414 switch (res >> 26) {
7415 case ALC880_HP_EVENT:
7416 alc883_mitac_hp_automute(codec);
7417 break;
7418 case ALC880_MIC_EVENT:
7419 /* alc883_mitac_mic_automute(codec); */
7420 break;
7421 }
7422}
7423
7424static struct hda_verb alc883_mitac_verbs[] = {
7425 /* HP */
7426 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7428 /* Subwoofer */
7429 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7430 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431
7432 /* enable unsolicited event */
7433 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7434 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7435
7436 { } /* end */
7437};
7438
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007439static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007440 /* HP */
7441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7443 /* Int speaker */
7444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7446
7447 /* enable unsolicited event */
7448 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007449 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007450
7451 { } /* end */
7452};
7453
Jiang zhefb97dc62008-03-06 11:07:11 +01007454static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7455 /* HP */
7456 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7458 /* Subwoofer */
7459 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7461
7462 /* enable unsolicited event */
7463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7464
7465 { } /* end */
7466};
7467
Kailang Yangccc656c2006-10-17 12:32:26 +02007468static struct hda_verb alc883_tagra_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_HP},
7473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7474
7475 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7476 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7478
7479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007480 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7481 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7482 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007483
7484 { } /* end */
7485};
7486
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007487static struct hda_verb alc883_lenovo_101e_verbs[] = {
7488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7489 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7490 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7491 { } /* end */
7492};
7493
Kailang Yang272a5272007-05-14 11:00:38 +02007494static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7495 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7497 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7499 { } /* end */
7500};
7501
7502static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7506 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7507 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7508 { } /* end */
7509};
7510
Kailang Yang189609a2007-08-20 11:31:23 +02007511static struct hda_verb alc883_haier_w66_verbs[] = {
7512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7514
7515 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7516
7517 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7518 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7519 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7521 { } /* end */
7522};
7523
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007524static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007525 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007526 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7527 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007528 { }
7529};
7530
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007531static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7533 { }
7534};
7535
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007536static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007537 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7538 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7540 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7541 { }
7542};
7543
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007544static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007545 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7546 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7547 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7548 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7549 { }
7550};
7551
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007552static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7553 { 2, alc888_3st_hp_2ch_init },
7554 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007555};
7556
Kailang Yang272a5272007-05-14 11:00:38 +02007557/* toggle front-jack and RCA according to the hp-jack state */
7558static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7559{
7560 unsigned int present;
7561
7562 present = snd_hda_codec_read(codec, 0x1b, 0,
7563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007564 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7565 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7566 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7567 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007568}
7569
7570/* toggle RCA according to the front-jack state */
7571static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7572{
7573 unsigned int present;
7574
7575 present = snd_hda_codec_read(codec, 0x14, 0,
7576 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007577 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7578 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007579}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007580
Kailang Yang272a5272007-05-14 11:00:38 +02007581static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7582 unsigned int res)
7583{
7584 if ((res >> 26) == ALC880_HP_EVENT)
7585 alc888_lenovo_ms7195_front_automute(codec);
7586 if ((res >> 26) == ALC880_FRONT_EVENT)
7587 alc888_lenovo_ms7195_rca_automute(codec);
7588}
7589
7590static struct hda_verb alc883_medion_md2_verbs[] = {
7591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7593
7594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7595
7596 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7597 { } /* end */
7598};
7599
7600/* toggle speaker-output according to the hp-jack state */
7601static void alc883_medion_md2_automute(struct hda_codec *codec)
7602{
7603 unsigned int present;
7604
7605 present = snd_hda_codec_read(codec, 0x14, 0,
7606 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007607 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7608 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007609}
7610
7611static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7612 unsigned int res)
7613{
7614 if ((res >> 26) == ALC880_HP_EVENT)
7615 alc883_medion_md2_automute(codec);
7616}
7617
Kailang Yangccc656c2006-10-17 12:32:26 +02007618/* toggle speaker-output according to the hp-jack state */
7619static void alc883_tagra_automute(struct hda_codec *codec)
7620{
7621 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007622 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007623
7624 present = snd_hda_codec_read(codec, 0x14, 0,
7625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007626 bits = present ? HDA_AMP_MUTE : 0;
7627 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7628 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007629 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7630 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007631}
7632
7633static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7634{
7635 if ((res >> 26) == ALC880_HP_EVENT)
7636 alc883_tagra_automute(codec);
7637}
7638
Jiang zhe368c7a92008-03-04 11:20:33 +01007639/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007640static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007641{
7642 unsigned int present;
7643 unsigned char bits;
7644
7645 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7646 & AC_PINSENSE_PRESENCE;
7647 bits = present ? HDA_AMP_MUTE : 0;
7648 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7649 HDA_AMP_MUTE, bits);
7650}
7651
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007652static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7653{
7654 unsigned int present;
7655
7656 present = snd_hda_codec_read(codec, 0x18, 0,
7657 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7658 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7659 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7660}
7661
7662static void alc883_clevo_m720_automute(struct hda_codec *codec)
7663{
7664 alc883_clevo_m720_hp_automute(codec);
7665 alc883_clevo_m720_mic_automute(codec);
7666}
7667
7668static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007669 unsigned int res)
7670{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007671 switch (res >> 26) {
7672 case ALC880_HP_EVENT:
7673 alc883_clevo_m720_hp_automute(codec);
7674 break;
7675 case ALC880_MIC_EVENT:
7676 alc883_clevo_m720_mic_automute(codec);
7677 break;
7678 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007679}
7680
Jiang zhefb97dc62008-03-06 11:07:11 +01007681/* toggle speaker-output according to the hp-jack state */
7682static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7683{
7684 unsigned int present;
7685 unsigned char bits;
7686
7687 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7688 & AC_PINSENSE_PRESENCE;
7689 bits = present ? HDA_AMP_MUTE : 0;
7690 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7691 HDA_AMP_MUTE, bits);
7692}
7693
7694static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7695 unsigned int res)
7696{
7697 if ((res >> 26) == ALC880_HP_EVENT)
7698 alc883_2ch_fujitsu_pi2515_automute(codec);
7699}
7700
Kailang Yang189609a2007-08-20 11:31:23 +02007701static void alc883_haier_w66_automute(struct hda_codec *codec)
7702{
7703 unsigned int present;
7704 unsigned char bits;
7705
7706 present = snd_hda_codec_read(codec, 0x1b, 0,
7707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7708 bits = present ? 0x80 : 0;
7709 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7710 0x80, bits);
7711}
7712
7713static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7714 unsigned int res)
7715{
7716 if ((res >> 26) == ALC880_HP_EVENT)
7717 alc883_haier_w66_automute(codec);
7718}
7719
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007720static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7721{
7722 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007723 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007724
7725 present = snd_hda_codec_read(codec, 0x14, 0,
7726 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007727 bits = present ? HDA_AMP_MUTE : 0;
7728 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7729 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007730}
7731
7732static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7733{
7734 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007735 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007736
7737 present = snd_hda_codec_read(codec, 0x1b, 0,
7738 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007739 bits = present ? HDA_AMP_MUTE : 0;
7740 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7741 HDA_AMP_MUTE, bits);
7742 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7743 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007744}
7745
7746static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7747 unsigned int res)
7748{
7749 if ((res >> 26) == ALC880_HP_EVENT)
7750 alc883_lenovo_101e_all_automute(codec);
7751 if ((res >> 26) == ALC880_FRONT_EVENT)
7752 alc883_lenovo_101e_ispeaker_automute(codec);
7753}
7754
Takashi Iwai676a9b52007-08-16 15:23:35 +02007755/* toggle speaker-output according to the hp-jack state */
7756static void alc883_acer_aspire_automute(struct hda_codec *codec)
7757{
7758 unsigned int present;
7759
7760 present = snd_hda_codec_read(codec, 0x14, 0,
7761 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7762 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7764 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7766}
7767
7768static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7769 unsigned int res)
7770{
7771 if ((res >> 26) == ALC880_HP_EVENT)
7772 alc883_acer_aspire_automute(codec);
7773}
7774
Kailang Yangd1a991a2007-08-15 16:21:59 +02007775static struct hda_verb alc883_acer_eapd_verbs[] = {
7776 /* HP Pin: output 0 (0x0c) */
7777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7779 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7780 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7782 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007784 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7785 /* eanable EAPD on medion laptop */
7786 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7787 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007788 /* enable unsolicited event */
7789 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007790 { }
7791};
7792
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007793static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7794{
7795 unsigned int present;
7796
7797 present = snd_hda_codec_read(codec, 0x1b, 0,
7798 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7799 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7800 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7801 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7802 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7803 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7804 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7805 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7806 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7807}
7808
7809static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7810 unsigned int res)
7811{
7812 switch (res >> 26) {
7813 case ALC880_HP_EVENT:
7814 printk("hp_event\n");
7815 alc888_6st_dell_front_automute(codec);
7816 break;
7817 }
7818}
7819
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007820/*
7821 * generic initialization of ADC, input mixers and output mixers
7822 */
7823static struct hda_verb alc883_auto_init_verbs[] = {
7824 /*
7825 * Unmute ADC0-2 and set the default input to mic-in
7826 */
7827 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7831
Takashi Iwaicb53c622007-08-10 17:21:45 +02007832 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007833 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007834 * Note: PASD motherboards uses the Line In 2 as the input for
7835 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007836 */
7837 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007843
7844 /*
7845 * Set up output mixers (0x0c - 0x0f)
7846 */
7847 /* set vol=0 to output mixers */
7848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7852 /* set up input amps for analog loopback */
7853 /* Amp Indices: DAC = 0, mixer = 1 */
7854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7860 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7861 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7862 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7863 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7864
7865 /* FIXME: use matrix-type input source selection */
7866 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7867 /* Input mixer1 */
7868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007871 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7873 /* Input mixer2 */
7874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007877 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007879
7880 { }
7881};
7882
7883/* capture mixer elements */
7884static struct snd_kcontrol_new alc883_capture_mixer[] = {
7885 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7886 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7887 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7888 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7889 {
7890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7891 /* The multiple "Capture Source" controls confuse alsamixer
7892 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007893 */
7894 /* .name = "Capture Source", */
7895 .name = "Input Source",
7896 .count = 2,
7897 .info = alc882_mux_enum_info,
7898 .get = alc882_mux_enum_get,
7899 .put = alc882_mux_enum_put,
7900 },
7901 { } /* end */
7902};
7903
Takashi Iwaicb53c622007-08-10 17:21:45 +02007904#ifdef CONFIG_SND_HDA_POWER_SAVE
7905#define alc883_loopbacks alc880_loopbacks
7906#endif
7907
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007908/* pcm configuration: identiacal with ALC880 */
7909#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7910#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007911#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007912#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7913#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7914
7915/*
7916 * configuration and preset
7917 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007918static const char *alc883_models[ALC883_MODEL_LAST] = {
7919 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7920 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7921 [ALC883_3ST_6ch] = "3stack-6ch",
7922 [ALC883_6ST_DIG] = "6stack-dig",
7923 [ALC883_TARGA_DIG] = "targa-dig",
7924 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007925 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007926 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007927 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007928 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007929 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007930 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007931 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7932 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007933 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007934 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007935 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007936 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007937 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01007938 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02007939 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007940 [ALC883_AUTO] = "auto",
7941};
7942
7943static struct snd_pci_quirk alc883_cfg_tbl[] = {
7944 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007945 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7946 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7947 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02007948 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007949 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007950 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007951 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007952 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7953 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01007954 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007955 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02007956 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007957 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007958 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7959 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7960 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007961 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007962 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7963 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7964 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02007965 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007966 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007967 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007968 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7969 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7970 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7971 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7972 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7973 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7974 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7975 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7976 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007977 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7978 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007979 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01007980 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007981 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007982 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007983 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007984 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007985 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7986 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007987 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007988 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007989 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007990 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007991 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007992 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007993 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7994 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007995 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007996 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007997 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007998 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7999 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008000 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008001 {}
8002};
8003
8004static struct alc_config_preset alc883_presets[] = {
8005 [ALC883_3ST_2ch_DIG] = {
8006 .mixers = { alc883_3ST_2ch_mixer },
8007 .init_verbs = { alc883_init_verbs },
8008 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8009 .dac_nids = alc883_dac_nids,
8010 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008011 .dig_in_nid = ALC883_DIGIN_NID,
8012 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8013 .channel_mode = alc883_3ST_2ch_modes,
8014 .input_mux = &alc883_capture_source,
8015 },
8016 [ALC883_3ST_6ch_DIG] = {
8017 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8018 .init_verbs = { alc883_init_verbs },
8019 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8020 .dac_nids = alc883_dac_nids,
8021 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008022 .dig_in_nid = ALC883_DIGIN_NID,
8023 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8024 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008025 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008026 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008027 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008028 [ALC883_3ST_6ch] = {
8029 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8030 .init_verbs = { alc883_init_verbs },
8031 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8032 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008033 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8034 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008035 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008036 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008037 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008038 [ALC883_3ST_6ch_INTEL] = {
8039 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8040 .init_verbs = { alc883_init_verbs },
8041 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8042 .dac_nids = alc883_dac_nids,
8043 .dig_out_nid = ALC883_DIGOUT_NID,
8044 .dig_in_nid = ALC883_DIGIN_NID,
8045 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8046 .channel_mode = alc883_3ST_6ch_intel_modes,
8047 .need_dac_fix = 1,
8048 .input_mux = &alc883_3stack_6ch_intel,
8049 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008050 [ALC883_6ST_DIG] = {
8051 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8052 .init_verbs = { alc883_init_verbs },
8053 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8054 .dac_nids = alc883_dac_nids,
8055 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008056 .dig_in_nid = ALC883_DIGIN_NID,
8057 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8058 .channel_mode = alc883_sixstack_modes,
8059 .input_mux = &alc883_capture_source,
8060 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008061 [ALC883_TARGA_DIG] = {
8062 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8063 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8064 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8065 .dac_nids = alc883_dac_nids,
8066 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008067 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8068 .channel_mode = alc883_3ST_6ch_modes,
8069 .need_dac_fix = 1,
8070 .input_mux = &alc883_capture_source,
8071 .unsol_event = alc883_tagra_unsol_event,
8072 .init_hook = alc883_tagra_automute,
8073 },
8074 [ALC883_TARGA_2ch_DIG] = {
8075 .mixers = { alc883_tagra_2ch_mixer},
8076 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8078 .dac_nids = alc883_dac_nids,
8079 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008080 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8081 .channel_mode = alc883_3ST_2ch_modes,
8082 .input_mux = &alc883_capture_source,
8083 .unsol_event = alc883_tagra_unsol_event,
8084 .init_hook = alc883_tagra_automute,
8085 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008086 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008087 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008088 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8089 * and the headphone jack. Turn this on and rely on the
8090 * standard mute methods whenever the user wants to turn
8091 * these outputs off.
8092 */
8093 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8095 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8097 .channel_mode = alc883_3ST_2ch_modes,
8098 .input_mux = &alc883_capture_source,
8099 },
Tobin Davis2880a862007-08-07 11:50:26 +02008100 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008101 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008102 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8104 .dac_nids = alc883_dac_nids,
8105 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8107 .channel_mode = alc883_3ST_2ch_modes,
8108 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008109 .unsol_event = alc883_acer_aspire_unsol_event,
8110 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008111 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008112 [ALC883_MEDION] = {
8113 .mixers = { alc883_fivestack_mixer,
8114 alc883_chmode_mixer },
8115 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008116 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8118 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008119 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8120 .channel_mode = alc883_sixstack_modes,
8121 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008122 },
Kailang Yang272a5272007-05-14 11:00:38 +02008123 [ALC883_MEDION_MD2] = {
8124 .mixers = { alc883_medion_md2_mixer},
8125 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8127 .dac_nids = alc883_dac_nids,
8128 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8130 .channel_mode = alc883_3ST_2ch_modes,
8131 .input_mux = &alc883_capture_source,
8132 .unsol_event = alc883_medion_md2_unsol_event,
8133 .init_hook = alc883_medion_md2_automute,
8134 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008135 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008136 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008137 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8139 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008140 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8141 .channel_mode = alc883_3ST_2ch_modes,
8142 .input_mux = &alc883_capture_source,
8143 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008144 [ALC883_CLEVO_M720] = {
8145 .mixers = { alc883_clevo_m720_mixer },
8146 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008147 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8148 .dac_nids = alc883_dac_nids,
8149 .dig_out_nid = ALC883_DIGOUT_NID,
8150 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8151 .channel_mode = alc883_3ST_2ch_modes,
8152 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008153 .unsol_event = alc883_clevo_m720_unsol_event,
8154 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008155 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008156 [ALC883_LENOVO_101E_2ch] = {
8157 .mixers = { alc883_lenovo_101e_2ch_mixer},
8158 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8159 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8160 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008161 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8162 .channel_mode = alc883_3ST_2ch_modes,
8163 .input_mux = &alc883_lenovo_101e_capture_source,
8164 .unsol_event = alc883_lenovo_101e_unsol_event,
8165 .init_hook = alc883_lenovo_101e_all_automute,
8166 },
Kailang Yang272a5272007-05-14 11:00:38 +02008167 [ALC883_LENOVO_NB0763] = {
8168 .mixers = { alc883_lenovo_nb0763_mixer },
8169 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8171 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8173 .channel_mode = alc883_3ST_2ch_modes,
8174 .need_dac_fix = 1,
8175 .input_mux = &alc883_lenovo_nb0763_capture_source,
8176 .unsol_event = alc883_medion_md2_unsol_event,
8177 .init_hook = alc883_medion_md2_automute,
8178 },
8179 [ALC888_LENOVO_MS7195_DIG] = {
8180 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8181 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8182 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8183 .dac_nids = alc883_dac_nids,
8184 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008185 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8186 .channel_mode = alc883_3ST_6ch_modes,
8187 .need_dac_fix = 1,
8188 .input_mux = &alc883_capture_source,
8189 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8190 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008191 },
8192 [ALC883_HAIER_W66] = {
8193 .mixers = { alc883_tagra_2ch_mixer},
8194 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8195 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8196 .dac_nids = alc883_dac_nids,
8197 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008198 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8199 .channel_mode = alc883_3ST_2ch_modes,
8200 .input_mux = &alc883_capture_source,
8201 .unsol_event = alc883_haier_w66_unsol_event,
8202 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008203 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008204 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008205 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008206 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008207 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8208 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008209 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8210 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008211 .need_dac_fix = 1,
8212 .input_mux = &alc883_capture_source,
8213 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008214 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008215 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008216 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8217 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8218 .dac_nids = alc883_dac_nids,
8219 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008220 .dig_in_nid = ALC883_DIGIN_NID,
8221 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8222 .channel_mode = alc883_sixstack_modes,
8223 .input_mux = &alc883_capture_source,
8224 .unsol_event = alc888_6st_dell_unsol_event,
8225 .init_hook = alc888_6st_dell_front_automute,
8226 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008227 [ALC883_MITAC] = {
8228 .mixers = { alc883_mitac_mixer },
8229 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8230 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8231 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008232 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8233 .channel_mode = alc883_3ST_2ch_modes,
8234 .input_mux = &alc883_capture_source,
8235 .unsol_event = alc883_mitac_unsol_event,
8236 .init_hook = alc883_mitac_automute,
8237 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008238 [ALC883_FUJITSU_PI2515] = {
8239 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8240 .init_verbs = { alc883_init_verbs,
8241 alc883_2ch_fujitsu_pi2515_verbs},
8242 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8243 .dac_nids = alc883_dac_nids,
8244 .dig_out_nid = ALC883_DIGOUT_NID,
8245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8246 .channel_mode = alc883_3ST_2ch_modes,
8247 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8248 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8249 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8250 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008251};
8252
8253
8254/*
8255 * BIOS auto configuration
8256 */
8257static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8258 hda_nid_t nid, int pin_type,
8259 int dac_idx)
8260{
8261 /* set as output */
8262 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008263 int idx;
8264
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008265 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008266 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8267 idx = 4;
8268 else
8269 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008270 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8271
8272}
8273
8274static void alc883_auto_init_multi_out(struct hda_codec *codec)
8275{
8276 struct alc_spec *spec = codec->spec;
8277 int i;
8278
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008279 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008280 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008281 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008282 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008283 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008284 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008285 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008286 }
8287}
8288
8289static void alc883_auto_init_hp_out(struct hda_codec *codec)
8290{
8291 struct alc_spec *spec = codec->spec;
8292 hda_nid_t pin;
8293
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008294 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008295 if (pin) /* connect to front */
8296 /* use dac 0 */
8297 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008298 pin = spec->autocfg.speaker_pins[0];
8299 if (pin)
8300 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008301}
8302
8303#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8304#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8305
8306static void alc883_auto_init_analog_input(struct hda_codec *codec)
8307{
8308 struct alc_spec *spec = codec->spec;
8309 int i;
8310
8311 for (i = 0; i < AUTO_PIN_LAST; i++) {
8312 hda_nid_t nid = spec->autocfg.input_pins[i];
8313 if (alc883_is_input_pin(nid)) {
8314 snd_hda_codec_write(codec, nid, 0,
8315 AC_VERB_SET_PIN_WIDGET_CONTROL,
8316 (i <= AUTO_PIN_FRONT_MIC ?
8317 PIN_VREF80 : PIN_IN));
8318 if (nid != ALC883_PIN_CD_NID)
8319 snd_hda_codec_write(codec, nid, 0,
8320 AC_VERB_SET_AMP_GAIN_MUTE,
8321 AMP_OUT_MUTE);
8322 }
8323 }
8324}
8325
Takashi Iwaif511b012008-08-15 16:46:42 +02008326#define alc883_auto_init_input_src alc882_auto_init_input_src
8327
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008328/* almost identical with ALC880 parser... */
8329static int alc883_parse_auto_config(struct hda_codec *codec)
8330{
8331 struct alc_spec *spec = codec->spec;
8332 int err = alc880_parse_auto_config(codec);
8333
8334 if (err < 0)
8335 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008336 else if (!err)
8337 return 0; /* no config found */
8338
8339 err = alc_auto_add_mic_boost(codec);
8340 if (err < 0)
8341 return err;
8342
8343 /* hack - override the init verbs */
8344 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008345 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8346 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008347
8348 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008349}
8350
8351/* additional initialization for auto-configuration model */
8352static void alc883_auto_init(struct hda_codec *codec)
8353{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008354 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008355 alc883_auto_init_multi_out(codec);
8356 alc883_auto_init_hp_out(codec);
8357 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008358 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008359 if (spec->unsol_event)
8360 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008361}
8362
8363static int patch_alc883(struct hda_codec *codec)
8364{
8365 struct alc_spec *spec;
8366 int err, board_config;
8367
8368 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8369 if (spec == NULL)
8370 return -ENOMEM;
8371
8372 codec->spec = spec;
8373
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008374 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8375
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008376 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8377 alc883_models,
8378 alc883_cfg_tbl);
8379 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8381 "trying auto-probe from BIOS...\n");
8382 board_config = ALC883_AUTO;
8383 }
8384
8385 if (board_config == ALC883_AUTO) {
8386 /* automatic parse from the BIOS config */
8387 err = alc883_parse_auto_config(codec);
8388 if (err < 0) {
8389 alc_free(codec);
8390 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008391 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008392 printk(KERN_INFO
8393 "hda_codec: Cannot set up configuration "
8394 "from BIOS. Using base mode...\n");
8395 board_config = ALC883_3ST_2ch_DIG;
8396 }
8397 }
8398
8399 if (board_config != ALC883_AUTO)
8400 setup_preset(spec, &alc883_presets[board_config]);
8401
Kailang Yang2f893282008-05-27 12:14:47 +02008402 switch (codec->vendor_id) {
8403 case 0x10ec0888:
8404 spec->stream_name_analog = "ALC888 Analog";
8405 spec->stream_name_digital = "ALC888 Digital";
8406 break;
8407 case 0x10ec0889:
8408 spec->stream_name_analog = "ALC889 Analog";
8409 spec->stream_name_digital = "ALC889 Digital";
8410 break;
8411 default:
8412 spec->stream_name_analog = "ALC883 Analog";
8413 spec->stream_name_digital = "ALC883 Digital";
8414 break;
8415 }
8416
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008417 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8418 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008419 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008421 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8422 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8423
Takashi Iwaie1406342008-02-11 18:32:32 +01008424 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8425 spec->adc_nids = alc883_adc_nids;
8426 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008427
Takashi Iwai2134ea42008-01-10 16:53:55 +01008428 spec->vmaster_nid = 0x0c;
8429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008430 codec->patch_ops = alc_patch_ops;
8431 if (board_config == ALC883_AUTO)
8432 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008433
Takashi Iwaicb53c622007-08-10 17:21:45 +02008434#ifdef CONFIG_SND_HDA_POWER_SAVE
8435 if (!spec->loopback.amplist)
8436 spec->loopback.amplist = alc883_loopbacks;
8437#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008438
8439 return 0;
8440}
8441
8442/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008443 * ALC262 support
8444 */
8445
8446#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8447#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8448
8449#define alc262_dac_nids alc260_dac_nids
8450#define alc262_adc_nids alc882_adc_nids
8451#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008452#define alc262_capsrc_nids alc882_capsrc_nids
8453#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008454
8455#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008456#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008457
8458static struct snd_kcontrol_new alc262_base_mixer[] = {
8459 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8460 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8461 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8462 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8463 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8464 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008468 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008470 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008471 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008472 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008473 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8475 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8476 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008477 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008478};
8479
Kailang Yangccc656c2006-10-17 12:32:26 +02008480static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8481 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8482 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8485 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8486 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8487 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8488 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008489 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008490 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008492 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008493 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008494 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008495 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8497 { } /* end */
8498};
8499
Takashi Iwaice875f02008-01-28 18:17:43 +01008500/* update HP, line and mono-out pins according to the master switch */
8501static void alc262_hp_master_update(struct hda_codec *codec)
8502{
8503 struct alc_spec *spec = codec->spec;
8504 int val = spec->master_sw;
8505
8506 /* HP & line-out */
8507 snd_hda_codec_write_cache(codec, 0x1b, 0,
8508 AC_VERB_SET_PIN_WIDGET_CONTROL,
8509 val ? PIN_HP : 0);
8510 snd_hda_codec_write_cache(codec, 0x15, 0,
8511 AC_VERB_SET_PIN_WIDGET_CONTROL,
8512 val ? PIN_HP : 0);
8513 /* mono (speaker) depending on the HP jack sense */
8514 val = val && !spec->jack_present;
8515 snd_hda_codec_write_cache(codec, 0x16, 0,
8516 AC_VERB_SET_PIN_WIDGET_CONTROL,
8517 val ? PIN_OUT : 0);
8518}
8519
8520static void alc262_hp_bpc_automute(struct hda_codec *codec)
8521{
8522 struct alc_spec *spec = codec->spec;
8523 unsigned int presence;
8524 presence = snd_hda_codec_read(codec, 0x1b, 0,
8525 AC_VERB_GET_PIN_SENSE, 0);
8526 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8527 alc262_hp_master_update(codec);
8528}
8529
8530static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8531{
8532 if ((res >> 26) != ALC880_HP_EVENT)
8533 return;
8534 alc262_hp_bpc_automute(codec);
8535}
8536
8537static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8538{
8539 struct alc_spec *spec = codec->spec;
8540 unsigned int presence;
8541 presence = snd_hda_codec_read(codec, 0x15, 0,
8542 AC_VERB_GET_PIN_SENSE, 0);
8543 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8544 alc262_hp_master_update(codec);
8545}
8546
8547static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8548 unsigned int res)
8549{
8550 if ((res >> 26) != ALC880_HP_EVENT)
8551 return;
8552 alc262_hp_wildwest_automute(codec);
8553}
8554
8555static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8556 struct snd_ctl_elem_value *ucontrol)
8557{
8558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8559 struct alc_spec *spec = codec->spec;
8560 *ucontrol->value.integer.value = spec->master_sw;
8561 return 0;
8562}
8563
8564static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8565 struct snd_ctl_elem_value *ucontrol)
8566{
8567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8568 struct alc_spec *spec = codec->spec;
8569 int val = !!*ucontrol->value.integer.value;
8570
8571 if (val == spec->master_sw)
8572 return 0;
8573 spec->master_sw = val;
8574 alc262_hp_master_update(codec);
8575 return 1;
8576}
8577
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008578static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008579 {
8580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8581 .name = "Master Playback Switch",
8582 .info = snd_ctl_boolean_mono_info,
8583 .get = alc262_hp_master_sw_get,
8584 .put = alc262_hp_master_sw_put,
8585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8587 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008589 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8590 HDA_OUTPUT),
8591 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8592 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008598 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8601 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8602 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8603 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8604 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8605 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8606 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8607 { } /* end */
8608};
8609
Kailang Yangcd7509a2007-01-26 18:33:17 +01008610static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008611 {
8612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8613 .name = "Master Playback Switch",
8614 .info = snd_ctl_boolean_mono_info,
8615 .get = alc262_hp_master_sw_get,
8616 .put = alc262_hp_master_sw_put,
8617 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8619 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8620 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008622 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8623 HDA_OUTPUT),
8624 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8625 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8627 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008628 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8631 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8632 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8633 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8634 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8635 { } /* end */
8636};
8637
8638static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8639 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8640 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008641 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008642 { } /* end */
8643};
8644
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008645/* mute/unmute internal speaker according to the hp jack and mute state */
8646static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8647{
8648 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008649
8650 if (force || !spec->sense_updated) {
8651 unsigned int present;
8652 present = snd_hda_codec_read(codec, 0x15, 0,
8653 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008654 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008655 spec->sense_updated = 1;
8656 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008657 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8658 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008659}
8660
8661static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8662 unsigned int res)
8663{
8664 if ((res >> 26) != ALC880_HP_EVENT)
8665 return;
8666 alc262_hp_t5735_automute(codec, 1);
8667}
8668
8669static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8670{
8671 alc262_hp_t5735_automute(codec, 1);
8672}
8673
8674static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008677 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8682 { } /* end */
8683};
8684
8685static struct hda_verb alc262_hp_t5735_verbs[] = {
8686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8688
8689 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8690 { }
8691};
8692
Kailang Yang8c427222008-01-10 13:03:59 +01008693static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008696 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8697 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008698 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8699 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8700 { } /* end */
8701};
8702
8703static struct hda_verb alc262_hp_rp5700_verbs[] = {
8704 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8705 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8707 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8709 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8712 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8714 {}
8715};
8716
8717static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8718 .num_items = 1,
8719 .items = {
8720 { "Line", 0x1 },
8721 },
8722};
8723
Takashi Iwai0724ea22007-08-23 00:31:43 +02008724/* bind hp and internal speaker mute (with plug check) */
8725static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8726 struct snd_ctl_elem_value *ucontrol)
8727{
8728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8729 long *valp = ucontrol->value.integer.value;
8730 int change;
8731
8732 /* change hp mute */
8733 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8734 HDA_AMP_MUTE,
8735 valp[0] ? 0 : HDA_AMP_MUTE);
8736 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8737 HDA_AMP_MUTE,
8738 valp[1] ? 0 : HDA_AMP_MUTE);
8739 if (change) {
8740 /* change speaker according to HP jack state */
8741 struct alc_spec *spec = codec->spec;
8742 unsigned int mute;
8743 if (spec->jack_present)
8744 mute = HDA_AMP_MUTE;
8745 else
8746 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8747 HDA_OUTPUT, 0);
8748 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8749 HDA_AMP_MUTE, mute);
8750 }
8751 return change;
8752}
Takashi Iwai5b319542007-07-26 11:49:22 +02008753
Kailang Yang272a5272007-05-14 11:00:38 +02008754static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008755 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8756 {
8757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8758 .name = "Master Playback Switch",
8759 .info = snd_hda_mixer_amp_switch_info,
8760 .get = snd_hda_mixer_amp_switch_get,
8761 .put = alc262_sony_master_sw_put,
8762 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8763 },
Kailang Yang272a5272007-05-14 11:00:38 +02008764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8766 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8767 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8768 { } /* end */
8769};
8770
Kailang Yang83c34212007-07-05 11:43:05 +02008771static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8772 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8777 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8778 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8779 { } /* end */
8780};
Kailang Yang272a5272007-05-14 11:00:38 +02008781
Kailang Yangdf694da2005-12-05 19:42:22 +01008782#define alc262_capture_mixer alc882_capture_mixer
8783#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8784
8785/*
8786 * generic initialization of ADC, input mixers and output mixers
8787 */
8788static struct hda_verb alc262_init_verbs[] = {
8789 /*
8790 * Unmute ADC0-2 and set the default input to mic-in
8791 */
8792 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8794 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8796 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8798
Takashi Iwaicb53c622007-08-10 17:21:45 +02008799 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008800 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008801 * Note: PASD motherboards uses the Line In 2 as the input for
8802 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008803 */
8804 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008810
8811 /*
8812 * Set up output mixers (0x0c - 0x0e)
8813 */
8814 /* set vol=0 to output mixers */
8815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8818 /* set up input amps for analog loopback */
8819 /* Amp Indices: DAC = 0, mixer = 1 */
8820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8826
8827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8830 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8831 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8832 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8833
8834 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8839
8840 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8841 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8842
8843 /* FIXME: use matrix-type input source selection */
8844 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8845 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8850 /* Input mixer2 */
8851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8855 /* Input mixer3 */
8856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008860
8861 { }
8862};
8863
Kailang Yangccc656c2006-10-17 12:32:26 +02008864static struct hda_verb alc262_hippo_unsol_verbs[] = {
8865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8867 {}
8868};
8869
8870static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8872 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8874
8875 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8876 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8877 {}
8878};
8879
Kailang Yang272a5272007-05-14 11:00:38 +02008880static struct hda_verb alc262_sony_unsol_verbs[] = {
8881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8883 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8884
8885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008887 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008888};
8889
Kailang Yangccc656c2006-10-17 12:32:26 +02008890/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008891static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008892{
8893 struct alc_spec *spec = codec->spec;
8894 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008895 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008896
Takashi Iwai5b319542007-07-26 11:49:22 +02008897 /* need to execute and sync at first */
8898 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8899 present = snd_hda_codec_read(codec, 0x15, 0,
8900 AC_VERB_GET_PIN_SENSE, 0);
8901 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008902 if (spec->jack_present) {
8903 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008904 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8905 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008906 } else {
8907 /* unmute internal speaker if necessary */
8908 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008909 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8910 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008911 }
8912}
8913
8914/* unsolicited event for HP jack sensing */
8915static void alc262_hippo_unsol_event(struct hda_codec *codec,
8916 unsigned int res)
8917{
8918 if ((res >> 26) != ALC880_HP_EVENT)
8919 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008920 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008921}
8922
Takashi Iwai5b319542007-07-26 11:49:22 +02008923static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008924{
Kailang Yangccc656c2006-10-17 12:32:26 +02008925 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008926 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008927
Takashi Iwai5b319542007-07-26 11:49:22 +02008928 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8929 present = snd_hda_codec_read(codec, 0x1b, 0,
8930 AC_VERB_GET_PIN_SENSE, 0);
8931 present = (present & 0x80000000) != 0;
8932 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008933 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008934 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8935 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008936 } else {
8937 /* unmute internal speaker if necessary */
8938 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008939 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8940 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008941 }
8942}
8943
8944/* unsolicited event for HP jack sensing */
8945static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8946 unsigned int res)
8947{
8948 if ((res >> 26) != ALC880_HP_EVENT)
8949 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008950 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008951}
8952
Takashi Iwai834be882006-03-01 14:16:17 +01008953/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02008954 * nec model
8955 * 0x15 = headphone
8956 * 0x16 = internal speaker
8957 * 0x18 = external mic
8958 */
8959
8960static struct snd_kcontrol_new alc262_nec_mixer[] = {
8961 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8962 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
8963
8964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8967
8968 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8970 { } /* end */
8971};
8972
8973static struct hda_verb alc262_nec_verbs[] = {
8974 /* Unmute Speaker */
8975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8976
8977 /* Headphone */
8978 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8980
8981 /* External mic to headphone */
8982 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8983 /* External mic to speaker */
8984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8985 {}
8986};
8987
8988/*
Takashi Iwai834be882006-03-01 14:16:17 +01008989 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008990 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8991 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008992 */
8993
8994#define ALC_HP_EVENT 0x37
8995
8996static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8997 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008999 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9000 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009001 {}
9002};
9003
Jiang zhe0e31daf2008-03-20 12:12:39 +01009004static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9005 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9007 {}
9008};
9009
Takashi Iwai834be882006-03-01 14:16:17 +01009010static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009011 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009012 .items = {
9013 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009014 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009015 { "CD", 0x4 },
9016 },
9017};
9018
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009019static struct hda_input_mux alc262_HP_capture_source = {
9020 .num_items = 5,
9021 .items = {
9022 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009023 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009024 { "Line", 0x2 },
9025 { "CD", 0x4 },
9026 { "AUX IN", 0x6 },
9027 },
9028};
9029
zhejiangaccbe492007-08-31 12:36:05 +02009030static struct hda_input_mux alc262_HP_D7000_capture_source = {
9031 .num_items = 4,
9032 .items = {
9033 { "Mic", 0x0 },
9034 { "Front Mic", 0x2 },
9035 { "Line", 0x1 },
9036 { "CD", 0x4 },
9037 },
9038};
9039
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009040/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009041static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9042{
9043 struct alc_spec *spec = codec->spec;
9044 unsigned int mute;
9045
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009046 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009047 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009048 /* need to execute and sync at first */
9049 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009050 /* check laptop HP jack */
9051 present = snd_hda_codec_read(codec, 0x14, 0,
9052 AC_VERB_GET_PIN_SENSE, 0);
9053 /* need to execute and sync at first */
9054 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9055 /* check docking HP jack */
9056 present |= snd_hda_codec_read(codec, 0x1b, 0,
9057 AC_VERB_GET_PIN_SENSE, 0);
9058 if (present & AC_PINSENSE_PRESENCE)
9059 spec->jack_present = 1;
9060 else
9061 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009062 spec->sense_updated = 1;
9063 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009064 /* unmute internal speaker only if both HPs are unplugged and
9065 * master switch is on
9066 */
9067 if (spec->jack_present)
9068 mute = HDA_AMP_MUTE;
9069 else
Takashi Iwai834be882006-03-01 14:16:17 +01009070 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009071 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9072 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009073}
9074
9075/* unsolicited event for HP jack sensing */
9076static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9077 unsigned int res)
9078{
9079 if ((res >> 26) != ALC_HP_EVENT)
9080 return;
9081 alc262_fujitsu_automute(codec, 1);
9082}
9083
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009084static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9085{
9086 alc262_fujitsu_automute(codec, 1);
9087}
9088
Takashi Iwai834be882006-03-01 14:16:17 +01009089/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009090static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9091 .ops = &snd_hda_bind_vol,
9092 .values = {
9093 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9094 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9095 0
9096 },
9097};
Takashi Iwai834be882006-03-01 14:16:17 +01009098
Jiang zhe0e31daf2008-03-20 12:12:39 +01009099/* mute/unmute internal speaker according to the hp jack and mute state */
9100static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9101{
9102 struct alc_spec *spec = codec->spec;
9103 unsigned int mute;
9104
9105 if (force || !spec->sense_updated) {
9106 unsigned int present_int_hp;
9107 /* need to execute and sync at first */
9108 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9109 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9110 AC_VERB_GET_PIN_SENSE, 0);
9111 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9112 spec->sense_updated = 1;
9113 }
9114 if (spec->jack_present) {
9115 /* mute internal speaker */
9116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9117 HDA_AMP_MUTE, HDA_AMP_MUTE);
9118 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9119 HDA_AMP_MUTE, HDA_AMP_MUTE);
9120 } else {
9121 /* unmute internal speaker if necessary */
9122 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9123 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9124 HDA_AMP_MUTE, mute);
9125 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9126 HDA_AMP_MUTE, mute);
9127 }
9128}
9129
9130/* unsolicited event for HP jack sensing */
9131static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9132 unsigned int res)
9133{
9134 if ((res >> 26) != ALC_HP_EVENT)
9135 return;
9136 alc262_lenovo_3000_automute(codec, 1);
9137}
9138
Takashi Iwai834be882006-03-01 14:16:17 +01009139/* bind hp and internal speaker mute (with plug check) */
9140static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9141 struct snd_ctl_elem_value *ucontrol)
9142{
9143 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9144 long *valp = ucontrol->value.integer.value;
9145 int change;
9146
Tony Vroon5d9fab22008-03-14 17:09:18 +01009147 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9148 HDA_AMP_MUTE,
9149 valp ? 0 : HDA_AMP_MUTE);
9150 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9151 HDA_AMP_MUTE,
9152 valp ? 0 : HDA_AMP_MUTE);
9153
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009154 if (change)
9155 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009156 return change;
9157}
9158
9159static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009160 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009161 {
9162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9163 .name = "Master Playback Switch",
9164 .info = snd_hda_mixer_amp_switch_info,
9165 .get = snd_hda_mixer_amp_switch_get,
9166 .put = alc262_fujitsu_master_sw_put,
9167 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9168 },
9169 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9170 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009171 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9172 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009173 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009176 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9177 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9178 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009179 { } /* end */
9180};
9181
Jiang zhe0e31daf2008-03-20 12:12:39 +01009182/* bind hp and internal speaker mute (with plug check) */
9183static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9184 struct snd_ctl_elem_value *ucontrol)
9185{
9186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9187 long *valp = ucontrol->value.integer.value;
9188 int change;
9189
9190 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9191 HDA_AMP_MUTE,
9192 valp ? 0 : HDA_AMP_MUTE);
9193
9194 if (change)
9195 alc262_lenovo_3000_automute(codec, 0);
9196 return change;
9197}
9198
9199static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9200 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9201 {
9202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9203 .name = "Master Playback Switch",
9204 .info = snd_hda_mixer_amp_switch_info,
9205 .get = snd_hda_mixer_amp_switch_get,
9206 .put = alc262_lenovo_3000_master_sw_put,
9207 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9208 },
9209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9211 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9214 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9215 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9216 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9217 { } /* end */
9218};
9219
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009220/* additional init verbs for Benq laptops */
9221static struct hda_verb alc262_EAPD_verbs[] = {
9222 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9223 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9224 {}
9225};
9226
Kailang Yang83c34212007-07-05 11:43:05 +02009227static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9230
9231 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9232 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9233 {}
9234};
9235
Tobin Davisf651b502007-10-26 12:40:47 +02009236/* Samsung Q1 Ultra Vista model setup */
9237static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009238 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9239 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9242 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009243 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009244 { } /* end */
9245};
9246
9247static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009248 /* output mixer */
9249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9252 /* speaker */
9253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9254 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9256 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9257 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9263 /* internal mic */
9264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9266 /* ADC, choose mic */
9267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009277 {}
9278};
9279
Tobin Davisf651b502007-10-26 12:40:47 +02009280/* mute/unmute internal speaker according to the hp jack and mute state */
9281static void alc262_ultra_automute(struct hda_codec *codec)
9282{
9283 struct alc_spec *spec = codec->spec;
9284 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009285
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009286 mute = 0;
9287 /* auto-mute only when HP is used as HP */
9288 if (!spec->cur_mux[0]) {
9289 unsigned int present;
9290 /* need to execute and sync at first */
9291 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9292 present = snd_hda_codec_read(codec, 0x15, 0,
9293 AC_VERB_GET_PIN_SENSE, 0);
9294 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9295 if (spec->jack_present)
9296 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009297 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009298 /* mute/unmute internal speaker */
9299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9300 HDA_AMP_MUTE, mute);
9301 /* mute/unmute HP */
9302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9303 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009304}
9305
9306/* unsolicited event for HP jack sensing */
9307static void alc262_ultra_unsol_event(struct hda_codec *codec,
9308 unsigned int res)
9309{
9310 if ((res >> 26) != ALC880_HP_EVENT)
9311 return;
9312 alc262_ultra_automute(codec);
9313}
9314
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009315static struct hda_input_mux alc262_ultra_capture_source = {
9316 .num_items = 2,
9317 .items = {
9318 { "Mic", 0x1 },
9319 { "Headphone", 0x7 },
9320 },
9321};
9322
9323static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9324 struct snd_ctl_elem_value *ucontrol)
9325{
9326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9327 struct alc_spec *spec = codec->spec;
9328 int ret;
9329
9330 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9331 if (!ret)
9332 return 0;
9333 /* reprogram the HP pin as mic or HP according to the input source */
9334 snd_hda_codec_write_cache(codec, 0x15, 0,
9335 AC_VERB_SET_PIN_WIDGET_CONTROL,
9336 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9337 alc262_ultra_automute(codec); /* mute/unmute HP */
9338 return ret;
9339}
9340
9341static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9342 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9343 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9344 {
9345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9346 .name = "Capture Source",
9347 .info = alc882_mux_enum_info,
9348 .get = alc882_mux_enum_get,
9349 .put = alc262_ultra_mux_enum_put,
9350 },
9351 { } /* end */
9352};
9353
Kailang Yangdf694da2005-12-05 19:42:22 +01009354/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009355static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9356 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009357{
9358 hda_nid_t nid;
9359 int err;
9360
9361 spec->multiout.num_dacs = 1; /* only use one dac */
9362 spec->multiout.dac_nids = spec->private_dac_nids;
9363 spec->multiout.dac_nids[0] = 2;
9364
9365 nid = cfg->line_out_pins[0];
9366 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9368 "Front Playback Volume",
9369 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9370 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009372 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9373 "Front Playback Switch",
9374 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9375 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009376 return err;
9377 }
9378
Takashi Iwai82bc9552006-03-21 11:24:42 +01009379 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009380 if (nid) {
9381 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009382 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9383 "Speaker Playback Volume",
9384 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9385 HDA_OUTPUT));
9386 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009387 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009388 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9389 "Speaker Playback Switch",
9390 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9391 HDA_OUTPUT));
9392 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009393 return err;
9394 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009395 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9396 "Speaker Playback Switch",
9397 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9398 HDA_OUTPUT));
9399 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009400 return err;
9401 }
9402 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009403 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009404 if (nid) {
9405 /* spec->multiout.hp_nid = 2; */
9406 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009407 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9408 "Headphone Playback Volume",
9409 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9410 HDA_OUTPUT));
9411 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009412 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9416 HDA_OUTPUT));
9417 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009418 return err;
9419 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009420 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9421 "Headphone Playback Switch",
9422 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9423 HDA_OUTPUT));
9424 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009425 return err;
9426 }
9427 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009428 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009429}
9430
9431/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009432#define alc262_auto_create_analog_input_ctls \
9433 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009434
9435/*
9436 * generic initialization of ADC, input mixers and output mixers
9437 */
9438static struct hda_verb alc262_volume_init_verbs[] = {
9439 /*
9440 * Unmute ADC0-2 and set the default input to mic-in
9441 */
9442 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9444 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9446 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9448
Takashi Iwaicb53c622007-08-10 17:21:45 +02009449 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009450 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009451 * Note: PASD motherboards uses the Line In 2 as the input for
9452 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009453 */
9454 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009460
9461 /*
9462 * Set up output mixers (0x0c - 0x0f)
9463 */
9464 /* set vol=0 to output mixers */
9465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9468
9469 /* set up input amps for analog loopback */
9470 /* Amp Indices: DAC = 0, mixer = 1 */
9471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9477
9478 /* FIXME: use matrix-type input source selection */
9479 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9480 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9485 /* Input mixer2 */
9486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9490 /* Input mixer3 */
9491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9495
9496 { }
9497};
9498
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9500 /*
9501 * Unmute ADC0-2 and set the default input to mic-in
9502 */
9503 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9505 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9507 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9509
Takashi Iwaicb53c622007-08-10 17:21:45 +02009510 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009511 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 * Note: PASD motherboards uses the Line In 2 as the input for
9513 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009514 */
9515 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009523
9524 /*
9525 * Set up output mixers (0x0c - 0x0e)
9526 */
9527 /* set vol=0 to output mixers */
9528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9531
9532 /* set up input amps for analog loopback */
9533 /* Amp Indices: DAC = 0, mixer = 1 */
9534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9540
Takashi Iwaice875f02008-01-28 18:17:43 +01009541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9544
9545 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9547
9548 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9550
9551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9556
9557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9561 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9562 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9563
9564
9565 /* FIXME: use matrix-type input source selection */
9566 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9567 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9572 /* Input mixer2 */
9573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9577 /* Input mixer3 */
9578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9582
Takashi Iwaice875f02008-01-28 18:17:43 +01009583 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9584
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009585 { }
9586};
9587
Kailang Yangcd7509a2007-01-26 18:33:17 +01009588static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9589 /*
9590 * Unmute ADC0-2 and set the default input to mic-in
9591 */
9592 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9594 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9596 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9598
Takashi Iwaicb53c622007-08-10 17:21:45 +02009599 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009600 * mixer widget
9601 * Note: PASD motherboards uses the Line In 2 as the input for front
9602 * panel mic (mic 2)
9603 */
9604 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009613 /*
9614 * Set up output mixers (0x0c - 0x0e)
9615 */
9616 /* set vol=0 to output mixers */
9617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9620
9621 /* set up input amps for analog loopback */
9622 /* Amp Indices: DAC = 0, mixer = 1 */
9623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9629
9630
9631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9634 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9637 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9638
9639 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9641
9642 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9644
9645 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9649 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9650 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9651
9652 /* FIXME: use matrix-type input source selection */
9653 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9654 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9660 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9662 /* Input mixer2 */
9663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9668 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9670 /* Input mixer3 */
9671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9676 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9678
Takashi Iwaice875f02008-01-28 18:17:43 +01009679 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9680
Kailang Yangcd7509a2007-01-26 18:33:17 +01009681 { }
9682};
9683
Takashi Iwaicb53c622007-08-10 17:21:45 +02009684#ifdef CONFIG_SND_HDA_POWER_SAVE
9685#define alc262_loopbacks alc880_loopbacks
9686#endif
9687
Kailang Yangdf694da2005-12-05 19:42:22 +01009688/* pcm configuration: identiacal with ALC880 */
9689#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9690#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9691#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9692#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9693
9694/*
9695 * BIOS auto configuration
9696 */
9697static int alc262_parse_auto_config(struct hda_codec *codec)
9698{
9699 struct alc_spec *spec = codec->spec;
9700 int err;
9701 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9702
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009703 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9704 alc262_ignore);
9705 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009706 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009707 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009708 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009709 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9710 if (err < 0)
9711 return err;
9712 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9713 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009714 return err;
9715
9716 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9717
9718 if (spec->autocfg.dig_out_pin)
9719 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9720 if (spec->autocfg.dig_in_pin)
9721 spec->dig_in_nid = ALC262_DIGIN_NID;
9722
9723 if (spec->kctl_alloc)
9724 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9725
9726 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009727 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009728 spec->input_mux = &spec->private_imux;
9729
Takashi Iwai776e1842007-08-29 15:07:11 +02009730 err = alc_auto_add_mic_boost(codec);
9731 if (err < 0)
9732 return err;
9733
Kailang Yangdf694da2005-12-05 19:42:22 +01009734 return 1;
9735}
9736
9737#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9738#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9739#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +02009740#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +01009741
9742
9743/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009744static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009745{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009746 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009747 alc262_auto_init_multi_out(codec);
9748 alc262_auto_init_hp_out(codec);
9749 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009750 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009751 if (spec->unsol_event)
9752 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009753}
9754
9755/*
9756 * configuration and preset
9757 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009758static const char *alc262_models[ALC262_MODEL_LAST] = {
9759 [ALC262_BASIC] = "basic",
9760 [ALC262_HIPPO] = "hippo",
9761 [ALC262_HIPPO_1] = "hippo_1",
9762 [ALC262_FUJITSU] = "fujitsu",
9763 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009764 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009765 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009766 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009767 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009768 [ALC262_BENQ_T31] = "benq-t31",
9769 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009770 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009771 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009772 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009773 [ALC262_AUTO] = "auto",
9774};
9775
9776static struct snd_pci_quirk alc262_cfg_tbl[] = {
9777 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009778 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009779 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009780 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009781 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9782 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009783 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009784 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009785 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009786 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009787 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009788 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009789 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009790 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009791 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009792 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009793 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009794 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009795 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9796 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9797 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009798 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9799 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009800 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009801 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009802 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009803 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9804 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9805 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009806 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9807 ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009808 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009809 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009810 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009811 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009812 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009813 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009814 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009815 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009816 {}
9817};
9818
9819static struct alc_config_preset alc262_presets[] = {
9820 [ALC262_BASIC] = {
9821 .mixers = { alc262_base_mixer },
9822 .init_verbs = { alc262_init_verbs },
9823 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9824 .dac_nids = alc262_dac_nids,
9825 .hp_nid = 0x03,
9826 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9827 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009828 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009829 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009830 [ALC262_HIPPO] = {
9831 .mixers = { alc262_base_mixer },
9832 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9833 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9834 .dac_nids = alc262_dac_nids,
9835 .hp_nid = 0x03,
9836 .dig_out_nid = ALC262_DIGOUT_NID,
9837 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9838 .channel_mode = alc262_modes,
9839 .input_mux = &alc262_capture_source,
9840 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009841 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009842 },
9843 [ALC262_HIPPO_1] = {
9844 .mixers = { alc262_hippo1_mixer },
9845 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9847 .dac_nids = alc262_dac_nids,
9848 .hp_nid = 0x02,
9849 .dig_out_nid = ALC262_DIGOUT_NID,
9850 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9851 .channel_mode = alc262_modes,
9852 .input_mux = &alc262_capture_source,
9853 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009854 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009855 },
Takashi Iwai834be882006-03-01 14:16:17 +01009856 [ALC262_FUJITSU] = {
9857 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009858 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9859 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009860 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9861 .dac_nids = alc262_dac_nids,
9862 .hp_nid = 0x03,
9863 .dig_out_nid = ALC262_DIGOUT_NID,
9864 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9865 .channel_mode = alc262_modes,
9866 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009867 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009868 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009869 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009870 [ALC262_HP_BPC] = {
9871 .mixers = { alc262_HP_BPC_mixer },
9872 .init_verbs = { alc262_HP_BPC_init_verbs },
9873 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9874 .dac_nids = alc262_dac_nids,
9875 .hp_nid = 0x03,
9876 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9877 .channel_mode = alc262_modes,
9878 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009879 .unsol_event = alc262_hp_bpc_unsol_event,
9880 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009881 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009882 [ALC262_HP_BPC_D7000_WF] = {
9883 .mixers = { alc262_HP_BPC_WildWest_mixer },
9884 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9885 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9886 .dac_nids = alc262_dac_nids,
9887 .hp_nid = 0x03,
9888 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9889 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009890 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009891 .unsol_event = alc262_hp_wildwest_unsol_event,
9892 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009893 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009894 [ALC262_HP_BPC_D7000_WL] = {
9895 .mixers = { alc262_HP_BPC_WildWest_mixer,
9896 alc262_HP_BPC_WildWest_option_mixer },
9897 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9898 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9899 .dac_nids = alc262_dac_nids,
9900 .hp_nid = 0x03,
9901 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9902 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009903 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009904 .unsol_event = alc262_hp_wildwest_unsol_event,
9905 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009906 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009907 [ALC262_HP_TC_T5735] = {
9908 .mixers = { alc262_hp_t5735_mixer },
9909 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9910 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9911 .dac_nids = alc262_dac_nids,
9912 .hp_nid = 0x03,
9913 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9914 .channel_mode = alc262_modes,
9915 .input_mux = &alc262_capture_source,
9916 .unsol_event = alc262_hp_t5735_unsol_event,
9917 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009918 },
9919 [ALC262_HP_RP5700] = {
9920 .mixers = { alc262_hp_rp5700_mixer },
9921 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9922 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9923 .dac_nids = alc262_dac_nids,
9924 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9925 .channel_mode = alc262_modes,
9926 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009927 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009928 [ALC262_BENQ_ED8] = {
9929 .mixers = { alc262_base_mixer },
9930 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9931 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9932 .dac_nids = alc262_dac_nids,
9933 .hp_nid = 0x03,
9934 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9935 .channel_mode = alc262_modes,
9936 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009937 },
Kailang Yang272a5272007-05-14 11:00:38 +02009938 [ALC262_SONY_ASSAMD] = {
9939 .mixers = { alc262_sony_mixer },
9940 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9941 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9942 .dac_nids = alc262_dac_nids,
9943 .hp_nid = 0x02,
9944 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9945 .channel_mode = alc262_modes,
9946 .input_mux = &alc262_capture_source,
9947 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009948 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009949 },
9950 [ALC262_BENQ_T31] = {
9951 .mixers = { alc262_benq_t31_mixer },
9952 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9953 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9954 .dac_nids = alc262_dac_nids,
9955 .hp_nid = 0x03,
9956 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9957 .channel_mode = alc262_modes,
9958 .input_mux = &alc262_capture_source,
9959 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009960 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009961 },
Tobin Davisf651b502007-10-26 12:40:47 +02009962 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009963 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9964 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9966 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009967 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9968 .channel_mode = alc262_modes,
9969 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009970 .adc_nids = alc262_adc_nids, /* ADC0 */
9971 .capsrc_nids = alc262_capsrc_nids,
9972 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009973 .unsol_event = alc262_ultra_unsol_event,
9974 .init_hook = alc262_ultra_automute,
9975 },
Jiang zhe0e31daf2008-03-20 12:12:39 +01009976 [ALC262_LENOVO_3000] = {
9977 .mixers = { alc262_lenovo_3000_mixer },
9978 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9979 alc262_lenovo_3000_unsol_verbs },
9980 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9981 .dac_nids = alc262_dac_nids,
9982 .hp_nid = 0x03,
9983 .dig_out_nid = ALC262_DIGOUT_NID,
9984 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9985 .channel_mode = alc262_modes,
9986 .input_mux = &alc262_fujitsu_capture_source,
9987 .unsol_event = alc262_lenovo_3000_unsol_event,
9988 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009989 [ALC262_NEC] = {
9990 .mixers = { alc262_nec_mixer },
9991 .init_verbs = { alc262_nec_verbs },
9992 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9993 .dac_nids = alc262_dac_nids,
9994 .hp_nid = 0x03,
9995 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9996 .channel_mode = alc262_modes,
9997 .input_mux = &alc262_capture_source,
9998 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009999};
10000
10001static int patch_alc262(struct hda_codec *codec)
10002{
10003 struct alc_spec *spec;
10004 int board_config;
10005 int err;
10006
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010007 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010008 if (spec == NULL)
10009 return -ENOMEM;
10010
10011 codec->spec = spec;
10012#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010013 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10014 * under-run
10015 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010016 {
10017 int tmp;
10018 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10019 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10020 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10021 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10022 }
10023#endif
10024
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010025 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10026
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010027 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10028 alc262_models,
10029 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010030
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010031 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010032 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10033 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010034 board_config = ALC262_AUTO;
10035 }
10036
10037 if (board_config == ALC262_AUTO) {
10038 /* automatic parse from the BIOS config */
10039 err = alc262_parse_auto_config(codec);
10040 if (err < 0) {
10041 alc_free(codec);
10042 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010043 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010044 printk(KERN_INFO
10045 "hda_codec: Cannot set up configuration "
10046 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010047 board_config = ALC262_BASIC;
10048 }
10049 }
10050
10051 if (board_config != ALC262_AUTO)
10052 setup_preset(spec, &alc262_presets[board_config]);
10053
10054 spec->stream_name_analog = "ALC262 Analog";
10055 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10056 spec->stream_analog_capture = &alc262_pcm_analog_capture;
10057
10058 spec->stream_name_digital = "ALC262 Digital";
10059 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10060 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010062 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010063 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010064 unsigned int wcap = get_wcaps(codec, 0x07);
10065
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010066 /* get type */
10067 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010068 if (wcap != AC_WID_AUD_IN) {
10069 spec->adc_nids = alc262_adc_nids_alt;
10070 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010071 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010072 spec->mixers[spec->num_mixers] =
10073 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010074 spec->num_mixers++;
10075 } else {
10076 spec->adc_nids = alc262_adc_nids;
10077 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010078 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010079 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10080 spec->num_mixers++;
10081 }
10082 }
10083
Takashi Iwai2134ea42008-01-10 16:53:55 +010010084 spec->vmaster_nid = 0x0c;
10085
Kailang Yangdf694da2005-12-05 19:42:22 +010010086 codec->patch_ops = alc_patch_ops;
10087 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010088 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010089#ifdef CONFIG_SND_HDA_POWER_SAVE
10090 if (!spec->loopback.amplist)
10091 spec->loopback.amplist = alc262_loopbacks;
10092#endif
Takashi Iwai834be882006-03-01 14:16:17 +010010093
Kailang Yangdf694da2005-12-05 19:42:22 +010010094 return 0;
10095}
10096
Kailang Yangdf694da2005-12-05 19:42:22 +010010097/*
Kailang Yanga361d842007-06-05 12:30:55 +020010098 * ALC268 channel source setting (2 channel)
10099 */
10100#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10101#define alc268_modes alc260_modes
10102
10103static hda_nid_t alc268_dac_nids[2] = {
10104 /* front, hp */
10105 0x02, 0x03
10106};
10107
10108static hda_nid_t alc268_adc_nids[2] = {
10109 /* ADC0-1 */
10110 0x08, 0x07
10111};
10112
10113static hda_nid_t alc268_adc_nids_alt[1] = {
10114 /* ADC0 */
10115 0x08
10116};
10117
Takashi Iwaie1406342008-02-11 18:32:32 +010010118static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10119
Kailang Yanga361d842007-06-05 12:30:55 +020010120static struct snd_kcontrol_new alc268_base_mixer[] = {
10121 /* output mixer control */
10122 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10123 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10124 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010126 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10128 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010129 { }
10130};
10131
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010132/* bind Beep switches of both NID 0x0f and 0x10 */
10133static struct hda_bind_ctls alc268_bind_beep_sw = {
10134 .ops = &snd_hda_bind_sw,
10135 .values = {
10136 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10137 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10138 0
10139 },
10140};
10141
10142static struct snd_kcontrol_new alc268_beep_mixer[] = {
10143 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10144 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10145 { }
10146};
10147
Kailang Yangd1a991a2007-08-15 16:21:59 +020010148static struct hda_verb alc268_eapd_verbs[] = {
10149 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10150 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10151 { }
10152};
10153
Takashi Iwaid2738092007-08-16 14:59:45 +020010154/* Toshiba specific */
10155#define alc268_toshiba_automute alc262_hippo_automute
10156
10157static struct hda_verb alc268_toshiba_verbs[] = {
10158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10159 { } /* end */
10160};
10161
10162/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010163/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010164static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10165 .ops = &snd_hda_bind_vol,
10166 .values = {
10167 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10168 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10169 0
10170 },
10171};
10172
Takashi Iwai889c4392007-08-23 18:56:52 +020010173/* mute/unmute internal speaker according to the hp jack and mute state */
10174static void alc268_acer_automute(struct hda_codec *codec, int force)
10175{
10176 struct alc_spec *spec = codec->spec;
10177 unsigned int mute;
10178
10179 if (force || !spec->sense_updated) {
10180 unsigned int present;
10181 present = snd_hda_codec_read(codec, 0x14, 0,
10182 AC_VERB_GET_PIN_SENSE, 0);
10183 spec->jack_present = (present & 0x80000000) != 0;
10184 spec->sense_updated = 1;
10185 }
10186 if (spec->jack_present)
10187 mute = HDA_AMP_MUTE; /* mute internal speaker */
10188 else /* unmute internal speaker if necessary */
10189 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10190 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10191 HDA_AMP_MUTE, mute);
10192}
10193
10194
10195/* bind hp and internal speaker mute (with plug check) */
10196static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10197 struct snd_ctl_elem_value *ucontrol)
10198{
10199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10200 long *valp = ucontrol->value.integer.value;
10201 int change;
10202
10203 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10204 HDA_AMP_MUTE,
10205 valp[0] ? 0 : HDA_AMP_MUTE);
10206 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10207 HDA_AMP_MUTE,
10208 valp[1] ? 0 : HDA_AMP_MUTE);
10209 if (change)
10210 alc268_acer_automute(codec, 0);
10211 return change;
10212}
Takashi Iwaid2738092007-08-16 14:59:45 +020010213
10214static struct snd_kcontrol_new alc268_acer_mixer[] = {
10215 /* output mixer control */
10216 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10217 {
10218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10219 .name = "Master Playback Switch",
10220 .info = snd_hda_mixer_amp_switch_info,
10221 .get = snd_hda_mixer_amp_switch_get,
10222 .put = alc268_acer_master_sw_put,
10223 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10224 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10226 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10227 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010228 { }
10229};
10230
10231static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010232 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10233 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10237 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010238
10239 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10240 { }
10241};
10242
10243/* unsolicited event for HP jack sensing */
10244static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10245 unsigned int res)
10246{
Takashi Iwai889c4392007-08-23 18:56:52 +020010247 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010248 return;
10249 alc268_toshiba_automute(codec);
10250}
10251
10252static void alc268_acer_unsol_event(struct hda_codec *codec,
10253 unsigned int res)
10254{
Takashi Iwai889c4392007-08-23 18:56:52 +020010255 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010256 return;
10257 alc268_acer_automute(codec, 1);
10258}
10259
Takashi Iwai889c4392007-08-23 18:56:52 +020010260static void alc268_acer_init_hook(struct hda_codec *codec)
10261{
10262 alc268_acer_automute(codec, 1);
10263}
10264
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010265static struct snd_kcontrol_new alc268_dell_mixer[] = {
10266 /* output mixer control */
10267 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10268 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10271 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10273 { }
10274};
10275
10276static struct hda_verb alc268_dell_verbs[] = {
10277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10280 { }
10281};
10282
10283/* mute/unmute internal speaker according to the hp jack and mute state */
10284static void alc268_dell_automute(struct hda_codec *codec)
10285{
10286 unsigned int present;
10287 unsigned int mute;
10288
10289 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10290 if (present & 0x80000000)
10291 mute = HDA_AMP_MUTE;
10292 else
10293 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10294 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10295 HDA_AMP_MUTE, mute);
10296}
10297
10298static void alc268_dell_unsol_event(struct hda_codec *codec,
10299 unsigned int res)
10300{
10301 if ((res >> 26) != ALC880_HP_EVENT)
10302 return;
10303 alc268_dell_automute(codec);
10304}
10305
10306#define alc268_dell_init_hook alc268_dell_automute
10307
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010308static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10310 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10311 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10313 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10314 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10315 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10316 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10317 { }
10318};
10319
10320static struct hda_verb alc267_quanta_il1_verbs[] = {
10321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10322 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10323 { }
10324};
10325
10326static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10327{
10328 unsigned int present;
10329
10330 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10331 & AC_PINSENSE_PRESENCE;
10332 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10333 present ? 0 : PIN_OUT);
10334}
10335
10336static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10337{
10338 unsigned int present;
10339
10340 present = snd_hda_codec_read(codec, 0x18, 0,
10341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10342 snd_hda_codec_write(codec, 0x23, 0,
10343 AC_VERB_SET_CONNECT_SEL,
10344 present ? 0x00 : 0x01);
10345}
10346
10347static void alc267_quanta_il1_automute(struct hda_codec *codec)
10348{
10349 alc267_quanta_il1_hp_automute(codec);
10350 alc267_quanta_il1_mic_automute(codec);
10351}
10352
10353static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10354 unsigned int res)
10355{
10356 switch (res >> 26) {
10357 case ALC880_HP_EVENT:
10358 alc267_quanta_il1_hp_automute(codec);
10359 break;
10360 case ALC880_MIC_EVENT:
10361 alc267_quanta_il1_mic_automute(codec);
10362 break;
10363 }
10364}
10365
Kailang Yanga361d842007-06-05 12:30:55 +020010366/*
10367 * generic initialization of ADC, input mixers and output mixers
10368 */
10369static struct hda_verb alc268_base_init_verbs[] = {
10370 /* Unmute DAC0-1 and set vol = 0 */
10371 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10372 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10373 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10374 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10375 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10377
10378 /*
10379 * Set up output mixers (0x0c - 0x0e)
10380 */
10381 /* set vol=0 to output mixers */
10382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10385 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10386
10387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10388 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10389
10390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10393 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10395 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10396 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10397 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10398
10399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10401 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10405 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010406
10407 /* set PCBEEP vol = 0, mute connections */
10408 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10410 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010411
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010412 /* Unmute Selector 23h,24h and set the default input to mic-in */
10413
10414 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10416 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010418
Kailang Yanga361d842007-06-05 12:30:55 +020010419 { }
10420};
10421
10422/*
10423 * generic initialization of ADC, input mixers and output mixers
10424 */
10425static struct hda_verb alc268_volume_init_verbs[] = {
10426 /* set output DAC */
10427 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10428 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10429 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10430 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10431
10432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10436 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10437
10438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10442 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10443
10444 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10446 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10447 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10448
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010449 /* set PCBEEP vol = 0, mute connections */
10450 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010453
10454 { }
10455};
10456
10457#define alc268_mux_enum_info alc_mux_enum_info
10458#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010459#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010460
10461static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10462 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10463 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10464 {
10465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10466 /* The multiple "Capture Source" controls confuse alsamixer
10467 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010468 */
10469 /* .name = "Capture Source", */
10470 .name = "Input Source",
10471 .count = 1,
10472 .info = alc268_mux_enum_info,
10473 .get = alc268_mux_enum_get,
10474 .put = alc268_mux_enum_put,
10475 },
10476 { } /* end */
10477};
10478
10479static struct snd_kcontrol_new alc268_capture_mixer[] = {
10480 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10481 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10482 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10483 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10484 {
10485 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10486 /* The multiple "Capture Source" controls confuse alsamixer
10487 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010488 */
10489 /* .name = "Capture Source", */
10490 .name = "Input Source",
10491 .count = 2,
10492 .info = alc268_mux_enum_info,
10493 .get = alc268_mux_enum_get,
10494 .put = alc268_mux_enum_put,
10495 },
10496 { } /* end */
10497};
10498
10499static struct hda_input_mux alc268_capture_source = {
10500 .num_items = 4,
10501 .items = {
10502 { "Mic", 0x0 },
10503 { "Front Mic", 0x1 },
10504 { "Line", 0x2 },
10505 { "CD", 0x3 },
10506 },
10507};
10508
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010509static struct hda_input_mux alc268_acer_capture_source = {
10510 .num_items = 3,
10511 .items = {
10512 { "Mic", 0x0 },
10513 { "Internal Mic", 0x6 },
10514 { "Line", 0x2 },
10515 },
10516};
10517
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010518#ifdef CONFIG_SND_DEBUG
10519static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010520 /* Volume widgets */
10521 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10522 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10523 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10524 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10525 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10526 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10527 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10528 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10529 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10530 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10531 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10532 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10533 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010534 /* The below appears problematic on some hardwares */
10535 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010536 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10537 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10538 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10539 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10540
10541 /* Modes for retasking pin widgets */
10542 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10543 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10544 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10545 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10546
10547 /* Controls for GPIO pins, assuming they are configured as outputs */
10548 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10549 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10550 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10551 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10552
10553 /* Switches to allow the digital SPDIF output pin to be enabled.
10554 * The ALC268 does not have an SPDIF input.
10555 */
10556 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10557
10558 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10559 * this output to turn on an external amplifier.
10560 */
10561 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10562 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10563
10564 { } /* end */
10565};
10566#endif
10567
Kailang Yanga361d842007-06-05 12:30:55 +020010568/* create input playback/capture controls for the given pin */
10569static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10570 const char *ctlname, int idx)
10571{
10572 char name[32];
10573 int err;
10574
10575 sprintf(name, "%s Playback Volume", ctlname);
10576 if (nid == 0x14) {
10577 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10578 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10579 HDA_OUTPUT));
10580 if (err < 0)
10581 return err;
10582 } else if (nid == 0x15) {
10583 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10584 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10585 HDA_OUTPUT));
10586 if (err < 0)
10587 return err;
10588 } else
10589 return -1;
10590 sprintf(name, "%s Playback Switch", ctlname);
10591 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10592 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10593 if (err < 0)
10594 return err;
10595 return 0;
10596}
10597
10598/* add playback controls from the parsed DAC table */
10599static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10600 const struct auto_pin_cfg *cfg)
10601{
10602 hda_nid_t nid;
10603 int err;
10604
10605 spec->multiout.num_dacs = 2; /* only use one dac */
10606 spec->multiout.dac_nids = spec->private_dac_nids;
10607 spec->multiout.dac_nids[0] = 2;
10608 spec->multiout.dac_nids[1] = 3;
10609
10610 nid = cfg->line_out_pins[0];
10611 if (nid)
10612 alc268_new_analog_output(spec, nid, "Front", 0);
10613
10614 nid = cfg->speaker_pins[0];
10615 if (nid == 0x1d) {
10616 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10617 "Speaker Playback Volume",
10618 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10619 if (err < 0)
10620 return err;
10621 }
10622 nid = cfg->hp_pins[0];
10623 if (nid)
10624 alc268_new_analog_output(spec, nid, "Headphone", 0);
10625
10626 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10627 if (nid == 0x16) {
10628 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10629 "Mono Playback Switch",
10630 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10631 if (err < 0)
10632 return err;
10633 }
10634 return 0;
10635}
10636
10637/* create playback/capture controls for input pins */
10638static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10639 const struct auto_pin_cfg *cfg)
10640{
10641 struct hda_input_mux *imux = &spec->private_imux;
10642 int i, idx1;
10643
10644 for (i = 0; i < AUTO_PIN_LAST; i++) {
10645 switch(cfg->input_pins[i]) {
10646 case 0x18:
10647 idx1 = 0; /* Mic 1 */
10648 break;
10649 case 0x19:
10650 idx1 = 1; /* Mic 2 */
10651 break;
10652 case 0x1a:
10653 idx1 = 2; /* Line In */
10654 break;
10655 case 0x1c:
10656 idx1 = 3; /* CD */
10657 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010658 case 0x12:
10659 case 0x13:
10660 idx1 = 6; /* digital mics */
10661 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010662 default:
10663 continue;
10664 }
10665 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10666 imux->items[imux->num_items].index = idx1;
10667 imux->num_items++;
10668 }
10669 return 0;
10670}
10671
10672static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10673{
10674 struct alc_spec *spec = codec->spec;
10675 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10676 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10677 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10678 unsigned int dac_vol1, dac_vol2;
10679
10680 if (speaker_nid) {
10681 snd_hda_codec_write(codec, speaker_nid, 0,
10682 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10683 snd_hda_codec_write(codec, 0x0f, 0,
10684 AC_VERB_SET_AMP_GAIN_MUTE,
10685 AMP_IN_UNMUTE(1));
10686 snd_hda_codec_write(codec, 0x10, 0,
10687 AC_VERB_SET_AMP_GAIN_MUTE,
10688 AMP_IN_UNMUTE(1));
10689 } else {
10690 snd_hda_codec_write(codec, 0x0f, 0,
10691 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10692 snd_hda_codec_write(codec, 0x10, 0,
10693 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10694 }
10695
10696 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10697 if (line_nid == 0x14)
10698 dac_vol2 = AMP_OUT_ZERO;
10699 else if (line_nid == 0x15)
10700 dac_vol1 = AMP_OUT_ZERO;
10701 if (hp_nid == 0x14)
10702 dac_vol2 = AMP_OUT_ZERO;
10703 else if (hp_nid == 0x15)
10704 dac_vol1 = AMP_OUT_ZERO;
10705 if (line_nid != 0x16 || hp_nid != 0x16 ||
10706 spec->autocfg.line_out_pins[1] != 0x16 ||
10707 spec->autocfg.line_out_pins[2] != 0x16)
10708 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10709
10710 snd_hda_codec_write(codec, 0x02, 0,
10711 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10712 snd_hda_codec_write(codec, 0x03, 0,
10713 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10714}
10715
10716/* pcm configuration: identiacal with ALC880 */
10717#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10718#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010719#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010720#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10721
10722/*
10723 * BIOS auto configuration
10724 */
10725static int alc268_parse_auto_config(struct hda_codec *codec)
10726{
10727 struct alc_spec *spec = codec->spec;
10728 int err;
10729 static hda_nid_t alc268_ignore[] = { 0 };
10730
10731 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10732 alc268_ignore);
10733 if (err < 0)
10734 return err;
10735 if (!spec->autocfg.line_outs)
10736 return 0; /* can't find valid BIOS pin config */
10737
10738 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10739 if (err < 0)
10740 return err;
10741 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10742 if (err < 0)
10743 return err;
10744
10745 spec->multiout.max_channels = 2;
10746
10747 /* digital only support output */
10748 if (spec->autocfg.dig_out_pin)
10749 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10750
10751 if (spec->kctl_alloc)
10752 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10753
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010754 if (spec->autocfg.speaker_pins[0] != 0x1d)
10755 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10756
Kailang Yanga361d842007-06-05 12:30:55 +020010757 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10758 spec->num_mux_defs = 1;
10759 spec->input_mux = &spec->private_imux;
10760
Takashi Iwai776e1842007-08-29 15:07:11 +020010761 err = alc_auto_add_mic_boost(codec);
10762 if (err < 0)
10763 return err;
10764
Kailang Yanga361d842007-06-05 12:30:55 +020010765 return 1;
10766}
10767
10768#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10769#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10770#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10771
10772/* init callback for auto-configuration model -- overriding the default init */
10773static void alc268_auto_init(struct hda_codec *codec)
10774{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010775 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010776 alc268_auto_init_multi_out(codec);
10777 alc268_auto_init_hp_out(codec);
10778 alc268_auto_init_mono_speaker_out(codec);
10779 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010780 if (spec->unsol_event)
10781 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010782}
10783
10784/*
10785 * configuration and preset
10786 */
10787static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010788 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010789 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010790 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010791 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010792 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010793 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010794#ifdef CONFIG_SND_DEBUG
10795 [ALC268_TEST] = "test",
10796#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010797 [ALC268_AUTO] = "auto",
10798};
10799
10800static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010801 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010802 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010803 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010804 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010805 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010806 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010807 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010808 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010809 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010810 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010811 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010812 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010813 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010814 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010815 {}
10816};
10817
10818static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010819 [ALC267_QUANTA_IL1] = {
10820 .mixers = { alc267_quanta_il1_mixer },
10821 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10822 alc267_quanta_il1_verbs },
10823 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10824 .dac_nids = alc268_dac_nids,
10825 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10826 .adc_nids = alc268_adc_nids_alt,
10827 .hp_nid = 0x03,
10828 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10829 .channel_mode = alc268_modes,
10830 .input_mux = &alc268_capture_source,
10831 .unsol_event = alc267_quanta_il1_unsol_event,
10832 .init_hook = alc267_quanta_il1_automute,
10833 },
Kailang Yanga361d842007-06-05 12:30:55 +020010834 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010835 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10836 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010837 .init_verbs = { alc268_base_init_verbs },
10838 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10839 .dac_nids = alc268_dac_nids,
10840 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10841 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010842 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010843 .hp_nid = 0x03,
10844 .dig_out_nid = ALC268_DIGOUT_NID,
10845 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10846 .channel_mode = alc268_modes,
10847 .input_mux = &alc268_capture_source,
10848 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010849 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010850 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10851 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010852 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10853 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010854 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10855 .dac_nids = alc268_dac_nids,
10856 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10857 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010858 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010859 .hp_nid = 0x03,
10860 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10861 .channel_mode = alc268_modes,
10862 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010863 .unsol_event = alc268_toshiba_unsol_event,
10864 .init_hook = alc268_toshiba_automute,
10865 },
10866 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010867 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10868 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010869 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10870 alc268_acer_verbs },
10871 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10872 .dac_nids = alc268_dac_nids,
10873 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10874 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010875 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010876 .hp_nid = 0x02,
10877 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10878 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010879 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010880 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010881 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010882 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010883 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010884 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010885 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10886 alc268_dell_verbs },
10887 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10888 .dac_nids = alc268_dac_nids,
10889 .hp_nid = 0x02,
10890 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10891 .channel_mode = alc268_modes,
10892 .unsol_event = alc268_dell_unsol_event,
10893 .init_hook = alc268_dell_init_hook,
10894 .input_mux = &alc268_capture_source,
10895 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010896 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010897 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10898 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010899 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10900 alc268_toshiba_verbs },
10901 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10902 .dac_nids = alc268_dac_nids,
10903 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10904 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010905 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010906 .hp_nid = 0x03,
10907 .dig_out_nid = ALC268_DIGOUT_NID,
10908 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10909 .channel_mode = alc268_modes,
10910 .input_mux = &alc268_capture_source,
10911 .unsol_event = alc268_toshiba_unsol_event,
10912 .init_hook = alc268_toshiba_automute
10913 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010914#ifdef CONFIG_SND_DEBUG
10915 [ALC268_TEST] = {
10916 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10917 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10918 alc268_volume_init_verbs },
10919 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10920 .dac_nids = alc268_dac_nids,
10921 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10922 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010923 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010924 .hp_nid = 0x03,
10925 .dig_out_nid = ALC268_DIGOUT_NID,
10926 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10927 .channel_mode = alc268_modes,
10928 .input_mux = &alc268_capture_source,
10929 },
10930#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010931};
10932
10933static int patch_alc268(struct hda_codec *codec)
10934{
10935 struct alc_spec *spec;
10936 int board_config;
10937 int err;
10938
10939 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10940 if (spec == NULL)
10941 return -ENOMEM;
10942
10943 codec->spec = spec;
10944
10945 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10946 alc268_models,
10947 alc268_cfg_tbl);
10948
10949 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10950 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10951 "trying auto-probe from BIOS...\n");
10952 board_config = ALC268_AUTO;
10953 }
10954
10955 if (board_config == ALC268_AUTO) {
10956 /* automatic parse from the BIOS config */
10957 err = alc268_parse_auto_config(codec);
10958 if (err < 0) {
10959 alc_free(codec);
10960 return err;
10961 } else if (!err) {
10962 printk(KERN_INFO
10963 "hda_codec: Cannot set up configuration "
10964 "from BIOS. Using base mode...\n");
10965 board_config = ALC268_3ST;
10966 }
10967 }
10968
10969 if (board_config != ALC268_AUTO)
10970 setup_preset(spec, &alc268_presets[board_config]);
10971
Kailang Yang2f893282008-05-27 12:14:47 +020010972 if (codec->vendor_id == 0x10ec0267) {
10973 spec->stream_name_analog = "ALC267 Analog";
10974 spec->stream_name_digital = "ALC267 Digital";
10975 } else {
10976 spec->stream_name_analog = "ALC268 Analog";
10977 spec->stream_name_digital = "ALC268 Digital";
10978 }
10979
Kailang Yanga361d842007-06-05 12:30:55 +020010980 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10981 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010982 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010983
Kailang Yanga361d842007-06-05 12:30:55 +020010984 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10985
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010986 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10987 /* override the amp caps for beep generator */
10988 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10989 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10990 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10991 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10992 (0 << AC_AMPCAP_MUTE_SHIFT));
10993
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010994 if (!spec->adc_nids && spec->input_mux) {
10995 /* check whether NID 0x07 is valid */
10996 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010997 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010998
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010999 /* get type */
11000 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011001 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011002 spec->adc_nids = alc268_adc_nids_alt;
11003 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11004 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011005 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011006 spec->num_mixers++;
11007 } else {
11008 spec->adc_nids = alc268_adc_nids;
11009 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11010 spec->mixers[spec->num_mixers] =
11011 alc268_capture_mixer;
11012 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011013 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011014 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011015 /* set default input source */
11016 for (i = 0; i < spec->num_adc_nids; i++)
11017 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11018 0, AC_VERB_SET_CONNECT_SEL,
11019 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011020 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011021
11022 spec->vmaster_nid = 0x02;
11023
Kailang Yanga361d842007-06-05 12:30:55 +020011024 codec->patch_ops = alc_patch_ops;
11025 if (board_config == ALC268_AUTO)
11026 spec->init_hook = alc268_auto_init;
11027
11028 return 0;
11029}
11030
11031/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011032 * ALC269 channel source setting (2 channel)
11033 */
11034#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11035
11036#define alc269_dac_nids alc260_dac_nids
11037
11038static hda_nid_t alc269_adc_nids[1] = {
11039 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011040 0x08,
11041};
11042
11043static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11044 .num_items = 2,
11045 .items = {
11046 { "i-Mic", 0x5 },
11047 { "e-Mic", 0x0 },
11048 },
11049};
11050
11051static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11052 .num_items = 2,
11053 .items = {
11054 { "i-Mic", 0x1 },
11055 { "e-Mic", 0x0 },
11056 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011057};
11058
11059#define alc269_modes alc260_modes
11060#define alc269_capture_source alc880_lg_lw_capture_source
11061
11062static struct snd_kcontrol_new alc269_base_mixer[] = {
11063 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11064 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11066 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11070 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11072 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11074 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11075 { } /* end */
11076};
11077
Kailang Yangf53281e2008-07-18 12:36:43 +020011078/* bind volumes of both NID 0x0c and 0x0d */
11079static struct hda_bind_ctls alc269_epc_bind_vol = {
11080 .ops = &snd_hda_bind_vol,
11081 .values = {
11082 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11083 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11084 0
11085 },
11086};
11087
11088static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11089 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11090 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11091 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11092 { } /* end */
11093};
11094
Kailang Yangf6a92242007-12-13 16:52:54 +010011095/* capture mixer elements */
11096static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011097 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11098 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011099 {
11100 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11101 /* The multiple "Capture Source" controls confuse alsamixer
11102 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011103 */
11104 /* .name = "Capture Source", */
11105 .name = "Input Source",
11106 .count = 1,
11107 .info = alc_mux_enum_info,
11108 .get = alc_mux_enum_get,
11109 .put = alc_mux_enum_put,
11110 },
11111 { } /* end */
11112};
11113
Kailang Yangf53281e2008-07-18 12:36:43 +020011114/* capture mixer elements */
11115static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11116 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11117 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11118 { } /* end */
11119};
11120
Kailang Yangf6a92242007-12-13 16:52:54 +010011121/*
11122 * generic initialization of ADC, input mixers and output mixers
11123 */
11124static struct hda_verb alc269_init_verbs[] = {
11125 /*
11126 * Unmute ADC0 and set the default input to mic-in
11127 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011129
11130 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11131 * analog-loopback mixer widget
11132 * Note: PASD motherboards uses the Line In 2 as the input for
11133 * front panel mic (mic 2)
11134 */
11135 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11141
11142 /*
11143 * Set up output mixers (0x0c - 0x0e)
11144 */
11145 /* set vol=0 to output mixers */
11146 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11147 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11148
11149 /* set up input amps for analog loopback */
11150 /* Amp Indices: DAC = 0, mixer = 1 */
11151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11157
11158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11160 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11161 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11163 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11165
11166 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11167 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11169 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11170 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11172 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11173
11174 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11176
11177 /* FIXME: use matrix-type input source selection */
11178 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11179 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11184
11185 /* set EAPD */
11186 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11187 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11188 { }
11189};
11190
Kailang Yangf53281e2008-07-18 12:36:43 +020011191static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11193 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11194 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11196 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11197 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11199 {}
11200};
11201
11202static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11204 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11205 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11207 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11209 {}
11210};
11211
11212/* toggle speaker-output according to the hp-jack state */
11213static void alc269_speaker_automute(struct hda_codec *codec)
11214{
11215 unsigned int present;
11216 unsigned int bits;
11217
11218 present = snd_hda_codec_read(codec, 0x15, 0,
11219 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11220 bits = present ? AMP_IN_MUTE(0) : 0;
11221 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11222 AMP_IN_MUTE(0), bits);
11223 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11224 AMP_IN_MUTE(0), bits);
11225}
11226
11227static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11228{
11229 unsigned int present;
11230
11231 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11232 & AC_PINSENSE_PRESENCE;
11233 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11234 present ? 0 : 5);
11235}
11236
11237static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11238{
11239 unsigned int present;
11240
11241 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11242 & AC_PINSENSE_PRESENCE;
11243 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11244 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11245 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11246 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11247}
11248
11249/* unsolicited event for HP jack sensing */
11250static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11251 unsigned int res)
11252{
11253 if ((res >> 26) == ALC880_HP_EVENT)
11254 alc269_speaker_automute(codec);
11255
11256 if ((res >> 26) == ALC880_MIC_EVENT)
11257 alc269_eeepc_dmic_automute(codec);
11258}
11259
11260static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11261{
11262 alc269_speaker_automute(codec);
11263 alc269_eeepc_dmic_automute(codec);
11264}
11265
11266/* unsolicited event for HP jack sensing */
11267static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11268 unsigned int res)
11269{
11270 if ((res >> 26) == ALC880_HP_EVENT)
11271 alc269_speaker_automute(codec);
11272
11273 if ((res >> 26) == ALC880_MIC_EVENT)
11274 alc269_eeepc_amic_automute(codec);
11275}
11276
11277static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11278{
11279 alc269_speaker_automute(codec);
11280 alc269_eeepc_amic_automute(codec);
11281}
11282
Kailang Yangf6a92242007-12-13 16:52:54 +010011283/* add playback controls from the parsed DAC table */
11284static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11285 const struct auto_pin_cfg *cfg)
11286{
11287 hda_nid_t nid;
11288 int err;
11289
11290 spec->multiout.num_dacs = 1; /* only use one dac */
11291 spec->multiout.dac_nids = spec->private_dac_nids;
11292 spec->multiout.dac_nids[0] = 2;
11293
11294 nid = cfg->line_out_pins[0];
11295 if (nid) {
11296 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11297 "Front Playback Volume",
11298 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11299 if (err < 0)
11300 return err;
11301 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11302 "Front Playback Switch",
11303 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11304 if (err < 0)
11305 return err;
11306 }
11307
11308 nid = cfg->speaker_pins[0];
11309 if (nid) {
11310 if (!cfg->line_out_pins[0]) {
11311 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11312 "Speaker Playback Volume",
11313 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11314 HDA_OUTPUT));
11315 if (err < 0)
11316 return err;
11317 }
11318 if (nid == 0x16) {
11319 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11320 "Speaker Playback Switch",
11321 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11322 HDA_OUTPUT));
11323 if (err < 0)
11324 return err;
11325 } else {
11326 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11327 "Speaker Playback Switch",
11328 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11329 HDA_OUTPUT));
11330 if (err < 0)
11331 return err;
11332 }
11333 }
11334 nid = cfg->hp_pins[0];
11335 if (nid) {
11336 /* spec->multiout.hp_nid = 2; */
11337 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11338 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11339 "Headphone Playback Volume",
11340 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11341 HDA_OUTPUT));
11342 if (err < 0)
11343 return err;
11344 }
11345 if (nid == 0x16) {
11346 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11347 "Headphone Playback Switch",
11348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11349 HDA_OUTPUT));
11350 if (err < 0)
11351 return err;
11352 } else {
11353 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11354 "Headphone Playback Switch",
11355 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11356 HDA_OUTPUT));
11357 if (err < 0)
11358 return err;
11359 }
11360 }
11361 return 0;
11362}
11363
11364#define alc269_auto_create_analog_input_ctls \
11365 alc880_auto_create_analog_input_ctls
11366
11367#ifdef CONFIG_SND_HDA_POWER_SAVE
11368#define alc269_loopbacks alc880_loopbacks
11369#endif
11370
11371/* pcm configuration: identiacal with ALC880 */
11372#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11373#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11374#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11375#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11376
11377/*
11378 * BIOS auto configuration
11379 */
11380static int alc269_parse_auto_config(struct hda_codec *codec)
11381{
11382 struct alc_spec *spec = codec->spec;
11383 int err;
11384 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11385
11386 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11387 alc269_ignore);
11388 if (err < 0)
11389 return err;
11390
11391 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11392 if (err < 0)
11393 return err;
11394 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11395 if (err < 0)
11396 return err;
11397
11398 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11399
11400 if (spec->autocfg.dig_out_pin)
11401 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11402
11403 if (spec->kctl_alloc)
11404 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11405
11406 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11407 spec->num_mux_defs = 1;
11408 spec->input_mux = &spec->private_imux;
11409
11410 err = alc_auto_add_mic_boost(codec);
11411 if (err < 0)
11412 return err;
11413
Kailang Yangf53281e2008-07-18 12:36:43 +020011414 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11415 spec->num_mixers++;
11416
Kailang Yangf6a92242007-12-13 16:52:54 +010011417 return 1;
11418}
11419
11420#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11421#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11422#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11423
11424
11425/* init callback for auto-configuration model -- overriding the default init */
11426static void alc269_auto_init(struct hda_codec *codec)
11427{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011428 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011429 alc269_auto_init_multi_out(codec);
11430 alc269_auto_init_hp_out(codec);
11431 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011432 if (spec->unsol_event)
11433 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011434}
11435
11436/*
11437 * configuration and preset
11438 */
11439static const char *alc269_models[ALC269_MODEL_LAST] = {
11440 [ALC269_BASIC] = "basic",
11441};
11442
11443static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011444 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11445 ALC269_ASUS_EEEPC_P703),
11446 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11447 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010011448 {}
11449};
11450
11451static struct alc_config_preset alc269_presets[] = {
11452 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011453 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010011454 .init_verbs = { alc269_init_verbs },
11455 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11456 .dac_nids = alc269_dac_nids,
11457 .hp_nid = 0x03,
11458 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11459 .channel_mode = alc269_modes,
11460 .input_mux = &alc269_capture_source,
11461 },
Kailang Yangf53281e2008-07-18 12:36:43 +020011462 [ALC269_ASUS_EEEPC_P703] = {
11463 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11464 .init_verbs = { alc269_init_verbs,
11465 alc269_eeepc_amic_init_verbs },
11466 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11467 .dac_nids = alc269_dac_nids,
11468 .hp_nid = 0x03,
11469 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11470 .channel_mode = alc269_modes,
11471 .input_mux = &alc269_eeepc_amic_capture_source,
11472 .unsol_event = alc269_eeepc_amic_unsol_event,
11473 .init_hook = alc269_eeepc_amic_inithook,
11474 },
11475 [ALC269_ASUS_EEEPC_P901] = {
11476 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11477 .init_verbs = { alc269_init_verbs,
11478 alc269_eeepc_dmic_init_verbs },
11479 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11480 .dac_nids = alc269_dac_nids,
11481 .hp_nid = 0x03,
11482 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11483 .channel_mode = alc269_modes,
11484 .input_mux = &alc269_eeepc_dmic_capture_source,
11485 .unsol_event = alc269_eeepc_dmic_unsol_event,
11486 .init_hook = alc269_eeepc_dmic_inithook,
11487 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011488};
11489
11490static int patch_alc269(struct hda_codec *codec)
11491{
11492 struct alc_spec *spec;
11493 int board_config;
11494 int err;
11495
11496 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11497 if (spec == NULL)
11498 return -ENOMEM;
11499
11500 codec->spec = spec;
11501
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011502 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11503
Kailang Yangf6a92242007-12-13 16:52:54 +010011504 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11505 alc269_models,
11506 alc269_cfg_tbl);
11507
11508 if (board_config < 0) {
11509 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11510 "trying auto-probe from BIOS...\n");
11511 board_config = ALC269_AUTO;
11512 }
11513
11514 if (board_config == ALC269_AUTO) {
11515 /* automatic parse from the BIOS config */
11516 err = alc269_parse_auto_config(codec);
11517 if (err < 0) {
11518 alc_free(codec);
11519 return err;
11520 } else if (!err) {
11521 printk(KERN_INFO
11522 "hda_codec: Cannot set up configuration "
11523 "from BIOS. Using base mode...\n");
11524 board_config = ALC269_BASIC;
11525 }
11526 }
11527
11528 if (board_config != ALC269_AUTO)
11529 setup_preset(spec, &alc269_presets[board_config]);
11530
11531 spec->stream_name_analog = "ALC269 Analog";
11532 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11533 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11534
11535 spec->stream_name_digital = "ALC269 Digital";
11536 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11537 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11538
11539 spec->adc_nids = alc269_adc_nids;
11540 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Kailang Yangf6a92242007-12-13 16:52:54 +010011541
11542 codec->patch_ops = alc_patch_ops;
11543 if (board_config == ALC269_AUTO)
11544 spec->init_hook = alc269_auto_init;
11545#ifdef CONFIG_SND_HDA_POWER_SAVE
11546 if (!spec->loopback.amplist)
11547 spec->loopback.amplist = alc269_loopbacks;
11548#endif
11549
11550 return 0;
11551}
11552
11553/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011554 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11555 */
11556
11557/*
11558 * set the path ways for 2 channel output
11559 * need to set the codec line out and mic 1 pin widgets to inputs
11560 */
11561static struct hda_verb alc861_threestack_ch2_init[] = {
11562 /* set pin widget 1Ah (line in) for input */
11563 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011564 /* set pin widget 18h (mic1/2) for input, for mic also enable
11565 * the vref
11566 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011567 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11568
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011569 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11570#if 0
11571 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11572 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11573#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011574 { } /* end */
11575};
11576/*
11577 * 6ch mode
11578 * need to set the codec line out and mic 1 pin widgets to outputs
11579 */
11580static struct hda_verb alc861_threestack_ch6_init[] = {
11581 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11582 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11583 /* set pin widget 18h (mic1) for output (CLFE)*/
11584 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11585
11586 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011587 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011588
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011589 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11590#if 0
11591 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11593#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011594 { } /* end */
11595};
11596
11597static struct hda_channel_mode alc861_threestack_modes[2] = {
11598 { 2, alc861_threestack_ch2_init },
11599 { 6, alc861_threestack_ch6_init },
11600};
Takashi Iwai22309c32006-08-09 16:57:28 +020011601/* Set mic1 as input and unmute the mixer */
11602static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11603 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11604 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11605 { } /* end */
11606};
11607/* Set mic1 as output and mute mixer */
11608static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11609 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11611 { } /* end */
11612};
11613
11614static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11615 { 2, alc861_uniwill_m31_ch2_init },
11616 { 4, alc861_uniwill_m31_ch4_init },
11617};
Kailang Yangdf694da2005-12-05 19:42:22 +010011618
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011619/* Set mic1 and line-in as input and unmute the mixer */
11620static struct hda_verb alc861_asus_ch2_init[] = {
11621 /* set pin widget 1Ah (line in) for input */
11622 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011623 /* set pin widget 18h (mic1/2) for input, for mic also enable
11624 * the vref
11625 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11627
11628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11629#if 0
11630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11632#endif
11633 { } /* end */
11634};
11635/* Set mic1 nad line-in as output and mute mixer */
11636static struct hda_verb alc861_asus_ch6_init[] = {
11637 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11638 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11639 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11640 /* set pin widget 18h (mic1) for output (CLFE)*/
11641 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11642 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11643 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11644 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11645
11646 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11647#if 0
11648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11650#endif
11651 { } /* end */
11652};
11653
11654static struct hda_channel_mode alc861_asus_modes[2] = {
11655 { 2, alc861_asus_ch2_init },
11656 { 6, alc861_asus_ch6_init },
11657};
11658
Kailang Yangdf694da2005-12-05 19:42:22 +010011659/* patch-ALC861 */
11660
11661static struct snd_kcontrol_new alc861_base_mixer[] = {
11662 /* output mixer control */
11663 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11664 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11665 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11666 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11667 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11668
11669 /*Input mixer control */
11670 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11671 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11672 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11673 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11674 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11675 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11677 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011680
Kailang Yangdf694da2005-12-05 19:42:22 +010011681 /* Capture mixer control */
11682 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11683 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11684 {
11685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11686 .name = "Capture Source",
11687 .count = 1,
11688 .info = alc_mux_enum_info,
11689 .get = alc_mux_enum_get,
11690 .put = alc_mux_enum_put,
11691 },
11692 { } /* end */
11693};
11694
11695static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11696 /* output mixer control */
11697 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11698 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11699 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11700 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11701 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11702
11703 /* Input mixer control */
11704 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11705 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11706 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11707 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11708 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11709 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11711 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11712 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011714
Kailang Yangdf694da2005-12-05 19:42:22 +010011715 /* Capture mixer control */
11716 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11717 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11718 {
11719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11720 .name = "Capture Source",
11721 .count = 1,
11722 .info = alc_mux_enum_info,
11723 .get = alc_mux_enum_get,
11724 .put = alc_mux_enum_put,
11725 },
11726 {
11727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11728 .name = "Channel Mode",
11729 .info = alc_ch_mode_info,
11730 .get = alc_ch_mode_get,
11731 .put = alc_ch_mode_put,
11732 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11733 },
11734 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011735};
11736
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011737static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011738 /* output mixer control */
11739 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11741 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11742
11743 /*Capture mixer control */
11744 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11745 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11746 {
11747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11748 .name = "Capture Source",
11749 .count = 1,
11750 .info = alc_mux_enum_info,
11751 .get = alc_mux_enum_get,
11752 .put = alc_mux_enum_put,
11753 },
11754
11755 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011756};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011757
Takashi Iwai22309c32006-08-09 16:57:28 +020011758static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11759 /* output mixer control */
11760 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11761 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11762 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11763 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11764 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11765
11766 /* Input mixer control */
11767 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11768 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11769 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11770 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11771 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11772 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11774 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11775 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011777
Takashi Iwai22309c32006-08-09 16:57:28 +020011778 /* Capture mixer control */
11779 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11780 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11781 {
11782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11783 .name = "Capture Source",
11784 .count = 1,
11785 .info = alc_mux_enum_info,
11786 .get = alc_mux_enum_get,
11787 .put = alc_mux_enum_put,
11788 },
11789 {
11790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11791 .name = "Channel Mode",
11792 .info = alc_ch_mode_info,
11793 .get = alc_ch_mode_get,
11794 .put = alc_ch_mode_put,
11795 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11796 },
11797 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011798};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011799
11800static struct snd_kcontrol_new alc861_asus_mixer[] = {
11801 /* output mixer control */
11802 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11803 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11804 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11805 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11806 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11807
11808 /* Input mixer control */
11809 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11810 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11811 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11812 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11813 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11814 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11816 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011818 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11819
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011820 /* Capture mixer control */
11821 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11822 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11823 {
11824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11825 .name = "Capture Source",
11826 .count = 1,
11827 .info = alc_mux_enum_info,
11828 .get = alc_mux_enum_get,
11829 .put = alc_mux_enum_put,
11830 },
11831 {
11832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11833 .name = "Channel Mode",
11834 .info = alc_ch_mode_info,
11835 .get = alc_ch_mode_get,
11836 .put = alc_ch_mode_put,
11837 .private_value = ARRAY_SIZE(alc861_asus_modes),
11838 },
11839 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011840};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011841
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011842/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011843static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011844 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11845 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11846 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11847 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11848 { }
11849};
11850
Kailang Yangdf694da2005-12-05 19:42:22 +010011851/*
11852 * generic initialization of ADC, input mixers and output mixers
11853 */
11854static struct hda_verb alc861_base_init_verbs[] = {
11855 /*
11856 * Unmute ADC0 and set the default input to mic-in
11857 */
11858 /* port-A for surround (rear panel) */
11859 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11860 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11861 /* port-B for mic-in (rear panel) with vref */
11862 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11863 /* port-C for line-in (rear panel) */
11864 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11865 /* port-D for Front */
11866 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11867 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11868 /* port-E for HP out (front panel) */
11869 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11870 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011871 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011872 /* port-F for mic-in (front panel) with vref */
11873 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11874 /* port-G for CLFE (rear panel) */
11875 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11876 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11877 /* port-H for side (rear panel) */
11878 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11879 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11880 /* CD-in */
11881 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11882 /* route front mic to ADC1*/
11883 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11885
11886 /* Unmute DAC0~3 & spdif out*/
11887 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11888 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11889 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11890 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11892
11893 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11894 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11895 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11896 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11897 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11898
11899 /* Unmute Stereo Mixer 15 */
11900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011904
11905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11906 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11908 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011913 /* hp used DAC 3 (Front) */
11914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11916
11917 { }
11918};
11919
11920static struct hda_verb alc861_threestack_init_verbs[] = {
11921 /*
11922 * Unmute ADC0 and set the default input to mic-in
11923 */
11924 /* port-A for surround (rear panel) */
11925 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11926 /* port-B for mic-in (rear panel) with vref */
11927 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11928 /* port-C for line-in (rear panel) */
11929 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11930 /* port-D for Front */
11931 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11932 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11933 /* port-E for HP out (front panel) */
11934 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11935 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011936 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011937 /* port-F for mic-in (front panel) with vref */
11938 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11939 /* port-G for CLFE (rear panel) */
11940 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11941 /* port-H for side (rear panel) */
11942 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11943 /* CD-in */
11944 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11945 /* route front mic to ADC1*/
11946 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11948 /* Unmute DAC0~3 & spdif out*/
11949 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11950 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11951 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11952 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11954
11955 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11956 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11957 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11958 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11959 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11960
11961 /* Unmute Stereo Mixer 15 */
11962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011965 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011966
11967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11968 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11969 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11970 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11971 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011975 /* hp used DAC 3 (Front) */
11976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011977 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11978 { }
11979};
Takashi Iwai22309c32006-08-09 16:57:28 +020011980
11981static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11982 /*
11983 * Unmute ADC0 and set the default input to mic-in
11984 */
11985 /* port-A for surround (rear panel) */
11986 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11987 /* port-B for mic-in (rear panel) with vref */
11988 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11989 /* port-C for line-in (rear panel) */
11990 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11991 /* port-D for Front */
11992 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11993 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11994 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011995 /* this has to be set to VREF80 */
11996 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011997 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011998 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011999 /* port-F for mic-in (front panel) with vref */
12000 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12001 /* port-G for CLFE (rear panel) */
12002 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12003 /* port-H for side (rear panel) */
12004 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12005 /* CD-in */
12006 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12007 /* route front mic to ADC1*/
12008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12010 /* Unmute DAC0~3 & spdif out*/
12011 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12012 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12013 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12014 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12016
12017 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12018 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12019 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12020 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12021 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12022
12023 /* Unmute Stereo Mixer 15 */
12024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012028
12029 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12030 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12031 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12032 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12034 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12035 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012037 /* hp used DAC 3 (Front) */
12038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12040 { }
12041};
12042
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012043static struct hda_verb alc861_asus_init_verbs[] = {
12044 /*
12045 * Unmute ADC0 and set the default input to mic-in
12046 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012047 /* port-A for surround (rear panel)
12048 * according to codec#0 this is the HP jack
12049 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012050 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12051 /* route front PCM to HP */
12052 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12053 /* port-B for mic-in (rear panel) with vref */
12054 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12055 /* port-C for line-in (rear panel) */
12056 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12057 /* port-D for Front */
12058 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12059 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12060 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012061 /* this has to be set to VREF80 */
12062 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012063 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012064 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012065 /* port-F for mic-in (front panel) with vref */
12066 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12067 /* port-G for CLFE (rear panel) */
12068 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12069 /* port-H for side (rear panel) */
12070 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12071 /* CD-in */
12072 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12073 /* route front mic to ADC1*/
12074 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12076 /* Unmute DAC0~3 & spdif out*/
12077 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12078 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12079 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12080 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12082 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12083 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12084 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12085 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12086 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12087
12088 /* Unmute Stereo Mixer 15 */
12089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012093
12094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12097 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12098 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12100 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012102 /* hp used DAC 3 (Front) */
12103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12105 { }
12106};
12107
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012108/* additional init verbs for ASUS laptops */
12109static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12110 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12111 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12112 { }
12113};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012114
Kailang Yangdf694da2005-12-05 19:42:22 +010012115/*
12116 * generic initialization of ADC, input mixers and output mixers
12117 */
12118static struct hda_verb alc861_auto_init_verbs[] = {
12119 /*
12120 * Unmute ADC0 and set the default input to mic-in
12121 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012122 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12124
12125 /* Unmute DAC0~3 & spdif out*/
12126 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12127 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12128 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12129 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12131
12132 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12133 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12134 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12135 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12136 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12137
12138 /* Unmute Stereo Mixer 15 */
12139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12143
12144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12145 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12146 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12147 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12149 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12152
12153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012155 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12156 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012162 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012163
12164 { }
12165};
12166
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012167static struct hda_verb alc861_toshiba_init_verbs[] = {
12168 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012169
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012170 { }
12171};
12172
12173/* toggle speaker-output according to the hp-jack state */
12174static void alc861_toshiba_automute(struct hda_codec *codec)
12175{
12176 unsigned int present;
12177
12178 present = snd_hda_codec_read(codec, 0x0f, 0,
12179 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012180 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12181 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12182 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12183 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012184}
12185
12186static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12187 unsigned int res)
12188{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012189 if ((res >> 26) == ALC880_HP_EVENT)
12190 alc861_toshiba_automute(codec);
12191}
12192
Kailang Yangdf694da2005-12-05 19:42:22 +010012193/* pcm configuration: identiacal with ALC880 */
12194#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12195#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12196#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12197#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12198
12199
12200#define ALC861_DIGOUT_NID 0x07
12201
12202static struct hda_channel_mode alc861_8ch_modes[1] = {
12203 { 8, NULL }
12204};
12205
12206static hda_nid_t alc861_dac_nids[4] = {
12207 /* front, surround, clfe, side */
12208 0x03, 0x06, 0x05, 0x04
12209};
12210
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012211static hda_nid_t alc660_dac_nids[3] = {
12212 /* front, clfe, surround */
12213 0x03, 0x05, 0x06
12214};
12215
Kailang Yangdf694da2005-12-05 19:42:22 +010012216static hda_nid_t alc861_adc_nids[1] = {
12217 /* ADC0-2 */
12218 0x08,
12219};
12220
12221static struct hda_input_mux alc861_capture_source = {
12222 .num_items = 5,
12223 .items = {
12224 { "Mic", 0x0 },
12225 { "Front Mic", 0x3 },
12226 { "Line", 0x1 },
12227 { "CD", 0x4 },
12228 { "Mixer", 0x5 },
12229 },
12230};
12231
12232/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012233static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12234 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012235{
12236 int i;
12237 hda_nid_t nid;
12238
12239 spec->multiout.dac_nids = spec->private_dac_nids;
12240 for (i = 0; i < cfg->line_outs; i++) {
12241 nid = cfg->line_out_pins[i];
12242 if (nid) {
12243 if (i >= ARRAY_SIZE(alc861_dac_nids))
12244 continue;
12245 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12246 }
12247 }
12248 spec->multiout.num_dacs = cfg->line_outs;
12249 return 0;
12250}
12251
12252/* add playback controls from the parsed DAC table */
12253static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12254 const struct auto_pin_cfg *cfg)
12255{
12256 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012257 static const char *chname[4] = {
12258 "Front", "Surround", NULL /*CLFE*/, "Side"
12259 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012260 hda_nid_t nid;
12261 int i, idx, err;
12262
12263 for (i = 0; i < cfg->line_outs; i++) {
12264 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012265 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012266 continue;
12267 if (nid == 0x05) {
12268 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012269 err = add_control(spec, ALC_CTL_BIND_MUTE,
12270 "Center Playback Switch",
12271 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12272 HDA_OUTPUT));
12273 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012274 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012275 err = add_control(spec, ALC_CTL_BIND_MUTE,
12276 "LFE Playback Switch",
12277 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12278 HDA_OUTPUT));
12279 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012280 return err;
12281 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012282 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12283 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012284 if (nid == alc861_dac_nids[idx])
12285 break;
12286 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012287 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12288 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12289 HDA_OUTPUT));
12290 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012291 return err;
12292 }
12293 }
12294 return 0;
12295}
12296
12297static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12298{
12299 int err;
12300 hda_nid_t nid;
12301
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012302 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012303 return 0;
12304
12305 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12306 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012307 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12308 "Headphone Playback Switch",
12309 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12310 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012311 return err;
12312 spec->multiout.hp_nid = nid;
12313 }
12314 return 0;
12315}
12316
12317/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012318static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12319 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012320{
Kailang Yangdf694da2005-12-05 19:42:22 +010012321 struct hda_input_mux *imux = &spec->private_imux;
12322 int i, err, idx, idx1;
12323
12324 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012325 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012326 case 0x0c:
12327 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012328 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012329 break;
12330 case 0x0f:
12331 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012332 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012333 break;
12334 case 0x0d:
12335 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012336 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012337 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012338 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012339 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012340 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012341 break;
12342 case 0x11:
12343 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012344 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012345 break;
12346 default:
12347 continue;
12348 }
12349
Takashi Iwai4a471b72005-12-07 13:56:29 +010012350 err = new_analog_input(spec, cfg->input_pins[i],
12351 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012352 if (err < 0)
12353 return err;
12354
Takashi Iwai4a471b72005-12-07 13:56:29 +010012355 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012356 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012357 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012358 }
12359 return 0;
12360}
12361
12362static struct snd_kcontrol_new alc861_capture_mixer[] = {
12363 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12364 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12365
12366 {
12367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12368 /* The multiple "Capture Source" controls confuse alsamixer
12369 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012370 */
12371 /* .name = "Capture Source", */
12372 .name = "Input Source",
12373 .count = 1,
12374 .info = alc_mux_enum_info,
12375 .get = alc_mux_enum_get,
12376 .put = alc_mux_enum_put,
12377 },
12378 { } /* end */
12379};
12380
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012381static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12382 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012383 int pin_type, int dac_idx)
12384{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12386 pin_type);
12387 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12388 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012389}
12390
12391static void alc861_auto_init_multi_out(struct hda_codec *codec)
12392{
12393 struct alc_spec *spec = codec->spec;
12394 int i;
12395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012396 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012397 for (i = 0; i < spec->autocfg.line_outs; i++) {
12398 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012399 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012400 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012401 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012402 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012403 }
12404}
12405
12406static void alc861_auto_init_hp_out(struct hda_codec *codec)
12407{
12408 struct alc_spec *spec = codec->spec;
12409 hda_nid_t pin;
12410
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012411 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012412 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012413 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12414 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012415 pin = spec->autocfg.speaker_pins[0];
12416 if (pin)
12417 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012418}
12419
12420static void alc861_auto_init_analog_input(struct hda_codec *codec)
12421{
12422 struct alc_spec *spec = codec->spec;
12423 int i;
12424
12425 for (i = 0; i < AUTO_PIN_LAST; i++) {
12426 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012427 if (nid >= 0x0c && nid <= 0x11) {
12428 snd_hda_codec_write(codec, nid, 0,
12429 AC_VERB_SET_PIN_WIDGET_CONTROL,
12430 i <= AUTO_PIN_FRONT_MIC ?
12431 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012432 }
12433 }
12434}
12435
12436/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012437/* return 1 if successful, 0 if the proper config is not found,
12438 * or a negative error code
12439 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012440static int alc861_parse_auto_config(struct hda_codec *codec)
12441{
12442 struct alc_spec *spec = codec->spec;
12443 int err;
12444 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012446 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12447 alc861_ignore);
12448 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012449 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012450 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012451 return 0; /* can't find valid BIOS pin config */
12452
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012453 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12454 if (err < 0)
12455 return err;
12456 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12457 if (err < 0)
12458 return err;
12459 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12460 if (err < 0)
12461 return err;
12462 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12463 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012464 return err;
12465
12466 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12467
12468 if (spec->autocfg.dig_out_pin)
12469 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12470
12471 if (spec->kctl_alloc)
12472 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12473
12474 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12475
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012476 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012477 spec->input_mux = &spec->private_imux;
12478
12479 spec->adc_nids = alc861_adc_nids;
12480 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12481 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12482 spec->num_mixers++;
12483
12484 return 1;
12485}
12486
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012487/* additional initialization for auto-configuration model */
12488static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012489{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012490 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012491 alc861_auto_init_multi_out(codec);
12492 alc861_auto_init_hp_out(codec);
12493 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012494 if (spec->unsol_event)
12495 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012496}
12497
Takashi Iwaicb53c622007-08-10 17:21:45 +020012498#ifdef CONFIG_SND_HDA_POWER_SAVE
12499static struct hda_amp_list alc861_loopbacks[] = {
12500 { 0x15, HDA_INPUT, 0 },
12501 { 0x15, HDA_INPUT, 1 },
12502 { 0x15, HDA_INPUT, 2 },
12503 { 0x15, HDA_INPUT, 3 },
12504 { } /* end */
12505};
12506#endif
12507
Kailang Yangdf694da2005-12-05 19:42:22 +010012508
12509/*
12510 * configuration and preset
12511 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012512static const char *alc861_models[ALC861_MODEL_LAST] = {
12513 [ALC861_3ST] = "3stack",
12514 [ALC660_3ST] = "3stack-660",
12515 [ALC861_3ST_DIG] = "3stack-dig",
12516 [ALC861_6ST_DIG] = "6stack-dig",
12517 [ALC861_UNIWILL_M31] = "uniwill-m31",
12518 [ALC861_TOSHIBA] = "toshiba",
12519 [ALC861_ASUS] = "asus",
12520 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12521 [ALC861_AUTO] = "auto",
12522};
12523
12524static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012525 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012526 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12527 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12528 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012529 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012530 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012531 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012532 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12533 * Any other models that need this preset?
12534 */
12535 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012536 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12537 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012538 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12539 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12540 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12541 /* FIXME: the below seems conflict */
12542 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12543 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12544 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 {}
12546};
12547
12548static struct alc_config_preset alc861_presets[] = {
12549 [ALC861_3ST] = {
12550 .mixers = { alc861_3ST_mixer },
12551 .init_verbs = { alc861_threestack_init_verbs },
12552 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12553 .dac_nids = alc861_dac_nids,
12554 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12555 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012556 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012557 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12558 .adc_nids = alc861_adc_nids,
12559 .input_mux = &alc861_capture_source,
12560 },
12561 [ALC861_3ST_DIG] = {
12562 .mixers = { alc861_base_mixer },
12563 .init_verbs = { alc861_threestack_init_verbs },
12564 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12565 .dac_nids = alc861_dac_nids,
12566 .dig_out_nid = ALC861_DIGOUT_NID,
12567 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12568 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012569 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012570 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12571 .adc_nids = alc861_adc_nids,
12572 .input_mux = &alc861_capture_source,
12573 },
12574 [ALC861_6ST_DIG] = {
12575 .mixers = { alc861_base_mixer },
12576 .init_verbs = { alc861_base_init_verbs },
12577 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12578 .dac_nids = alc861_dac_nids,
12579 .dig_out_nid = ALC861_DIGOUT_NID,
12580 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12581 .channel_mode = alc861_8ch_modes,
12582 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12583 .adc_nids = alc861_adc_nids,
12584 .input_mux = &alc861_capture_source,
12585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012586 [ALC660_3ST] = {
12587 .mixers = { alc861_3ST_mixer },
12588 .init_verbs = { alc861_threestack_init_verbs },
12589 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12590 .dac_nids = alc660_dac_nids,
12591 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12592 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012593 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012594 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12595 .adc_nids = alc861_adc_nids,
12596 .input_mux = &alc861_capture_source,
12597 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012598 [ALC861_UNIWILL_M31] = {
12599 .mixers = { alc861_uniwill_m31_mixer },
12600 .init_verbs = { alc861_uniwill_m31_init_verbs },
12601 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12602 .dac_nids = alc861_dac_nids,
12603 .dig_out_nid = ALC861_DIGOUT_NID,
12604 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12605 .channel_mode = alc861_uniwill_m31_modes,
12606 .need_dac_fix = 1,
12607 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12608 .adc_nids = alc861_adc_nids,
12609 .input_mux = &alc861_capture_source,
12610 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012611 [ALC861_TOSHIBA] = {
12612 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012613 .init_verbs = { alc861_base_init_verbs,
12614 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012615 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12616 .dac_nids = alc861_dac_nids,
12617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12618 .channel_mode = alc883_3ST_2ch_modes,
12619 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12620 .adc_nids = alc861_adc_nids,
12621 .input_mux = &alc861_capture_source,
12622 .unsol_event = alc861_toshiba_unsol_event,
12623 .init_hook = alc861_toshiba_automute,
12624 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012625 [ALC861_ASUS] = {
12626 .mixers = { alc861_asus_mixer },
12627 .init_verbs = { alc861_asus_init_verbs },
12628 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12629 .dac_nids = alc861_dac_nids,
12630 .dig_out_nid = ALC861_DIGOUT_NID,
12631 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12632 .channel_mode = alc861_asus_modes,
12633 .need_dac_fix = 1,
12634 .hp_nid = 0x06,
12635 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12636 .adc_nids = alc861_adc_nids,
12637 .input_mux = &alc861_capture_source,
12638 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012639 [ALC861_ASUS_LAPTOP] = {
12640 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12641 .init_verbs = { alc861_asus_init_verbs,
12642 alc861_asus_laptop_init_verbs },
12643 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12644 .dac_nids = alc861_dac_nids,
12645 .dig_out_nid = ALC861_DIGOUT_NID,
12646 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12647 .channel_mode = alc883_3ST_2ch_modes,
12648 .need_dac_fix = 1,
12649 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12650 .adc_nids = alc861_adc_nids,
12651 .input_mux = &alc861_capture_source,
12652 },
12653};
Kailang Yangdf694da2005-12-05 19:42:22 +010012654
12655
12656static int patch_alc861(struct hda_codec *codec)
12657{
12658 struct alc_spec *spec;
12659 int board_config;
12660 int err;
12661
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012662 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012663 if (spec == NULL)
12664 return -ENOMEM;
12665
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012666 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012667
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012668 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12669 alc861_models,
12670 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012671
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012672 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012673 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12674 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012675 board_config = ALC861_AUTO;
12676 }
12677
12678 if (board_config == ALC861_AUTO) {
12679 /* automatic parse from the BIOS config */
12680 err = alc861_parse_auto_config(codec);
12681 if (err < 0) {
12682 alc_free(codec);
12683 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012684 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012685 printk(KERN_INFO
12686 "hda_codec: Cannot set up configuration "
12687 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012688 board_config = ALC861_3ST_DIG;
12689 }
12690 }
12691
12692 if (board_config != ALC861_AUTO)
12693 setup_preset(spec, &alc861_presets[board_config]);
12694
12695 spec->stream_name_analog = "ALC861 Analog";
12696 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12697 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12698
12699 spec->stream_name_digital = "ALC861 Digital";
12700 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12701 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12702
Takashi Iwai2134ea42008-01-10 16:53:55 +010012703 spec->vmaster_nid = 0x03;
12704
Kailang Yangdf694da2005-12-05 19:42:22 +010012705 codec->patch_ops = alc_patch_ops;
12706 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012707 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012708#ifdef CONFIG_SND_HDA_POWER_SAVE
12709 if (!spec->loopback.amplist)
12710 spec->loopback.amplist = alc861_loopbacks;
12711#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012712
12713 return 0;
12714}
12715
12716/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012717 * ALC861-VD support
12718 *
12719 * Based on ALC882
12720 *
12721 * In addition, an independent DAC
12722 */
12723#define ALC861VD_DIGOUT_NID 0x06
12724
12725static hda_nid_t alc861vd_dac_nids[4] = {
12726 /* front, surr, clfe, side surr */
12727 0x02, 0x03, 0x04, 0x05
12728};
12729
12730/* dac_nids for ALC660vd are in a different order - according to
12731 * Realtek's driver.
12732 * This should probably tesult in a different mixer for 6stack models
12733 * of ALC660vd codecs, but for now there is only 3stack mixer
12734 * - and it is the same as in 861vd.
12735 * adc_nids in ALC660vd are (is) the same as in 861vd
12736 */
12737static hda_nid_t alc660vd_dac_nids[3] = {
12738 /* front, rear, clfe, rear_surr */
12739 0x02, 0x04, 0x03
12740};
12741
12742static hda_nid_t alc861vd_adc_nids[1] = {
12743 /* ADC0 */
12744 0x09,
12745};
12746
Takashi Iwaie1406342008-02-11 18:32:32 +010012747static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12748
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012749/* input MUX */
12750/* FIXME: should be a matrix-type input source selection */
12751static struct hda_input_mux alc861vd_capture_source = {
12752 .num_items = 4,
12753 .items = {
12754 { "Mic", 0x0 },
12755 { "Front Mic", 0x1 },
12756 { "Line", 0x2 },
12757 { "CD", 0x4 },
12758 },
12759};
12760
Kailang Yang272a5272007-05-14 11:00:38 +020012761static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012762 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012763 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012764 { "Ext Mic", 0x0 },
12765 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012766 },
12767};
12768
Kailang Yangd1a991a2007-08-15 16:21:59 +020012769static struct hda_input_mux alc861vd_hp_capture_source = {
12770 .num_items = 2,
12771 .items = {
12772 { "Front Mic", 0x0 },
12773 { "ATAPI Mic", 0x1 },
12774 },
12775};
12776
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012777#define alc861vd_mux_enum_info alc_mux_enum_info
12778#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012779/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12780#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012781
12782/*
12783 * 2ch mode
12784 */
12785static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12786 { 2, NULL }
12787};
12788
12789/*
12790 * 6ch mode
12791 */
12792static struct hda_verb alc861vd_6stack_ch6_init[] = {
12793 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12794 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12795 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12796 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12797 { } /* end */
12798};
12799
12800/*
12801 * 8ch mode
12802 */
12803static struct hda_verb alc861vd_6stack_ch8_init[] = {
12804 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12805 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12806 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12807 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12808 { } /* end */
12809};
12810
12811static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12812 { 6, alc861vd_6stack_ch6_init },
12813 { 8, alc861vd_6stack_ch8_init },
12814};
12815
12816static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12817 {
12818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12819 .name = "Channel Mode",
12820 .info = alc_ch_mode_info,
12821 .get = alc_ch_mode_get,
12822 .put = alc_ch_mode_put,
12823 },
12824 { } /* end */
12825};
12826
12827static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12828 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12829 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12830
12831 {
12832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12833 /* The multiple "Capture Source" controls confuse alsamixer
12834 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012835 */
12836 /* .name = "Capture Source", */
12837 .name = "Input Source",
12838 .count = 1,
12839 .info = alc861vd_mux_enum_info,
12840 .get = alc861vd_mux_enum_get,
12841 .put = alc861vd_mux_enum_put,
12842 },
12843 { } /* end */
12844};
12845
12846/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12847 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12848 */
12849static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12850 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12852
12853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12855
12856 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12857 HDA_OUTPUT),
12858 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12859 HDA_OUTPUT),
12860 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12861 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12862
12863 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12864 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12865
12866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12867
12868 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12871
12872 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12875
12876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12878
12879 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12880 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12881
12882 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12883 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12884
12885 { } /* end */
12886};
12887
12888static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12889 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12890 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12891
12892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12893
12894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12897
12898 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12900 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12901
12902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12903 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12904
12905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12907
12908 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12909 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12910
12911 { } /* end */
12912};
12913
Kailang Yangbdd148a2007-05-08 15:19:08 +020012914static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12916 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12917 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12918
12919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12920
12921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12924
12925 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12928
12929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12931
12932 { } /* end */
12933};
12934
Tobin Davisb419f342008-03-07 11:57:51 +010012935/* Pin assignment: Speaker=0x14, HP = 0x15,
12936 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012937 */
12938static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12940 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12942 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012943 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12944 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12945 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12946 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12947 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12948 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12949 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12950 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012951 { } /* end */
12952};
12953
Kailang Yangd1a991a2007-08-15 16:21:59 +020012954/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12955 * Front Mic=0x18, ATAPI Mic = 0x19,
12956 */
12957static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12958 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12964 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12965 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12966
12967 { } /* end */
12968};
12969
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012970/*
12971 * generic initialization of ADC, input mixers and output mixers
12972 */
12973static struct hda_verb alc861vd_volume_init_verbs[] = {
12974 /*
12975 * Unmute ADC0 and set the default input to mic-in
12976 */
12977 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12979
12980 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12981 * the analog-loopback mixer widget
12982 */
12983 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012989
12990 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012995
12996 /*
12997 * Set up output mixers (0x02 - 0x05)
12998 */
12999 /* set vol=0 to output mixers */
13000 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13001 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13002 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13003 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13004
13005 /* set up input amps for analog loopback */
13006 /* Amp Indices: DAC = 0, mixer = 1 */
13007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13009 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13010 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13011 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13012 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13014 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13015
13016 { }
13017};
13018
13019/*
13020 * 3-stack pin configuration:
13021 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13022 */
13023static struct hda_verb alc861vd_3stack_init_verbs[] = {
13024 /*
13025 * Set pin mode and muting
13026 */
13027 /* set front pin widgets 0x14 for output */
13028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13030 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13031
13032 /* Mic (rear) pin: input vref at 80% */
13033 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13034 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13035 /* Front Mic pin: input vref at 80% */
13036 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13038 /* Line In pin: input */
13039 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13041 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13043 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13044 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13045 /* CD pin widget for input */
13046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13047
13048 { }
13049};
13050
13051/*
13052 * 6-stack pin configuration:
13053 */
13054static struct hda_verb alc861vd_6stack_init_verbs[] = {
13055 /*
13056 * Set pin mode and muting
13057 */
13058 /* set front pin widgets 0x14 for output */
13059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13062
13063 /* Rear Pin: output 1 (0x0d) */
13064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13067 /* CLFE Pin: output 2 (0x0e) */
13068 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13070 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13071 /* Side Pin: output 3 (0x0f) */
13072 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13073 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13074 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13075
13076 /* Mic (rear) pin: input vref at 80% */
13077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13079 /* Front Mic pin: input vref at 80% */
13080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13082 /* Line In pin: input */
13083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13085 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13086 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13088 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13089 /* CD pin widget for input */
13090 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13091
13092 { }
13093};
13094
Kailang Yangbdd148a2007-05-08 15:19:08 +020013095static struct hda_verb alc861vd_eapd_verbs[] = {
13096 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13097 { }
13098};
13099
Kailang Yangf9423e72008-05-27 12:32:25 +020013100static struct hda_verb alc660vd_eapd_verbs[] = {
13101 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13102 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13103 { }
13104};
13105
Kailang Yangbdd148a2007-05-08 15:19:08 +020013106static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13112 {}
13113};
13114
13115/* toggle speaker-output according to the hp-jack state */
13116static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13117{
13118 unsigned int present;
13119 unsigned char bits;
13120
13121 present = snd_hda_codec_read(codec, 0x1b, 0,
13122 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013123 bits = present ? HDA_AMP_MUTE : 0;
13124 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13125 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013126}
13127
13128static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13129{
13130 unsigned int present;
13131 unsigned char bits;
13132
13133 present = snd_hda_codec_read(codec, 0x18, 0,
13134 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013135 bits = present ? HDA_AMP_MUTE : 0;
13136 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13137 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013138}
13139
13140static void alc861vd_lenovo_automute(struct hda_codec *codec)
13141{
13142 alc861vd_lenovo_hp_automute(codec);
13143 alc861vd_lenovo_mic_automute(codec);
13144}
13145
13146static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13147 unsigned int res)
13148{
13149 switch (res >> 26) {
13150 case ALC880_HP_EVENT:
13151 alc861vd_lenovo_hp_automute(codec);
13152 break;
13153 case ALC880_MIC_EVENT:
13154 alc861vd_lenovo_mic_automute(codec);
13155 break;
13156 }
13157}
13158
Kailang Yang272a5272007-05-14 11:00:38 +020013159static struct hda_verb alc861vd_dallas_verbs[] = {
13160 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13161 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13162 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13163 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13164
13165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13173
13174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13178 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13180 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13182
13183 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13187 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13188 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13189 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13190 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13191
13192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13196
13197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13198 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13199 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13200
13201 { } /* end */
13202};
13203
13204/* toggle speaker-output according to the hp-jack state */
13205static void alc861vd_dallas_automute(struct hda_codec *codec)
13206{
13207 unsigned int present;
13208
13209 present = snd_hda_codec_read(codec, 0x15, 0,
13210 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013211 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13212 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013213}
13214
13215static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13216{
13217 if ((res >> 26) == ALC880_HP_EVENT)
13218 alc861vd_dallas_automute(codec);
13219}
13220
Takashi Iwaicb53c622007-08-10 17:21:45 +020013221#ifdef CONFIG_SND_HDA_POWER_SAVE
13222#define alc861vd_loopbacks alc880_loopbacks
13223#endif
13224
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013225/* pcm configuration: identiacal with ALC880 */
13226#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13227#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13228#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13229#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13230
13231/*
13232 * configuration and preset
13233 */
13234static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13235 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013236 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013237 [ALC861VD_3ST] = "3stack",
13238 [ALC861VD_3ST_DIG] = "3stack-digout",
13239 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013240 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013241 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013242 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013243 [ALC861VD_AUTO] = "auto",
13244};
13245
13246static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013247 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13248 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013249 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013250 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013251 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013252 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013253 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013254 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013255 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013256 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013257 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013258 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013259 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013260 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13261 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013262 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013263 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013264 {}
13265};
13266
13267static struct alc_config_preset alc861vd_presets[] = {
13268 [ALC660VD_3ST] = {
13269 .mixers = { alc861vd_3st_mixer },
13270 .init_verbs = { alc861vd_volume_init_verbs,
13271 alc861vd_3stack_init_verbs },
13272 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13273 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013274 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13275 .channel_mode = alc861vd_3stack_2ch_modes,
13276 .input_mux = &alc861vd_capture_source,
13277 },
Mike Crash6963f842007-06-25 12:12:51 +020013278 [ALC660VD_3ST_DIG] = {
13279 .mixers = { alc861vd_3st_mixer },
13280 .init_verbs = { alc861vd_volume_init_verbs,
13281 alc861vd_3stack_init_verbs },
13282 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13283 .dac_nids = alc660vd_dac_nids,
13284 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013285 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13286 .channel_mode = alc861vd_3stack_2ch_modes,
13287 .input_mux = &alc861vd_capture_source,
13288 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013289 [ALC861VD_3ST] = {
13290 .mixers = { alc861vd_3st_mixer },
13291 .init_verbs = { alc861vd_volume_init_verbs,
13292 alc861vd_3stack_init_verbs },
13293 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13294 .dac_nids = alc861vd_dac_nids,
13295 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13296 .channel_mode = alc861vd_3stack_2ch_modes,
13297 .input_mux = &alc861vd_capture_source,
13298 },
13299 [ALC861VD_3ST_DIG] = {
13300 .mixers = { alc861vd_3st_mixer },
13301 .init_verbs = { alc861vd_volume_init_verbs,
13302 alc861vd_3stack_init_verbs },
13303 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13304 .dac_nids = alc861vd_dac_nids,
13305 .dig_out_nid = ALC861VD_DIGOUT_NID,
13306 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13307 .channel_mode = alc861vd_3stack_2ch_modes,
13308 .input_mux = &alc861vd_capture_source,
13309 },
13310 [ALC861VD_6ST_DIG] = {
13311 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13312 .init_verbs = { alc861vd_volume_init_verbs,
13313 alc861vd_6stack_init_verbs },
13314 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13315 .dac_nids = alc861vd_dac_nids,
13316 .dig_out_nid = ALC861VD_DIGOUT_NID,
13317 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13318 .channel_mode = alc861vd_6stack_modes,
13319 .input_mux = &alc861vd_capture_source,
13320 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013321 [ALC861VD_LENOVO] = {
13322 .mixers = { alc861vd_lenovo_mixer },
13323 .init_verbs = { alc861vd_volume_init_verbs,
13324 alc861vd_3stack_init_verbs,
13325 alc861vd_eapd_verbs,
13326 alc861vd_lenovo_unsol_verbs },
13327 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13328 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013329 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13330 .channel_mode = alc861vd_3stack_2ch_modes,
13331 .input_mux = &alc861vd_capture_source,
13332 .unsol_event = alc861vd_lenovo_unsol_event,
13333 .init_hook = alc861vd_lenovo_automute,
13334 },
Kailang Yang272a5272007-05-14 11:00:38 +020013335 [ALC861VD_DALLAS] = {
13336 .mixers = { alc861vd_dallas_mixer },
13337 .init_verbs = { alc861vd_dallas_verbs },
13338 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13339 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013340 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13341 .channel_mode = alc861vd_3stack_2ch_modes,
13342 .input_mux = &alc861vd_dallas_capture_source,
13343 .unsol_event = alc861vd_dallas_unsol_event,
13344 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013345 },
13346 [ALC861VD_HP] = {
13347 .mixers = { alc861vd_hp_mixer },
13348 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13349 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13350 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013351 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013352 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13353 .channel_mode = alc861vd_3stack_2ch_modes,
13354 .input_mux = &alc861vd_hp_capture_source,
13355 .unsol_event = alc861vd_dallas_unsol_event,
13356 .init_hook = alc861vd_dallas_automute,
13357 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013358};
13359
13360/*
13361 * BIOS auto configuration
13362 */
13363static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13364 hda_nid_t nid, int pin_type, int dac_idx)
13365{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013366 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013367}
13368
13369static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13370{
13371 struct alc_spec *spec = codec->spec;
13372 int i;
13373
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013374 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013375 for (i = 0; i <= HDA_SIDE; i++) {
13376 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013377 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013378 if (nid)
13379 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013380 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013381 }
13382}
13383
13384
13385static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13386{
13387 struct alc_spec *spec = codec->spec;
13388 hda_nid_t pin;
13389
13390 pin = spec->autocfg.hp_pins[0];
13391 if (pin) /* connect to front and use dac 0 */
13392 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013393 pin = spec->autocfg.speaker_pins[0];
13394 if (pin)
13395 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013396}
13397
13398#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13399#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13400
13401static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13402{
13403 struct alc_spec *spec = codec->spec;
13404 int i;
13405
13406 for (i = 0; i < AUTO_PIN_LAST; i++) {
13407 hda_nid_t nid = spec->autocfg.input_pins[i];
13408 if (alc861vd_is_input_pin(nid)) {
13409 snd_hda_codec_write(codec, nid, 0,
13410 AC_VERB_SET_PIN_WIDGET_CONTROL,
13411 i <= AUTO_PIN_FRONT_MIC ?
13412 PIN_VREF80 : PIN_IN);
13413 if (nid != ALC861VD_PIN_CD_NID)
13414 snd_hda_codec_write(codec, nid, 0,
13415 AC_VERB_SET_AMP_GAIN_MUTE,
13416 AMP_OUT_MUTE);
13417 }
13418 }
13419}
13420
Takashi Iwaif511b012008-08-15 16:46:42 +020013421#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13422
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013423#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13424#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13425
13426/* add playback controls from the parsed DAC table */
13427/* Based on ALC880 version. But ALC861VD has separate,
13428 * different NIDs for mute/unmute switch and volume control */
13429static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13430 const struct auto_pin_cfg *cfg)
13431{
13432 char name[32];
13433 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13434 hda_nid_t nid_v, nid_s;
13435 int i, err;
13436
13437 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013438 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013439 continue;
13440 nid_v = alc861vd_idx_to_mixer_vol(
13441 alc880_dac_to_idx(
13442 spec->multiout.dac_nids[i]));
13443 nid_s = alc861vd_idx_to_mixer_switch(
13444 alc880_dac_to_idx(
13445 spec->multiout.dac_nids[i]));
13446
13447 if (i == 2) {
13448 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013449 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13450 "Center Playback Volume",
13451 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13452 HDA_OUTPUT));
13453 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013454 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013455 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13456 "LFE Playback Volume",
13457 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13458 HDA_OUTPUT));
13459 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013460 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013461 err = add_control(spec, ALC_CTL_BIND_MUTE,
13462 "Center Playback Switch",
13463 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13464 HDA_INPUT));
13465 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013466 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013467 err = add_control(spec, ALC_CTL_BIND_MUTE,
13468 "LFE Playback Switch",
13469 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13470 HDA_INPUT));
13471 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013472 return err;
13473 } else {
13474 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013475 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13476 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13477 HDA_OUTPUT));
13478 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013479 return err;
13480 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013481 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013482 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013483 HDA_INPUT));
13484 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013485 return err;
13486 }
13487 }
13488 return 0;
13489}
13490
13491/* add playback controls for speaker and HP outputs */
13492/* Based on ALC880 version. But ALC861VD has separate,
13493 * different NIDs for mute/unmute switch and volume control */
13494static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13495 hda_nid_t pin, const char *pfx)
13496{
13497 hda_nid_t nid_v, nid_s;
13498 int err;
13499 char name[32];
13500
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013501 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013502 return 0;
13503
13504 if (alc880_is_fixed_pin(pin)) {
13505 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13506 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013507 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013508 spec->multiout.hp_nid = nid_v;
13509 else
13510 spec->multiout.extra_out_nid[0] = nid_v;
13511 /* control HP volume/switch on the output mixer amp */
13512 nid_v = alc861vd_idx_to_mixer_vol(
13513 alc880_fixed_pin_idx(pin));
13514 nid_s = alc861vd_idx_to_mixer_switch(
13515 alc880_fixed_pin_idx(pin));
13516
13517 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013518 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13519 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13520 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013521 return err;
13522 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013523 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13524 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13525 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013526 return err;
13527 } else if (alc880_is_multi_pin(pin)) {
13528 /* set manual connection */
13529 /* we have only a switch on HP-out PIN */
13530 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013531 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13532 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13533 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013534 return err;
13535 }
13536 return 0;
13537}
13538
13539/* parse the BIOS configuration and set up the alc_spec
13540 * return 1 if successful, 0 if the proper config is not found,
13541 * or a negative error code
13542 * Based on ALC880 version - had to change it to override
13543 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13544static int alc861vd_parse_auto_config(struct hda_codec *codec)
13545{
13546 struct alc_spec *spec = codec->spec;
13547 int err;
13548 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13549
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013550 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13551 alc861vd_ignore);
13552 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013553 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013554 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013555 return 0; /* can't find valid BIOS pin config */
13556
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013557 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13558 if (err < 0)
13559 return err;
13560 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13561 if (err < 0)
13562 return err;
13563 err = alc861vd_auto_create_extra_out(spec,
13564 spec->autocfg.speaker_pins[0],
13565 "Speaker");
13566 if (err < 0)
13567 return err;
13568 err = alc861vd_auto_create_extra_out(spec,
13569 spec->autocfg.hp_pins[0],
13570 "Headphone");
13571 if (err < 0)
13572 return err;
13573 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13574 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013575 return err;
13576
13577 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13578
13579 if (spec->autocfg.dig_out_pin)
13580 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13581
13582 if (spec->kctl_alloc)
13583 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13584
13585 spec->init_verbs[spec->num_init_verbs++]
13586 = alc861vd_volume_init_verbs;
13587
13588 spec->num_mux_defs = 1;
13589 spec->input_mux = &spec->private_imux;
13590
Takashi Iwai776e1842007-08-29 15:07:11 +020013591 err = alc_auto_add_mic_boost(codec);
13592 if (err < 0)
13593 return err;
13594
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013595 return 1;
13596}
13597
13598/* additional initialization for auto-configuration model */
13599static void alc861vd_auto_init(struct hda_codec *codec)
13600{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013601 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013602 alc861vd_auto_init_multi_out(codec);
13603 alc861vd_auto_init_hp_out(codec);
13604 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020013605 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013606 if (spec->unsol_event)
13607 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013608}
13609
13610static int patch_alc861vd(struct hda_codec *codec)
13611{
13612 struct alc_spec *spec;
13613 int err, board_config;
13614
13615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13616 if (spec == NULL)
13617 return -ENOMEM;
13618
13619 codec->spec = spec;
13620
13621 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13622 alc861vd_models,
13623 alc861vd_cfg_tbl);
13624
13625 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13626 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13627 "ALC861VD, trying auto-probe from BIOS...\n");
13628 board_config = ALC861VD_AUTO;
13629 }
13630
13631 if (board_config == ALC861VD_AUTO) {
13632 /* automatic parse from the BIOS config */
13633 err = alc861vd_parse_auto_config(codec);
13634 if (err < 0) {
13635 alc_free(codec);
13636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013637 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013638 printk(KERN_INFO
13639 "hda_codec: Cannot set up configuration "
13640 "from BIOS. Using base mode...\n");
13641 board_config = ALC861VD_3ST;
13642 }
13643 }
13644
13645 if (board_config != ALC861VD_AUTO)
13646 setup_preset(spec, &alc861vd_presets[board_config]);
13647
Kailang Yang2f893282008-05-27 12:14:47 +020013648 if (codec->vendor_id == 0x10ec0660) {
13649 spec->stream_name_analog = "ALC660-VD Analog";
13650 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013651 /* always turn on EAPD */
13652 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013653 } else {
13654 spec->stream_name_analog = "ALC861VD Analog";
13655 spec->stream_name_digital = "ALC861VD Digital";
13656 }
13657
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013658 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13659 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13660
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013661 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13662 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13663
13664 spec->adc_nids = alc861vd_adc_nids;
13665 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013666 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013667
13668 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13669 spec->num_mixers++;
13670
Takashi Iwai2134ea42008-01-10 16:53:55 +010013671 spec->vmaster_nid = 0x02;
13672
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013673 codec->patch_ops = alc_patch_ops;
13674
13675 if (board_config == ALC861VD_AUTO)
13676 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013677#ifdef CONFIG_SND_HDA_POWER_SAVE
13678 if (!spec->loopback.amplist)
13679 spec->loopback.amplist = alc861vd_loopbacks;
13680#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013681
13682 return 0;
13683}
13684
13685/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013686 * ALC662 support
13687 *
13688 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13689 * configuration. Each pin widget can choose any input DACs and a mixer.
13690 * Each ADC is connected from a mixer of all inputs. This makes possible
13691 * 6-channel independent captures.
13692 *
13693 * In addition, an independent DAC for the multi-playback (not used in this
13694 * driver yet).
13695 */
13696#define ALC662_DIGOUT_NID 0x06
13697#define ALC662_DIGIN_NID 0x0a
13698
13699static hda_nid_t alc662_dac_nids[4] = {
13700 /* front, rear, clfe, rear_surr */
13701 0x02, 0x03, 0x04
13702};
13703
13704static hda_nid_t alc662_adc_nids[1] = {
13705 /* ADC1-2 */
13706 0x09,
13707};
Takashi Iwaie1406342008-02-11 18:32:32 +010013708
Kailang Yang77a261b2008-02-19 11:38:05 +010013709static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013711/* input MUX */
13712/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013713static struct hda_input_mux alc662_capture_source = {
13714 .num_items = 4,
13715 .items = {
13716 { "Mic", 0x0 },
13717 { "Front Mic", 0x1 },
13718 { "Line", 0x2 },
13719 { "CD", 0x4 },
13720 },
13721};
13722
13723static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13724 .num_items = 2,
13725 .items = {
13726 { "Mic", 0x1 },
13727 { "Line", 0x2 },
13728 },
13729};
Kailang Yang291702f2007-10-16 14:28:03 +020013730
13731static struct hda_input_mux alc662_eeepc_capture_source = {
13732 .num_items = 2,
13733 .items = {
13734 { "i-Mic", 0x1 },
13735 { "e-Mic", 0x0 },
13736 },
13737};
13738
Kailang Yang6dda9f42008-05-27 12:05:31 +020013739static struct hda_input_mux alc663_capture_source = {
13740 .num_items = 3,
13741 .items = {
13742 { "Mic", 0x0 },
13743 { "Front Mic", 0x1 },
13744 { "Line", 0x2 },
13745 },
13746};
13747
13748static struct hda_input_mux alc663_m51va_capture_source = {
13749 .num_items = 2,
13750 .items = {
13751 { "Ext-Mic", 0x0 },
13752 { "D-Mic", 0x9 },
13753 },
13754};
13755
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013756#define alc662_mux_enum_info alc_mux_enum_info
13757#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013758#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013759
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013760/*
13761 * 2ch mode
13762 */
13763static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13764 { 2, NULL }
13765};
13766
13767/*
13768 * 2ch mode
13769 */
13770static struct hda_verb alc662_3ST_ch2_init[] = {
13771 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13772 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13773 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13774 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13775 { } /* end */
13776};
13777
13778/*
13779 * 6ch mode
13780 */
13781static struct hda_verb alc662_3ST_ch6_init[] = {
13782 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13783 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13784 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13785 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13786 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13787 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13788 { } /* end */
13789};
13790
13791static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13792 { 2, alc662_3ST_ch2_init },
13793 { 6, alc662_3ST_ch6_init },
13794};
13795
13796/*
13797 * 2ch mode
13798 */
13799static struct hda_verb alc662_sixstack_ch6_init[] = {
13800 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13801 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13802 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13803 { } /* end */
13804};
13805
13806/*
13807 * 6ch mode
13808 */
13809static struct hda_verb alc662_sixstack_ch8_init[] = {
13810 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13811 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13813 { } /* end */
13814};
13815
13816static struct hda_channel_mode alc662_5stack_modes[2] = {
13817 { 2, alc662_sixstack_ch6_init },
13818 { 6, alc662_sixstack_ch8_init },
13819};
13820
13821/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13822 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13823 */
13824
13825static struct snd_kcontrol_new alc662_base_mixer[] = {
13826 /* output mixer control */
13827 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013828 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013830 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013833 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13834 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13836
13837 /*Input mixer control */
13838 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13839 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13840 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13841 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13842 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13843 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013846 { } /* end */
13847};
13848
13849static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13850 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013851 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013852 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13853 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13854 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13855 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13856 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13859 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13861 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13862 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013863 { } /* end */
13864};
13865
13866static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13867 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013868 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013869 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013870 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013871 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13872 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013873 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13874 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013875 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13876 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13877 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13878 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13879 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13882 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13883 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13884 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13885 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013886 { } /* end */
13887};
13888
13889static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13890 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13891 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013892 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13893 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013894 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013899 { } /* end */
13900};
13901
Kailang Yang291702f2007-10-16 14:28:03 +020013902static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013903 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013904
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013905 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13906 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013907
13908 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13909 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13910 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13911
13912 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13913 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13914 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13915 { } /* end */
13916};
13917
Kailang Yang8c427222008-01-10 13:03:59 +010013918static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013919 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13920 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013921 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13922 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13923 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13924 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13925 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13926 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013927 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013928 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13929 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13930 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13933 { } /* end */
13934};
13935
Kailang Yang6dda9f42008-05-27 12:05:31 +020013936static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13937 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13938 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13939 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13941 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13942 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13943 { } /* end */
13944};
13945
13946static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13949 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13950 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13952
13953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13955 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13956 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13957 { } /* end */
13958};
13959
13960static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13962 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13963 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13964
13965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13966 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13967 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13968 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13971 { } /* end */
13972};
13973
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013974static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13975 {
13976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13977 .name = "Channel Mode",
13978 .info = alc_ch_mode_info,
13979 .get = alc_ch_mode_get,
13980 .put = alc_ch_mode_put,
13981 },
13982 { } /* end */
13983};
13984
13985static struct hda_verb alc662_init_verbs[] = {
13986 /* ADC: mute amp left and right */
13987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13988 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13989 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13990
Takashi Iwaicb53c622007-08-10 17:21:45 +020013991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13993 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013996
Kailang Yangb60dd392007-09-20 12:50:29 +020013997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014003
14004 /* Front Pin: output 0 (0x0c) */
14005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14007
14008 /* Rear Pin: output 1 (0x0d) */
14009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14011
14012 /* CLFE Pin: output 2 (0x0e) */
14013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14015
14016 /* Mic (rear) pin: input vref at 80% */
14017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14018 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14019 /* Front Mic pin: input vref at 80% */
14020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14022 /* Line In pin: input */
14023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14025 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14027 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14028 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14029 /* CD pin widget for input */
14030 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14031
14032 /* FIXME: use matrix-type input source selection */
14033 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14034 /* Input mixer */
14035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014039
14040 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014044
14045 /* always trun on EAPD */
14046 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14047 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014049 { }
14050};
14051
14052static struct hda_verb alc662_sue_init_verbs[] = {
14053 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14054 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014055 {}
14056};
14057
14058static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14059 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14060 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14061 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014062};
14063
Kailang Yang8c427222008-01-10 13:03:59 +010014064/* Set Unsolicited Event*/
14065static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14066 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14068 {}
14069};
14070
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014071/*
14072 * generic initialization of ADC, input mixers and output mixers
14073 */
14074static struct hda_verb alc662_auto_init_verbs[] = {
14075 /*
14076 * Unmute ADC and set the default input to mic-in
14077 */
14078 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080
14081 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14082 * mixer widget
14083 * Note: PASD motherboards uses the Line In 2 as the input for front
14084 * panel mic (mic 2)
14085 */
14086 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014092
14093 /*
14094 * Set up output mixers (0x0c - 0x0f)
14095 */
14096 /* set vol=0 to output mixers */
14097 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14098 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14099 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14100
14101 /* set up input amps for analog loopback */
14102 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014109
14110
14111 /* FIXME: use matrix-type input source selection */
14112 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14113 /* Input mixer */
14114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014116 { }
14117};
14118
Takashi Iwai24fb9172008-09-02 14:48:20 +020014119/* additional verbs for ALC663 */
14120static struct hda_verb alc663_auto_init_verbs[] = {
14121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14123 { }
14124};
14125
Kailang Yang6dda9f42008-05-27 12:05:31 +020014126static struct hda_verb alc663_m51va_init_verbs[] = {
14127 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14128 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14129 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14130
14131 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14132
14133 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14134 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14135 {}
14136};
14137
14138static struct hda_verb alc663_g71v_init_verbs[] = {
14139 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14140 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14141 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14142
14143 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14144 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14145 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14146
14147 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14148 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14149 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14150 {}
14151};
14152
14153static struct hda_verb alc663_g50v_init_verbs[] = {
14154 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14155 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14156 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14157
14158 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14159 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14160 {}
14161};
14162
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014163/* capture mixer elements */
14164static struct snd_kcontrol_new alc662_capture_mixer[] = {
14165 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14166 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14167 {
14168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14169 /* The multiple "Capture Source" controls confuse alsamixer
14170 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014171 */
14172 /* .name = "Capture Source", */
14173 .name = "Input Source",
14174 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010014175 .info = alc662_mux_enum_info,
14176 .get = alc662_mux_enum_get,
14177 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014178 },
14179 { } /* end */
14180};
14181
14182static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14183{
14184 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014185 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014186
14187 present = snd_hda_codec_read(codec, 0x14, 0,
14188 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014189 bits = present ? HDA_AMP_MUTE : 0;
14190 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14191 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014192}
14193
14194static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14195{
14196 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014197 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014198
14199 present = snd_hda_codec_read(codec, 0x1b, 0,
14200 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014201 bits = present ? HDA_AMP_MUTE : 0;
14202 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14203 HDA_AMP_MUTE, bits);
14204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14205 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014206}
14207
14208static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14209 unsigned int res)
14210{
14211 if ((res >> 26) == ALC880_HP_EVENT)
14212 alc662_lenovo_101e_all_automute(codec);
14213 if ((res >> 26) == ALC880_FRONT_EVENT)
14214 alc662_lenovo_101e_ispeaker_automute(codec);
14215}
14216
Kailang Yang291702f2007-10-16 14:28:03 +020014217static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14218{
14219 unsigned int present;
14220
14221 present = snd_hda_codec_read(codec, 0x18, 0,
14222 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14223 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14224 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14225 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14226 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14227 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14228 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14229 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14230 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14231}
14232
14233/* unsolicited event for HP jack sensing */
14234static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14235 unsigned int res)
14236{
14237 if ((res >> 26) == ALC880_HP_EVENT)
14238 alc262_hippo1_automute( codec );
14239
14240 if ((res >> 26) == ALC880_MIC_EVENT)
14241 alc662_eeepc_mic_automute(codec);
14242}
14243
14244static void alc662_eeepc_inithook(struct hda_codec *codec)
14245{
14246 alc262_hippo1_automute( codec );
14247 alc662_eeepc_mic_automute(codec);
14248}
14249
Kailang Yang8c427222008-01-10 13:03:59 +010014250static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14251{
14252 unsigned int mute;
14253 unsigned int present;
14254
14255 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14256 present = snd_hda_codec_read(codec, 0x14, 0,
14257 AC_VERB_GET_PIN_SENSE, 0);
14258 present = (present & 0x80000000) != 0;
14259 if (present) {
14260 /* mute internal speaker */
14261 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
14262 HDA_AMP_MUTE, HDA_AMP_MUTE);
14263 } else {
14264 /* unmute internal speaker if necessary */
14265 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14266 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
14267 HDA_AMP_MUTE, mute);
14268 }
14269}
14270
14271/* unsolicited event for HP jack sensing */
14272static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14273 unsigned int res)
14274{
14275 if ((res >> 26) == ALC880_HP_EVENT)
14276 alc662_eeepc_ep20_automute(codec);
14277}
14278
14279static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14280{
14281 alc662_eeepc_ep20_automute(codec);
14282}
14283
Kailang Yang6dda9f42008-05-27 12:05:31 +020014284static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14285{
14286 unsigned int present;
14287 unsigned char bits;
14288
14289 present = snd_hda_codec_read(codec, 0x21, 0,
14290 AC_VERB_GET_PIN_SENSE, 0)
14291 & AC_PINSENSE_PRESENCE;
14292 bits = present ? HDA_AMP_MUTE : 0;
14293 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14294 HDA_AMP_MUTE, bits);
14295}
14296
14297static void alc663_m51va_mic_automute(struct hda_codec *codec)
14298{
14299 unsigned int present;
14300
14301 present = snd_hda_codec_read(codec, 0x18, 0,
14302 AC_VERB_GET_PIN_SENSE, 0)
14303 & AC_PINSENSE_PRESENCE;
14304 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14305 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14306 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14307 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14308 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14309 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14310 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14311 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14312}
14313
14314static void alc663_m51va_unsol_event(struct hda_codec *codec,
14315 unsigned int res)
14316{
14317 switch (res >> 26) {
14318 case ALC880_HP_EVENT:
14319 alc663_m51va_speaker_automute(codec);
14320 break;
14321 case ALC880_MIC_EVENT:
14322 alc663_m51va_mic_automute(codec);
14323 break;
14324 }
14325}
14326
14327static void alc663_m51va_inithook(struct hda_codec *codec)
14328{
14329 alc663_m51va_speaker_automute(codec);
14330 alc663_m51va_mic_automute(codec);
14331}
14332
14333static void alc663_g71v_hp_automute(struct hda_codec *codec)
14334{
14335 unsigned int present;
14336 unsigned char bits;
14337
14338 present = snd_hda_codec_read(codec, 0x21, 0,
14339 AC_VERB_GET_PIN_SENSE, 0)
14340 & AC_PINSENSE_PRESENCE;
14341 bits = present ? HDA_AMP_MUTE : 0;
14342 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14343 HDA_AMP_MUTE, bits);
14344 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14345 HDA_AMP_MUTE, bits);
14346}
14347
14348static void alc663_g71v_front_automute(struct hda_codec *codec)
14349{
14350 unsigned int present;
14351 unsigned char bits;
14352
14353 present = snd_hda_codec_read(codec, 0x15, 0,
14354 AC_VERB_GET_PIN_SENSE, 0)
14355 & AC_PINSENSE_PRESENCE;
14356 bits = present ? HDA_AMP_MUTE : 0;
14357 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14358 HDA_AMP_MUTE, bits);
14359}
14360
14361static void alc663_g71v_unsol_event(struct hda_codec *codec,
14362 unsigned int res)
14363{
14364 switch (res >> 26) {
14365 case ALC880_HP_EVENT:
14366 alc663_g71v_hp_automute(codec);
14367 break;
14368 case ALC880_FRONT_EVENT:
14369 alc663_g71v_front_automute(codec);
14370 break;
14371 case ALC880_MIC_EVENT:
14372 alc662_eeepc_mic_automute(codec);
14373 break;
14374 }
14375}
14376
14377static void alc663_g71v_inithook(struct hda_codec *codec)
14378{
14379 alc663_g71v_front_automute(codec);
14380 alc663_g71v_hp_automute(codec);
14381 alc662_eeepc_mic_automute(codec);
14382}
14383
14384static void alc663_g50v_unsol_event(struct hda_codec *codec,
14385 unsigned int res)
14386{
14387 switch (res >> 26) {
14388 case ALC880_HP_EVENT:
14389 alc663_m51va_speaker_automute(codec);
14390 break;
14391 case ALC880_MIC_EVENT:
14392 alc662_eeepc_mic_automute(codec);
14393 break;
14394 }
14395}
14396
14397static void alc663_g50v_inithook(struct hda_codec *codec)
14398{
14399 alc663_m51va_speaker_automute(codec);
14400 alc662_eeepc_mic_automute(codec);
14401}
14402
Takashi Iwaicb53c622007-08-10 17:21:45 +020014403#ifdef CONFIG_SND_HDA_POWER_SAVE
14404#define alc662_loopbacks alc880_loopbacks
14405#endif
14406
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014407
14408/* pcm configuration: identiacal with ALC880 */
14409#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14410#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14411#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14412#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14413
14414/*
14415 * configuration and preset
14416 */
14417static const char *alc662_models[ALC662_MODEL_LAST] = {
14418 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14419 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14420 [ALC662_3ST_6ch] = "3stack-6ch",
14421 [ALC662_5ST_DIG] = "6stack-dig",
14422 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014423 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014424 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014425 [ALC663_ASUS_M51VA] = "m51va",
14426 [ALC663_ASUS_G71V] = "g71v",
14427 [ALC663_ASUS_H13] = "h13",
14428 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014429 [ALC662_AUTO] = "auto",
14430};
14431
14432static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014433 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14434 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14435 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014436 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014437 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014438 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014439 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014440 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14441 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14442 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014443 {}
14444};
14445
14446static struct alc_config_preset alc662_presets[] = {
14447 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014448 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014449 .init_verbs = { alc662_init_verbs },
14450 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14451 .dac_nids = alc662_dac_nids,
14452 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014453 .dig_in_nid = ALC662_DIGIN_NID,
14454 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14455 .channel_mode = alc662_3ST_2ch_modes,
14456 .input_mux = &alc662_capture_source,
14457 },
14458 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014459 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14460 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014461 .init_verbs = { alc662_init_verbs },
14462 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14463 .dac_nids = alc662_dac_nids,
14464 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014465 .dig_in_nid = ALC662_DIGIN_NID,
14466 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14467 .channel_mode = alc662_3ST_6ch_modes,
14468 .need_dac_fix = 1,
14469 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014470 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014471 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014472 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14473 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014474 .init_verbs = { alc662_init_verbs },
14475 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14476 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014477 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14478 .channel_mode = alc662_3ST_6ch_modes,
14479 .need_dac_fix = 1,
14480 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014481 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014482 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014483 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14484 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014485 .init_verbs = { alc662_init_verbs },
14486 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14487 .dac_nids = alc662_dac_nids,
14488 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014489 .dig_in_nid = ALC662_DIGIN_NID,
14490 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14491 .channel_mode = alc662_5stack_modes,
14492 .input_mux = &alc662_capture_source,
14493 },
14494 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014495 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014496 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14497 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14498 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014499 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14500 .channel_mode = alc662_3ST_2ch_modes,
14501 .input_mux = &alc662_lenovo_101e_capture_source,
14502 .unsol_event = alc662_lenovo_101e_unsol_event,
14503 .init_hook = alc662_lenovo_101e_all_automute,
14504 },
Kailang Yang291702f2007-10-16 14:28:03 +020014505 [ALC662_ASUS_EEEPC_P701] = {
14506 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14507 .init_verbs = { alc662_init_verbs,
14508 alc662_eeepc_sue_init_verbs },
14509 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14510 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014511 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14512 .channel_mode = alc662_3ST_2ch_modes,
14513 .input_mux = &alc662_eeepc_capture_source,
14514 .unsol_event = alc662_eeepc_unsol_event,
14515 .init_hook = alc662_eeepc_inithook,
14516 },
Kailang Yang8c427222008-01-10 13:03:59 +010014517 [ALC662_ASUS_EEEPC_EP20] = {
14518 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14519 alc662_chmode_mixer },
14520 .init_verbs = { alc662_init_verbs,
14521 alc662_eeepc_ep20_sue_init_verbs },
14522 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14523 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014524 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14525 .channel_mode = alc662_3ST_6ch_modes,
14526 .input_mux = &alc662_lenovo_101e_capture_source,
14527 .unsol_event = alc662_eeepc_ep20_unsol_event,
14528 .init_hook = alc662_eeepc_ep20_inithook,
14529 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014530 [ALC663_ASUS_M51VA] = {
14531 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14532 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14533 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14534 .dac_nids = alc662_dac_nids,
14535 .dig_out_nid = ALC662_DIGOUT_NID,
14536 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14537 .channel_mode = alc662_3ST_2ch_modes,
14538 .input_mux = &alc663_m51va_capture_source,
14539 .unsol_event = alc663_m51va_unsol_event,
14540 .init_hook = alc663_m51va_inithook,
14541 },
14542 [ALC663_ASUS_G71V] = {
14543 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14544 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14545 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14546 .dac_nids = alc662_dac_nids,
14547 .dig_out_nid = ALC662_DIGOUT_NID,
14548 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14549 .channel_mode = alc662_3ST_2ch_modes,
14550 .input_mux = &alc662_eeepc_capture_source,
14551 .unsol_event = alc663_g71v_unsol_event,
14552 .init_hook = alc663_g71v_inithook,
14553 },
14554 [ALC663_ASUS_H13] = {
14555 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14556 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14557 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14558 .dac_nids = alc662_dac_nids,
14559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14560 .channel_mode = alc662_3ST_2ch_modes,
14561 .input_mux = &alc663_m51va_capture_source,
14562 .unsol_event = alc663_m51va_unsol_event,
14563 .init_hook = alc663_m51va_inithook,
14564 },
14565 [ALC663_ASUS_G50V] = {
14566 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14567 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14569 .dac_nids = alc662_dac_nids,
14570 .dig_out_nid = ALC662_DIGOUT_NID,
14571 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14572 .channel_mode = alc662_3ST_6ch_modes,
14573 .input_mux = &alc663_capture_source,
14574 .unsol_event = alc663_g50v_unsol_event,
14575 .init_hook = alc663_g50v_inithook,
14576 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014577};
14578
14579
14580/*
14581 * BIOS auto configuration
14582 */
14583
14584/* add playback controls from the parsed DAC table */
14585static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14586 const struct auto_pin_cfg *cfg)
14587{
14588 char name[32];
14589 static const char *chname[4] = {
14590 "Front", "Surround", NULL /*CLFE*/, "Side"
14591 };
14592 hda_nid_t nid;
14593 int i, err;
14594
14595 for (i = 0; i < cfg->line_outs; i++) {
14596 if (!spec->multiout.dac_nids[i])
14597 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014598 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014599 if (i == 2) {
14600 /* Center/LFE */
14601 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14602 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014603 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14604 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014605 if (err < 0)
14606 return err;
14607 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14608 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014609 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14610 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014611 if (err < 0)
14612 return err;
14613 err = add_control(spec, ALC_CTL_BIND_MUTE,
14614 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014615 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14616 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014617 if (err < 0)
14618 return err;
14619 err = add_control(spec, ALC_CTL_BIND_MUTE,
14620 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014621 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14622 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014623 if (err < 0)
14624 return err;
14625 } else {
14626 sprintf(name, "%s Playback Volume", chname[i]);
14627 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014628 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14629 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014630 if (err < 0)
14631 return err;
14632 sprintf(name, "%s Playback Switch", chname[i]);
14633 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014634 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14635 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014636 if (err < 0)
14637 return err;
14638 }
14639 }
14640 return 0;
14641}
14642
14643/* add playback controls for speaker and HP outputs */
14644static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14645 const char *pfx)
14646{
14647 hda_nid_t nid;
14648 int err;
14649 char name[32];
14650
14651 if (!pin)
14652 return 0;
14653
Takashi Iwai24fb9172008-09-02 14:48:20 +020014654 if (pin == 0x17) {
14655 /* ALC663 has a mono output pin on 0x17 */
14656 sprintf(name, "%s Playback Switch", pfx);
14657 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14658 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
14659 return err;
14660 }
14661
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014662 if (alc880_is_fixed_pin(pin)) {
14663 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14664 /* printk("DAC nid=%x\n",nid); */
14665 /* specify the DAC as the extra output */
14666 if (!spec->multiout.hp_nid)
14667 spec->multiout.hp_nid = nid;
14668 else
14669 spec->multiout.extra_out_nid[0] = nid;
14670 /* control HP volume/switch on the output mixer amp */
14671 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14672 sprintf(name, "%s Playback Volume", pfx);
14673 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14674 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14675 if (err < 0)
14676 return err;
14677 sprintf(name, "%s Playback Switch", pfx);
14678 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14679 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14680 if (err < 0)
14681 return err;
14682 } else if (alc880_is_multi_pin(pin)) {
14683 /* set manual connection */
14684 /* we have only a switch on HP-out PIN */
14685 sprintf(name, "%s Playback Switch", pfx);
14686 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14687 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14688 if (err < 0)
14689 return err;
14690 }
14691 return 0;
14692}
14693
14694/* create playback/capture controls for input pins */
14695static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14696 const struct auto_pin_cfg *cfg)
14697{
14698 struct hda_input_mux *imux = &spec->private_imux;
14699 int i, err, idx;
14700
14701 for (i = 0; i < AUTO_PIN_LAST; i++) {
14702 if (alc880_is_input_pin(cfg->input_pins[i])) {
14703 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14704 err = new_analog_input(spec, cfg->input_pins[i],
14705 auto_pin_cfg_labels[i],
14706 idx, 0x0b);
14707 if (err < 0)
14708 return err;
14709 imux->items[imux->num_items].label =
14710 auto_pin_cfg_labels[i];
14711 imux->items[imux->num_items].index =
14712 alc880_input_pin_idx(cfg->input_pins[i]);
14713 imux->num_items++;
14714 }
14715 }
14716 return 0;
14717}
14718
14719static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14720 hda_nid_t nid, int pin_type,
14721 int dac_idx)
14722{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014723 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014724 /* need the manual connection? */
14725 if (alc880_is_multi_pin(nid)) {
14726 struct alc_spec *spec = codec->spec;
14727 int idx = alc880_multi_pin_idx(nid);
14728 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14729 AC_VERB_SET_CONNECT_SEL,
14730 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14731 }
14732}
14733
14734static void alc662_auto_init_multi_out(struct hda_codec *codec)
14735{
14736 struct alc_spec *spec = codec->spec;
14737 int i;
14738
Kailang Yang8c427222008-01-10 13:03:59 +010014739 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014740 for (i = 0; i <= HDA_SIDE; i++) {
14741 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014742 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014743 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014744 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014745 i);
14746 }
14747}
14748
14749static void alc662_auto_init_hp_out(struct hda_codec *codec)
14750{
14751 struct alc_spec *spec = codec->spec;
14752 hda_nid_t pin;
14753
14754 pin = spec->autocfg.hp_pins[0];
14755 if (pin) /* connect to front */
14756 /* use dac 0 */
14757 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014758 pin = spec->autocfg.speaker_pins[0];
14759 if (pin)
14760 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014761}
14762
14763#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14764#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14765
14766static void alc662_auto_init_analog_input(struct hda_codec *codec)
14767{
14768 struct alc_spec *spec = codec->spec;
14769 int i;
14770
14771 for (i = 0; i < AUTO_PIN_LAST; i++) {
14772 hda_nid_t nid = spec->autocfg.input_pins[i];
14773 if (alc662_is_input_pin(nid)) {
14774 snd_hda_codec_write(codec, nid, 0,
14775 AC_VERB_SET_PIN_WIDGET_CONTROL,
14776 (i <= AUTO_PIN_FRONT_MIC ?
14777 PIN_VREF80 : PIN_IN));
14778 if (nid != ALC662_PIN_CD_NID)
14779 snd_hda_codec_write(codec, nid, 0,
14780 AC_VERB_SET_AMP_GAIN_MUTE,
14781 AMP_OUT_MUTE);
14782 }
14783 }
14784}
14785
Takashi Iwaif511b012008-08-15 16:46:42 +020014786#define alc662_auto_init_input_src alc882_auto_init_input_src
14787
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014788static int alc662_parse_auto_config(struct hda_codec *codec)
14789{
14790 struct alc_spec *spec = codec->spec;
14791 int err;
14792 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14793
14794 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14795 alc662_ignore);
14796 if (err < 0)
14797 return err;
14798 if (!spec->autocfg.line_outs)
14799 return 0; /* can't find valid BIOS pin config */
14800
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014801 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14802 if (err < 0)
14803 return err;
14804 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14805 if (err < 0)
14806 return err;
14807 err = alc662_auto_create_extra_out(spec,
14808 spec->autocfg.speaker_pins[0],
14809 "Speaker");
14810 if (err < 0)
14811 return err;
14812 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14813 "Headphone");
14814 if (err < 0)
14815 return err;
14816 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14817 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014818 return err;
14819
14820 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14821
14822 if (spec->autocfg.dig_out_pin)
14823 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14824
14825 if (spec->kctl_alloc)
14826 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14827
14828 spec->num_mux_defs = 1;
14829 spec->input_mux = &spec->private_imux;
14830
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014831 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020014832 if (codec->vendor_id == 0x10ec0663)
14833 spec->init_verbs[spec->num_init_verbs++] =
14834 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020014835
14836 err = alc_auto_add_mic_boost(codec);
14837 if (err < 0)
14838 return err;
14839
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014840 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14841 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014842 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014843}
14844
14845/* additional initialization for auto-configuration model */
14846static void alc662_auto_init(struct hda_codec *codec)
14847{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014848 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014849 alc662_auto_init_multi_out(codec);
14850 alc662_auto_init_hp_out(codec);
14851 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014852 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014853 if (spec->unsol_event)
14854 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014855}
14856
14857static int patch_alc662(struct hda_codec *codec)
14858{
14859 struct alc_spec *spec;
14860 int err, board_config;
14861
14862 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14863 if (!spec)
14864 return -ENOMEM;
14865
14866 codec->spec = spec;
14867
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014868 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14869
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014870 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14871 alc662_models,
14872 alc662_cfg_tbl);
14873 if (board_config < 0) {
14874 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14875 "trying auto-probe from BIOS...\n");
14876 board_config = ALC662_AUTO;
14877 }
14878
14879 if (board_config == ALC662_AUTO) {
14880 /* automatic parse from the BIOS config */
14881 err = alc662_parse_auto_config(codec);
14882 if (err < 0) {
14883 alc_free(codec);
14884 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020014885 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014886 printk(KERN_INFO
14887 "hda_codec: Cannot set up configuration "
14888 "from BIOS. Using base mode...\n");
14889 board_config = ALC662_3ST_2ch_DIG;
14890 }
14891 }
14892
14893 if (board_config != ALC662_AUTO)
14894 setup_preset(spec, &alc662_presets[board_config]);
14895
Kailang Yang6dda9f42008-05-27 12:05:31 +020014896 if (codec->vendor_id == 0x10ec0663) {
14897 spec->stream_name_analog = "ALC663 Analog";
14898 spec->stream_name_digital = "ALC663 Digital";
14899 } else {
14900 spec->stream_name_analog = "ALC662 Analog";
14901 spec->stream_name_digital = "ALC662 Digital";
14902 }
14903
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014904 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14905 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14906
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014907 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14908 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14909
Takashi Iwaie1406342008-02-11 18:32:32 +010014910 spec->adc_nids = alc662_adc_nids;
14911 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14912 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014913
Takashi Iwai2134ea42008-01-10 16:53:55 +010014914 spec->vmaster_nid = 0x02;
14915
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014916 codec->patch_ops = alc_patch_ops;
14917 if (board_config == ALC662_AUTO)
14918 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014919#ifdef CONFIG_SND_HDA_POWER_SAVE
14920 if (!spec->loopback.amplist)
14921 spec->loopback.amplist = alc662_loopbacks;
14922#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014923
14924 return 0;
14925}
14926
14927/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070014928 * patch entries
14929 */
14930struct hda_codec_preset snd_hda_preset_realtek[] = {
14931 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014932 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014933 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020014934 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014935 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014936 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014937 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014938 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14939 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14940 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014941 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14942 .patch = patch_alc883 },
14943 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14944 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014945 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014946 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014947 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014948 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020014949 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020014950 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010014951 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014952 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014953 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014954 {} /* terminator */
14955};