blob: 8174050da15fdd11e62a3f3b0f16d5f857474910 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Kailang Yangdf694da2005-12-05 19:42:22 +0100103 ALC262_AUTO,
104 ALC262_MODEL_LAST /* last tag */
105};
106
Kailang Yanga361d842007-06-05 12:30:55 +0200107/* ALC268 models */
108enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200109 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200110 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200111 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200112 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100113 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100114 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100115#ifdef CONFIG_SND_DEBUG
116 ALC268_TEST,
117#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200118 ALC268_AUTO,
119 ALC268_MODEL_LAST /* last tag */
120};
121
Kailang Yangf6a92242007-12-13 16:52:54 +0100122/* ALC269 models */
123enum {
124 ALC269_BASIC,
125 ALC269_AUTO,
126 ALC269_MODEL_LAST /* last tag */
127};
128
Kailang Yangdf694da2005-12-05 19:42:22 +0100129/* ALC861 models */
130enum {
131 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200132 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100133 ALC861_3ST_DIG,
134 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200135 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200136 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200137 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100138 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100139 ALC861_AUTO,
140 ALC861_MODEL_LAST,
141};
142
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100143/* ALC861-VD models */
144enum {
145 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200146 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100147 ALC861VD_3ST,
148 ALC861VD_3ST_DIG,
149 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200150 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200151 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200152 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153 ALC861VD_AUTO,
154 ALC861VD_MODEL_LAST,
155};
156
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200157/* ALC662 models */
158enum {
159 ALC662_3ST_2ch_DIG,
160 ALC662_3ST_6ch_DIG,
161 ALC662_3ST_6ch,
162 ALC662_5ST_DIG,
163 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200164 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100165 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200166 ALC663_ASUS_M51VA,
167 ALC663_ASUS_G71V,
168 ALC663_ASUS_H13,
169 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170 ALC662_AUTO,
171 ALC662_MODEL_LAST,
172};
173
Kailang Yangdf694da2005-12-05 19:42:22 +0100174/* ALC882 models */
175enum {
176 ALC882_3ST_DIG,
177 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200178 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200179 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200180 ALC882_TARGA,
181 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200182 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100183 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200184 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200185 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200186 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100187 ALC882_MODEL_LAST,
188};
189
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200190/* ALC883 models */
191enum {
192 ALC883_3ST_2ch_DIG,
193 ALC883_3ST_6ch_DIG,
194 ALC883_3ST_6ch,
195 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200196 ALC883_TARGA_DIG,
197 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200198 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200199 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200200 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100202 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200203 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200205 ALC888_LENOVO_MS7195_DIG,
206 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200207 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100208 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100209 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100210 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100211 ALC883_FUJITSU_PI2515,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200212 ALC883_AUTO,
213 ALC883_MODEL_LAST,
214};
215
Kailang Yangdf694da2005-12-05 19:42:22 +0100216/* for GPIO Poll */
217#define GPIO_MASK 0x03
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219struct alc_spec {
220 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100221 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 unsigned int num_mixers;
223
Kailang Yangdf694da2005-12-05 19:42:22 +0100224 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200225 * don't forget NULL
226 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200227 */
228 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Takashi Iwai16ded522005-06-10 19:58:24 +0200230 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 struct hda_pcm_stream *stream_analog_playback;
232 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100233 struct hda_pcm_stream *stream_analog_alt_playback;
234 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200236 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 struct hda_pcm_stream *stream_digital_playback;
238 struct hda_pcm_stream *stream_digital_capture;
239
240 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200241 struct hda_multi_out multiout; /* playback set-up
242 * max_channels, dacs must be set
243 * dig_out_nid and hp_nid are optional
244 */
Takashi Iwai63300792008-01-24 15:31:36 +0100245 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 /* capture */
248 unsigned int num_adc_nids;
249 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100250 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200251 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200254 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 const struct hda_input_mux *input_mux;
256 unsigned int cur_mux[3];
257
258 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100259 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200261 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100264 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200265
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200266 /* dynamic controls, init_verbs and input_mux */
267 struct auto_pin_cfg autocfg;
268 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100269 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200270 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200271 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100272
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100273 /* hooks */
274 void (*init_hook)(struct hda_codec *codec);
275 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
276
Takashi Iwai834be882006-03-01 14:16:17 +0100277 /* for pin sensing */
278 unsigned int sense_updated: 1;
279 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100280 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200281
Takashi Iwai2134ea42008-01-10 16:53:55 +0100282 /* for virtual master */
283 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200284#ifdef CONFIG_SND_HDA_POWER_SAVE
285 struct hda_loopback_check loopback;
286#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100287};
288
289/*
290 * configuration template - to be copied to the spec instance
291 */
292struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200293 struct snd_kcontrol_new *mixers[5]; /* should be identical size
294 * with spec
295 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100296 const struct hda_verb *init_verbs[5];
297 unsigned int num_dacs;
298 hda_nid_t *dac_nids;
299 hda_nid_t dig_out_nid; /* optional */
300 hda_nid_t hp_nid; /* optional */
301 unsigned int num_adc_nids;
302 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100303 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 hda_nid_t dig_in_nid;
305 unsigned int num_channel_mode;
306 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200307 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200308 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100309 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100310 void (*unsol_event)(struct hda_codec *, unsigned int);
311 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200312#ifdef CONFIG_SND_HDA_POWER_SAVE
313 struct hda_amp_list *loopbacks;
314#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315};
316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
318/*
319 * input MUX handling
320 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200321static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200326 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
327 if (mux_idx >= spec->num_mux_defs)
328 mux_idx = 0;
329 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330}
331
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200332static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
338
339 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
340 return 0;
341}
342
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
348 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200349 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100350 hda_nid_t nid = spec->capsrc_nids ?
351 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200352 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100353 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354}
355
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357/*
358 * channel mode setting
359 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200360static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
361 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
364 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100365 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
366 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367}
368
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100374 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200375 spec->num_channel_mode,
376 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200379static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381{
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200384 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
385 spec->num_channel_mode,
386 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200387 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200388 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
389 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393 * Control the mode of pin widget settings via the mixer. "pc" is used
394 * instead of "%" to avoid consequences of accidently treating the % as
395 * being part of a format specifier. Maximum allowed length of a value is
396 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100397 *
398 * Note: some retasking pin complexes seem to ignore requests for input
399 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
400 * are requested. Therefore order this list so that this behaviour will not
401 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200402 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
403 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200404 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100406 "Mic 50pc bias", "Mic 80pc bias",
407 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100408};
409static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100410 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411};
412/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200413 * in the pin being assumed to be exclusively an input or an output pin. In
414 * addition, "input" pins may or may not process the mic bias option
415 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
416 * accept requests for bias as of chip versions up to March 2006) and/or
417 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200419#define ALC_PIN_DIR_IN 0x00
420#define ALC_PIN_DIR_OUT 0x01
421#define ALC_PIN_DIR_INOUT 0x02
422#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
423#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100424
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200425/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426 * For each direction the minimum and maximum values are given.
427 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200428static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429 { 0, 2 }, /* ALC_PIN_DIR_IN */
430 { 3, 4 }, /* ALC_PIN_DIR_OUT */
431 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200432 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
433 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434};
435#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
436#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
437#define alc_pin_mode_n_items(_dir) \
438 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
439
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200442{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100443 unsigned int item_num = uinfo->value.enumerated.item;
444 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
445
446 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200447 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
449
450 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
451 item_num = alc_pin_mode_min(dir);
452 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200453 return 0;
454}
455
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
457 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200458{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200463 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
465 AC_VERB_GET_PIN_WIDGET_CONTROL,
466 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200467
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468 /* Find enumerated value for current pinctl setting */
469 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 return 0;
474}
475
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478{
479 signed int change;
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 hda_nid_t nid = kcontrol->private_value & 0xffff;
482 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
483 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
485 AC_VERB_GET_PIN_WIDGET_CONTROL,
486 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200488 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 val = alc_pin_mode_min(dir);
490
491 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100492 if (change) {
493 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200494 snd_hda_codec_write_cache(codec, nid, 0,
495 AC_VERB_SET_PIN_WIDGET_CONTROL,
496 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100497
498 /* Also enable the retasking pin's input/output as required
499 * for the requested pin mode. Enum values of 2 or less are
500 * input modes.
501 *
502 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200503 * reduces noise slightly (particularly on input) so we'll
504 * do it. However, having both input and output buffers
505 * enabled simultaneously doesn't seem to be problematic if
506 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100507 */
508 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200509 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
510 HDA_AMP_MUTE, HDA_AMP_MUTE);
511 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
512 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100513 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200514 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
515 HDA_AMP_MUTE, HDA_AMP_MUTE);
516 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
517 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100518 }
519 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200520 return change;
521}
522
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200524 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 .info = alc_pin_mode_info, \
526 .get = alc_pin_mode_get, \
527 .put = alc_pin_mode_put, \
528 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100529
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100530/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
531 * together using a mask with more than one bit set. This control is
532 * currently used only by the ALC260 test model. At this stage they are not
533 * needed for any "production" models.
534 */
535#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200536#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200537
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100540{
541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 hda_nid_t nid = kcontrol->private_value & 0xffff;
543 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
544 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545 unsigned int val = snd_hda_codec_read(codec, nid, 0,
546 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100547
548 *valp = (val & mask) != 0;
549 return 0;
550}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100553{
554 signed int change;
555 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
556 hda_nid_t nid = kcontrol->private_value & 0xffff;
557 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
558 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
560 AC_VERB_GET_GPIO_DATA,
561 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100562
563 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
565 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100566 gpio_data &= ~mask;
567 else
568 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200569 snd_hda_codec_write_cache(codec, nid, 0,
570 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100571
572 return change;
573}
574#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
575 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
576 .info = alc_gpio_data_info, \
577 .get = alc_gpio_data_get, \
578 .put = alc_gpio_data_put, \
579 .private_value = nid | (mask<<16) }
580#endif /* CONFIG_SND_DEBUG */
581
Jonathan Woithe92621f12006-02-28 11:47:47 +0100582/* A switch control to allow the enabling of the digital IO pins on the
583 * ALC260. This is incredibly simplistic; the intention of this control is
584 * to provide something in the test model allowing digital outputs to be
585 * identified if present. If models are found which can utilise these
586 * outputs a more complete mixer control can be devised for those models if
587 * necessary.
588 */
589#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200590#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200591
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200592static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100594{
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 hda_nid_t nid = kcontrol->private_value & 0xffff;
597 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
598 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100600 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100601
602 *valp = (val & mask) != 0;
603 return 0;
604}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100607{
608 signed int change;
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 hda_nid_t nid = kcontrol->private_value & 0xffff;
611 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
612 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100614 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100616
617 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200618 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100619 if (val==0)
620 ctrl_data &= ~mask;
621 else
622 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200623 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
624 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100625
626 return change;
627}
628#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
629 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
630 .info = alc_spdif_ctrl_info, \
631 .get = alc_spdif_ctrl_get, \
632 .put = alc_spdif_ctrl_put, \
633 .private_value = nid | (mask<<16) }
634#endif /* CONFIG_SND_DEBUG */
635
Jonathan Woithef8225f62008-01-08 12:16:54 +0100636/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
637 * Again, this is only used in the ALC26x test models to help identify when
638 * the EAPD line must be asserted for features to work.
639 */
640#ifdef CONFIG_SND_DEBUG
641#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
642
643static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
645{
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 hda_nid_t nid = kcontrol->private_value & 0xffff;
648 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
649 long *valp = ucontrol->value.integer.value;
650 unsigned int val = snd_hda_codec_read(codec, nid, 0,
651 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
652
653 *valp = (val & mask) != 0;
654 return 0;
655}
656
657static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
658 struct snd_ctl_elem_value *ucontrol)
659{
660 int change;
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 hda_nid_t nid = kcontrol->private_value & 0xffff;
663 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
664 long val = *ucontrol->value.integer.value;
665 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_EAPD_BTLENABLE,
667 0x00);
668
669 /* Set/unset the masked control bit(s) as needed */
670 change = (!val ? 0 : mask) != (ctrl_data & mask);
671 if (!val)
672 ctrl_data &= ~mask;
673 else
674 ctrl_data |= mask;
675 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
676 ctrl_data);
677
678 return change;
679}
680
681#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
683 .info = alc_eapd_ctrl_info, \
684 .get = alc_eapd_ctrl_get, \
685 .put = alc_eapd_ctrl_put, \
686 .private_value = nid | (mask<<16) }
687#endif /* CONFIG_SND_DEBUG */
688
Kailang Yangdf694da2005-12-05 19:42:22 +0100689/*
690 * set up from the preset table
691 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692static void setup_preset(struct alc_spec *spec,
693 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100694{
695 int i;
696
697 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
698 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200699 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
700 i++)
701 spec->init_verbs[spec->num_init_verbs++] =
702 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100703
704 spec->channel_mode = preset->channel_mode;
705 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200706 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100707
708 spec->multiout.max_channels = spec->channel_mode[0].channels;
709
710 spec->multiout.num_dacs = preset->num_dacs;
711 spec->multiout.dac_nids = preset->dac_nids;
712 spec->multiout.dig_out_nid = preset->dig_out_nid;
713 spec->multiout.hp_nid = preset->hp_nid;
714
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200715 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200716 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200717 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100718 spec->input_mux = preset->input_mux;
719
720 spec->num_adc_nids = preset->num_adc_nids;
721 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100722 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100723 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100724
725 spec->unsol_event = preset->unsol_event;
726 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200727#ifdef CONFIG_SND_HDA_POWER_SAVE
728 spec->loopback.amplist = preset->loopbacks;
729#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100730}
731
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200732/* Enable GPIO mask and set output */
733static struct hda_verb alc_gpio1_init_verbs[] = {
734 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
735 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
736 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
737 { }
738};
739
740static struct hda_verb alc_gpio2_init_verbs[] = {
741 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
742 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
743 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
744 { }
745};
746
Kailang Yangbdd148a2007-05-08 15:19:08 +0200747static struct hda_verb alc_gpio3_init_verbs[] = {
748 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
749 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
750 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
751 { }
752};
753
Kailang Yangc9b58002007-10-16 14:30:01 +0200754static void alc_sku_automute(struct hda_codec *codec)
755{
756 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200757 unsigned int present;
758 unsigned int hp_nid = spec->autocfg.hp_pins[0];
759 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
760
761 /* need to execute and sync at first */
762 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
763 present = snd_hda_codec_read(codec, hp_nid, 0,
764 AC_VERB_GET_PIN_SENSE, 0);
765 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100766 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
767 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200768}
769
770/* unsolicited event for HP jack sensing */
771static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
772{
773 if (codec->vendor_id == 0x10ec0880)
774 res >>= 28;
775 else
776 res >>= 26;
777 if (res != ALC880_HP_EVENT)
778 return;
779
780 alc_sku_automute(codec);
781}
782
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200783/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
784 * 31 ~ 16 : Manufacture ID
785 * 15 ~ 8 : SKU ID
786 * 7 ~ 0 : Assembly ID
787 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
788 */
789static void alc_subsystem_id(struct hda_codec *codec,
790 unsigned int porta, unsigned int porte,
791 unsigned int portd)
792{
Kailang Yangc9b58002007-10-16 14:30:01 +0200793 unsigned int ass, tmp, i;
794 unsigned nid;
795 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200796
Kailang Yangc9b58002007-10-16 14:30:01 +0200797 ass = codec->subsystem_id & 0xffff;
798 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
799 goto do_sku;
800
801 /*
802 * 31~30 : port conetcivity
803 * 29~21 : reserve
804 * 20 : PCBEEP input
805 * 19~16 : Check sum (15:1)
806 * 15~1 : Custom
807 * 0 : override
808 */
809 nid = 0x1d;
810 if (codec->vendor_id == 0x10ec0260)
811 nid = 0x17;
812 ass = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_CONFIG_DEFAULT, 0);
814 if (!(ass & 1) && !(ass & 0x100000))
815 return;
816 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200817 return;
818
Kailang Yangc9b58002007-10-16 14:30:01 +0200819 /* check sum */
820 tmp = 0;
821 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100822 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200823 tmp++;
824 }
825 if (((ass >> 16) & 0xf) != tmp)
826 return;
827do_sku:
828 /*
829 * 0 : override
830 * 1 : Swap Jack
831 * 2 : 0 --> Desktop, 1 --> Laptop
832 * 3~5 : External Amplifier control
833 * 7~6 : Reserved
834 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200835 tmp = (ass & 0x38) >> 3; /* external Amp control */
836 switch (tmp) {
837 case 1:
838 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
839 break;
840 case 3:
841 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
842 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200843 case 7:
844 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
845 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200846 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200847 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200848 case 0x10ec0260:
849 snd_hda_codec_write(codec, 0x0f, 0,
850 AC_VERB_SET_EAPD_BTLENABLE, 2);
851 snd_hda_codec_write(codec, 0x10, 0,
852 AC_VERB_SET_EAPD_BTLENABLE, 2);
853 break;
854 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200855 case 0x10ec0267:
856 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200857 case 0x10ec0269:
858 case 0x10ec0862:
859 case 0x10ec0662:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200860 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200861 snd_hda_codec_write(codec, 0x14, 0,
862 AC_VERB_SET_EAPD_BTLENABLE, 2);
863 snd_hda_codec_write(codec, 0x15, 0,
864 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200865 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200866 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200867 switch (codec->vendor_id) {
868 case 0x10ec0260:
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_COEF_INDEX, 7);
871 tmp = snd_hda_codec_read(codec, 0x1a, 0,
872 AC_VERB_GET_PROC_COEF, 0);
873 snd_hda_codec_write(codec, 0x1a, 0,
874 AC_VERB_SET_COEF_INDEX, 7);
875 snd_hda_codec_write(codec, 0x1a, 0,
876 AC_VERB_SET_PROC_COEF,
877 tmp | 0x2010);
878 break;
879 case 0x10ec0262:
880 case 0x10ec0880:
881 case 0x10ec0882:
882 case 0x10ec0883:
883 case 0x10ec0885:
884 case 0x10ec0888:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200885 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200886 snd_hda_codec_write(codec, 0x20, 0,
887 AC_VERB_SET_COEF_INDEX, 7);
888 tmp = snd_hda_codec_read(codec, 0x20, 0,
889 AC_VERB_GET_PROC_COEF, 0);
890 snd_hda_codec_write(codec, 0x20, 0,
891 AC_VERB_SET_COEF_INDEX, 7);
892 snd_hda_codec_write(codec, 0x20, 0,
893 AC_VERB_SET_PROC_COEF,
894 tmp | 0x2010);
895 break;
896 case 0x10ec0267:
897 case 0x10ec0268:
898 snd_hda_codec_write(codec, 0x20, 0,
899 AC_VERB_SET_COEF_INDEX, 7);
900 tmp = snd_hda_codec_read(codec, 0x20, 0,
901 AC_VERB_GET_PROC_COEF, 0);
902 snd_hda_codec_write(codec, 0x20, 0,
903 AC_VERB_SET_COEF_INDEX, 7);
904 snd_hda_codec_write(codec, 0x20, 0,
905 AC_VERB_SET_PROC_COEF,
906 tmp | 0x3000);
907 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200908 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200909 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200910 break;
911 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200912
Kailang Yang8c427222008-01-10 13:03:59 +0100913 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200914 * when the external headphone out jack is plugged"
915 */
Kailang Yang8c427222008-01-10 13:03:59 +0100916 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200917 return;
918 /*
919 * 10~8 : Jack location
920 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
921 * 14~13: Resvered
922 * 15 : 1 --> enable the function "Mute internal speaker
923 * when the external headphone out jack is plugged"
924 */
925 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100926 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200927 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100928 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200929 else
930 return;
931 }
932
933 if (!spec->autocfg.hp_pins[0]) {
934 tmp = (ass >> 11) & 0x3; /* HP to chassis */
935 if (tmp == 0)
936 spec->autocfg.hp_pins[0] = porta;
937 else if (tmp == 1)
938 spec->autocfg.hp_pins[0] = porte;
939 else if (tmp == 2)
940 spec->autocfg.hp_pins[0] = portd;
941 else
942 return;
943 }
944
945 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
946 AC_VERB_SET_UNSOLICITED_ENABLE,
947 AC_USRSP_EN | ALC880_HP_EVENT);
948 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200949}
950
Takashi Iwai41e41f12005-06-08 14:48:49 +0200951/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200952 * Fix-up pin default configurations
953 */
954
955struct alc_pincfg {
956 hda_nid_t nid;
957 u32 val;
958};
959
960static void alc_fix_pincfg(struct hda_codec *codec,
961 const struct snd_pci_quirk *quirk,
962 const struct alc_pincfg **pinfix)
963{
964 const struct alc_pincfg *cfg;
965
966 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
967 if (!quirk)
968 return;
969
970 cfg = pinfix[quirk->value];
971 for (; cfg->nid; cfg++) {
972 int i;
973 u32 val = cfg->val;
974 for (i = 0; i < 4; i++) {
975 snd_hda_codec_write(codec, cfg->nid, 0,
976 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
977 val & 0xff);
978 val >>= 8;
979 }
980 }
981}
982
983/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200984 * ALC880 3-stack model
985 *
986 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200987 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
988 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 */
990
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200991static hda_nid_t alc880_dac_nids[4] = {
992 /* front, rear, clfe, rear_surr */
993 0x02, 0x05, 0x04, 0x03
994};
995
996static hda_nid_t alc880_adc_nids[3] = {
997 /* ADC0-2 */
998 0x07, 0x08, 0x09,
999};
1000
1001/* The datasheet says the node 0x07 is connected from inputs,
1002 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001003 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005static hda_nid_t alc880_adc_nids_alt[2] = {
1006 /* ADC1-2 */
1007 0x08, 0x09,
1008};
1009
1010#define ALC880_DIGOUT_NID 0x06
1011#define ALC880_DIGIN_NID 0x0a
1012
1013static struct hda_input_mux alc880_capture_source = {
1014 .num_items = 4,
1015 .items = {
1016 { "Mic", 0x0 },
1017 { "Front Mic", 0x3 },
1018 { "Line", 0x2 },
1019 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001021};
1022
1023/* channel source setting (2/6 channel selection for 3-stack) */
1024/* 2ch mode */
1025static struct hda_verb alc880_threestack_ch2_init[] = {
1026 /* set line-in to input, mute it */
1027 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1028 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1029 /* set mic-in to input vref 80%, mute it */
1030 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1031 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 { } /* end */
1033};
1034
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001035/* 6ch mode */
1036static struct hda_verb alc880_threestack_ch6_init[] = {
1037 /* set line-in to output, unmute it */
1038 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1039 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1040 /* set mic-in to output, unmute it */
1041 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1042 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1043 { } /* end */
1044};
1045
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001046static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001047 { 2, alc880_threestack_ch2_init },
1048 { 6, alc880_threestack_ch6_init },
1049};
1050
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001051static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001055 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001056 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1068 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1069 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071 {
1072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1073 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001074 .info = alc_ch_mode_info,
1075 .get = alc_ch_mode_get,
1076 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 },
1078 { } /* end */
1079};
1080
1081/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001082static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1084 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1087 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1088 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1089 {
1090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1091 /* The multiple "Capture Source" controls confuse alsamixer
1092 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001093 */
1094 /* .name = "Capture Source", */
1095 .name = "Input Source",
1096 .count = 3,
1097 .info = alc_mux_enum_info,
1098 .get = alc_mux_enum_get,
1099 .put = alc_mux_enum_put,
1100 },
1101 { } /* end */
1102};
1103
1104/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001105static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1108 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1109 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 {
1111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1112 /* The multiple "Capture Source" controls confuse alsamixer
1113 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 */
1115 /* .name = "Capture Source", */
1116 .name = "Input Source",
1117 .count = 2,
1118 .info = alc_mux_enum_info,
1119 .get = alc_mux_enum_get,
1120 .put = alc_mux_enum_put,
1121 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 { } /* end */
1123};
1124
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125
1126
1127/*
1128 * ALC880 5-stack model
1129 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001130 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1131 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001132 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1133 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1134 */
1135
1136/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001137static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001138 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001139 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 { } /* end */
1141};
1142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001143/* channel source setting (6/8 channel selection for 5-stack) */
1144/* 6ch mode */
1145static struct hda_verb alc880_fivestack_ch6_init[] = {
1146 /* set line-in to input, mute it */
1147 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1148 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001149 { } /* end */
1150};
1151
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001152/* 8ch mode */
1153static struct hda_verb alc880_fivestack_ch8_init[] = {
1154 /* set line-in to output, unmute it */
1155 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1156 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1157 { } /* end */
1158};
1159
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001160static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161 { 6, alc880_fivestack_ch6_init },
1162 { 8, alc880_fivestack_ch8_init },
1163};
1164
1165
1166/*
1167 * ALC880 6-stack model
1168 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001169 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1170 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001171 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1172 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1173 */
1174
1175static hda_nid_t alc880_6st_dac_nids[4] = {
1176 /* front, rear, clfe, rear_surr */
1177 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001178};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001179
1180static struct hda_input_mux alc880_6stack_capture_source = {
1181 .num_items = 4,
1182 .items = {
1183 { "Mic", 0x0 },
1184 { "Front Mic", 0x1 },
1185 { "Line", 0x2 },
1186 { "CD", 0x4 },
1187 },
1188};
1189
1190/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001191static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001192 { 8, NULL },
1193};
1194
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001195static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001198 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001199 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001200 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1201 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001202 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1203 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001204 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001205 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1209 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1214 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1215 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001216 {
1217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1218 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001219 .info = alc_ch_mode_info,
1220 .get = alc_ch_mode_get,
1221 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001222 },
1223 { } /* end */
1224};
1225
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226
1227/*
1228 * ALC880 W810 model
1229 *
1230 * W810 has rear IO for:
1231 * Front (DAC 02)
1232 * Surround (DAC 03)
1233 * Center/LFE (DAC 04)
1234 * Digital out (06)
1235 *
1236 * The system also has a pair of internal speakers, and a headphone jack.
1237 * These are both connected to Line2 on the codec, hence to DAC 02.
1238 *
1239 * There is a variable resistor to control the speaker or headphone
1240 * volume. This is a hardware-only device without a software API.
1241 *
1242 * Plugging headphones in will disable the internal speakers. This is
1243 * implemented in hardware, not via the driver using jack sense. In
1244 * a similar fashion, plugging into the rear socket marked "front" will
1245 * disable both the speakers and headphones.
1246 *
1247 * For input, there's a microphone jack, and an "audio in" jack.
1248 * These may not do anything useful with this driver yet, because I
1249 * haven't setup any initialization verbs for these yet...
1250 */
1251
1252static hda_nid_t alc880_w810_dac_nids[3] = {
1253 /* front, rear/surround, clfe */
1254 0x02, 0x03, 0x04
1255};
1256
1257/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001258static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 { 6, NULL }
1260};
1261
1262/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001263static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001265 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001267 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1273 { } /* end */
1274};
1275
1276
1277/*
1278 * Z710V model
1279 *
1280 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001281 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1282 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001283 */
1284
1285static hda_nid_t alc880_z71v_dac_nids[1] = {
1286 0x02
1287};
1288#define ALC880_Z71V_HP_DAC 0x03
1289
1290/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001291static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292 { 2, NULL }
1293};
1294
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001295static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001299 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1304 { } /* end */
1305};
1306
1307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001308/*
1309 * ALC880 F1734 model
1310 *
1311 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1312 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1313 */
1314
1315static hda_nid_t alc880_f1734_dac_nids[1] = {
1316 0x03
1317};
1318#define ALC880_F1734_HP_DAC 0x02
1319
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001320static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001322 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1324 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001325 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1326 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001329 { } /* end */
1330};
1331
Takashi Iwai937b4162008-02-11 14:52:36 +01001332static struct hda_input_mux alc880_f1734_capture_source = {
1333 .num_items = 2,
1334 .items = {
1335 { "Mic", 0x1 },
1336 { "CD", 0x4 },
1337 },
1338};
1339
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001340
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001341/*
1342 * ALC880 ASUS model
1343 *
1344 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1345 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1346 * Mic = 0x18, Line = 0x1a
1347 */
1348
1349#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1350#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1351
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001352static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001354 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001355 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001356 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001359 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1360 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001361 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1362 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1364 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001367 {
1368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1369 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001370 .info = alc_ch_mode_info,
1371 .get = alc_ch_mode_get,
1372 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001373 },
1374 { } /* end */
1375};
1376
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377/*
1378 * ALC880 ASUS W1V model
1379 *
1380 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1381 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1382 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1383 */
1384
1385/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001386static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001387 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1388 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001389 { } /* end */
1390};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001391
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001392/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001393static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001394 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1395 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1396 { } /* end */
1397};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001398
Kailang Yangdf694da2005-12-05 19:42:22 +01001399/* TCL S700 */
1400static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1402 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1404 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1405 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1407 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1408 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1409 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1410 {
1411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1412 /* The multiple "Capture Source" controls confuse alsamixer
1413 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001414 */
1415 /* .name = "Capture Source", */
1416 .name = "Input Source",
1417 .count = 1,
1418 .info = alc_mux_enum_info,
1419 .get = alc_mux_enum_get,
1420 .put = alc_mux_enum_put,
1421 },
1422 { } /* end */
1423};
1424
Kailang Yangccc656c2006-10-17 12:32:26 +02001425/* Uniwill */
1426static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001427 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1428 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1430 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001431 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1432 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1433 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1434 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1443 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1444 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1445 {
1446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1447 .name = "Channel Mode",
1448 .info = alc_ch_mode_info,
1449 .get = alc_ch_mode_get,
1450 .put = alc_ch_mode_put,
1451 },
1452 { } /* end */
1453};
1454
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001455static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1462 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1463 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1464 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1465 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1466 { } /* end */
1467};
1468
Kailang Yangccc656c2006-10-17 12:32:26 +02001469static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1471 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1473 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1476 { } /* end */
1477};
1478
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001480 * virtual master controls
1481 */
1482
1483/*
1484 * slave controls for virtual master
1485 */
1486static const char *alc_slave_vols[] = {
1487 "Front Playback Volume",
1488 "Surround Playback Volume",
1489 "Center Playback Volume",
1490 "LFE Playback Volume",
1491 "Side Playback Volume",
1492 "Headphone Playback Volume",
1493 "Speaker Playback Volume",
1494 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001495 "Line-Out Playback Volume",
1496 NULL,
1497};
1498
1499static const char *alc_slave_sws[] = {
1500 "Front Playback Switch",
1501 "Surround Playback Switch",
1502 "Center Playback Switch",
1503 "LFE Playback Switch",
1504 "Side Playback Switch",
1505 "Headphone Playback Switch",
1506 "Speaker Playback Switch",
1507 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001508 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001509 NULL,
1510};
1511
1512/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001513 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 */
1515static int alc_build_controls(struct hda_codec *codec)
1516{
1517 struct alc_spec *spec = codec->spec;
1518 int err;
1519 int i;
1520
1521 for (i = 0; i < spec->num_mixers; i++) {
1522 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1523 if (err < 0)
1524 return err;
1525 }
1526
1527 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001528 err = snd_hda_create_spdif_out_ctls(codec,
1529 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 if (err < 0)
1531 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001532 err = snd_hda_create_spdif_share_sw(codec,
1533 &spec->multiout);
1534 if (err < 0)
1535 return err;
1536 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 }
1538 if (spec->dig_in_nid) {
1539 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1540 if (err < 0)
1541 return err;
1542 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001543
1544 /* if we have no master control, let's create it */
1545 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001546 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001547 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001548 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001549 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001550 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001551 if (err < 0)
1552 return err;
1553 }
1554 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1555 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1556 NULL, alc_slave_sws);
1557 if (err < 0)
1558 return err;
1559 }
1560
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561 return 0;
1562}
1563
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001564
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565/*
1566 * initialize the codec volumes, etc
1567 */
1568
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001569/*
1570 * generic initialization of ADC, input mixers and output mixers
1571 */
1572static struct hda_verb alc880_volume_init_verbs[] = {
1573 /*
1574 * Unmute ADC0-2 and set the default input to mic-in
1575 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001576 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001578 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001579 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001580 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001583 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1584 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001585 * Note: PASD motherboards uses the Line In 2 as the input for front
1586 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001588 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001597 /*
1598 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001600 /* set vol=0 to output mixers */
1601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1603 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1605 /* set up input amps for analog loopback */
1606 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001609 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001613 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615
1616 { }
1617};
1618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001619/*
1620 * 3-stack pin configuration:
1621 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1622 */
1623static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1624 /*
1625 * preset connection lists of input pins
1626 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1627 */
1628 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1629 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1630 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1631
1632 /*
1633 * Set pin mode and muting
1634 */
1635 /* set front pin widgets 0x14 for output */
1636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1641 /* Mic2 (as headphone out) for HP output */
1642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1644 /* Line In pin widget for input */
1645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1647 /* Line2 (as front mic) pin widget for input and vref at 80% */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1650 /* CD pin widget for input */
1651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1652
1653 { }
1654};
1655
1656/*
1657 * 5-stack pin configuration:
1658 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1659 * line-in/side = 0x1a, f-mic = 0x1b
1660 */
1661static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1662 /*
1663 * preset connection lists of input pins
1664 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1665 */
1666 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1667 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1668
1669 /*
1670 * Set pin mode and muting
1671 */
1672 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1675 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1676 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677 /* unmute pins for output (no gain on this amp) */
1678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1681 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1682
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1686 /* Mic2 (as headphone out) for HP output */
1687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001689 /* Line In pin widget for input */
1690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1692 /* Line2 (as front mic) pin widget for input and vref at 80% */
1693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1695 /* CD pin widget for input */
1696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697
1698 { }
1699};
1700
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001701/*
1702 * W810 pin configuration:
1703 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1704 */
1705static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 /* hphone/speaker input selector: front DAC */
1707 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1708
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1715
1716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 { }
1720};
1721
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001722/*
1723 * Z71V pin configuration:
1724 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1725 */
1726static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001731
Takashi Iwai16ded522005-06-10 19:58:24 +02001732 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001736
1737 { }
1738};
1739
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001740/*
1741 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001742 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1743 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 */
1745static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1746 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1747
Takashi Iwai16ded522005-06-10 19:58:24 +02001748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001754 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001755 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1756
Takashi Iwai16ded522005-06-10 19:58:24 +02001757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001763 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001764 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001765 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1766
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767 { }
1768};
Takashi Iwai16ded522005-06-10 19:58:24 +02001769
Kailang Yangccc656c2006-10-17 12:32:26 +02001770/*
1771 * Uniwill pin configuration:
1772 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1773 * line = 0x1a
1774 */
1775static struct hda_verb alc880_uniwill_init_verbs[] = {
1776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1777
1778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1783 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1784 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1785 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1792
1793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1795 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1799 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1800 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1801 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1802
1803 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1805
1806 { }
1807};
1808
1809/*
1810* Uniwill P53
1811* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1812 */
1813static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1814 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1815
1816 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1818 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1820 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1821 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1828
1829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1830 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1835
1836 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1837 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1838
1839 { }
1840};
1841
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001842static struct hda_verb alc880_beep_init_verbs[] = {
1843 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1844 { }
1845};
1846
Kailang Yangccc656c2006-10-17 12:32:26 +02001847/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001848static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001849{
1850 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001851 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001852
1853 present = snd_hda_codec_read(codec, 0x14, 0,
1854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001855 bits = present ? HDA_AMP_MUTE : 0;
1856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1857 HDA_AMP_MUTE, bits);
1858 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1859 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001860}
1861
1862/* auto-toggle front mic */
1863static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1864{
1865 unsigned int present;
1866 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001867
1868 present = snd_hda_codec_read(codec, 0x18, 0,
1869 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001870 bits = present ? HDA_AMP_MUTE : 0;
1871 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001872}
1873
1874static void alc880_uniwill_automute(struct hda_codec *codec)
1875{
1876 alc880_uniwill_hp_automute(codec);
1877 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001878}
1879
1880static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1881 unsigned int res)
1882{
1883 /* Looks like the unsol event is incompatible with the standard
1884 * definition. 4bit tag is placed at 28 bit!
1885 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001886 switch (res >> 28) {
1887 case ALC880_HP_EVENT:
1888 alc880_uniwill_hp_automute(codec);
1889 break;
1890 case ALC880_MIC_EVENT:
1891 alc880_uniwill_mic_automute(codec);
1892 break;
1893 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001894}
1895
1896static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1897{
1898 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001899 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001900
1901 present = snd_hda_codec_read(codec, 0x14, 0,
1902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001903 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001904 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001905}
1906
1907static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1908{
1909 unsigned int present;
1910
1911 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001912 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1913 present &= HDA_AMP_VOLMASK;
1914 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1915 HDA_AMP_VOLMASK, present);
1916 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1917 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001918}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001919
Kailang Yangccc656c2006-10-17 12:32:26 +02001920static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1921 unsigned int res)
1922{
1923 /* Looks like the unsol event is incompatible with the standard
1924 * definition. 4bit tag is placed at 28 bit!
1925 */
1926 if ((res >> 28) == ALC880_HP_EVENT)
1927 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001928 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001929 alc880_uniwill_p53_dcvol_automute(codec);
1930}
1931
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001932/*
1933 * F1734 pin configuration:
1934 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1935 */
1936static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01001937 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1939 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1940 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1941 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1942
1943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1945 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947
1948 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1949 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01001950 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1952 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1953 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1955 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1956 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001957
Takashi Iwai937b4162008-02-11 14:52:36 +01001958 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1959 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1960
Takashi Iwai16ded522005-06-10 19:58:24 +02001961 { }
1962};
1963
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001964/*
1965 * ASUS pin configuration:
1966 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1967 */
1968static struct hda_verb alc880_pin_asus_init_verbs[] = {
1969 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1970 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1971 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1972 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1973
1974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1978 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1980 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1982
1983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1986 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1987 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1990 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1991 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1992
1993 { }
1994};
1995
1996/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001997#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1998#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999
Kailang Yangdf694da2005-12-05 19:42:22 +01002000/* Clevo m520g init */
2001static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2002 /* headphone output */
2003 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2004 /* line-out */
2005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2007 /* Line-in */
2008 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2009 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2010 /* CD */
2011 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2012 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 /* Mic1 (rear panel) */
2014 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2016 /* Mic2 (front panel) */
2017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2019 /* headphone */
2020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2022 /* change to EAPD mode */
2023 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2024 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2025
2026 { }
2027};
2028
2029static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002030 /* change to EAPD mode */
2031 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2032 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2033
Kailang Yangdf694da2005-12-05 19:42:22 +01002034 /* Headphone output */
2035 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2036 /* Front output*/
2037 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2038 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2039
2040 /* Line In pin widget for input */
2041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2042 /* CD pin widget for input */
2043 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2044 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2046
2047 /* change to EAPD mode */
2048 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2049 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2050
2051 { }
2052};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053
2054/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002055 * LG m1 express dual
2056 *
2057 * Pin assignment:
2058 * Rear Line-In/Out (blue): 0x14
2059 * Build-in Mic-In: 0x15
2060 * Speaker-out: 0x17
2061 * HP-Out (green): 0x1b
2062 * Mic-In/Out (red): 0x19
2063 * SPDIF-Out: 0x1e
2064 */
2065
2066/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2067static hda_nid_t alc880_lg_dac_nids[3] = {
2068 0x05, 0x02, 0x03
2069};
2070
2071/* seems analog CD is not working */
2072static struct hda_input_mux alc880_lg_capture_source = {
2073 .num_items = 3,
2074 .items = {
2075 { "Mic", 0x1 },
2076 { "Line", 0x5 },
2077 { "Internal Mic", 0x6 },
2078 },
2079};
2080
2081/* 2,4,6 channel modes */
2082static struct hda_verb alc880_lg_ch2_init[] = {
2083 /* set line-in and mic-in to input */
2084 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2085 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2086 { }
2087};
2088
2089static struct hda_verb alc880_lg_ch4_init[] = {
2090 /* set line-in to out and mic-in to input */
2091 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2092 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2093 { }
2094};
2095
2096static struct hda_verb alc880_lg_ch6_init[] = {
2097 /* set line-in and mic-in to output */
2098 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2099 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2100 { }
2101};
2102
2103static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2104 { 2, alc880_lg_ch2_init },
2105 { 4, alc880_lg_ch4_init },
2106 { 6, alc880_lg_ch6_init },
2107};
2108
2109static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2111 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2113 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2123 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2124 {
2125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2126 .name = "Channel Mode",
2127 .info = alc_ch_mode_info,
2128 .get = alc_ch_mode_get,
2129 .put = alc_ch_mode_put,
2130 },
2131 { } /* end */
2132};
2133
2134static struct hda_verb alc880_lg_init_verbs[] = {
2135 /* set capture source to mic-in */
2136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2139 /* mute all amp mixer inputs */
2140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002143 /* line-in to input */
2144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2146 /* built-in mic */
2147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2149 /* speaker-out */
2150 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2152 /* mic-in to input */
2153 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2154 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2156 /* HP-out */
2157 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2158 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2160 /* jack sense */
2161 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2162 { }
2163};
2164
2165/* toggle speaker-output according to the hp-jack state */
2166static void alc880_lg_automute(struct hda_codec *codec)
2167{
2168 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002169 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002170
2171 present = snd_hda_codec_read(codec, 0x1b, 0,
2172 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002173 bits = present ? HDA_AMP_MUTE : 0;
2174 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2175 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002176}
2177
2178static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2179{
2180 /* Looks like the unsol event is incompatible with the standard
2181 * definition. 4bit tag is placed at 28 bit!
2182 */
2183 if ((res >> 28) == 0x01)
2184 alc880_lg_automute(codec);
2185}
2186
2187/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002188 * LG LW20
2189 *
2190 * Pin assignment:
2191 * Speaker-out: 0x14
2192 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002193 * Built-in Mic-In: 0x19
2194 * Line-In: 0x1b
2195 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002196 * SPDIF-Out: 0x1e
2197 */
2198
Takashi Iwaid6815182006-03-23 16:06:23 +01002199static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002200 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002201 .items = {
2202 { "Mic", 0x0 },
2203 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002204 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002205 },
2206};
2207
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002208#define alc880_lg_lw_modes alc880_threestack_modes
2209
Takashi Iwaid6815182006-03-23 16:06:23 +01002210static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2214 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2215 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2216 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2217 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2218 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2219 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2220 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2223 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2224 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002225 {
2226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2227 .name = "Channel Mode",
2228 .info = alc_ch_mode_info,
2229 .get = alc_ch_mode_get,
2230 .put = alc_ch_mode_put,
2231 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002232 { } /* end */
2233};
2234
2235static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002236 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2237 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2238 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2239
Takashi Iwaid6815182006-03-23 16:06:23 +01002240 /* set capture source to mic-in */
2241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002245 /* speaker-out */
2246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2247 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2248 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2251 /* mic-in to input */
2252 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2253 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2254 /* built-in mic */
2255 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2256 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2257 /* jack sense */
2258 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2259 { }
2260};
2261
2262/* toggle speaker-output according to the hp-jack state */
2263static void alc880_lg_lw_automute(struct hda_codec *codec)
2264{
2265 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002266 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002267
2268 present = snd_hda_codec_read(codec, 0x1b, 0,
2269 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002270 bits = present ? HDA_AMP_MUTE : 0;
2271 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2272 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002273}
2274
2275static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2276{
2277 /* Looks like the unsol event is incompatible with the standard
2278 * definition. 4bit tag is placed at 28 bit!
2279 */
2280 if ((res >> 28) == 0x01)
2281 alc880_lg_lw_automute(codec);
2282}
2283
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002284static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2285 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2286 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2289 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2290 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2291 { } /* end */
2292};
2293
2294static struct hda_input_mux alc880_medion_rim_capture_source = {
2295 .num_items = 2,
2296 .items = {
2297 { "Mic", 0x0 },
2298 { "Internal Mic", 0x1 },
2299 },
2300};
2301
2302static struct hda_verb alc880_medion_rim_init_verbs[] = {
2303 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2304
2305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307
2308 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2309 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2311 /* Mic2 (as headphone out) for HP output */
2312 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2313 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2314 /* Internal Speaker */
2315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2317
2318 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2319 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2320
2321 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2322 { }
2323};
2324
2325/* toggle speaker-output according to the hp-jack state */
2326static void alc880_medion_rim_automute(struct hda_codec *codec)
2327{
2328 unsigned int present;
2329 unsigned char bits;
2330
2331 present = snd_hda_codec_read(codec, 0x14, 0,
2332 AC_VERB_GET_PIN_SENSE, 0)
2333 & AC_PINSENSE_PRESENCE;
2334 bits = present ? HDA_AMP_MUTE : 0;
2335 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2336 HDA_AMP_MUTE, bits);
2337 if (present)
2338 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2339 else
2340 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2341}
2342
2343static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2344 unsigned int res)
2345{
2346 /* Looks like the unsol event is incompatible with the standard
2347 * definition. 4bit tag is placed at 28 bit!
2348 */
2349 if ((res >> 28) == ALC880_HP_EVENT)
2350 alc880_medion_rim_automute(codec);
2351}
2352
Takashi Iwaicb53c622007-08-10 17:21:45 +02002353#ifdef CONFIG_SND_HDA_POWER_SAVE
2354static struct hda_amp_list alc880_loopbacks[] = {
2355 { 0x0b, HDA_INPUT, 0 },
2356 { 0x0b, HDA_INPUT, 1 },
2357 { 0x0b, HDA_INPUT, 2 },
2358 { 0x0b, HDA_INPUT, 3 },
2359 { 0x0b, HDA_INPUT, 4 },
2360 { } /* end */
2361};
2362
2363static struct hda_amp_list alc880_lg_loopbacks[] = {
2364 { 0x0b, HDA_INPUT, 1 },
2365 { 0x0b, HDA_INPUT, 6 },
2366 { 0x0b, HDA_INPUT, 7 },
2367 { } /* end */
2368};
2369#endif
2370
Takashi Iwaid6815182006-03-23 16:06:23 +01002371/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002372 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002373 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002374
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375static int alc_init(struct hda_codec *codec)
2376{
2377 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 unsigned int i;
2379
2380 for (i = 0; i < spec->num_init_verbs; i++)
2381 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002382
2383 if (spec->init_hook)
2384 spec->init_hook(codec);
2385
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 return 0;
2387}
2388
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002389static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2390{
2391 struct alc_spec *spec = codec->spec;
2392
2393 if (spec->unsol_event)
2394 spec->unsol_event(codec, res);
2395}
2396
Takashi Iwaicb53c622007-08-10 17:21:45 +02002397#ifdef CONFIG_SND_HDA_POWER_SAVE
2398static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2399{
2400 struct alc_spec *spec = codec->spec;
2401 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2402}
2403#endif
2404
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405/*
2406 * Analog playback callbacks
2407 */
2408static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2409 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002410 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411{
2412 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002413 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2414 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415}
2416
2417static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2418 struct hda_codec *codec,
2419 unsigned int stream_tag,
2420 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002421 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422{
2423 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002424 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2425 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426}
2427
2428static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2429 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002430 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431{
2432 struct alc_spec *spec = codec->spec;
2433 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2434}
2435
2436/*
2437 * Digital out
2438 */
2439static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2440 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002441 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442{
2443 struct alc_spec *spec = codec->spec;
2444 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2445}
2446
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002447static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2448 struct hda_codec *codec,
2449 unsigned int stream_tag,
2450 unsigned int format,
2451 struct snd_pcm_substream *substream)
2452{
2453 struct alc_spec *spec = codec->spec;
2454 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2455 stream_tag, format, substream);
2456}
2457
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2459 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002460 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461{
2462 struct alc_spec *spec = codec->spec;
2463 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2464}
2465
2466/*
2467 * Analog capture
2468 */
Takashi Iwai63300792008-01-24 15:31:36 +01002469static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470 struct hda_codec *codec,
2471 unsigned int stream_tag,
2472 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002473 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474{
2475 struct alc_spec *spec = codec->spec;
2476
Takashi Iwai63300792008-01-24 15:31:36 +01002477 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 stream_tag, 0, format);
2479 return 0;
2480}
2481
Takashi Iwai63300792008-01-24 15:31:36 +01002482static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002484 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485{
2486 struct alc_spec *spec = codec->spec;
2487
Takashi Iwai888afa12008-03-18 09:57:50 +01002488 snd_hda_codec_cleanup_stream(codec,
2489 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 return 0;
2491}
2492
2493
2494/*
2495 */
2496static struct hda_pcm_stream alc880_pcm_analog_playback = {
2497 .substreams = 1,
2498 .channels_min = 2,
2499 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 .ops = {
2502 .open = alc880_playback_pcm_open,
2503 .prepare = alc880_playback_pcm_prepare,
2504 .cleanup = alc880_playback_pcm_cleanup
2505 },
2506};
2507
2508static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002509 .substreams = 1,
2510 .channels_min = 2,
2511 .channels_max = 2,
2512 /* NID is set in alc_build_pcms */
2513};
2514
2515static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2516 .substreams = 1,
2517 .channels_min = 2,
2518 .channels_max = 2,
2519 /* NID is set in alc_build_pcms */
2520};
2521
2522static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2523 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 .channels_min = 2,
2525 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002528 .prepare = alc880_alt_capture_pcm_prepare,
2529 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530 },
2531};
2532
2533static struct hda_pcm_stream alc880_pcm_digital_playback = {
2534 .substreams = 1,
2535 .channels_min = 2,
2536 .channels_max = 2,
2537 /* NID is set in alc_build_pcms */
2538 .ops = {
2539 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002540 .close = alc880_dig_playback_pcm_close,
2541 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542 },
2543};
2544
2545static struct hda_pcm_stream alc880_pcm_digital_capture = {
2546 .substreams = 1,
2547 .channels_min = 2,
2548 .channels_max = 2,
2549 /* NID is set in alc_build_pcms */
2550};
2551
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002552/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002553static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002554 .substreams = 0,
2555 .channels_min = 0,
2556 .channels_max = 0,
2557};
2558
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559static int alc_build_pcms(struct hda_codec *codec)
2560{
2561 struct alc_spec *spec = codec->spec;
2562 struct hda_pcm *info = spec->pcm_rec;
2563 int i;
2564
2565 codec->num_pcms = 1;
2566 codec->pcm_info = info;
2567
2568 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002569 if (spec->stream_analog_playback) {
2570 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2571 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2572 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2573 }
2574 if (spec->stream_analog_capture) {
2575 snd_assert(spec->adc_nids, return -EINVAL);
2576 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2577 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2578 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579
Takashi Iwai4a471b72005-12-07 13:56:29 +01002580 if (spec->channel_mode) {
2581 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2582 for (i = 0; i < spec->num_channel_mode; i++) {
2583 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2584 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2585 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 }
2587 }
2588
Takashi Iwaie08a0072006-09-07 17:52:14 +02002589 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002591 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002592 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002594 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002595 if (spec->multiout.dig_out_nid &&
2596 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2598 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2599 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002600 if (spec->dig_in_nid &&
2601 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2603 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2604 }
2605 }
2606
Takashi Iwaie08a0072006-09-07 17:52:14 +02002607 /* If the use of more than one ADC is requested for the current
2608 * model, configure a second analog capture-only PCM.
2609 */
2610 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002611 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2612 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002613 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002614 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002615 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002616 if (spec->alt_dac_nid) {
2617 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2618 *spec->stream_analog_alt_playback;
2619 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2620 spec->alt_dac_nid;
2621 } else {
2622 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2623 alc_pcm_null_stream;
2624 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2625 }
2626 if (spec->num_adc_nids > 1) {
2627 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2628 *spec->stream_analog_alt_capture;
2629 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2630 spec->adc_nids[1];
2631 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2632 spec->num_adc_nids - 1;
2633 } else {
2634 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2635 alc_pcm_null_stream;
2636 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002637 }
2638 }
2639
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 return 0;
2641}
2642
2643static void alc_free(struct hda_codec *codec)
2644{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 struct alc_spec *spec = codec->spec;
2646 unsigned int i;
2647
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002648 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649 return;
2650
2651 if (spec->kctl_alloc) {
2652 for (i = 0; i < spec->num_kctl_used; i++)
2653 kfree(spec->kctl_alloc[i].name);
2654 kfree(spec->kctl_alloc);
2655 }
2656 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002657 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658}
2659
2660/*
2661 */
2662static struct hda_codec_ops alc_patch_ops = {
2663 .build_controls = alc_build_controls,
2664 .build_pcms = alc_build_pcms,
2665 .init = alc_init,
2666 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002667 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002668#ifdef CONFIG_SND_HDA_POWER_SAVE
2669 .check_power_status = alc_check_power_status,
2670#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671};
2672
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002673
2674/*
2675 * Test configuration for debugging
2676 *
2677 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2678 * enum controls.
2679 */
2680#ifdef CONFIG_SND_DEBUG
2681static hda_nid_t alc880_test_dac_nids[4] = {
2682 0x02, 0x03, 0x04, 0x05
2683};
2684
2685static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002686 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002687 .items = {
2688 { "In-1", 0x0 },
2689 { "In-2", 0x1 },
2690 { "In-3", 0x2 },
2691 { "In-4", 0x3 },
2692 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002693 { "Front", 0x5 },
2694 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002695 },
2696};
2697
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002698static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002699 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002700 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002701 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002702 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002703};
2704
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002705static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2706 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002707{
2708 static char *texts[] = {
2709 "N/A", "Line Out", "HP Out",
2710 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2711 };
2712 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2713 uinfo->count = 1;
2714 uinfo->value.enumerated.items = 8;
2715 if (uinfo->value.enumerated.item >= 8)
2716 uinfo->value.enumerated.item = 7;
2717 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2718 return 0;
2719}
2720
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002721static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2722 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002723{
2724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2725 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2726 unsigned int pin_ctl, item = 0;
2727
2728 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2729 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2730 if (pin_ctl & AC_PINCTL_OUT_EN) {
2731 if (pin_ctl & AC_PINCTL_HP_EN)
2732 item = 2;
2733 else
2734 item = 1;
2735 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2736 switch (pin_ctl & AC_PINCTL_VREFEN) {
2737 case AC_PINCTL_VREF_HIZ: item = 3; break;
2738 case AC_PINCTL_VREF_50: item = 4; break;
2739 case AC_PINCTL_VREF_GRD: item = 5; break;
2740 case AC_PINCTL_VREF_80: item = 6; break;
2741 case AC_PINCTL_VREF_100: item = 7; break;
2742 }
2743 }
2744 ucontrol->value.enumerated.item[0] = item;
2745 return 0;
2746}
2747
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002748static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2749 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002750{
2751 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2752 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2753 static unsigned int ctls[] = {
2754 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2755 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2756 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2757 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2758 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2759 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2760 };
2761 unsigned int old_ctl, new_ctl;
2762
2763 old_ctl = snd_hda_codec_read(codec, nid, 0,
2764 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2765 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2766 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002767 int val;
2768 snd_hda_codec_write_cache(codec, nid, 0,
2769 AC_VERB_SET_PIN_WIDGET_CONTROL,
2770 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002771 val = ucontrol->value.enumerated.item[0] >= 3 ?
2772 HDA_AMP_MUTE : 0;
2773 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2774 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002775 return 1;
2776 }
2777 return 0;
2778}
2779
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002780static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2781 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002782{
2783 static char *texts[] = {
2784 "Front", "Surround", "CLFE", "Side"
2785 };
2786 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2787 uinfo->count = 1;
2788 uinfo->value.enumerated.items = 4;
2789 if (uinfo->value.enumerated.item >= 4)
2790 uinfo->value.enumerated.item = 3;
2791 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2792 return 0;
2793}
2794
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002795static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2796 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002797{
2798 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2799 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2800 unsigned int sel;
2801
2802 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2803 ucontrol->value.enumerated.item[0] = sel & 3;
2804 return 0;
2805}
2806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002807static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2808 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002809{
2810 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2811 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2812 unsigned int sel;
2813
2814 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2815 if (ucontrol->value.enumerated.item[0] != sel) {
2816 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002817 snd_hda_codec_write_cache(codec, nid, 0,
2818 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002819 return 1;
2820 }
2821 return 0;
2822}
2823
2824#define PIN_CTL_TEST(xname,nid) { \
2825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2826 .name = xname, \
2827 .info = alc_test_pin_ctl_info, \
2828 .get = alc_test_pin_ctl_get, \
2829 .put = alc_test_pin_ctl_put, \
2830 .private_value = nid \
2831 }
2832
2833#define PIN_SRC_TEST(xname,nid) { \
2834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2835 .name = xname, \
2836 .info = alc_test_pin_src_info, \
2837 .get = alc_test_pin_src_get, \
2838 .put = alc_test_pin_src_put, \
2839 .private_value = nid \
2840 }
2841
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002842static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002843 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2844 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2845 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2846 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002847 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2848 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2849 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2850 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002851 PIN_CTL_TEST("Front Pin Mode", 0x14),
2852 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2853 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2854 PIN_CTL_TEST("Side Pin Mode", 0x17),
2855 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2856 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2857 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2858 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2859 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2860 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2861 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2862 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2863 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2864 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2865 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2866 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2867 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2868 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2869 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2870 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002873 {
2874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2875 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002876 .info = alc_ch_mode_info,
2877 .get = alc_ch_mode_get,
2878 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002879 },
2880 { } /* end */
2881};
2882
2883static struct hda_verb alc880_test_init_verbs[] = {
2884 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2891 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2892 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002893 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2897 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002898 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2902 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002903 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002908 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002914 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002915 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2917 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2918 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002919 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002921 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002922 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002923 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002924 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002925 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002926 /* Analog input/passthru */
2927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002932 { }
2933};
2934#endif
2935
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936/*
2937 */
2938
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002939static const char *alc880_models[ALC880_MODEL_LAST] = {
2940 [ALC880_3ST] = "3stack",
2941 [ALC880_TCL_S700] = "tcl",
2942 [ALC880_3ST_DIG] = "3stack-digout",
2943 [ALC880_CLEVO] = "clevo",
2944 [ALC880_5ST] = "5stack",
2945 [ALC880_5ST_DIG] = "5stack-digout",
2946 [ALC880_W810] = "w810",
2947 [ALC880_Z71V] = "z71v",
2948 [ALC880_6ST] = "6stack",
2949 [ALC880_6ST_DIG] = "6stack-digout",
2950 [ALC880_ASUS] = "asus",
2951 [ALC880_ASUS_W1V] = "asus-w1v",
2952 [ALC880_ASUS_DIG] = "asus-dig",
2953 [ALC880_ASUS_DIG2] = "asus-dig2",
2954 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002955 [ALC880_UNIWILL_P53] = "uniwill-p53",
2956 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002957 [ALC880_F1734] = "F1734",
2958 [ALC880_LG] = "lg",
2959 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002960 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002961#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002962 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002963#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002964 [ALC880_AUTO] = "auto",
2965};
2966
2967static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002968 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002969 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2970 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2971 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2972 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2973 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2974 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2975 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2976 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002977 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2978 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002979 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2980 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2981 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2982 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2983 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2984 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2985 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2986 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2987 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2988 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02002989 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002990 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2991 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2992 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002993 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002994 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01002995 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2996 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002997 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2998 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002999 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3000 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3001 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3002 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003003 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3004 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003005 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003006 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003007 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003008 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003009 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3010 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003011 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003012 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003013 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003014 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003015 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003016 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003017 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003018 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003019 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3020 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003021 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003022 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3023 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3024 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3025 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003026 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3027 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003028 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003029 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003030 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3031 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003032 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3033 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3034 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003035 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3036 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3037 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003038 {}
3039};
3040
Takashi Iwai16ded522005-06-10 19:58:24 +02003041/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003042 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003043 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003044static struct alc_config_preset alc880_presets[] = {
3045 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003047 .init_verbs = { alc880_volume_init_verbs,
3048 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003049 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003050 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003051 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3052 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003053 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003054 .input_mux = &alc880_capture_source,
3055 },
3056 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 .init_verbs = { alc880_volume_init_verbs,
3059 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003061 .dac_nids = alc880_dac_nids,
3062 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003063 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3064 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003065 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003066 .input_mux = &alc880_capture_source,
3067 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003068 [ALC880_TCL_S700] = {
3069 .mixers = { alc880_tcl_s700_mixer },
3070 .init_verbs = { alc880_volume_init_verbs,
3071 alc880_pin_tcl_S700_init_verbs,
3072 alc880_gpio2_init_verbs },
3073 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3074 .dac_nids = alc880_dac_nids,
3075 .hp_nid = 0x03,
3076 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3077 .channel_mode = alc880_2_jack_modes,
3078 .input_mux = &alc880_capture_source,
3079 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003080 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003081 .mixers = { alc880_three_stack_mixer,
3082 alc880_five_stack_mixer},
3083 .init_verbs = { alc880_volume_init_verbs,
3084 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003085 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3086 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003087 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3088 .channel_mode = alc880_fivestack_modes,
3089 .input_mux = &alc880_capture_source,
3090 },
3091 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003092 .mixers = { alc880_three_stack_mixer,
3093 alc880_five_stack_mixer },
3094 .init_verbs = { alc880_volume_init_verbs,
3095 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003096 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3097 .dac_nids = alc880_dac_nids,
3098 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003099 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3100 .channel_mode = alc880_fivestack_modes,
3101 .input_mux = &alc880_capture_source,
3102 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003103 [ALC880_6ST] = {
3104 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003105 .init_verbs = { alc880_volume_init_verbs,
3106 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003107 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3108 .dac_nids = alc880_6st_dac_nids,
3109 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3110 .channel_mode = alc880_sixstack_modes,
3111 .input_mux = &alc880_6stack_capture_source,
3112 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003113 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003114 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003117 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3118 .dac_nids = alc880_6st_dac_nids,
3119 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003120 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3121 .channel_mode = alc880_sixstack_modes,
3122 .input_mux = &alc880_6stack_capture_source,
3123 },
3124 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003126 .init_verbs = { alc880_volume_init_verbs,
3127 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003128 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3130 .dac_nids = alc880_w810_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003132 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3133 .channel_mode = alc880_w810_modes,
3134 .input_mux = &alc880_capture_source,
3135 },
3136 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003138 .init_verbs = { alc880_volume_init_verbs,
3139 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3141 .dac_nids = alc880_z71v_dac_nids,
3142 .dig_out_nid = ALC880_DIGOUT_NID,
3143 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3145 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003146 .input_mux = &alc880_capture_source,
3147 },
3148 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003150 .init_verbs = { alc880_volume_init_verbs,
3151 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003152 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3153 .dac_nids = alc880_f1734_dac_nids,
3154 .hp_nid = 0x02,
3155 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3156 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003157 .input_mux = &alc880_f1734_capture_source,
3158 .unsol_event = alc880_uniwill_p53_unsol_event,
3159 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 },
3161 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003162 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003163 .init_verbs = { alc880_volume_init_verbs,
3164 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165 alc880_gpio1_init_verbs },
3166 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3167 .dac_nids = alc880_asus_dac_nids,
3168 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3169 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003170 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003171 .input_mux = &alc880_capture_source,
3172 },
3173 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003175 .init_verbs = { alc880_volume_init_verbs,
3176 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 alc880_gpio1_init_verbs },
3178 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3179 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003180 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003181 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3182 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003183 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003184 .input_mux = &alc880_capture_source,
3185 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003186 [ALC880_ASUS_DIG2] = {
3187 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003188 .init_verbs = { alc880_volume_init_verbs,
3189 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003190 alc880_gpio2_init_verbs }, /* use GPIO2 */
3191 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3192 .dac_nids = alc880_asus_dac_nids,
3193 .dig_out_nid = ALC880_DIGOUT_NID,
3194 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3195 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003196 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003197 .input_mux = &alc880_capture_source,
3198 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003199 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003201 .init_verbs = { alc880_volume_init_verbs,
3202 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203 alc880_gpio1_init_verbs },
3204 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3205 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003206 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3208 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003209 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003210 .input_mux = &alc880_capture_source,
3211 },
3212 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003213 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003214 .init_verbs = { alc880_volume_init_verbs,
3215 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3217 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003218 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3220 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003221 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003222 .input_mux = &alc880_capture_source,
3223 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003224 [ALC880_UNIWILL] = {
3225 .mixers = { alc880_uniwill_mixer },
3226 .init_verbs = { alc880_volume_init_verbs,
3227 alc880_uniwill_init_verbs },
3228 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3229 .dac_nids = alc880_asus_dac_nids,
3230 .dig_out_nid = ALC880_DIGOUT_NID,
3231 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3232 .channel_mode = alc880_threestack_modes,
3233 .need_dac_fix = 1,
3234 .input_mux = &alc880_capture_source,
3235 .unsol_event = alc880_uniwill_unsol_event,
3236 .init_hook = alc880_uniwill_automute,
3237 },
3238 [ALC880_UNIWILL_P53] = {
3239 .mixers = { alc880_uniwill_p53_mixer },
3240 .init_verbs = { alc880_volume_init_verbs,
3241 alc880_uniwill_p53_init_verbs },
3242 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3243 .dac_nids = alc880_asus_dac_nids,
3244 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003245 .channel_mode = alc880_threestack_modes,
3246 .input_mux = &alc880_capture_source,
3247 .unsol_event = alc880_uniwill_p53_unsol_event,
3248 .init_hook = alc880_uniwill_p53_hp_automute,
3249 },
3250 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003251 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003252 alc880_pcbeep_mixer, },
3253 .init_verbs = { alc880_volume_init_verbs,
3254 alc880_uniwill_p53_init_verbs,
3255 alc880_beep_init_verbs },
3256 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3257 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003258 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003259 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3260 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003261 .input_mux = &alc880_capture_source,
3262 .unsol_event = alc880_uniwill_p53_unsol_event,
3263 .init_hook = alc880_uniwill_p53_hp_automute,
3264 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003265 [ALC880_CLEVO] = {
3266 .mixers = { alc880_three_stack_mixer },
3267 .init_verbs = { alc880_volume_init_verbs,
3268 alc880_pin_clevo_init_verbs },
3269 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3270 .dac_nids = alc880_dac_nids,
3271 .hp_nid = 0x03,
3272 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3273 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003274 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003275 .input_mux = &alc880_capture_source,
3276 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003277 [ALC880_LG] = {
3278 .mixers = { alc880_lg_mixer },
3279 .init_verbs = { alc880_volume_init_verbs,
3280 alc880_lg_init_verbs },
3281 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3282 .dac_nids = alc880_lg_dac_nids,
3283 .dig_out_nid = ALC880_DIGOUT_NID,
3284 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3285 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003286 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003287 .input_mux = &alc880_lg_capture_source,
3288 .unsol_event = alc880_lg_unsol_event,
3289 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003290#ifdef CONFIG_SND_HDA_POWER_SAVE
3291 .loopbacks = alc880_lg_loopbacks,
3292#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003293 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003294 [ALC880_LG_LW] = {
3295 .mixers = { alc880_lg_lw_mixer },
3296 .init_verbs = { alc880_volume_init_verbs,
3297 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003298 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003299 .dac_nids = alc880_dac_nids,
3300 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003301 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3302 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003303 .input_mux = &alc880_lg_lw_capture_source,
3304 .unsol_event = alc880_lg_lw_unsol_event,
3305 .init_hook = alc880_lg_lw_automute,
3306 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003307 [ALC880_MEDION_RIM] = {
3308 .mixers = { alc880_medion_rim_mixer },
3309 .init_verbs = { alc880_volume_init_verbs,
3310 alc880_medion_rim_init_verbs,
3311 alc_gpio2_init_verbs },
3312 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3313 .dac_nids = alc880_dac_nids,
3314 .dig_out_nid = ALC880_DIGOUT_NID,
3315 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3316 .channel_mode = alc880_2_jack_modes,
3317 .input_mux = &alc880_medion_rim_capture_source,
3318 .unsol_event = alc880_medion_rim_unsol_event,
3319 .init_hook = alc880_medion_rim_automute,
3320 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003321#ifdef CONFIG_SND_DEBUG
3322 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003323 .mixers = { alc880_test_mixer },
3324 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003325 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3326 .dac_nids = alc880_test_dac_nids,
3327 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003328 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3329 .channel_mode = alc880_test_modes,
3330 .input_mux = &alc880_test_capture_source,
3331 },
3332#endif
3333};
3334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003335/*
3336 * Automatic parse of I/O pins from the BIOS configuration
3337 */
3338
3339#define NUM_CONTROL_ALLOC 32
3340#define NUM_VERB_ALLOC 32
3341
3342enum {
3343 ALC_CTL_WIDGET_VOL,
3344 ALC_CTL_WIDGET_MUTE,
3345 ALC_CTL_BIND_MUTE,
3346};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003347static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3349 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003350 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003351};
3352
3353/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354static int add_control(struct alc_spec *spec, int type, const char *name,
3355 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003357 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358
3359 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3360 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3361
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003362 /* array + terminator */
3363 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3364 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365 return -ENOMEM;
3366 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003367 memcpy(knew, spec->kctl_alloc,
3368 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003369 kfree(spec->kctl_alloc);
3370 }
3371 spec->kctl_alloc = knew;
3372 spec->num_kctl_alloc = num;
3373 }
3374
3375 knew = &spec->kctl_alloc[spec->num_kctl_used];
3376 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003377 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003379 return -ENOMEM;
3380 knew->private_value = val;
3381 spec->num_kctl_used++;
3382 return 0;
3383}
3384
3385#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3386#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3387#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3388#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3389#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3390#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3391#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3392#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3393#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3394#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3395#define ALC880_PIN_CD_NID 0x1c
3396
3397/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003398static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3399 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400{
3401 hda_nid_t nid;
3402 int assigned[4];
3403 int i, j;
3404
3405 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003406 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407
3408 /* check the pins hardwired to audio widget */
3409 for (i = 0; i < cfg->line_outs; i++) {
3410 nid = cfg->line_out_pins[i];
3411 if (alc880_is_fixed_pin(nid)) {
3412 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003413 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003414 assigned[idx] = 1;
3415 }
3416 }
3417 /* left pins can be connect to any audio widget */
3418 for (i = 0; i < cfg->line_outs; i++) {
3419 nid = cfg->line_out_pins[i];
3420 if (alc880_is_fixed_pin(nid))
3421 continue;
3422 /* search for an empty channel */
3423 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 if (!assigned[j]) {
3425 spec->multiout.dac_nids[i] =
3426 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427 assigned[j] = 1;
3428 break;
3429 }
3430 }
3431 }
3432 spec->multiout.num_dacs = cfg->line_outs;
3433 return 0;
3434}
3435
3436/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003437static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3438 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439{
3440 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441 static const char *chname[4] = {
3442 "Front", "Surround", NULL /*CLFE*/, "Side"
3443 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003444 hda_nid_t nid;
3445 int i, err;
3446
3447 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003448 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 continue;
3450 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3451 if (i == 2) {
3452 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003453 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3454 "Center Playback Volume",
3455 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3456 HDA_OUTPUT));
3457 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003459 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3460 "LFE Playback Volume",
3461 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3462 HDA_OUTPUT));
3463 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003465 err = add_control(spec, ALC_CTL_BIND_MUTE,
3466 "Center Playback Switch",
3467 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3468 HDA_INPUT));
3469 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003471 err = add_control(spec, ALC_CTL_BIND_MUTE,
3472 "LFE Playback Switch",
3473 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3474 HDA_INPUT));
3475 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476 return err;
3477 } else {
3478 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003479 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3480 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3481 HDA_OUTPUT));
3482 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 return err;
3484 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003485 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3486 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3487 HDA_INPUT));
3488 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 return err;
3490 }
3491 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003492 return 0;
3493}
3494
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003495/* add playback controls for speaker and HP outputs */
3496static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3497 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498{
3499 hda_nid_t nid;
3500 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003501 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003502
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003503 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003504 return 0;
3505
3506 if (alc880_is_fixed_pin(pin)) {
3507 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003508 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003509 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003510 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003511 else
3512 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 /* control HP volume/switch on the output mixer amp */
3514 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003515 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003516 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3517 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3518 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003520 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003521 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3522 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3523 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003524 return err;
3525 } else if (alc880_is_multi_pin(pin)) {
3526 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003527 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003528 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003529 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3530 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3531 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003532 return err;
3533 }
3534 return 0;
3535}
3536
3537/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003538static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3539 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003540 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003541{
3542 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003543 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544
3545 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003546 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3547 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3548 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003549 return err;
3550 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003551 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3552 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3553 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003554 return err;
3555 return 0;
3556}
3557
3558/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003559static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3560 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003561{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003562 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003563 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003564
3565 for (i = 0; i < AUTO_PIN_LAST; i++) {
3566 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003567 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003568 err = new_analog_input(spec, cfg->input_pins[i],
3569 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003570 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003571 if (err < 0)
3572 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003573 imux->items[imux->num_items].label =
3574 auto_pin_cfg_labels[i];
3575 imux->items[imux->num_items].index =
3576 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 imux->num_items++;
3578 }
3579 }
3580 return 0;
3581}
3582
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003583static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3584 unsigned int pin_type)
3585{
3586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3587 pin_type);
3588 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003589 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3590 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003591}
3592
Kailang Yangdf694da2005-12-05 19:42:22 +01003593static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3594 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 int dac_idx)
3596{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003597 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003598 /* need the manual connection? */
3599 if (alc880_is_multi_pin(nid)) {
3600 struct alc_spec *spec = codec->spec;
3601 int idx = alc880_multi_pin_idx(nid);
3602 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3603 AC_VERB_SET_CONNECT_SEL,
3604 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3605 }
3606}
3607
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003608static int get_pin_type(int line_out_type)
3609{
3610 if (line_out_type == AUTO_PIN_HP_OUT)
3611 return PIN_HP;
3612 else
3613 return PIN_OUT;
3614}
3615
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003616static void alc880_auto_init_multi_out(struct hda_codec *codec)
3617{
3618 struct alc_spec *spec = codec->spec;
3619 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003620
3621 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622 for (i = 0; i < spec->autocfg.line_outs; i++) {
3623 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003624 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3625 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003626 }
3627}
3628
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003629static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630{
3631 struct alc_spec *spec = codec->spec;
3632 hda_nid_t pin;
3633
Takashi Iwai82bc9552006-03-21 11:24:42 +01003634 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003635 if (pin) /* connect to front */
3636 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003637 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638 if (pin) /* connect to front */
3639 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3640}
3641
3642static void alc880_auto_init_analog_input(struct hda_codec *codec)
3643{
3644 struct alc_spec *spec = codec->spec;
3645 int i;
3646
3647 for (i = 0; i < AUTO_PIN_LAST; i++) {
3648 hda_nid_t nid = spec->autocfg.input_pins[i];
3649 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003650 snd_hda_codec_write(codec, nid, 0,
3651 AC_VERB_SET_PIN_WIDGET_CONTROL,
3652 i <= AUTO_PIN_FRONT_MIC ?
3653 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003654 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003655 snd_hda_codec_write(codec, nid, 0,
3656 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 AMP_OUT_MUTE);
3658 }
3659 }
3660}
3661
3662/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003663/* return 1 if successful, 0 if the proper config is not found,
3664 * or a negative error code
3665 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666static int alc880_parse_auto_config(struct hda_codec *codec)
3667{
3668 struct alc_spec *spec = codec->spec;
3669 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003670 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003671
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003672 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3673 alc880_ignore);
3674 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003675 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003676 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003678
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003679 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3680 if (err < 0)
3681 return err;
3682 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3683 if (err < 0)
3684 return err;
3685 err = alc880_auto_create_extra_out(spec,
3686 spec->autocfg.speaker_pins[0],
3687 "Speaker");
3688 if (err < 0)
3689 return err;
3690 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3691 "Headphone");
3692 if (err < 0)
3693 return err;
3694 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3695 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 return err;
3697
3698 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3699
3700 if (spec->autocfg.dig_out_pin)
3701 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3702 if (spec->autocfg.dig_in_pin)
3703 spec->dig_in_nid = ALC880_DIGIN_NID;
3704
3705 if (spec->kctl_alloc)
3706 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3707
3708 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3709
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003710 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 spec->input_mux = &spec->private_imux;
3712
3713 return 1;
3714}
3715
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003716/* additional initialization for auto-configuration model */
3717static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003718{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003719 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003720 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003721 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003723 if (spec->unsol_event)
3724 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725}
3726
3727/*
3728 * OK, here we have finally the patch for ALC880
3729 */
3730
Linus Torvalds1da177e2005-04-16 15:20:36 -07003731static int patch_alc880(struct hda_codec *codec)
3732{
3733 struct alc_spec *spec;
3734 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003735 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003737 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003738 if (spec == NULL)
3739 return -ENOMEM;
3740
3741 codec->spec = spec;
3742
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003743 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3744 alc880_models,
3745 alc880_cfg_tbl);
3746 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003747 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3748 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003749 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003750 }
3751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752 if (board_config == ALC880_AUTO) {
3753 /* automatic parse from the BIOS config */
3754 err = alc880_parse_auto_config(codec);
3755 if (err < 0) {
3756 alc_free(codec);
3757 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003758 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003759 printk(KERN_INFO
3760 "hda_codec: Cannot set up configuration "
3761 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 board_config = ALC880_3ST;
3763 }
3764 }
3765
Kailang Yangdf694da2005-12-05 19:42:22 +01003766 if (board_config != ALC880_AUTO)
3767 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003768
3769 spec->stream_name_analog = "ALC880 Analog";
3770 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3771 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003772 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003773
3774 spec->stream_name_digital = "ALC880 Digital";
3775 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3776 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3777
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003778 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003780 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003781 /* get type */
3782 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 if (wcap != AC_WID_AUD_IN) {
3784 spec->adc_nids = alc880_adc_nids_alt;
3785 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003786 spec->mixers[spec->num_mixers] =
3787 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 spec->num_mixers++;
3789 } else {
3790 spec->adc_nids = alc880_adc_nids;
3791 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3792 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3793 spec->num_mixers++;
3794 }
3795 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003796
Takashi Iwai2134ea42008-01-10 16:53:55 +01003797 spec->vmaster_nid = 0x0c;
3798
Linus Torvalds1da177e2005-04-16 15:20:36 -07003799 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003800 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003801 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003802#ifdef CONFIG_SND_HDA_POWER_SAVE
3803 if (!spec->loopback.amplist)
3804 spec->loopback.amplist = alc880_loopbacks;
3805#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003806
3807 return 0;
3808}
3809
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811/*
3812 * ALC260 support
3813 */
3814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003815static hda_nid_t alc260_dac_nids[1] = {
3816 /* front */
3817 0x02,
3818};
3819
3820static hda_nid_t alc260_adc_nids[1] = {
3821 /* ADC0 */
3822 0x04,
3823};
3824
Kailang Yangdf694da2005-12-05 19:42:22 +01003825static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003826 /* ADC1 */
3827 0x05,
3828};
3829
Kailang Yangdf694da2005-12-05 19:42:22 +01003830static hda_nid_t alc260_hp_adc_nids[2] = {
3831 /* ADC1, 0 */
3832 0x05, 0x04
3833};
3834
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003835/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3836 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3837 */
3838static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003839 /* ADC0, ADC1 */
3840 0x04, 0x05
3841};
3842
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003843#define ALC260_DIGOUT_NID 0x03
3844#define ALC260_DIGIN_NID 0x06
3845
3846static struct hda_input_mux alc260_capture_source = {
3847 .num_items = 4,
3848 .items = {
3849 { "Mic", 0x0 },
3850 { "Front Mic", 0x1 },
3851 { "Line", 0x2 },
3852 { "CD", 0x4 },
3853 },
3854};
3855
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003856/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003857 * headphone jack and the internal CD lines since these are the only pins at
3858 * which audio can appear. For flexibility, also allow the option of
3859 * recording the mixer output on the second ADC (ADC0 doesn't have a
3860 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003861 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003862static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3863 {
3864 .num_items = 3,
3865 .items = {
3866 { "Mic/Line", 0x0 },
3867 { "CD", 0x4 },
3868 { "Headphone", 0x2 },
3869 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003870 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003871 {
3872 .num_items = 4,
3873 .items = {
3874 { "Mic/Line", 0x0 },
3875 { "CD", 0x4 },
3876 { "Headphone", 0x2 },
3877 { "Mixer", 0x5 },
3878 },
3879 },
3880
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003881};
3882
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003883/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3884 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003885 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003886static struct hda_input_mux alc260_acer_capture_sources[2] = {
3887 {
3888 .num_items = 4,
3889 .items = {
3890 { "Mic", 0x0 },
3891 { "Line", 0x2 },
3892 { "CD", 0x4 },
3893 { "Headphone", 0x5 },
3894 },
3895 },
3896 {
3897 .num_items = 5,
3898 .items = {
3899 { "Mic", 0x0 },
3900 { "Line", 0x2 },
3901 { "CD", 0x4 },
3902 { "Headphone", 0x6 },
3903 { "Mixer", 0x5 },
3904 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003905 },
3906};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907/*
3908 * This is just place-holder, so there's something for alc_build_pcms to look
3909 * at when it calculates the maximum number of channels. ALC260 has no mixer
3910 * element which allows changing the channel mode, so the verb list is
3911 * never used.
3912 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003913static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003914 { 2, NULL },
3915};
3916
Kailang Yangdf694da2005-12-05 19:42:22 +01003917
3918/* Mixer combinations
3919 *
3920 * basic: base_output + input + pc_beep + capture
3921 * HP: base_output + input + capture_alt
3922 * HP_3013: hp_3013 + input + capture
3923 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003924 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003925 */
3926
3927static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003928 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003929 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003930 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3931 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3932 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3933 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3934 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003935};
Kailang Yangdf694da2005-12-05 19:42:22 +01003936
3937static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003938 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3939 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3940 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3941 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3943 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3944 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003946 { } /* end */
3947};
3948
Kailang Yangdf694da2005-12-05 19:42:22 +01003949static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3950 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3951 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3952 { } /* end */
3953};
3954
Takashi Iwaibec15c32008-01-28 18:16:30 +01003955/* update HP, line and mono out pins according to the master switch */
3956static void alc260_hp_master_update(struct hda_codec *codec,
3957 hda_nid_t hp, hda_nid_t line,
3958 hda_nid_t mono)
3959{
3960 struct alc_spec *spec = codec->spec;
3961 unsigned int val = spec->master_sw ? PIN_HP : 0;
3962 /* change HP and line-out pins */
3963 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3964 val);
3965 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3966 val);
3967 /* mono (speaker) depending on the HP jack sense */
3968 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3969 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3970 val);
3971}
3972
3973static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3974 struct snd_ctl_elem_value *ucontrol)
3975{
3976 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3977 struct alc_spec *spec = codec->spec;
3978 *ucontrol->value.integer.value = spec->master_sw;
3979 return 0;
3980}
3981
3982static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3983 struct snd_ctl_elem_value *ucontrol)
3984{
3985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3986 struct alc_spec *spec = codec->spec;
3987 int val = !!*ucontrol->value.integer.value;
3988 hda_nid_t hp, line, mono;
3989
3990 if (val == spec->master_sw)
3991 return 0;
3992 spec->master_sw = val;
3993 hp = (kcontrol->private_value >> 16) & 0xff;
3994 line = (kcontrol->private_value >> 8) & 0xff;
3995 mono = kcontrol->private_value & 0xff;
3996 alc260_hp_master_update(codec, hp, line, mono);
3997 return 1;
3998}
3999
4000static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4001 {
4002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4003 .name = "Master Playback Switch",
4004 .info = snd_ctl_boolean_mono_info,
4005 .get = alc260_hp_master_sw_get,
4006 .put = alc260_hp_master_sw_put,
4007 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4008 },
4009 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4010 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4012 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4013 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4014 HDA_OUTPUT),
4015 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4016 { } /* end */
4017};
4018
4019static struct hda_verb alc260_hp_unsol_verbs[] = {
4020 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4021 {},
4022};
4023
4024static void alc260_hp_automute(struct hda_codec *codec)
4025{
4026 struct alc_spec *spec = codec->spec;
4027 unsigned int present;
4028
4029 present = snd_hda_codec_read(codec, 0x10, 0,
4030 AC_VERB_GET_PIN_SENSE, 0);
4031 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4032 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4033}
4034
4035static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4036{
4037 if ((res >> 26) == ALC880_HP_EVENT)
4038 alc260_hp_automute(codec);
4039}
4040
Kailang Yangdf694da2005-12-05 19:42:22 +01004041static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004042 {
4043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4044 .name = "Master Playback Switch",
4045 .info = snd_ctl_boolean_mono_info,
4046 .get = alc260_hp_master_sw_get,
4047 .put = alc260_hp_master_sw_put,
4048 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4049 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004050 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4051 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4052 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4053 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004056 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4057 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004058 { } /* end */
4059};
4060
Takashi Iwaibec15c32008-01-28 18:16:30 +01004061static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4063 {},
4064};
4065
4066static void alc260_hp_3013_automute(struct hda_codec *codec)
4067{
4068 struct alc_spec *spec = codec->spec;
4069 unsigned int present;
4070
4071 present = snd_hda_codec_read(codec, 0x15, 0,
4072 AC_VERB_GET_PIN_SENSE, 0);
4073 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4074 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4075}
4076
4077static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4078 unsigned int res)
4079{
4080 if ((res >> 26) == ALC880_HP_EVENT)
4081 alc260_hp_3013_automute(codec);
4082}
4083
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004084/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4085 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4086 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004087static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004089 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004090 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004091 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4092 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4093 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4094 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004095 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004096 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4097 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004098 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4099 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004100 { } /* end */
4101};
4102
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004103/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4104 * versions of the ALC260 don't act on requests to enable mic bias from NID
4105 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4106 * datasheet doesn't mention this restriction. At this stage it's not clear
4107 * whether this behaviour is intentional or is a hardware bug in chip
4108 * revisions available in early 2006. Therefore for now allow the
4109 * "Headphone Jack Mode" control to span all choices, but if it turns out
4110 * that the lack of mic bias for this NID is intentional we could change the
4111 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4112 *
4113 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4114 * don't appear to make the mic bias available from the "line" jack, even
4115 * though the NID used for this jack (0x14) can supply it. The theory is
4116 * that perhaps Acer have included blocking capacitors between the ALC260
4117 * and the output jack. If this turns out to be the case for all such
4118 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4119 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004120 *
4121 * The C20x Tablet series have a mono internal speaker which is controlled
4122 * via the chip's Mono sum widget and pin complex, so include the necessary
4123 * controls for such models. On models without a "mono speaker" the control
4124 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004125 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004126static struct snd_kcontrol_new alc260_acer_mixer[] = {
4127 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4128 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004129 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004130 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004131 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004132 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004133 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004134 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4135 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4137 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4138 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4139 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4140 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4141 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4142 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4143 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4144 { } /* end */
4145};
4146
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004147/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4148 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4149 */
4150static struct snd_kcontrol_new alc260_will_mixer[] = {
4151 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4152 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4154 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4155 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4156 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4157 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4158 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4159 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4160 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4161 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4162 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4163 { } /* end */
4164};
4165
4166/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4167 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4168 */
4169static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4170 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4171 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4173 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4174 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4176 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4177 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4178 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4179 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4180 { } /* end */
4181};
4182
Kailang Yangdf694da2005-12-05 19:42:22 +01004183/* capture mixer elements */
4184static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004185 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4186 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004187 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4188 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004189 {
4190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004191 /* The multiple "Capture Source" controls confuse alsamixer
4192 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004193 */
4194 /* .name = "Capture Source", */
4195 .name = "Input Source",
4196 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004197 .info = alc_mux_enum_info,
4198 .get = alc_mux_enum_get,
4199 .put = alc_mux_enum_put,
4200 },
4201 { } /* end */
4202};
4203
Kailang Yangdf694da2005-12-05 19:42:22 +01004204static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4205 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4206 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4207 {
4208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4209 /* The multiple "Capture Source" controls confuse alsamixer
4210 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004211 */
4212 /* .name = "Capture Source", */
4213 .name = "Input Source",
4214 .count = 1,
4215 .info = alc_mux_enum_info,
4216 .get = alc_mux_enum_get,
4217 .put = alc_mux_enum_put,
4218 },
4219 { } /* end */
4220};
4221
4222/*
4223 * initialization verbs
4224 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004225static struct hda_verb alc260_init_verbs[] = {
4226 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004228 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004230 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004231 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004232 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004233 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004234 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004236 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004237 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004238 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004239 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004240 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004241 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004242 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004243 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4244 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004245 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004246 /* set connection select to line in (default select for this ADC) */
4247 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004248 /* mute capture amp left and right */
4249 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4250 /* set connection select to line in (default select for this ADC) */
4251 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004252 /* set vol=0 Line-Out mixer amp left and right */
4253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4254 /* unmute pin widget amp left and right (no gain on this amp) */
4255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4256 /* set vol=0 HP mixer amp left and right */
4257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4258 /* unmute pin widget amp left and right (no gain on this amp) */
4259 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4260 /* set vol=0 Mono mixer amp left and right */
4261 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4262 /* unmute pin widget amp left and right (no gain on this amp) */
4263 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4264 /* unmute LINE-2 out pin */
4265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004266 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4267 * Line In 2 = 0x03
4268 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004269 /* mute analog inputs */
4270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004275 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004276 /* mute Front out path */
4277 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4279 /* mute Headphone out path */
4280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4282 /* mute Mono out path */
4283 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4284 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004285 { }
4286};
4287
Takashi Iwai474167d2006-05-17 17:17:43 +02004288#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004289static struct hda_verb alc260_hp_init_verbs[] = {
4290 /* Headphone and output */
4291 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4292 /* mono output */
4293 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4294 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4296 /* Mic2 (front panel) pin widget for input and vref at 80% */
4297 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4298 /* Line In pin widget for input */
4299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4300 /* Line-2 pin widget for output */
4301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4302 /* CD pin widget for input */
4303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4304 /* unmute amp left and right */
4305 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4306 /* set connection select to line in (default select for this ADC) */
4307 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4308 /* unmute Line-Out mixer amp left and right (volume = 0) */
4309 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4310 /* mute pin widget amp left and right (no gain on this amp) */
4311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4312 /* unmute HP mixer amp left and right (volume = 0) */
4313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4314 /* mute pin widget amp left and right (no gain on this amp) */
4315 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004316 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4317 * Line In 2 = 0x03
4318 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004319 /* mute analog inputs */
4320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004325 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4326 /* Unmute Front out path */
4327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4329 /* Unmute Headphone out path */
4330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4332 /* Unmute Mono out path */
4333 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4334 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4335 { }
4336};
Takashi Iwai474167d2006-05-17 17:17:43 +02004337#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004338
4339static struct hda_verb alc260_hp_3013_init_verbs[] = {
4340 /* Line out and output */
4341 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4342 /* mono output */
4343 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4344 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4345 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4346 /* Mic2 (front panel) pin widget for input and vref at 80% */
4347 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4348 /* Line In pin widget for input */
4349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4350 /* Headphone pin widget for output */
4351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4352 /* CD pin widget for input */
4353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4354 /* unmute amp left and right */
4355 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4356 /* set connection select to line in (default select for this ADC) */
4357 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4358 /* unmute Line-Out mixer amp left and right (volume = 0) */
4359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4360 /* mute pin widget amp left and right (no gain on this amp) */
4361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4362 /* unmute HP mixer amp left and right (volume = 0) */
4363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4364 /* mute pin widget amp left and right (no gain on this amp) */
4365 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4367 * Line In 2 = 0x03
4368 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004369 /* mute analog inputs */
4370 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004375 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4376 /* Unmute Front out path */
4377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4379 /* Unmute Headphone out path */
4380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4382 /* Unmute Mono out path */
4383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4385 { }
4386};
4387
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004388/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004389 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4390 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004391 */
4392static struct hda_verb alc260_fujitsu_init_verbs[] = {
4393 /* Disable all GPIOs */
4394 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4395 /* Internal speaker is connected to headphone pin */
4396 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4397 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004399 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4400 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4401 /* Ensure all other unused pins are disabled and muted. */
4402 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4403 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004404 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004405 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004406 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004407 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004410
Jonathan Woithef7ace402006-02-28 11:46:14 +01004411 /* Disable digital (SPDIF) pins */
4412 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4413 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004414
Jonathan Woithef7ace402006-02-28 11:46:14 +01004415 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4416 * when acting as an output.
4417 */
4418 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4419
4420 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4429 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004430
Jonathan Woithef7ace402006-02-28 11:46:14 +01004431 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4432 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4433 /* Unmute Line1 pin widget output buffer since it starts as an output.
4434 * If the pin mode is changed by the user the pin mode control will
4435 * take care of enabling the pin's input/output buffers as needed.
4436 * Therefore there's no need to enable the input buffer at this
4437 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004438 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004440 /* Unmute input buffer of pin widget used for Line-in (no equiv
4441 * mixer ctrl)
4442 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004443 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004444
Jonathan Woithef7ace402006-02-28 11:46:14 +01004445 /* Mute capture amp left and right */
4446 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4447 /* Set ADC connection select to match default mixer setting - line
4448 * in (on mic1 pin)
4449 */
4450 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004451
Jonathan Woithef7ace402006-02-28 11:46:14 +01004452 /* Do the same for the second ADC: mute capture input amp and
4453 * set ADC connection to line in (on mic1 pin)
4454 */
4455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4456 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004457
Jonathan Woithef7ace402006-02-28 11:46:14 +01004458 /* Mute all inputs to mixer widget (even unconnected ones) */
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004467
4468 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004469};
4470
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004471/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4472 * similar laptops (adapted from Fujitsu init verbs).
4473 */
4474static struct hda_verb alc260_acer_init_verbs[] = {
4475 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4476 * the headphone jack. Turn this on and rely on the standard mute
4477 * methods whenever the user wants to turn these outputs off.
4478 */
4479 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4480 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4481 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4482 /* Internal speaker/Headphone jack is connected to Line-out pin */
4483 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4484 /* Internal microphone/Mic jack is connected to Mic1 pin */
4485 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4486 /* Line In jack is connected to Line1 pin */
4487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004488 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4489 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004490 /* Ensure all other unused pins are disabled and muted. */
4491 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4492 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004493 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4494 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4497 /* Disable digital (SPDIF) pins */
4498 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4499 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4500
4501 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4502 * bus when acting as outputs.
4503 */
4504 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4505 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4506
4507 /* Start with output sum widgets muted and their output gains at min */
4508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4516 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004518 /* Unmute Line-out pin widget amp left and right
4519 * (no equiv mixer ctrl)
4520 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004522 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4523 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004524 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4525 * inputs. If the pin mode is changed by the user the pin mode control
4526 * will take care of enabling the pin's input/output buffers as needed.
4527 * Therefore there's no need to enable the input buffer at this
4528 * stage.
4529 */
4530 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4532
4533 /* Mute capture amp left and right */
4534 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4535 /* Set ADC connection select to match default mixer setting - mic
4536 * (on mic1 pin)
4537 */
4538 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4539
4540 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004541 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004542 */
4543 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004544 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004545
4546 /* Mute all inputs to mixer widget (even unconnected ones) */
4547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4555
4556 { }
4557};
4558
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004559static struct hda_verb alc260_will_verbs[] = {
4560 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4561 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4562 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4563 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4564 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4565 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4566 {}
4567};
4568
4569static struct hda_verb alc260_replacer_672v_verbs[] = {
4570 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4571 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4572 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4573
4574 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4575 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4576 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4577
4578 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4579 {}
4580};
4581
4582/* toggle speaker-output according to the hp-jack state */
4583static void alc260_replacer_672v_automute(struct hda_codec *codec)
4584{
4585 unsigned int present;
4586
4587 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4588 present = snd_hda_codec_read(codec, 0x0f, 0,
4589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4590 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004591 snd_hda_codec_write_cache(codec, 0x01, 0,
4592 AC_VERB_SET_GPIO_DATA, 1);
4593 snd_hda_codec_write_cache(codec, 0x0f, 0,
4594 AC_VERB_SET_PIN_WIDGET_CONTROL,
4595 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004596 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004597 snd_hda_codec_write_cache(codec, 0x01, 0,
4598 AC_VERB_SET_GPIO_DATA, 0);
4599 snd_hda_codec_write_cache(codec, 0x0f, 0,
4600 AC_VERB_SET_PIN_WIDGET_CONTROL,
4601 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004602 }
4603}
4604
4605static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4606 unsigned int res)
4607{
4608 if ((res >> 26) == ALC880_HP_EVENT)
4609 alc260_replacer_672v_automute(codec);
4610}
4611
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004612/* Test configuration for debugging, modelled after the ALC880 test
4613 * configuration.
4614 */
4615#ifdef CONFIG_SND_DEBUG
4616static hda_nid_t alc260_test_dac_nids[1] = {
4617 0x02,
4618};
4619static hda_nid_t alc260_test_adc_nids[2] = {
4620 0x04, 0x05,
4621};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004622/* For testing the ALC260, each input MUX needs its own definition since
4623 * the signal assignments are different. This assumes that the first ADC
4624 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004625 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004626static struct hda_input_mux alc260_test_capture_sources[2] = {
4627 {
4628 .num_items = 7,
4629 .items = {
4630 { "MIC1 pin", 0x0 },
4631 { "MIC2 pin", 0x1 },
4632 { "LINE1 pin", 0x2 },
4633 { "LINE2 pin", 0x3 },
4634 { "CD pin", 0x4 },
4635 { "LINE-OUT pin", 0x5 },
4636 { "HP-OUT pin", 0x6 },
4637 },
4638 },
4639 {
4640 .num_items = 8,
4641 .items = {
4642 { "MIC1 pin", 0x0 },
4643 { "MIC2 pin", 0x1 },
4644 { "LINE1 pin", 0x2 },
4645 { "LINE2 pin", 0x3 },
4646 { "CD pin", 0x4 },
4647 { "Mixer", 0x5 },
4648 { "LINE-OUT pin", 0x6 },
4649 { "HP-OUT pin", 0x7 },
4650 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004651 },
4652};
4653static struct snd_kcontrol_new alc260_test_mixer[] = {
4654 /* Output driver widgets */
4655 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4656 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4657 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4658 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4659 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4660 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4661
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004662 /* Modes for retasking pin widgets
4663 * Note: the ALC260 doesn't seem to act on requests to enable mic
4664 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4665 * mention this restriction. At this stage it's not clear whether
4666 * this behaviour is intentional or is a hardware bug in chip
4667 * revisions available at least up until early 2006. Therefore for
4668 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4669 * choices, but if it turns out that the lack of mic bias for these
4670 * NIDs is intentional we could change their modes from
4671 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4672 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004673 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4674 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4675 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4676 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4677 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4678 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4679
4680 /* Loopback mixer controls */
4681 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4682 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4683 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4684 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4685 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4686 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4687 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4688 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4689 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4690 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4691 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4692 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4693 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4694 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4695 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4696 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004697
4698 /* Controls for GPIO pins, assuming they are configured as outputs */
4699 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4700 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4701 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4702 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4703
Jonathan Woithe92621f12006-02-28 11:47:47 +01004704 /* Switches to allow the digital IO pins to be enabled. The datasheet
4705 * is ambigious as to which NID is which; testing on laptops which
4706 * make this output available should provide clarification.
4707 */
4708 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4709 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4710
Jonathan Woithef8225f62008-01-08 12:16:54 +01004711 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4712 * this output to turn on an external amplifier.
4713 */
4714 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4715 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4716
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004717 { } /* end */
4718};
4719static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004720 /* Enable all GPIOs as outputs with an initial value of 0 */
4721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4722 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4723 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4724
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004725 /* Enable retasking pins as output, initially without power amp */
4726 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4727 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4730 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4731 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4732
Jonathan Woithe92621f12006-02-28 11:47:47 +01004733 /* Disable digital (SPDIF) pins initially, but users can enable
4734 * them via a mixer switch. In the case of SPDIF-out, this initverb
4735 * payload also sets the generation to 0, output to be in "consumer"
4736 * PCM format, copyright asserted, no pre-emphasis and no validity
4737 * control.
4738 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004739 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4740 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4741
Jonathan Woithef7ace402006-02-28 11:46:14 +01004742 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004743 * OUT1 sum bus when acting as an output.
4744 */
4745 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4746 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4747 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4748 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4749
4750 /* Start with output sum widgets muted and their output gains at min */
4751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4757 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4758 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4760
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004761 /* Unmute retasking pin widget output buffers since the default
4762 * state appears to be output. As the pin mode is changed by the
4763 * user the pin mode control will take care of enabling the pin's
4764 * input/output buffers as needed.
4765 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004766 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4767 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4770 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4771 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4772 /* Also unmute the mono-out pin widget */
4773 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4774
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004775 /* Mute capture amp left and right */
4776 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004777 /* Set ADC connection select to match default mixer setting (mic1
4778 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004779 */
4780 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4781
4782 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004783 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004784 */
4785 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4786 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4787
4788 /* Mute all inputs to mixer widget (even unconnected ones) */
4789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4797
4798 { }
4799};
4800#endif
4801
Takashi Iwai63300792008-01-24 15:31:36 +01004802#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4803#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004804
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004805#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4806#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4807
Kailang Yangdf694da2005-12-05 19:42:22 +01004808/*
4809 * for BIOS auto-configuration
4810 */
4811
4812static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4813 const char *pfx)
4814{
4815 hda_nid_t nid_vol;
4816 unsigned long vol_val, sw_val;
4817 char name[32];
4818 int err;
4819
4820 if (nid >= 0x0f && nid < 0x11) {
4821 nid_vol = nid - 0x7;
4822 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4823 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4824 } else if (nid == 0x11) {
4825 nid_vol = nid - 0x7;
4826 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4827 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4828 } else if (nid >= 0x12 && nid <= 0x15) {
4829 nid_vol = 0x08;
4830 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4831 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4832 } else
4833 return 0; /* N/A */
4834
4835 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004836 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4837 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004838 return err;
4839 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004840 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4841 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004842 return err;
4843 return 1;
4844}
4845
4846/* add playback controls from the parsed DAC table */
4847static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4848 const struct auto_pin_cfg *cfg)
4849{
4850 hda_nid_t nid;
4851 int err;
4852
4853 spec->multiout.num_dacs = 1;
4854 spec->multiout.dac_nids = spec->private_dac_nids;
4855 spec->multiout.dac_nids[0] = 0x02;
4856
4857 nid = cfg->line_out_pins[0];
4858 if (nid) {
4859 err = alc260_add_playback_controls(spec, nid, "Front");
4860 if (err < 0)
4861 return err;
4862 }
4863
Takashi Iwai82bc9552006-03-21 11:24:42 +01004864 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004865 if (nid) {
4866 err = alc260_add_playback_controls(spec, nid, "Speaker");
4867 if (err < 0)
4868 return err;
4869 }
4870
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004871 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004872 if (nid) {
4873 err = alc260_add_playback_controls(spec, nid, "Headphone");
4874 if (err < 0)
4875 return err;
4876 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004877 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004878}
4879
4880/* create playback/capture controls for input pins */
4881static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4882 const struct auto_pin_cfg *cfg)
4883{
Kailang Yangdf694da2005-12-05 19:42:22 +01004884 struct hda_input_mux *imux = &spec->private_imux;
4885 int i, err, idx;
4886
4887 for (i = 0; i < AUTO_PIN_LAST; i++) {
4888 if (cfg->input_pins[i] >= 0x12) {
4889 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004890 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004891 auto_pin_cfg_labels[i], idx,
4892 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004893 if (err < 0)
4894 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004895 imux->items[imux->num_items].label =
4896 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004897 imux->items[imux->num_items].index = idx;
4898 imux->num_items++;
4899 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004900 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004901 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004902 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004903 auto_pin_cfg_labels[i], idx,
4904 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004905 if (err < 0)
4906 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004907 imux->items[imux->num_items].label =
4908 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004909 imux->items[imux->num_items].index = idx;
4910 imux->num_items++;
4911 }
4912 }
4913 return 0;
4914}
4915
4916static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4917 hda_nid_t nid, int pin_type,
4918 int sel_idx)
4919{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004920 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01004921 /* need the manual connection? */
4922 if (nid >= 0x12) {
4923 int idx = nid - 0x12;
4924 snd_hda_codec_write(codec, idx + 0x0b, 0,
4925 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004926 }
4927}
4928
4929static void alc260_auto_init_multi_out(struct hda_codec *codec)
4930{
4931 struct alc_spec *spec = codec->spec;
4932 hda_nid_t nid;
4933
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004934 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004935 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004936 if (nid) {
4937 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4938 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4939 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004940
Takashi Iwai82bc9552006-03-21 11:24:42 +01004941 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004942 if (nid)
4943 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4944
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004945 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004947 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004948}
Kailang Yangdf694da2005-12-05 19:42:22 +01004949
4950#define ALC260_PIN_CD_NID 0x16
4951static void alc260_auto_init_analog_input(struct hda_codec *codec)
4952{
4953 struct alc_spec *spec = codec->spec;
4954 int i;
4955
4956 for (i = 0; i < AUTO_PIN_LAST; i++) {
4957 hda_nid_t nid = spec->autocfg.input_pins[i];
4958 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004959 snd_hda_codec_write(codec, nid, 0,
4960 AC_VERB_SET_PIN_WIDGET_CONTROL,
4961 i <= AUTO_PIN_FRONT_MIC ?
4962 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004963 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004964 snd_hda_codec_write(codec, nid, 0,
4965 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004966 AMP_OUT_MUTE);
4967 }
4968 }
4969}
4970
4971/*
4972 * generic initialization of ADC, input mixers and output mixers
4973 */
4974static struct hda_verb alc260_volume_init_verbs[] = {
4975 /*
4976 * Unmute ADC0-1 and set the default input to mic-in
4977 */
4978 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4979 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4980 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4981 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4982
4983 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4984 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004985 * Note: PASD motherboards uses the Line In 2 as the input for
4986 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004987 */
4988 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004989 /* mute analog inputs */
4990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004995
4996 /*
4997 * Set up output mixers (0x08 - 0x0a)
4998 */
4999 /* set vol=0 to output mixers */
5000 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5001 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5002 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5003 /* set up input amps for analog loopback */
5004 /* Amp Indices: DAC = 0, mixer = 1 */
5005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5007 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5009 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5010 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5011
5012 { }
5013};
5014
5015static int alc260_parse_auto_config(struct hda_codec *codec)
5016{
5017 struct alc_spec *spec = codec->spec;
5018 unsigned int wcap;
5019 int err;
5020 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5021
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005022 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5023 alc260_ignore);
5024 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005025 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005026 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5027 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005028 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005029 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005030 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005031 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5032 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005033 return err;
5034
5035 spec->multiout.max_channels = 2;
5036
5037 if (spec->autocfg.dig_out_pin)
5038 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5039 if (spec->kctl_alloc)
5040 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5041
5042 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5043
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005044 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005045 spec->input_mux = &spec->private_imux;
5046
5047 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005048 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005050 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005051 spec->adc_nids = alc260_adc_nids_alt;
5052 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5053 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005054 } else {
5055 spec->adc_nids = alc260_adc_nids;
5056 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5057 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005058 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005059 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005060
5061 return 1;
5062}
5063
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005064/* additional initialization for auto-configuration model */
5065static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005066{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005067 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005068 alc260_auto_init_multi_out(codec);
5069 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005070 if (spec->unsol_event)
5071 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005072}
5073
Takashi Iwaicb53c622007-08-10 17:21:45 +02005074#ifdef CONFIG_SND_HDA_POWER_SAVE
5075static struct hda_amp_list alc260_loopbacks[] = {
5076 { 0x07, HDA_INPUT, 0 },
5077 { 0x07, HDA_INPUT, 1 },
5078 { 0x07, HDA_INPUT, 2 },
5079 { 0x07, HDA_INPUT, 3 },
5080 { 0x07, HDA_INPUT, 4 },
5081 { } /* end */
5082};
5083#endif
5084
Kailang Yangdf694da2005-12-05 19:42:22 +01005085/*
5086 * ALC260 configurations
5087 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005088static const char *alc260_models[ALC260_MODEL_LAST] = {
5089 [ALC260_BASIC] = "basic",
5090 [ALC260_HP] = "hp",
5091 [ALC260_HP_3013] = "hp-3013",
5092 [ALC260_FUJITSU_S702X] = "fujitsu",
5093 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005094 [ALC260_WILL] = "will",
5095 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005096#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005097 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005098#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005099 [ALC260_AUTO] = "auto",
5100};
5101
5102static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005103 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005104 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005105 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005106 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005107 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5108 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5109 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5110 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5111 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5112 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5113 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5114 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5115 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5116 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5117 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5118 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005119 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005120 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005121 {}
5122};
5123
Kailang Yangdf694da2005-12-05 19:42:22 +01005124static struct alc_config_preset alc260_presets[] = {
5125 [ALC260_BASIC] = {
5126 .mixers = { alc260_base_output_mixer,
5127 alc260_input_mixer,
5128 alc260_pc_beep_mixer,
5129 alc260_capture_mixer },
5130 .init_verbs = { alc260_init_verbs },
5131 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5132 .dac_nids = alc260_dac_nids,
5133 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5134 .adc_nids = alc260_adc_nids,
5135 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5136 .channel_mode = alc260_modes,
5137 .input_mux = &alc260_capture_source,
5138 },
5139 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005140 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005141 alc260_input_mixer,
5142 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005143 .init_verbs = { alc260_init_verbs,
5144 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005145 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5146 .dac_nids = alc260_dac_nids,
5147 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5148 .adc_nids = alc260_hp_adc_nids,
5149 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5150 .channel_mode = alc260_modes,
5151 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005152 .unsol_event = alc260_hp_unsol_event,
5153 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005154 },
5155 [ALC260_HP_3013] = {
5156 .mixers = { alc260_hp_3013_mixer,
5157 alc260_input_mixer,
5158 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005159 .init_verbs = { alc260_hp_3013_init_verbs,
5160 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005161 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5162 .dac_nids = alc260_dac_nids,
5163 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5164 .adc_nids = alc260_hp_adc_nids,
5165 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5166 .channel_mode = alc260_modes,
5167 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005168 .unsol_event = alc260_hp_3013_unsol_event,
5169 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 },
5171 [ALC260_FUJITSU_S702X] = {
5172 .mixers = { alc260_fujitsu_mixer,
5173 alc260_capture_mixer },
5174 .init_verbs = { alc260_fujitsu_init_verbs },
5175 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5176 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005177 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5178 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005179 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5180 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005181 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5182 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005183 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005184 [ALC260_ACER] = {
5185 .mixers = { alc260_acer_mixer,
5186 alc260_capture_mixer },
5187 .init_verbs = { alc260_acer_init_verbs },
5188 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5189 .dac_nids = alc260_dac_nids,
5190 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5191 .adc_nids = alc260_dual_adc_nids,
5192 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5193 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005194 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5195 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005196 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005197 [ALC260_WILL] = {
5198 .mixers = { alc260_will_mixer,
5199 alc260_capture_mixer },
5200 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5201 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5202 .dac_nids = alc260_dac_nids,
5203 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5204 .adc_nids = alc260_adc_nids,
5205 .dig_out_nid = ALC260_DIGOUT_NID,
5206 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5207 .channel_mode = alc260_modes,
5208 .input_mux = &alc260_capture_source,
5209 },
5210 [ALC260_REPLACER_672V] = {
5211 .mixers = { alc260_replacer_672v_mixer,
5212 alc260_capture_mixer },
5213 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5214 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5215 .dac_nids = alc260_dac_nids,
5216 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5217 .adc_nids = alc260_adc_nids,
5218 .dig_out_nid = ALC260_DIGOUT_NID,
5219 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5220 .channel_mode = alc260_modes,
5221 .input_mux = &alc260_capture_source,
5222 .unsol_event = alc260_replacer_672v_unsol_event,
5223 .init_hook = alc260_replacer_672v_automute,
5224 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005225#ifdef CONFIG_SND_DEBUG
5226 [ALC260_TEST] = {
5227 .mixers = { alc260_test_mixer,
5228 alc260_capture_mixer },
5229 .init_verbs = { alc260_test_init_verbs },
5230 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5231 .dac_nids = alc260_test_dac_nids,
5232 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5233 .adc_nids = alc260_test_adc_nids,
5234 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5235 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5237 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005238 },
5239#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005240};
5241
Linus Torvalds1da177e2005-04-16 15:20:36 -07005242static int patch_alc260(struct hda_codec *codec)
5243{
5244 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005245 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005246
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005247 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005248 if (spec == NULL)
5249 return -ENOMEM;
5250
5251 codec->spec = spec;
5252
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005253 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5254 alc260_models,
5255 alc260_cfg_tbl);
5256 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005257 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5258 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005259 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005260 }
5261
Kailang Yangdf694da2005-12-05 19:42:22 +01005262 if (board_config == ALC260_AUTO) {
5263 /* automatic parse from the BIOS config */
5264 err = alc260_parse_auto_config(codec);
5265 if (err < 0) {
5266 alc_free(codec);
5267 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005268 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005269 printk(KERN_INFO
5270 "hda_codec: Cannot set up configuration "
5271 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005272 board_config = ALC260_BASIC;
5273 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005274 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005275
Kailang Yangdf694da2005-12-05 19:42:22 +01005276 if (board_config != ALC260_AUTO)
5277 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005278
5279 spec->stream_name_analog = "ALC260 Analog";
5280 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5281 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5282
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005283 spec->stream_name_digital = "ALC260 Digital";
5284 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5285 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5286
Takashi Iwai2134ea42008-01-10 16:53:55 +01005287 spec->vmaster_nid = 0x08;
5288
Linus Torvalds1da177e2005-04-16 15:20:36 -07005289 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005290 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005291 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005292#ifdef CONFIG_SND_HDA_POWER_SAVE
5293 if (!spec->loopback.amplist)
5294 spec->loopback.amplist = alc260_loopbacks;
5295#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005296
5297 return 0;
5298}
5299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005300
Linus Torvalds1da177e2005-04-16 15:20:36 -07005301/*
5302 * ALC882 support
5303 *
5304 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5305 * configuration. Each pin widget can choose any input DACs and a mixer.
5306 * Each ADC is connected from a mixer of all inputs. This makes possible
5307 * 6-channel independent captures.
5308 *
5309 * In addition, an independent DAC for the multi-playback (not used in this
5310 * driver yet).
5311 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005312#define ALC882_DIGOUT_NID 0x06
5313#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005314
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005315static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 { 8, NULL }
5317};
5318
5319static hda_nid_t alc882_dac_nids[4] = {
5320 /* front, rear, clfe, rear_surr */
5321 0x02, 0x03, 0x04, 0x05
5322};
5323
Kailang Yangdf694da2005-12-05 19:42:22 +01005324/* identical with ALC880 */
5325#define alc882_adc_nids alc880_adc_nids
5326#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005327
Takashi Iwaie1406342008-02-11 18:32:32 +01005328static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5329static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5330
Linus Torvalds1da177e2005-04-16 15:20:36 -07005331/* input MUX */
5332/* FIXME: should be a matrix-type input source selection */
5333
5334static struct hda_input_mux alc882_capture_source = {
5335 .num_items = 4,
5336 .items = {
5337 { "Mic", 0x0 },
5338 { "Front Mic", 0x1 },
5339 { "Line", 0x2 },
5340 { "CD", 0x4 },
5341 },
5342};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005343#define alc882_mux_enum_info alc_mux_enum_info
5344#define alc882_mux_enum_get alc_mux_enum_get
5345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005346static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5347 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005348{
5349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5350 struct alc_spec *spec = codec->spec;
5351 const struct hda_input_mux *imux = spec->input_mux;
5352 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005353 hda_nid_t nid = spec->capsrc_nids ?
5354 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005355 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5356 unsigned int i, idx;
5357
5358 idx = ucontrol->value.enumerated.item[0];
5359 if (idx >= imux->num_items)
5360 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005361 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005362 return 0;
5363 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005364 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5365 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005366 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005367 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005368 }
5369 *cur_val = idx;
5370 return 1;
5371}
5372
Kailang Yangdf694da2005-12-05 19:42:22 +01005373/*
Kailang Yang272a5272007-05-14 11:00:38 +02005374 * 2ch mode
5375 */
5376static struct hda_verb alc882_3ST_ch2_init[] = {
5377 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5378 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5379 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5380 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5381 { } /* end */
5382};
5383
5384/*
5385 * 6ch mode
5386 */
5387static struct hda_verb alc882_3ST_ch6_init[] = {
5388 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5389 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5390 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5393 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5394 { } /* end */
5395};
5396
5397static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5398 { 2, alc882_3ST_ch2_init },
5399 { 6, alc882_3ST_ch6_init },
5400};
5401
5402/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005403 * 6ch mode
5404 */
5405static struct hda_verb alc882_sixstack_ch6_init[] = {
5406 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5407 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5408 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5409 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5410 { } /* end */
5411};
5412
5413/*
5414 * 8ch mode
5415 */
5416static struct hda_verb alc882_sixstack_ch8_init[] = {
5417 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5418 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5419 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5420 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5421 { } /* end */
5422};
5423
5424static struct hda_channel_mode alc882_sixstack_modes[2] = {
5425 { 6, alc882_sixstack_ch6_init },
5426 { 8, alc882_sixstack_ch8_init },
5427};
5428
Takashi Iwai87350ad2007-08-16 18:19:38 +02005429/*
5430 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5431 */
5432
5433/*
5434 * 2ch mode
5435 */
5436static struct hda_verb alc885_mbp_ch2_init[] = {
5437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5438 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 { } /* end */
5441};
5442
5443/*
5444 * 6ch mode
5445 */
5446static struct hda_verb alc885_mbp_ch6_init[] = {
5447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5449 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5450 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5451 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5452 { } /* end */
5453};
5454
5455static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5456 { 2, alc885_mbp_ch2_init },
5457 { 6, alc885_mbp_ch6_init },
5458};
5459
5460
Linus Torvalds1da177e2005-04-16 15:20:36 -07005461/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5462 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5463 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005464static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005466 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005467 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005468 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005469 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5470 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005471 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5472 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005473 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005474 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5476 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5477 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5478 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5479 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005481 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005484 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5486 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5487 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005488 { } /* end */
5489};
5490
Takashi Iwai87350ad2007-08-16 18:19:38 +02005491static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005492 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5493 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5494 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5495 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5497 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5499 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005500 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005501 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5502 { } /* end */
5503};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005504static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5505 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5506 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5507 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5508 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5509 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5510 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5512 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5514 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5515 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5516 { } /* end */
5517};
5518
Kailang Yang272a5272007-05-14 11:00:38 +02005519static struct snd_kcontrol_new alc882_targa_mixer[] = {
5520 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5521 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5525 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5526 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5527 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5528 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005532 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005533 { } /* end */
5534};
5535
5536/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5537 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5538 */
5539static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5541 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5543 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5544 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5545 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5546 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5547 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5548 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5549 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005553 { } /* end */
5554};
5555
Takashi Iwai914759b2007-09-06 14:52:04 +02005556static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5558 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5560 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5561 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5562 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5563 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5567 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5568 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5569 { } /* end */
5570};
5571
Kailang Yangdf694da2005-12-05 19:42:22 +01005572static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5573 {
5574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5575 .name = "Channel Mode",
5576 .info = alc_ch_mode_info,
5577 .get = alc_ch_mode_get,
5578 .put = alc_ch_mode_put,
5579 },
5580 { } /* end */
5581};
5582
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583static struct hda_verb alc882_init_verbs[] = {
5584 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005588 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005592 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005596 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005597 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005600
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005601 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005605 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005609 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005610 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005611 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005612 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005613 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005614 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005615 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005616 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005617 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005619 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5620 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5623 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5626 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005630 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005631 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005632
5633 /* FIXME: use matrix-type input source selection */
5634 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5635 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005636 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5637 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5638 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5639 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005640 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005641 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005645 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5650 /* ADC1: mute amp left and right */
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005652 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005653 /* ADC2: mute amp left and right */
5654 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005655 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005656 /* ADC3: mute amp left and right */
5657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005658 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005659
5660 { }
5661};
5662
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005663static struct hda_verb alc882_eapd_verbs[] = {
5664 /* change to EAPD mode */
5665 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005666 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005667 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005668};
5669
Tobin Davis9102cd12006-12-15 10:02:12 +01005670/* Mac Pro test */
5671static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5674 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5675 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5676 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5677 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5678 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5679 { } /* end */
5680};
5681
5682static struct hda_verb alc882_macpro_init_verbs[] = {
5683 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5687 /* Front Pin: output 0 (0x0c) */
5688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5690 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5691 /* Front Mic pin: input vref at 80% */
5692 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5693 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5694 /* Speaker: output */
5695 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5697 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5698 /* Headphone output (output 0 - 0x0c) */
5699 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5701 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5702
5703 /* FIXME: use matrix-type input source selection */
5704 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5705 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5710 /* Input mixer2 */
5711 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5712 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5714 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5715 /* Input mixer3 */
5716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5719 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5720 /* ADC1: mute amp left and right */
5721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5722 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5723 /* ADC2: mute amp left and right */
5724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5725 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5726 /* ADC3: mute amp left and right */
5727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5728 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5729
5730 { }
5731};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005732
Takashi Iwai87350ad2007-08-16 18:19:38 +02005733/* Macbook Pro rev3 */
5734static struct hda_verb alc885_mbp3_init_verbs[] = {
5735 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5739 /* Rear mixer */
5740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5743 /* Front Pin: output 0 (0x0c) */
5744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5746 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5747 /* HP Pin: output 0 (0x0d) */
5748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5751 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5752 /* Mic (rear) pin: input vref at 80% */
5753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5755 /* Front Mic pin: input vref at 80% */
5756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5758 /* Line In pin: use output 1 when in LineOut mode */
5759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5761 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5762
5763 /* FIXME: use matrix-type input source selection */
5764 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5765 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5770 /* Input mixer2 */
5771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5773 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5775 /* Input mixer3 */
5776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5780 /* ADC1: mute amp left and right */
5781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5782 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5783 /* ADC2: mute amp left and right */
5784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5785 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5786 /* ADC3: mute amp left and right */
5787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5788 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5789
5790 { }
5791};
5792
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005793/* iMac 24 mixer. */
5794static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5795 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5796 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5797 { } /* end */
5798};
5799
5800/* iMac 24 init verbs. */
5801static struct hda_verb alc885_imac24_init_verbs[] = {
5802 /* Internal speakers: output 0 (0x0c) */
5803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5804 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5805 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5806 /* Internal speakers: output 0 (0x0c) */
5807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5809 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5810 /* Headphone: output 0 (0x0c) */
5811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5813 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5814 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5815 /* Front Mic: input vref at 80% */
5816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5818 { }
5819};
5820
5821/* Toggle speaker-output according to the hp-jack state */
5822static void alc885_imac24_automute(struct hda_codec *codec)
5823{
5824 unsigned int present;
5825
5826 present = snd_hda_codec_read(codec, 0x14, 0,
5827 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005828 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5829 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5830 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5831 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005832}
5833
5834/* Processes unsolicited events. */
5835static void alc885_imac24_unsol_event(struct hda_codec *codec,
5836 unsigned int res)
5837{
5838 /* Headphone insertion or removal. */
5839 if ((res >> 26) == ALC880_HP_EVENT)
5840 alc885_imac24_automute(codec);
5841}
5842
Takashi Iwai87350ad2007-08-16 18:19:38 +02005843static void alc885_mbp3_automute(struct hda_codec *codec)
5844{
5845 unsigned int present;
5846
5847 present = snd_hda_codec_read(codec, 0x15, 0,
5848 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5849 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5851 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5852 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5853
5854}
5855static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5856 unsigned int res)
5857{
5858 /* Headphone insertion or removal. */
5859 if ((res >> 26) == ALC880_HP_EVENT)
5860 alc885_mbp3_automute(codec);
5861}
5862
5863
Kailang Yang272a5272007-05-14 11:00:38 +02005864static struct hda_verb alc882_targa_verbs[] = {
5865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5867
5868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5870
5871 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5872 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5873 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5874
5875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5876 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5877 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5878 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5879 { } /* end */
5880};
5881
5882/* toggle speaker-output according to the hp-jack state */
5883static void alc882_targa_automute(struct hda_codec *codec)
5884{
5885 unsigned int present;
5886
5887 present = snd_hda_codec_read(codec, 0x14, 0,
5888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005889 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005891 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5892 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005893}
5894
5895static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5896{
5897 /* Looks like the unsol event is incompatible with the standard
5898 * definition. 4bit tag is placed at 26 bit!
5899 */
5900 if (((res >> 26) == ALC880_HP_EVENT)) {
5901 alc882_targa_automute(codec);
5902 }
5903}
5904
5905static struct hda_verb alc882_asus_a7j_verbs[] = {
5906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5908
5909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5912
5913 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5914 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5915 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5916
5917 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5918 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5919 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5920 { } /* end */
5921};
5922
Takashi Iwai914759b2007-09-06 14:52:04 +02005923static struct hda_verb alc882_asus_a7m_verbs[] = {
5924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5926
5927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5929 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5930
5931 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5933 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5934
5935 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5936 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5938 { } /* end */
5939};
5940
Tobin Davis9102cd12006-12-15 10:02:12 +01005941static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5942{
5943 unsigned int gpiostate, gpiomask, gpiodir;
5944
5945 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5946 AC_VERB_GET_GPIO_DATA, 0);
5947
5948 if (!muted)
5949 gpiostate |= (1 << pin);
5950 else
5951 gpiostate &= ~(1 << pin);
5952
5953 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5954 AC_VERB_GET_GPIO_MASK, 0);
5955 gpiomask |= (1 << pin);
5956
5957 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5958 AC_VERB_GET_GPIO_DIRECTION, 0);
5959 gpiodir |= (1 << pin);
5960
5961
5962 snd_hda_codec_write(codec, codec->afg, 0,
5963 AC_VERB_SET_GPIO_MASK, gpiomask);
5964 snd_hda_codec_write(codec, codec->afg, 0,
5965 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5966
5967 msleep(1);
5968
5969 snd_hda_codec_write(codec, codec->afg, 0,
5970 AC_VERB_SET_GPIO_DATA, gpiostate);
5971}
5972
Takashi Iwai7debbe52007-08-16 15:01:03 +02005973/* set up GPIO at initialization */
5974static void alc885_macpro_init_hook(struct hda_codec *codec)
5975{
5976 alc882_gpio_mute(codec, 0, 0);
5977 alc882_gpio_mute(codec, 1, 0);
5978}
5979
5980/* set up GPIO and update auto-muting at initialization */
5981static void alc885_imac24_init_hook(struct hda_codec *codec)
5982{
5983 alc885_macpro_init_hook(codec);
5984 alc885_imac24_automute(codec);
5985}
5986
Kailang Yangdf694da2005-12-05 19:42:22 +01005987/*
5988 * generic initialization of ADC, input mixers and output mixers
5989 */
5990static struct hda_verb alc882_auto_init_verbs[] = {
5991 /*
5992 * Unmute ADC0-2 and set the default input to mic-in
5993 */
5994 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5996 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5998 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5999 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6000
Takashi Iwaicb53c622007-08-10 17:21:45 +02006001 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006002 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006003 * Note: PASD motherboards uses the Line In 2 as the input for
6004 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006005 */
6006 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006012
6013 /*
6014 * Set up output mixers (0x0c - 0x0f)
6015 */
6016 /* set vol=0 to output mixers */
6017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6021 /* set up input amps for analog loopback */
6022 /* Amp Indices: DAC = 0, mixer = 1 */
6023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6026 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6028 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6029 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6030 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6031 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6032 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6033
6034 /* FIXME: use matrix-type input source selection */
6035 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6036 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6037 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6041 /* Input mixer2 */
6042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6046 /* Input mixer3 */
6047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6051
6052 { }
6053};
6054
6055/* capture mixer elements */
6056static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6057 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6058 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6059 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6060 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6061 {
6062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6063 /* The multiple "Capture Source" controls confuse alsamixer
6064 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006065 */
6066 /* .name = "Capture Source", */
6067 .name = "Input Source",
6068 .count = 2,
6069 .info = alc882_mux_enum_info,
6070 .get = alc882_mux_enum_get,
6071 .put = alc882_mux_enum_put,
6072 },
6073 { } /* end */
6074};
6075
6076static struct snd_kcontrol_new alc882_capture_mixer[] = {
6077 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6078 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6079 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6080 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6081 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6082 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6083 {
6084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6085 /* The multiple "Capture Source" controls confuse alsamixer
6086 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006087 */
6088 /* .name = "Capture Source", */
6089 .name = "Input Source",
6090 .count = 3,
6091 .info = alc882_mux_enum_info,
6092 .get = alc882_mux_enum_get,
6093 .put = alc882_mux_enum_put,
6094 },
6095 { } /* end */
6096};
6097
Takashi Iwaicb53c622007-08-10 17:21:45 +02006098#ifdef CONFIG_SND_HDA_POWER_SAVE
6099#define alc882_loopbacks alc880_loopbacks
6100#endif
6101
Kailang Yangdf694da2005-12-05 19:42:22 +01006102/* pcm configuration: identiacal with ALC880 */
6103#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6104#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6105#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6106#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6107
6108/*
6109 * configuration and preset
6110 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006111static const char *alc882_models[ALC882_MODEL_LAST] = {
6112 [ALC882_3ST_DIG] = "3stack-dig",
6113 [ALC882_6ST_DIG] = "6stack-dig",
6114 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006115 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006116 [ALC882_TARGA] = "targa",
6117 [ALC882_ASUS_A7J] = "asus-a7j",
6118 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006119 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006120 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006121 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006122 [ALC882_AUTO] = "auto",
6123};
6124
6125static struct snd_pci_quirk alc882_cfg_tbl[] = {
6126 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006127 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006128 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006129 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006130 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006131 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006132 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006133 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006134 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006135 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6136 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6137 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006138 {}
6139};
6140
6141static struct alc_config_preset alc882_presets[] = {
6142 [ALC882_3ST_DIG] = {
6143 .mixers = { alc882_base_mixer },
6144 .init_verbs = { alc882_init_verbs },
6145 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6146 .dac_nids = alc882_dac_nids,
6147 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006148 .dig_in_nid = ALC882_DIGIN_NID,
6149 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6150 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006151 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006152 .input_mux = &alc882_capture_source,
6153 },
6154 [ALC882_6ST_DIG] = {
6155 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6156 .init_verbs = { alc882_init_verbs },
6157 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6158 .dac_nids = alc882_dac_nids,
6159 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006160 .dig_in_nid = ALC882_DIGIN_NID,
6161 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6162 .channel_mode = alc882_sixstack_modes,
6163 .input_mux = &alc882_capture_source,
6164 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006165 [ALC882_ARIMA] = {
6166 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6167 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6168 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6169 .dac_nids = alc882_dac_nids,
6170 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6171 .channel_mode = alc882_sixstack_modes,
6172 .input_mux = &alc882_capture_source,
6173 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006174 [ALC882_W2JC] = {
6175 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6176 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6177 alc880_gpio1_init_verbs },
6178 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6179 .dac_nids = alc882_dac_nids,
6180 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6181 .channel_mode = alc880_threestack_modes,
6182 .need_dac_fix = 1,
6183 .input_mux = &alc882_capture_source,
6184 .dig_out_nid = ALC882_DIGOUT_NID,
6185 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006186 [ALC885_MBP3] = {
6187 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6188 .init_verbs = { alc885_mbp3_init_verbs,
6189 alc880_gpio1_init_verbs },
6190 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6191 .dac_nids = alc882_dac_nids,
6192 .channel_mode = alc885_mbp_6ch_modes,
6193 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6194 .input_mux = &alc882_capture_source,
6195 .dig_out_nid = ALC882_DIGOUT_NID,
6196 .dig_in_nid = ALC882_DIGIN_NID,
6197 .unsol_event = alc885_mbp3_unsol_event,
6198 .init_hook = alc885_mbp3_automute,
6199 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006200 [ALC885_MACPRO] = {
6201 .mixers = { alc882_macpro_mixer },
6202 .init_verbs = { alc882_macpro_init_verbs },
6203 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6204 .dac_nids = alc882_dac_nids,
6205 .dig_out_nid = ALC882_DIGOUT_NID,
6206 .dig_in_nid = ALC882_DIGIN_NID,
6207 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6208 .channel_mode = alc882_ch_modes,
6209 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006210 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006211 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006212 [ALC885_IMAC24] = {
6213 .mixers = { alc885_imac24_mixer },
6214 .init_verbs = { alc885_imac24_init_verbs },
6215 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6216 .dac_nids = alc882_dac_nids,
6217 .dig_out_nid = ALC882_DIGOUT_NID,
6218 .dig_in_nid = ALC882_DIGIN_NID,
6219 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6220 .channel_mode = alc882_ch_modes,
6221 .input_mux = &alc882_capture_source,
6222 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006223 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006224 },
Kailang Yang272a5272007-05-14 11:00:38 +02006225 [ALC882_TARGA] = {
6226 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6227 alc882_capture_mixer },
6228 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6229 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6230 .dac_nids = alc882_dac_nids,
6231 .dig_out_nid = ALC882_DIGOUT_NID,
6232 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6233 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006234 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006235 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6236 .channel_mode = alc882_3ST_6ch_modes,
6237 .need_dac_fix = 1,
6238 .input_mux = &alc882_capture_source,
6239 .unsol_event = alc882_targa_unsol_event,
6240 .init_hook = alc882_targa_automute,
6241 },
6242 [ALC882_ASUS_A7J] = {
6243 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6244 alc882_capture_mixer },
6245 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6246 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6247 .dac_nids = alc882_dac_nids,
6248 .dig_out_nid = ALC882_DIGOUT_NID,
6249 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6250 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006251 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006252 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6253 .channel_mode = alc882_3ST_6ch_modes,
6254 .need_dac_fix = 1,
6255 .input_mux = &alc882_capture_source,
6256 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006257 [ALC882_ASUS_A7M] = {
6258 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6259 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6260 alc880_gpio1_init_verbs,
6261 alc882_asus_a7m_verbs },
6262 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6263 .dac_nids = alc882_dac_nids,
6264 .dig_out_nid = ALC882_DIGOUT_NID,
6265 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6266 .channel_mode = alc880_threestack_modes,
6267 .need_dac_fix = 1,
6268 .input_mux = &alc882_capture_source,
6269 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006270};
6271
6272
6273/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006274 * Pin config fixes
6275 */
6276enum {
6277 PINFIX_ABIT_AW9D_MAX
6278};
6279
6280static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6281 { 0x15, 0x01080104 }, /* side */
6282 { 0x16, 0x01011012 }, /* rear */
6283 { 0x17, 0x01016011 }, /* clfe */
6284 { }
6285};
6286
6287static const struct alc_pincfg *alc882_pin_fixes[] = {
6288 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6289};
6290
6291static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6292 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6293 {}
6294};
6295
6296/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 * BIOS auto configuration
6298 */
6299static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6300 hda_nid_t nid, int pin_type,
6301 int dac_idx)
6302{
6303 /* set as output */
6304 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006305 int idx;
6306
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006307 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006308 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6309 idx = 4;
6310 else
6311 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6313
6314}
6315
6316static void alc882_auto_init_multi_out(struct hda_codec *codec)
6317{
6318 struct alc_spec *spec = codec->spec;
6319 int i;
6320
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006321 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006323 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006324 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006325 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006326 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006327 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 }
6329}
6330
6331static void alc882_auto_init_hp_out(struct hda_codec *codec)
6332{
6333 struct alc_spec *spec = codec->spec;
6334 hda_nid_t pin;
6335
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006336 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006337 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006338 /* use dac 0 */
6339 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006340 pin = spec->autocfg.speaker_pins[0];
6341 if (pin)
6342 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006343}
6344
6345#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6346#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6347
6348static void alc882_auto_init_analog_input(struct hda_codec *codec)
6349{
6350 struct alc_spec *spec = codec->spec;
6351 int i;
6352
6353 for (i = 0; i < AUTO_PIN_LAST; i++) {
6354 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006355 unsigned int vref;
6356 if (!nid)
6357 continue;
6358 vref = PIN_IN;
6359 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006360 unsigned int pincap;
6361 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6362 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006363 AC_PINCAP_VREF_80)
6364 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006365 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006366 snd_hda_codec_write(codec, nid, 0,
6367 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6368 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6369 snd_hda_codec_write(codec, nid, 0,
6370 AC_VERB_SET_AMP_GAIN_MUTE,
6371 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006372 }
6373}
6374
Takashi Iwai776e1842007-08-29 15:07:11 +02006375/* add mic boosts if needed */
6376static int alc_auto_add_mic_boost(struct hda_codec *codec)
6377{
6378 struct alc_spec *spec = codec->spec;
6379 int err;
6380 hda_nid_t nid;
6381
6382 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006383 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006384 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6385 "Mic Boost",
6386 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6387 if (err < 0)
6388 return err;
6389 }
6390 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006391 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006392 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6393 "Front Mic Boost",
6394 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6395 if (err < 0)
6396 return err;
6397 }
6398 return 0;
6399}
6400
Kailang Yangdf694da2005-12-05 19:42:22 +01006401/* almost identical with ALC880 parser... */
6402static int alc882_parse_auto_config(struct hda_codec *codec)
6403{
6404 struct alc_spec *spec = codec->spec;
6405 int err = alc880_parse_auto_config(codec);
6406
6407 if (err < 0)
6408 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006409 else if (!err)
6410 return 0; /* no config found */
6411
6412 err = alc_auto_add_mic_boost(codec);
6413 if (err < 0)
6414 return err;
6415
6416 /* hack - override the init verbs */
6417 spec->init_verbs[0] = alc882_auto_init_verbs;
6418
6419 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006420}
6421
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006422/* additional initialization for auto-configuration model */
6423static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006424{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006425 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 alc882_auto_init_multi_out(codec);
6427 alc882_auto_init_hp_out(codec);
6428 alc882_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006429 if (spec->unsol_event)
6430 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006431}
6432
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006433static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6434
Linus Torvalds1da177e2005-04-16 15:20:36 -07006435static int patch_alc882(struct hda_codec *codec)
6436{
6437 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006438 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006440 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441 if (spec == NULL)
6442 return -ENOMEM;
6443
Linus Torvalds1da177e2005-04-16 15:20:36 -07006444 codec->spec = spec;
6445
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006446 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6447 alc882_models,
6448 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449
Kailang Yangdf694da2005-12-05 19:42:22 +01006450 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006451 /* Pick up systems that don't supply PCI SSID */
6452 switch (codec->subsystem_id) {
6453 case 0x106b0c00: /* Mac Pro */
6454 board_config = ALC885_MACPRO;
6455 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006456 case 0x106b1000: /* iMac 24 */
6457 board_config = ALC885_IMAC24;
6458 break;
Jiang zhe3d5fa2e2008-01-10 13:05:47 +01006459 case 0x106b00a1: /* Macbook */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006460 case 0x106b2c00: /* Macbook Pro rev3 */
6461 board_config = ALC885_MBP3;
6462 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006463 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006464 /* ALC889A is handled better as ALC888-compatible */
6465 if (codec->revision_id == 0x100103) {
6466 alc_free(codec);
6467 return patch_alc883(codec);
6468 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006469 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6470 "trying auto-probe from BIOS...\n");
6471 board_config = ALC882_AUTO;
6472 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006474
Takashi Iwaif95474e2007-07-10 00:47:43 +02006475 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6476
Kailang Yangdf694da2005-12-05 19:42:22 +01006477 if (board_config == ALC882_AUTO) {
6478 /* automatic parse from the BIOS config */
6479 err = alc882_parse_auto_config(codec);
6480 if (err < 0) {
6481 alc_free(codec);
6482 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006483 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006484 printk(KERN_INFO
6485 "hda_codec: Cannot set up configuration "
6486 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 board_config = ALC882_3ST_DIG;
6488 }
6489 }
6490
6491 if (board_config != ALC882_AUTO)
6492 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006493
6494 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01006495 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6496 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006497 /* FIXME: setup DAC5 */
6498 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6499 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006500
6501 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01006502 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6503 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006504
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006506 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006507 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006508 /* get type */
6509 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006510 if (wcap != AC_WID_AUD_IN) {
6511 spec->adc_nids = alc882_adc_nids_alt;
6512 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006513 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006514 spec->mixers[spec->num_mixers] =
6515 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006516 spec->num_mixers++;
6517 } else {
6518 spec->adc_nids = alc882_adc_nids;
6519 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006520 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006521 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6522 spec->num_mixers++;
6523 }
6524 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006525
Takashi Iwai2134ea42008-01-10 16:53:55 +01006526 spec->vmaster_nid = 0x0c;
6527
Linus Torvalds1da177e2005-04-16 15:20:36 -07006528 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006529 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006530 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006531#ifdef CONFIG_SND_HDA_POWER_SAVE
6532 if (!spec->loopback.amplist)
6533 spec->loopback.amplist = alc882_loopbacks;
6534#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006535
6536 return 0;
6537}
6538
6539/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006540 * ALC883 support
6541 *
6542 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6543 * configuration. Each pin widget can choose any input DACs and a mixer.
6544 * Each ADC is connected from a mixer of all inputs. This makes possible
6545 * 6-channel independent captures.
6546 *
6547 * In addition, an independent DAC for the multi-playback (not used in this
6548 * driver yet).
6549 */
6550#define ALC883_DIGOUT_NID 0x06
6551#define ALC883_DIGIN_NID 0x0a
6552
6553static hda_nid_t alc883_dac_nids[4] = {
6554 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006555 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006556};
6557
6558static hda_nid_t alc883_adc_nids[2] = {
6559 /* ADC1-2 */
6560 0x08, 0x09,
6561};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006562
Takashi Iwaie1406342008-02-11 18:32:32 +01006563static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006565/* input MUX */
6566/* FIXME: should be a matrix-type input source selection */
6567
6568static struct hda_input_mux alc883_capture_source = {
6569 .num_items = 4,
6570 .items = {
6571 { "Mic", 0x0 },
6572 { "Front Mic", 0x1 },
6573 { "Line", 0x2 },
6574 { "CD", 0x4 },
6575 },
6576};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006577
6578static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6579 .num_items = 2,
6580 .items = {
6581 { "Mic", 0x1 },
6582 { "Line", 0x2 },
6583 },
6584};
6585
Kailang Yang272a5272007-05-14 11:00:38 +02006586static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6587 .num_items = 4,
6588 .items = {
6589 { "Mic", 0x0 },
6590 { "iMic", 0x1 },
6591 { "Line", 0x2 },
6592 { "CD", 0x4 },
6593 },
6594};
6595
Jiang zhefb97dc62008-03-06 11:07:11 +01006596static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6597 .num_items = 2,
6598 .items = {
6599 { "Mic", 0x0 },
6600 { "Int Mic", 0x1 },
6601 },
6602};
6603
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006604#define alc883_mux_enum_info alc_mux_enum_info
6605#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006606/* ALC883 has the ALC882-type input selection */
6607#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006608
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006609/*
6610 * 2ch mode
6611 */
6612static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6613 { 2, NULL }
6614};
6615
6616/*
6617 * 2ch mode
6618 */
6619static struct hda_verb alc883_3ST_ch2_init[] = {
6620 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6621 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6624 { } /* end */
6625};
6626
6627/*
Tobin Davisb2011312007-09-17 12:45:11 +02006628 * 4ch mode
6629 */
6630static struct hda_verb alc883_3ST_ch4_init[] = {
6631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6635 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6636 { } /* end */
6637};
6638
6639/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006640 * 6ch mode
6641 */
6642static struct hda_verb alc883_3ST_ch6_init[] = {
6643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6645 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6649 { } /* end */
6650};
6651
Tobin Davisb2011312007-09-17 12:45:11 +02006652static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006653 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006654 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006655 { 6, alc883_3ST_ch6_init },
6656};
6657
6658/*
6659 * 6ch mode
6660 */
6661static struct hda_verb alc883_sixstack_ch6_init[] = {
6662 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6663 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6665 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6666 { } /* end */
6667};
6668
6669/*
6670 * 8ch mode
6671 */
6672static struct hda_verb alc883_sixstack_ch8_init[] = {
6673 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6674 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6675 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6676 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { } /* end */
6678};
6679
6680static struct hda_channel_mode alc883_sixstack_modes[2] = {
6681 { 6, alc883_sixstack_ch6_init },
6682 { 8, alc883_sixstack_ch8_init },
6683};
6684
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006685static struct hda_verb alc883_medion_eapd_verbs[] = {
6686 /* eanable EAPD on medion laptop */
6687 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6688 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6689 { }
6690};
6691
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006692/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6693 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6694 */
6695
6696static struct snd_kcontrol_new alc883_base_mixer[] = {
6697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6700 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6705 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6706 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6708 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6709 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6710 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6711 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006713 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6715 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006716 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006717 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6718 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6719 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6720 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6721 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6722 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6723 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6724 {
6725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6726 /* .name = "Capture Source", */
6727 .name = "Input Source",
6728 .count = 2,
6729 .info = alc883_mux_enum_info,
6730 .get = alc883_mux_enum_get,
6731 .put = alc883_mux_enum_put,
6732 },
6733 { } /* end */
6734};
6735
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006736static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6737 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6738 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6739 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6740 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6745 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6747 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6748 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6749 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6750 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6751 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6752 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6753 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6754 {
6755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6756 /* .name = "Capture Source", */
6757 .name = "Input Source",
6758 .count = 2,
6759 .info = alc883_mux_enum_info,
6760 .get = alc883_mux_enum_get,
6761 .put = alc883_mux_enum_put,
6762 },
6763 { } /* end */
6764};
6765
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01006766static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01006767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6768 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6770 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6775 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6776 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6777 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6778 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6779 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6780 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6781 {
6782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6783 /* .name = "Capture Source", */
6784 .name = "Input Source",
6785 .count = 2,
6786 .info = alc883_mux_enum_info,
6787 .get = alc883_mux_enum_get,
6788 .put = alc883_mux_enum_put,
6789 },
6790 { } /* end */
6791};
6792
Jiang zhefb97dc62008-03-06 11:07:11 +01006793static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6794 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6795 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6797 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6802 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6803 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6806 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6807 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6808 {
6809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6810 /* .name = "Capture Source", */
6811 .name = "Input Source",
6812 .count = 2,
6813 .info = alc883_mux_enum_info,
6814 .get = alc883_mux_enum_get,
6815 .put = alc883_mux_enum_put,
6816 },
6817 { } /* end */
6818};
6819
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006820static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6826 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6827 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006829 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006832 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006833 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6837 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6838 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6839 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6840 {
6841 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6842 /* .name = "Capture Source", */
6843 .name = "Input Source",
6844 .count = 2,
6845 .info = alc883_mux_enum_info,
6846 .get = alc883_mux_enum_get,
6847 .put = alc883_mux_enum_put,
6848 },
6849 { } /* end */
6850};
6851
6852static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6853 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6855 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6856 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6857 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6859 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6860 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6872 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6873 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6874 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6875 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6876 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6877 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6878 {
6879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6880 /* .name = "Capture Source", */
6881 .name = "Input Source",
6882 .count = 2,
6883 .info = alc883_mux_enum_info,
6884 .get = alc883_mux_enum_get,
6885 .put = alc883_mux_enum_put,
6886 },
6887 { } /* end */
6888};
6889
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006890static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6892 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6894 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6895 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6896 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6897 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6898 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6900 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6901 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6902 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6903 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006908 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6910 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6911 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6912 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6913 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6914
6915 {
6916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6917 /* .name = "Capture Source", */
6918 .name = "Input Source",
6919 .count = 1,
6920 .info = alc883_mux_enum_info,
6921 .get = alc883_mux_enum_get,
6922 .put = alc883_mux_enum_put,
6923 },
6924 { } /* end */
6925};
6926
Kailang Yangccc656c2006-10-17 12:32:26 +02006927static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6930 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6932 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6933 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6934 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6935 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6936 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6937 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6938 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6944 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6946 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6947 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6948 {
6949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6950 /* .name = "Capture Source", */
6951 .name = "Input Source",
6952 .count = 2,
6953 .info = alc883_mux_enum_info,
6954 .get = alc883_mux_enum_get,
6955 .put = alc883_mux_enum_put,
6956 },
6957 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006958};
Kailang Yangccc656c2006-10-17 12:32:26 +02006959
6960static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6963 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6964 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6965 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006967 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02006969 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6970 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6971 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006972 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6973 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6974 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6975 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6976 {
6977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6978 /* .name = "Capture Source", */
6979 .name = "Input Source",
6980 .count = 2,
6981 .info = alc883_mux_enum_info,
6982 .get = alc883_mux_enum_get,
6983 .put = alc883_mux_enum_put,
6984 },
6985 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006986};
Kailang Yangccc656c2006-10-17 12:32:26 +02006987
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006988static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6990 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006991 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6992 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6999 {
7000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7001 /* .name = "Capture Source", */
7002 .name = "Input Source",
7003 .count = 1,
7004 .info = alc883_mux_enum_info,
7005 .get = alc883_mux_enum_get,
7006 .put = alc883_mux_enum_put,
7007 },
7008 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007009};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007010
Kailang Yang272a5272007-05-14 11:00:38 +02007011static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7012 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7013 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7015 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7016 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7018 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7019 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7020 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7021 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7023 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7024 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7025 {
7026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7027 /* .name = "Capture Source", */
7028 .name = "Input Source",
7029 .count = 2,
7030 .info = alc883_mux_enum_info,
7031 .get = alc883_mux_enum_get,
7032 .put = alc883_mux_enum_put,
7033 },
7034 { } /* end */
7035};
7036
7037static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7040 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7048 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7049 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7050 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7051 {
7052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7053 /* .name = "Capture Source", */
7054 .name = "Input Source",
7055 .count = 2,
7056 .info = alc883_mux_enum_info,
7057 .get = alc883_mux_enum_get,
7058 .put = alc883_mux_enum_put,
7059 },
7060 { } /* end */
7061};
7062
Tobin Davis2880a8672007-08-07 11:50:26 +02007063static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007064 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7065 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007067 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7068 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007072 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7073 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7074 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7075 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7076 {
7077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7078 /* .name = "Capture Source", */
7079 .name = "Input Source",
7080 .count = 2,
7081 .info = alc883_mux_enum_info,
7082 .get = alc883_mux_enum_get,
7083 .put = alc883_mux_enum_put,
7084 },
7085 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007086};
Tobin Davis2880a8672007-08-07 11:50:26 +02007087
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007088static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7089 {
7090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7091 .name = "Channel Mode",
7092 .info = alc_ch_mode_info,
7093 .get = alc_ch_mode_get,
7094 .put = alc_ch_mode_put,
7095 },
7096 { } /* end */
7097};
7098
7099static struct hda_verb alc883_init_verbs[] = {
7100 /* ADC1: mute amp left and right */
7101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7102 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7103 /* ADC2: mute amp left and right */
7104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7105 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7106 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7110 /* Rear mixer */
7111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7114 /* CLFE mixer */
7115 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7116 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7118 /* Side mixer */
7119 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7122
Takashi Iwaicb53c622007-08-10 17:21:45 +02007123 /* mute analog input loopbacks */
7124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007129
7130 /* Front Pin: output 0 (0x0c) */
7131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7132 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7134 /* Rear Pin: output 1 (0x0d) */
7135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7137 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7138 /* CLFE Pin: output 2 (0x0e) */
7139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7140 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7141 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7142 /* Side Pin: output 3 (0x0f) */
7143 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7144 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7145 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7146 /* Mic (rear) pin: input vref at 80% */
7147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7149 /* Front Mic pin: input vref at 80% */
7150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7152 /* Line In pin: input */
7153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7155 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7158 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7159 /* CD pin widget for input */
7160 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7161
7162 /* FIXME: use matrix-type input source selection */
7163 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7164 /* Input mixer2 */
7165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7168 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7169 /* Input mixer3 */
7170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7174 { }
7175};
7176
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007177/* toggle speaker-output according to the hp-jack state */
7178static void alc883_mitac_hp_automute(struct hda_codec *codec)
7179{
7180 unsigned int present;
7181
7182 present = snd_hda_codec_read(codec, 0x15, 0,
7183 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7184 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7185 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7186 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7187 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7188}
7189
7190/* auto-toggle front mic */
7191/*
7192static void alc883_mitac_mic_automute(struct hda_codec *codec)
7193{
7194 unsigned int present;
7195 unsigned char bits;
7196
7197 present = snd_hda_codec_read(codec, 0x18, 0,
7198 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7199 bits = present ? HDA_AMP_MUTE : 0;
7200 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7201}
7202*/
7203
7204static void alc883_mitac_automute(struct hda_codec *codec)
7205{
7206 alc883_mitac_hp_automute(codec);
7207 /* alc883_mitac_mic_automute(codec); */
7208}
7209
7210static void alc883_mitac_unsol_event(struct hda_codec *codec,
7211 unsigned int res)
7212{
7213 switch (res >> 26) {
7214 case ALC880_HP_EVENT:
7215 alc883_mitac_hp_automute(codec);
7216 break;
7217 case ALC880_MIC_EVENT:
7218 /* alc883_mitac_mic_automute(codec); */
7219 break;
7220 }
7221}
7222
7223static struct hda_verb alc883_mitac_verbs[] = {
7224 /* HP */
7225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7227 /* Subwoofer */
7228 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7229 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7230
7231 /* enable unsolicited event */
7232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7233 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7234
7235 { } /* end */
7236};
7237
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007238static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007239 /* HP */
7240 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7242 /* Int speaker */
7243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7245
7246 /* enable unsolicited event */
7247 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007248 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007249
7250 { } /* end */
7251};
7252
Jiang zhefb97dc62008-03-06 11:07:11 +01007253static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7254 /* HP */
7255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7257 /* Subwoofer */
7258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7260
7261 /* enable unsolicited event */
7262 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7263
7264 { } /* end */
7265};
7266
Kailang Yangccc656c2006-10-17 12:32:26 +02007267static struct hda_verb alc883_tagra_verbs[] = {
7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7270
7271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7273
7274 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7275 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7276 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7277
7278 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007279 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7280 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7281 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007282
7283 { } /* end */
7284};
7285
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007286static struct hda_verb alc883_lenovo_101e_verbs[] = {
7287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7290 { } /* end */
7291};
7292
Kailang Yang272a5272007-05-14 11:00:38 +02007293static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7296 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7298 { } /* end */
7299};
7300
7301static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7305 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7306 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7307 { } /* end */
7308};
7309
Kailang Yang189609a2007-08-20 11:31:23 +02007310static struct hda_verb alc883_haier_w66_verbs[] = {
7311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313
7314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7315
7316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7320 { } /* end */
7321};
7322
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007323static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007324 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007325 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7326 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007327 { }
7328};
7329
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007330static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7332 { }
7333};
7334
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007335static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007336 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7337 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7338 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7339 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7340 { }
7341};
7342
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007343static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007344 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7345 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7346 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7347 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7348 { }
7349};
7350
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007351static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7352 { 2, alc888_3st_hp_2ch_init },
7353 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007354};
7355
Kailang Yang272a5272007-05-14 11:00:38 +02007356/* toggle front-jack and RCA according to the hp-jack state */
7357static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7358{
7359 unsigned int present;
7360
7361 present = snd_hda_codec_read(codec, 0x1b, 0,
7362 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007363 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7364 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7365 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7366 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007367}
7368
7369/* toggle RCA according to the front-jack state */
7370static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7371{
7372 unsigned int present;
7373
7374 present = snd_hda_codec_read(codec, 0x14, 0,
7375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007376 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7377 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007378}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007379
Kailang Yang272a5272007-05-14 11:00:38 +02007380static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7381 unsigned int res)
7382{
7383 if ((res >> 26) == ALC880_HP_EVENT)
7384 alc888_lenovo_ms7195_front_automute(codec);
7385 if ((res >> 26) == ALC880_FRONT_EVENT)
7386 alc888_lenovo_ms7195_rca_automute(codec);
7387}
7388
7389static struct hda_verb alc883_medion_md2_verbs[] = {
7390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7392
7393 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7394
7395 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7396 { } /* end */
7397};
7398
7399/* toggle speaker-output according to the hp-jack state */
7400static void alc883_medion_md2_automute(struct hda_codec *codec)
7401{
7402 unsigned int present;
7403
7404 present = snd_hda_codec_read(codec, 0x14, 0,
7405 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007406 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7407 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007408}
7409
7410static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7411 unsigned int res)
7412{
7413 if ((res >> 26) == ALC880_HP_EVENT)
7414 alc883_medion_md2_automute(codec);
7415}
7416
Kailang Yangccc656c2006-10-17 12:32:26 +02007417/* toggle speaker-output according to the hp-jack state */
7418static void alc883_tagra_automute(struct hda_codec *codec)
7419{
7420 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007421 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007422
7423 present = snd_hda_codec_read(codec, 0x14, 0,
7424 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007425 bits = present ? HDA_AMP_MUTE : 0;
7426 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7427 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007428 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7429 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007430}
7431
7432static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7433{
7434 if ((res >> 26) == ALC880_HP_EVENT)
7435 alc883_tagra_automute(codec);
7436}
7437
Jiang zhe368c7a92008-03-04 11:20:33 +01007438/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007439static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007440{
7441 unsigned int present;
7442 unsigned char bits;
7443
7444 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7445 & AC_PINSENSE_PRESENCE;
7446 bits = present ? HDA_AMP_MUTE : 0;
7447 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7448 HDA_AMP_MUTE, bits);
7449}
7450
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007451static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7452{
7453 unsigned int present;
7454
7455 present = snd_hda_codec_read(codec, 0x18, 0,
7456 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7457 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7459}
7460
7461static void alc883_clevo_m720_automute(struct hda_codec *codec)
7462{
7463 alc883_clevo_m720_hp_automute(codec);
7464 alc883_clevo_m720_mic_automute(codec);
7465}
7466
7467static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007468 unsigned int res)
7469{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007470 switch (res >> 26) {
7471 case ALC880_HP_EVENT:
7472 alc883_clevo_m720_hp_automute(codec);
7473 break;
7474 case ALC880_MIC_EVENT:
7475 alc883_clevo_m720_mic_automute(codec);
7476 break;
7477 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007478}
7479
Jiang zhefb97dc62008-03-06 11:07:11 +01007480/* toggle speaker-output according to the hp-jack state */
7481static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7482{
7483 unsigned int present;
7484 unsigned char bits;
7485
7486 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7487 & AC_PINSENSE_PRESENCE;
7488 bits = present ? HDA_AMP_MUTE : 0;
7489 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7490 HDA_AMP_MUTE, bits);
7491}
7492
7493static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7494 unsigned int res)
7495{
7496 if ((res >> 26) == ALC880_HP_EVENT)
7497 alc883_2ch_fujitsu_pi2515_automute(codec);
7498}
7499
Kailang Yang189609a2007-08-20 11:31:23 +02007500static void alc883_haier_w66_automute(struct hda_codec *codec)
7501{
7502 unsigned int present;
7503 unsigned char bits;
7504
7505 present = snd_hda_codec_read(codec, 0x1b, 0,
7506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7507 bits = present ? 0x80 : 0;
7508 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7509 0x80, bits);
7510}
7511
7512static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7513 unsigned int res)
7514{
7515 if ((res >> 26) == ALC880_HP_EVENT)
7516 alc883_haier_w66_automute(codec);
7517}
7518
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007519static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7520{
7521 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007522 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007523
7524 present = snd_hda_codec_read(codec, 0x14, 0,
7525 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007526 bits = present ? HDA_AMP_MUTE : 0;
7527 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7528 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007529}
7530
7531static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7532{
7533 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007534 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007535
7536 present = snd_hda_codec_read(codec, 0x1b, 0,
7537 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007538 bits = present ? HDA_AMP_MUTE : 0;
7539 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7540 HDA_AMP_MUTE, bits);
7541 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7542 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007543}
7544
7545static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7546 unsigned int res)
7547{
7548 if ((res >> 26) == ALC880_HP_EVENT)
7549 alc883_lenovo_101e_all_automute(codec);
7550 if ((res >> 26) == ALC880_FRONT_EVENT)
7551 alc883_lenovo_101e_ispeaker_automute(codec);
7552}
7553
Takashi Iwai676a9b52007-08-16 15:23:35 +02007554/* toggle speaker-output according to the hp-jack state */
7555static void alc883_acer_aspire_automute(struct hda_codec *codec)
7556{
7557 unsigned int present;
7558
7559 present = snd_hda_codec_read(codec, 0x14, 0,
7560 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7562 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7563 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7564 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7565}
7566
7567static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7568 unsigned int res)
7569{
7570 if ((res >> 26) == ALC880_HP_EVENT)
7571 alc883_acer_aspire_automute(codec);
7572}
7573
Kailang Yangd1a991a2007-08-15 16:21:59 +02007574static struct hda_verb alc883_acer_eapd_verbs[] = {
7575 /* HP Pin: output 0 (0x0c) */
7576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7578 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7579 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007582 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007583 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7584 /* eanable EAPD on medion laptop */
7585 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7586 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007587 /* enable unsolicited event */
7588 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007589 { }
7590};
7591
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007592static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7593{
7594 unsigned int present;
7595
7596 present = snd_hda_codec_read(codec, 0x1b, 0,
7597 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7598 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7599 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7600 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7601 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7602 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7604 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7605 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7606}
7607
7608static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7609 unsigned int res)
7610{
7611 switch (res >> 26) {
7612 case ALC880_HP_EVENT:
7613 printk("hp_event\n");
7614 alc888_6st_dell_front_automute(codec);
7615 break;
7616 }
7617}
7618
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007619/*
7620 * generic initialization of ADC, input mixers and output mixers
7621 */
7622static struct hda_verb alc883_auto_init_verbs[] = {
7623 /*
7624 * Unmute ADC0-2 and set the default input to mic-in
7625 */
7626 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7628 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7630
Takashi Iwaicb53c622007-08-10 17:21:45 +02007631 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007632 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007633 * Note: PASD motherboards uses the Line In 2 as the input for
7634 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007635 */
7636 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007642
7643 /*
7644 * Set up output mixers (0x0c - 0x0f)
7645 */
7646 /* set vol=0 to output mixers */
7647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7651 /* set up input amps for analog loopback */
7652 /* Amp Indices: DAC = 0, mixer = 1 */
7653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7661 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663
7664 /* FIXME: use matrix-type input source selection */
7665 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7666 /* Input mixer1 */
7667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007670 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7672 /* Input mixer2 */
7673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007676 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007678
7679 { }
7680};
7681
7682/* capture mixer elements */
7683static struct snd_kcontrol_new alc883_capture_mixer[] = {
7684 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7685 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7686 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7687 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7688 {
7689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7690 /* The multiple "Capture Source" controls confuse alsamixer
7691 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007692 */
7693 /* .name = "Capture Source", */
7694 .name = "Input Source",
7695 .count = 2,
7696 .info = alc882_mux_enum_info,
7697 .get = alc882_mux_enum_get,
7698 .put = alc882_mux_enum_put,
7699 },
7700 { } /* end */
7701};
7702
Takashi Iwaicb53c622007-08-10 17:21:45 +02007703#ifdef CONFIG_SND_HDA_POWER_SAVE
7704#define alc883_loopbacks alc880_loopbacks
7705#endif
7706
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007707/* pcm configuration: identiacal with ALC880 */
7708#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7709#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007710#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007711#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7712#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7713
7714/*
7715 * configuration and preset
7716 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007717static const char *alc883_models[ALC883_MODEL_LAST] = {
7718 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7719 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7720 [ALC883_3ST_6ch] = "3stack-6ch",
7721 [ALC883_6ST_DIG] = "6stack-dig",
7722 [ALC883_TARGA_DIG] = "targa-dig",
7723 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007724 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02007725 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007726 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007727 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007728 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007729 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007730 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7731 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007732 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007733 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007734 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007735 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007736 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01007737 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007738 [ALC883_AUTO] = "auto",
7739};
7740
7741static struct snd_pci_quirk alc883_cfg_tbl[] = {
7742 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007743 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7744 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7745 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7746 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007747 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02007748 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007749 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7750 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01007751 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007752 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02007753 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007754 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007755 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7756 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7757 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02007758 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007759 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7760 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7761 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02007762 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007763 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01007764 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007765 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7766 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7767 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7768 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7769 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7770 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7771 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7772 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7773 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007774 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7775 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007776 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01007777 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007778 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007779 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007780 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007781 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007782 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7783 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007784 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04007785 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007786 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01007787 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02007788 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007789 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007790 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7791 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02007792 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01007793 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02007794 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007795 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007796 {}
7797};
7798
7799static struct alc_config_preset alc883_presets[] = {
7800 [ALC883_3ST_2ch_DIG] = {
7801 .mixers = { alc883_3ST_2ch_mixer },
7802 .init_verbs = { alc883_init_verbs },
7803 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7804 .dac_nids = alc883_dac_nids,
7805 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007806 .dig_in_nid = ALC883_DIGIN_NID,
7807 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7808 .channel_mode = alc883_3ST_2ch_modes,
7809 .input_mux = &alc883_capture_source,
7810 },
7811 [ALC883_3ST_6ch_DIG] = {
7812 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7813 .init_verbs = { alc883_init_verbs },
7814 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7815 .dac_nids = alc883_dac_nids,
7816 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007817 .dig_in_nid = ALC883_DIGIN_NID,
7818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7819 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007820 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007821 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007822 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007823 [ALC883_3ST_6ch] = {
7824 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7825 .init_verbs = { alc883_init_verbs },
7826 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7827 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007828 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7829 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007830 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007832 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007833 [ALC883_6ST_DIG] = {
7834 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7835 .init_verbs = { alc883_init_verbs },
7836 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7837 .dac_nids = alc883_dac_nids,
7838 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007839 .dig_in_nid = ALC883_DIGIN_NID,
7840 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7841 .channel_mode = alc883_sixstack_modes,
7842 .input_mux = &alc883_capture_source,
7843 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007844 [ALC883_TARGA_DIG] = {
7845 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7846 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7847 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7848 .dac_nids = alc883_dac_nids,
7849 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007850 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7851 .channel_mode = alc883_3ST_6ch_modes,
7852 .need_dac_fix = 1,
7853 .input_mux = &alc883_capture_source,
7854 .unsol_event = alc883_tagra_unsol_event,
7855 .init_hook = alc883_tagra_automute,
7856 },
7857 [ALC883_TARGA_2ch_DIG] = {
7858 .mixers = { alc883_tagra_2ch_mixer},
7859 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7860 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7861 .dac_nids = alc883_dac_nids,
7862 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02007863 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7864 .channel_mode = alc883_3ST_2ch_modes,
7865 .input_mux = &alc883_capture_source,
7866 .unsol_event = alc883_tagra_unsol_event,
7867 .init_hook = alc883_tagra_automute,
7868 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007869 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007870 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007871 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7872 * and the headphone jack. Turn this on and rely on the
7873 * standard mute methods whenever the user wants to turn
7874 * these outputs off.
7875 */
7876 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7877 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7878 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02007879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7880 .channel_mode = alc883_3ST_2ch_modes,
7881 .input_mux = &alc883_capture_source,
7882 },
Tobin Davis2880a8672007-08-07 11:50:26 +02007883 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007884 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007885 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02007886 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7887 .dac_nids = alc883_dac_nids,
7888 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02007889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7890 .channel_mode = alc883_3ST_2ch_modes,
7891 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007892 .unsol_event = alc883_acer_aspire_unsol_event,
7893 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007894 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007895 [ALC883_MEDION] = {
7896 .mixers = { alc883_fivestack_mixer,
7897 alc883_chmode_mixer },
7898 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007899 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007900 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7901 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02007902 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7903 .channel_mode = alc883_sixstack_modes,
7904 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007905 },
Kailang Yang272a5272007-05-14 11:00:38 +02007906 [ALC883_MEDION_MD2] = {
7907 .mixers = { alc883_medion_md2_mixer},
7908 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7909 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7910 .dac_nids = alc883_dac_nids,
7911 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007912 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7913 .channel_mode = alc883_3ST_2ch_modes,
7914 .input_mux = &alc883_capture_source,
7915 .unsol_event = alc883_medion_md2_unsol_event,
7916 .init_hook = alc883_medion_md2_automute,
7917 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007918 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007919 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007920 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7921 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7922 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007923 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7924 .channel_mode = alc883_3ST_2ch_modes,
7925 .input_mux = &alc883_capture_source,
7926 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007927 [ALC883_CLEVO_M720] = {
7928 .mixers = { alc883_clevo_m720_mixer },
7929 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01007930 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7931 .dac_nids = alc883_dac_nids,
7932 .dig_out_nid = ALC883_DIGOUT_NID,
7933 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7934 .channel_mode = alc883_3ST_2ch_modes,
7935 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007936 .unsol_event = alc883_clevo_m720_unsol_event,
7937 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01007938 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007939 [ALC883_LENOVO_101E_2ch] = {
7940 .mixers = { alc883_lenovo_101e_2ch_mixer},
7941 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7942 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7943 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007944 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7945 .channel_mode = alc883_3ST_2ch_modes,
7946 .input_mux = &alc883_lenovo_101e_capture_source,
7947 .unsol_event = alc883_lenovo_101e_unsol_event,
7948 .init_hook = alc883_lenovo_101e_all_automute,
7949 },
Kailang Yang272a5272007-05-14 11:00:38 +02007950 [ALC883_LENOVO_NB0763] = {
7951 .mixers = { alc883_lenovo_nb0763_mixer },
7952 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7953 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7954 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007955 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7956 .channel_mode = alc883_3ST_2ch_modes,
7957 .need_dac_fix = 1,
7958 .input_mux = &alc883_lenovo_nb0763_capture_source,
7959 .unsol_event = alc883_medion_md2_unsol_event,
7960 .init_hook = alc883_medion_md2_automute,
7961 },
7962 [ALC888_LENOVO_MS7195_DIG] = {
7963 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7964 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7965 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7966 .dac_nids = alc883_dac_nids,
7967 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02007968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7969 .channel_mode = alc883_3ST_6ch_modes,
7970 .need_dac_fix = 1,
7971 .input_mux = &alc883_capture_source,
7972 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7973 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007974 },
7975 [ALC883_HAIER_W66] = {
7976 .mixers = { alc883_tagra_2ch_mixer},
7977 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7978 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7979 .dac_nids = alc883_dac_nids,
7980 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02007981 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7982 .channel_mode = alc883_3ST_2ch_modes,
7983 .input_mux = &alc883_capture_source,
7984 .unsol_event = alc883_haier_w66_unsol_event,
7985 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01007986 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007987 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01007988 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007989 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007990 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7991 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007992 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7993 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007994 .need_dac_fix = 1,
7995 .input_mux = &alc883_capture_source,
7996 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007997 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01007998 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007999 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8001 .dac_nids = alc883_dac_nids,
8002 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008003 .dig_in_nid = ALC883_DIGIN_NID,
8004 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8005 .channel_mode = alc883_sixstack_modes,
8006 .input_mux = &alc883_capture_source,
8007 .unsol_event = alc888_6st_dell_unsol_event,
8008 .init_hook = alc888_6st_dell_front_automute,
8009 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008010 [ALC883_MITAC] = {
8011 .mixers = { alc883_mitac_mixer },
8012 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8013 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8014 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008015 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8016 .channel_mode = alc883_3ST_2ch_modes,
8017 .input_mux = &alc883_capture_source,
8018 .unsol_event = alc883_mitac_unsol_event,
8019 .init_hook = alc883_mitac_automute,
8020 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008021 [ALC883_FUJITSU_PI2515] = {
8022 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8023 .init_verbs = { alc883_init_verbs,
8024 alc883_2ch_fujitsu_pi2515_verbs},
8025 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8026 .dac_nids = alc883_dac_nids,
8027 .dig_out_nid = ALC883_DIGOUT_NID,
8028 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8029 .channel_mode = alc883_3ST_2ch_modes,
8030 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8031 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8032 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8033 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008034};
8035
8036
8037/*
8038 * BIOS auto configuration
8039 */
8040static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8041 hda_nid_t nid, int pin_type,
8042 int dac_idx)
8043{
8044 /* set as output */
8045 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008046 int idx;
8047
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008048 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008049 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8050 idx = 4;
8051 else
8052 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008053 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8054
8055}
8056
8057static void alc883_auto_init_multi_out(struct hda_codec *codec)
8058{
8059 struct alc_spec *spec = codec->spec;
8060 int i;
8061
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008062 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008063 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008064 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008065 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008066 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008067 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008068 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008069 }
8070}
8071
8072static void alc883_auto_init_hp_out(struct hda_codec *codec)
8073{
8074 struct alc_spec *spec = codec->spec;
8075 hda_nid_t pin;
8076
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008077 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008078 if (pin) /* connect to front */
8079 /* use dac 0 */
8080 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008081 pin = spec->autocfg.speaker_pins[0];
8082 if (pin)
8083 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008084}
8085
8086#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8087#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8088
8089static void alc883_auto_init_analog_input(struct hda_codec *codec)
8090{
8091 struct alc_spec *spec = codec->spec;
8092 int i;
8093
8094 for (i = 0; i < AUTO_PIN_LAST; i++) {
8095 hda_nid_t nid = spec->autocfg.input_pins[i];
8096 if (alc883_is_input_pin(nid)) {
8097 snd_hda_codec_write(codec, nid, 0,
8098 AC_VERB_SET_PIN_WIDGET_CONTROL,
8099 (i <= AUTO_PIN_FRONT_MIC ?
8100 PIN_VREF80 : PIN_IN));
8101 if (nid != ALC883_PIN_CD_NID)
8102 snd_hda_codec_write(codec, nid, 0,
8103 AC_VERB_SET_AMP_GAIN_MUTE,
8104 AMP_OUT_MUTE);
8105 }
8106 }
8107}
8108
8109/* almost identical with ALC880 parser... */
8110static int alc883_parse_auto_config(struct hda_codec *codec)
8111{
8112 struct alc_spec *spec = codec->spec;
8113 int err = alc880_parse_auto_config(codec);
8114
8115 if (err < 0)
8116 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008117 else if (!err)
8118 return 0; /* no config found */
8119
8120 err = alc_auto_add_mic_boost(codec);
8121 if (err < 0)
8122 return err;
8123
8124 /* hack - override the init verbs */
8125 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008126 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8127 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008128
8129 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008130}
8131
8132/* additional initialization for auto-configuration model */
8133static void alc883_auto_init(struct hda_codec *codec)
8134{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008135 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008136 alc883_auto_init_multi_out(codec);
8137 alc883_auto_init_hp_out(codec);
8138 alc883_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008139 if (spec->unsol_event)
8140 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008141}
8142
8143static int patch_alc883(struct hda_codec *codec)
8144{
8145 struct alc_spec *spec;
8146 int err, board_config;
8147
8148 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8149 if (spec == NULL)
8150 return -ENOMEM;
8151
8152 codec->spec = spec;
8153
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008154 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8155 alc883_models,
8156 alc883_cfg_tbl);
8157 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008158 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8159 "trying auto-probe from BIOS...\n");
8160 board_config = ALC883_AUTO;
8161 }
8162
8163 if (board_config == ALC883_AUTO) {
8164 /* automatic parse from the BIOS config */
8165 err = alc883_parse_auto_config(codec);
8166 if (err < 0) {
8167 alc_free(codec);
8168 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008169 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008170 printk(KERN_INFO
8171 "hda_codec: Cannot set up configuration "
8172 "from BIOS. Using base mode...\n");
8173 board_config = ALC883_3ST_2ch_DIG;
8174 }
8175 }
8176
8177 if (board_config != ALC883_AUTO)
8178 setup_preset(spec, &alc883_presets[board_config]);
8179
8180 spec->stream_name_analog = "ALC883 Analog";
8181 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8182 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008183 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008184
8185 spec->stream_name_digital = "ALC883 Digital";
8186 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8187 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8188
Takashi Iwaie1406342008-02-11 18:32:32 +01008189 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8190 spec->adc_nids = alc883_adc_nids;
8191 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008192
Takashi Iwai2134ea42008-01-10 16:53:55 +01008193 spec->vmaster_nid = 0x0c;
8194
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008195 codec->patch_ops = alc_patch_ops;
8196 if (board_config == ALC883_AUTO)
8197 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008198#ifdef CONFIG_SND_HDA_POWER_SAVE
8199 if (!spec->loopback.amplist)
8200 spec->loopback.amplist = alc883_loopbacks;
8201#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008202
8203 return 0;
8204}
8205
8206/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008207 * ALC262 support
8208 */
8209
8210#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8211#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8212
8213#define alc262_dac_nids alc260_dac_nids
8214#define alc262_adc_nids alc882_adc_nids
8215#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008216#define alc262_capsrc_nids alc882_capsrc_nids
8217#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008218
8219#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008220#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008221
8222static struct snd_kcontrol_new alc262_base_mixer[] = {
8223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8224 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008232 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8233 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008234 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008235 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008236 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008237 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8239 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8240 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008241 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008242};
8243
Kailang Yangccc656c2006-10-17 12:32:26 +02008244static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8246 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8247 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8248 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008254 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8255 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008256 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008257 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008258 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008259 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8261 { } /* end */
8262};
8263
Takashi Iwaice875f02008-01-28 18:17:43 +01008264/* update HP, line and mono-out pins according to the master switch */
8265static void alc262_hp_master_update(struct hda_codec *codec)
8266{
8267 struct alc_spec *spec = codec->spec;
8268 int val = spec->master_sw;
8269
8270 /* HP & line-out */
8271 snd_hda_codec_write_cache(codec, 0x1b, 0,
8272 AC_VERB_SET_PIN_WIDGET_CONTROL,
8273 val ? PIN_HP : 0);
8274 snd_hda_codec_write_cache(codec, 0x15, 0,
8275 AC_VERB_SET_PIN_WIDGET_CONTROL,
8276 val ? PIN_HP : 0);
8277 /* mono (speaker) depending on the HP jack sense */
8278 val = val && !spec->jack_present;
8279 snd_hda_codec_write_cache(codec, 0x16, 0,
8280 AC_VERB_SET_PIN_WIDGET_CONTROL,
8281 val ? PIN_OUT : 0);
8282}
8283
8284static void alc262_hp_bpc_automute(struct hda_codec *codec)
8285{
8286 struct alc_spec *spec = codec->spec;
8287 unsigned int presence;
8288 presence = snd_hda_codec_read(codec, 0x1b, 0,
8289 AC_VERB_GET_PIN_SENSE, 0);
8290 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8291 alc262_hp_master_update(codec);
8292}
8293
8294static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8295{
8296 if ((res >> 26) != ALC880_HP_EVENT)
8297 return;
8298 alc262_hp_bpc_automute(codec);
8299}
8300
8301static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8302{
8303 struct alc_spec *spec = codec->spec;
8304 unsigned int presence;
8305 presence = snd_hda_codec_read(codec, 0x15, 0,
8306 AC_VERB_GET_PIN_SENSE, 0);
8307 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8308 alc262_hp_master_update(codec);
8309}
8310
8311static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8312 unsigned int res)
8313{
8314 if ((res >> 26) != ALC880_HP_EVENT)
8315 return;
8316 alc262_hp_wildwest_automute(codec);
8317}
8318
8319static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8320 struct snd_ctl_elem_value *ucontrol)
8321{
8322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8323 struct alc_spec *spec = codec->spec;
8324 *ucontrol->value.integer.value = spec->master_sw;
8325 return 0;
8326}
8327
8328static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8329 struct snd_ctl_elem_value *ucontrol)
8330{
8331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8332 struct alc_spec *spec = codec->spec;
8333 int val = !!*ucontrol->value.integer.value;
8334
8335 if (val == spec->master_sw)
8336 return 0;
8337 spec->master_sw = val;
8338 alc262_hp_master_update(codec);
8339 return 1;
8340}
8341
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008342static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008343 {
8344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8345 .name = "Master Playback Switch",
8346 .info = snd_ctl_boolean_mono_info,
8347 .get = alc262_hp_master_sw_get,
8348 .put = alc262_hp_master_sw_put,
8349 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8351 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008353 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8354 HDA_OUTPUT),
8355 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8356 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008359 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008360 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8361 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008362 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008363 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8364 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8365 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8366 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8367 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8368 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8369 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8370 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8371 { } /* end */
8372};
8373
Kailang Yangcd7509a2007-01-26 18:33:17 +01008374static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008375 {
8376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8377 .name = "Master Playback Switch",
8378 .info = snd_ctl_boolean_mono_info,
8379 .get = alc262_hp_master_sw_get,
8380 .put = alc262_hp_master_sw_put,
8381 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008382 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8383 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8384 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008386 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8387 HDA_OUTPUT),
8388 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8389 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008392 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8395 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8396 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8397 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8398 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8399 { } /* end */
8400};
8401
8402static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8403 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8404 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008405 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008406 { } /* end */
8407};
8408
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008409/* mute/unmute internal speaker according to the hp jack and mute state */
8410static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8411{
8412 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008413
8414 if (force || !spec->sense_updated) {
8415 unsigned int present;
8416 present = snd_hda_codec_read(codec, 0x15, 0,
8417 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008418 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008419 spec->sense_updated = 1;
8420 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008421 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8422 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008423}
8424
8425static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8426 unsigned int res)
8427{
8428 if ((res >> 26) != ALC880_HP_EVENT)
8429 return;
8430 alc262_hp_t5735_automute(codec, 1);
8431}
8432
8433static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8434{
8435 alc262_hp_t5735_automute(codec, 1);
8436}
8437
8438static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008439 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008441 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8446 { } /* end */
8447};
8448
8449static struct hda_verb alc262_hp_t5735_verbs[] = {
8450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8452
8453 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8454 { }
8455};
8456
Kailang Yang8c427222008-01-10 13:03:59 +01008457static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008460 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8461 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8464 { } /* end */
8465};
8466
8467static struct hda_verb alc262_hp_rp5700_verbs[] = {
8468 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8473 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8478 {}
8479};
8480
8481static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8482 .num_items = 1,
8483 .items = {
8484 { "Line", 0x1 },
8485 },
8486};
8487
Takashi Iwai0724ea22007-08-23 00:31:43 +02008488/* bind hp and internal speaker mute (with plug check) */
8489static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8490 struct snd_ctl_elem_value *ucontrol)
8491{
8492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8493 long *valp = ucontrol->value.integer.value;
8494 int change;
8495
8496 /* change hp mute */
8497 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8498 HDA_AMP_MUTE,
8499 valp[0] ? 0 : HDA_AMP_MUTE);
8500 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8501 HDA_AMP_MUTE,
8502 valp[1] ? 0 : HDA_AMP_MUTE);
8503 if (change) {
8504 /* change speaker according to HP jack state */
8505 struct alc_spec *spec = codec->spec;
8506 unsigned int mute;
8507 if (spec->jack_present)
8508 mute = HDA_AMP_MUTE;
8509 else
8510 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8511 HDA_OUTPUT, 0);
8512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8513 HDA_AMP_MUTE, mute);
8514 }
8515 return change;
8516}
Takashi Iwai5b319542007-07-26 11:49:22 +02008517
Kailang Yang272a5272007-05-14 11:00:38 +02008518static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008519 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8520 {
8521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8522 .name = "Master Playback Switch",
8523 .info = snd_hda_mixer_amp_switch_info,
8524 .get = snd_hda_mixer_amp_switch_get,
8525 .put = alc262_sony_master_sw_put,
8526 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8527 },
Kailang Yang272a5272007-05-14 11:00:38 +02008528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8530 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8531 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8532 { } /* end */
8533};
8534
Kailang Yang83c34212007-07-05 11:43:05 +02008535static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8536 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8537 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8538 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8541 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8542 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8543 { } /* end */
8544};
Kailang Yang272a5272007-05-14 11:00:38 +02008545
Kailang Yangdf694da2005-12-05 19:42:22 +01008546#define alc262_capture_mixer alc882_capture_mixer
8547#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8548
8549/*
8550 * generic initialization of ADC, input mixers and output mixers
8551 */
8552static struct hda_verb alc262_init_verbs[] = {
8553 /*
8554 * Unmute ADC0-2 and set the default input to mic-in
8555 */
8556 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8558 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8560 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8562
Takashi Iwaicb53c622007-08-10 17:21:45 +02008563 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008564 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008565 * Note: PASD motherboards uses the Line In 2 as the input for
8566 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008567 */
8568 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008574
8575 /*
8576 * Set up output mixers (0x0c - 0x0e)
8577 */
8578 /* set vol=0 to output mixers */
8579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8582 /* set up input amps for analog loopback */
8583 /* Amp Indices: DAC = 0, mixer = 1 */
8584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8587 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8590
8591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8593 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8596 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8597
8598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8603
8604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8606
8607 /* FIXME: use matrix-type input source selection */
8608 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8609 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8614 /* Input mixer2 */
8615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8619 /* Input mixer3 */
8620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008624
8625 { }
8626};
8627
Kailang Yangccc656c2006-10-17 12:32:26 +02008628static struct hda_verb alc262_hippo_unsol_verbs[] = {
8629 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8631 {}
8632};
8633
8634static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8635 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8636 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8637 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8638
8639 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8641 {}
8642};
8643
Kailang Yang272a5272007-05-14 11:00:38 +02008644static struct hda_verb alc262_sony_unsol_verbs[] = {
8645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8646 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8648
8649 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008651 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008652};
8653
Kailang Yangccc656c2006-10-17 12:32:26 +02008654/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02008655static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008656{
8657 struct alc_spec *spec = codec->spec;
8658 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008659 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008660
Takashi Iwai5b319542007-07-26 11:49:22 +02008661 /* need to execute and sync at first */
8662 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8663 present = snd_hda_codec_read(codec, 0x15, 0,
8664 AC_VERB_GET_PIN_SENSE, 0);
8665 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02008666 if (spec->jack_present) {
8667 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8669 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008670 } else {
8671 /* unmute internal speaker if necessary */
8672 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008673 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8674 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008675 }
8676}
8677
8678/* unsolicited event for HP jack sensing */
8679static void alc262_hippo_unsol_event(struct hda_codec *codec,
8680 unsigned int res)
8681{
8682 if ((res >> 26) != ALC880_HP_EVENT)
8683 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008684 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008685}
8686
Takashi Iwai5b319542007-07-26 11:49:22 +02008687static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02008688{
Kailang Yangccc656c2006-10-17 12:32:26 +02008689 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02008690 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02008691
Takashi Iwai5b319542007-07-26 11:49:22 +02008692 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8693 present = snd_hda_codec_read(codec, 0x1b, 0,
8694 AC_VERB_GET_PIN_SENSE, 0);
8695 present = (present & 0x80000000) != 0;
8696 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02008697 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02008698 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8699 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02008700 } else {
8701 /* unmute internal speaker if necessary */
8702 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02008703 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8704 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02008705 }
8706}
8707
8708/* unsolicited event for HP jack sensing */
8709static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8710 unsigned int res)
8711{
8712 if ((res >> 26) != ALC880_HP_EVENT)
8713 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02008714 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02008715}
8716
Takashi Iwai834be882006-03-01 14:16:17 +01008717/*
8718 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01008719 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8720 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01008721 */
8722
8723#define ALC_HP_EVENT 0x37
8724
8725static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8726 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01008728 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01008730 {}
8731};
8732
Jiang zhe0e31daf2008-03-20 12:12:39 +01008733static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8734 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8736 {}
8737};
8738
Takashi Iwai834be882006-03-01 14:16:17 +01008739static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008740 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01008741 .items = {
8742 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008743 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01008744 { "CD", 0x4 },
8745 },
8746};
8747
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008748static struct hda_input_mux alc262_HP_capture_source = {
8749 .num_items = 5,
8750 .items = {
8751 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02008752 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008753 { "Line", 0x2 },
8754 { "CD", 0x4 },
8755 { "AUX IN", 0x6 },
8756 },
8757};
8758
zhejiangaccbe492007-08-31 12:36:05 +02008759static struct hda_input_mux alc262_HP_D7000_capture_source = {
8760 .num_items = 4,
8761 .items = {
8762 { "Mic", 0x0 },
8763 { "Front Mic", 0x2 },
8764 { "Line", 0x1 },
8765 { "CD", 0x4 },
8766 },
8767};
8768
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008769/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01008770static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8771{
8772 struct alc_spec *spec = codec->spec;
8773 unsigned int mute;
8774
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008775 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008776 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01008777 /* need to execute and sync at first */
8778 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008779 /* check laptop HP jack */
8780 present = snd_hda_codec_read(codec, 0x14, 0,
8781 AC_VERB_GET_PIN_SENSE, 0);
8782 /* need to execute and sync at first */
8783 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8784 /* check docking HP jack */
8785 present |= snd_hda_codec_read(codec, 0x1b, 0,
8786 AC_VERB_GET_PIN_SENSE, 0);
8787 if (present & AC_PINSENSE_PRESENCE)
8788 spec->jack_present = 1;
8789 else
8790 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01008791 spec->sense_updated = 1;
8792 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008793 /* unmute internal speaker only if both HPs are unplugged and
8794 * master switch is on
8795 */
8796 if (spec->jack_present)
8797 mute = HDA_AMP_MUTE;
8798 else
Takashi Iwai834be882006-03-01 14:16:17 +01008799 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008800 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8801 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01008802}
8803
8804/* unsolicited event for HP jack sensing */
8805static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8806 unsigned int res)
8807{
8808 if ((res >> 26) != ALC_HP_EVENT)
8809 return;
8810 alc262_fujitsu_automute(codec, 1);
8811}
8812
Takashi Iwaiebc7a402008-05-20 09:23:05 +02008813static void alc262_fujitsu_init_hook(struct hda_codec *codec)
8814{
8815 alc262_fujitsu_automute(codec, 1);
8816}
8817
Takashi Iwai834be882006-03-01 14:16:17 +01008818/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02008819static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8820 .ops = &snd_hda_bind_vol,
8821 .values = {
8822 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8823 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8824 0
8825 },
8826};
Takashi Iwai834be882006-03-01 14:16:17 +01008827
Jiang zhe0e31daf2008-03-20 12:12:39 +01008828/* mute/unmute internal speaker according to the hp jack and mute state */
8829static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
8830{
8831 struct alc_spec *spec = codec->spec;
8832 unsigned int mute;
8833
8834 if (force || !spec->sense_updated) {
8835 unsigned int present_int_hp;
8836 /* need to execute and sync at first */
8837 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8838 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
8839 AC_VERB_GET_PIN_SENSE, 0);
8840 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8841 spec->sense_updated = 1;
8842 }
8843 if (spec->jack_present) {
8844 /* mute internal speaker */
8845 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8846 HDA_AMP_MUTE, HDA_AMP_MUTE);
8847 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8848 HDA_AMP_MUTE, HDA_AMP_MUTE);
8849 } else {
8850 /* unmute internal speaker if necessary */
8851 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8852 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8853 HDA_AMP_MUTE, mute);
8854 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8855 HDA_AMP_MUTE, mute);
8856 }
8857}
8858
8859/* unsolicited event for HP jack sensing */
8860static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
8861 unsigned int res)
8862{
8863 if ((res >> 26) != ALC_HP_EVENT)
8864 return;
8865 alc262_lenovo_3000_automute(codec, 1);
8866}
8867
Takashi Iwai834be882006-03-01 14:16:17 +01008868/* bind hp and internal speaker mute (with plug check) */
8869static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8870 struct snd_ctl_elem_value *ucontrol)
8871{
8872 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8873 long *valp = ucontrol->value.integer.value;
8874 int change;
8875
Tony Vroon5d9fab22008-03-14 17:09:18 +01008876 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8877 HDA_AMP_MUTE,
8878 valp ? 0 : HDA_AMP_MUTE);
8879 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8880 HDA_AMP_MUTE,
8881 valp ? 0 : HDA_AMP_MUTE);
8882
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008883 if (change)
8884 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01008885 return change;
8886}
8887
8888static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02008889 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01008890 {
8891 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8892 .name = "Master Playback Switch",
8893 .info = snd_hda_mixer_amp_switch_info,
8894 .get = snd_hda_mixer_amp_switch_get,
8895 .put = alc262_fujitsu_master_sw_put,
8896 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8897 },
8898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02008900 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
8901 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008902 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008905 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8906 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8907 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01008908 { } /* end */
8909};
8910
Jiang zhe0e31daf2008-03-20 12:12:39 +01008911/* bind hp and internal speaker mute (with plug check) */
8912static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
8913 struct snd_ctl_elem_value *ucontrol)
8914{
8915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8916 long *valp = ucontrol->value.integer.value;
8917 int change;
8918
8919 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8920 HDA_AMP_MUTE,
8921 valp ? 0 : HDA_AMP_MUTE);
8922
8923 if (change)
8924 alc262_lenovo_3000_automute(codec, 0);
8925 return change;
8926}
8927
8928static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
8929 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8930 {
8931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8932 .name = "Master Playback Switch",
8933 .info = snd_hda_mixer_amp_switch_info,
8934 .get = snd_hda_mixer_amp_switch_get,
8935 .put = alc262_lenovo_3000_master_sw_put,
8936 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8937 },
8938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8940 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8943 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8944 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8945 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8946 { } /* end */
8947};
8948
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008949/* additional init verbs for Benq laptops */
8950static struct hda_verb alc262_EAPD_verbs[] = {
8951 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8952 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8953 {}
8954};
8955
Kailang Yang83c34212007-07-05 11:43:05 +02008956static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8957 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8959
8960 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8961 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8962 {}
8963};
8964
Tobin Davisf651b502007-10-26 12:40:47 +02008965/* Samsung Q1 Ultra Vista model setup */
8966static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008967 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8968 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02008969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008972 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02008973 { } /* end */
8974};
8975
8976static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008977 /* output mixer */
8978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8981 /* speaker */
8982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8985 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8986 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02008987 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01008988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8991 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8992 /* internal mic */
8993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8995 /* ADC, choose mic */
8996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9004 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009006 {}
9007};
9008
Tobin Davisf651b502007-10-26 12:40:47 +02009009/* mute/unmute internal speaker according to the hp jack and mute state */
9010static void alc262_ultra_automute(struct hda_codec *codec)
9011{
9012 struct alc_spec *spec = codec->spec;
9013 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009014
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009015 mute = 0;
9016 /* auto-mute only when HP is used as HP */
9017 if (!spec->cur_mux[0]) {
9018 unsigned int present;
9019 /* need to execute and sync at first */
9020 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9021 present = snd_hda_codec_read(codec, 0x15, 0,
9022 AC_VERB_GET_PIN_SENSE, 0);
9023 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9024 if (spec->jack_present)
9025 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009026 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009027 /* mute/unmute internal speaker */
9028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9029 HDA_AMP_MUTE, mute);
9030 /* mute/unmute HP */
9031 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9032 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009033}
9034
9035/* unsolicited event for HP jack sensing */
9036static void alc262_ultra_unsol_event(struct hda_codec *codec,
9037 unsigned int res)
9038{
9039 if ((res >> 26) != ALC880_HP_EVENT)
9040 return;
9041 alc262_ultra_automute(codec);
9042}
9043
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009044static struct hda_input_mux alc262_ultra_capture_source = {
9045 .num_items = 2,
9046 .items = {
9047 { "Mic", 0x1 },
9048 { "Headphone", 0x7 },
9049 },
9050};
9051
9052static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9053 struct snd_ctl_elem_value *ucontrol)
9054{
9055 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9056 struct alc_spec *spec = codec->spec;
9057 int ret;
9058
9059 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9060 if (!ret)
9061 return 0;
9062 /* reprogram the HP pin as mic or HP according to the input source */
9063 snd_hda_codec_write_cache(codec, 0x15, 0,
9064 AC_VERB_SET_PIN_WIDGET_CONTROL,
9065 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9066 alc262_ultra_automute(codec); /* mute/unmute HP */
9067 return ret;
9068}
9069
9070static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9071 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9072 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9073 {
9074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9075 .name = "Capture Source",
9076 .info = alc882_mux_enum_info,
9077 .get = alc882_mux_enum_get,
9078 .put = alc262_ultra_mux_enum_put,
9079 },
9080 { } /* end */
9081};
9082
Kailang Yangdf694da2005-12-05 19:42:22 +01009083/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009084static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9085 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009086{
9087 hda_nid_t nid;
9088 int err;
9089
9090 spec->multiout.num_dacs = 1; /* only use one dac */
9091 spec->multiout.dac_nids = spec->private_dac_nids;
9092 spec->multiout.dac_nids[0] = 2;
9093
9094 nid = cfg->line_out_pins[0];
9095 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009096 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9097 "Front Playback Volume",
9098 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9099 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009100 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009101 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9102 "Front Playback Switch",
9103 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9104 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009105 return err;
9106 }
9107
Takashi Iwai82bc9552006-03-21 11:24:42 +01009108 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009109 if (nid) {
9110 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009111 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9112 "Speaker Playback Volume",
9113 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9114 HDA_OUTPUT));
9115 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009116 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009117 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9118 "Speaker Playback Switch",
9119 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9120 HDA_OUTPUT));
9121 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009122 return err;
9123 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009124 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9125 "Speaker Playback Switch",
9126 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9127 HDA_OUTPUT));
9128 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009129 return err;
9130 }
9131 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009132 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009133 if (nid) {
9134 /* spec->multiout.hp_nid = 2; */
9135 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009136 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9137 "Headphone Playback Volume",
9138 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9139 HDA_OUTPUT));
9140 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009141 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009142 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9143 "Headphone Playback Switch",
9144 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9145 HDA_OUTPUT));
9146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009147 return err;
9148 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009149 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9150 "Headphone Playback Switch",
9151 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9152 HDA_OUTPUT));
9153 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009154 return err;
9155 }
9156 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009157 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009158}
9159
9160/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009161#define alc262_auto_create_analog_input_ctls \
9162 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009163
9164/*
9165 * generic initialization of ADC, input mixers and output mixers
9166 */
9167static struct hda_verb alc262_volume_init_verbs[] = {
9168 /*
9169 * Unmute ADC0-2 and set the default input to mic-in
9170 */
9171 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9173 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9175 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9176 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9177
Takashi Iwaicb53c622007-08-10 17:21:45 +02009178 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009179 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009180 * Note: PASD motherboards uses the Line In 2 as the input for
9181 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009182 */
9183 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009189
9190 /*
9191 * Set up output mixers (0x0c - 0x0f)
9192 */
9193 /* set vol=0 to output mixers */
9194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9197
9198 /* set up input amps for analog loopback */
9199 /* Amp Indices: DAC = 0, mixer = 1 */
9200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9202 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9204 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9206
9207 /* FIXME: use matrix-type input source selection */
9208 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9209 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9214 /* Input mixer2 */
9215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9219 /* Input mixer3 */
9220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9224
9225 { }
9226};
9227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9229 /*
9230 * Unmute ADC0-2 and set the default input to mic-in
9231 */
9232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9234 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9236 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238
Takashi Iwaicb53c622007-08-10 17:21:45 +02009239 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009240 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009241 * Note: PASD motherboards uses the Line In 2 as the input for
9242 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243 */
9244 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009252
9253 /*
9254 * Set up output mixers (0x0c - 0x0e)
9255 */
9256 /* set vol=0 to output mixers */
9257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9260
9261 /* set up input amps for analog loopback */
9262 /* Amp Indices: DAC = 0, mixer = 1 */
9263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9269
Takashi Iwaice875f02008-01-28 18:17:43 +01009270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9273
9274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9276
9277 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9278 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9279
9280 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9284 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9285
9286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9290 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9291 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9292
9293
9294 /* FIXME: use matrix-type input source selection */
9295 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9296 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9301 /* Input mixer2 */
9302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9306 /* Input mixer3 */
9307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9311
Takashi Iwaice875f02008-01-28 18:17:43 +01009312 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009314 { }
9315};
9316
Kailang Yangcd7509a2007-01-26 18:33:17 +01009317static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9318 /*
9319 * Unmute ADC0-2 and set the default input to mic-in
9320 */
9321 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9325 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9327
Takashi Iwaicb53c622007-08-10 17:21:45 +02009328 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009329 * mixer widget
9330 * Note: PASD motherboards uses the Line In 2 as the input for front
9331 * panel mic (mic 2)
9332 */
9333 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009342 /*
9343 * Set up output mixers (0x0c - 0x0e)
9344 */
9345 /* set vol=0 to output mixers */
9346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9349
9350 /* set up input amps for analog loopback */
9351 /* Amp Indices: DAC = 0, mixer = 1 */
9352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9358
9359
9360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9361 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9363 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9366 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9367
9368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9370
9371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9373
9374 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9378 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9379 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9380
9381 /* FIXME: use matrix-type input source selection */
9382 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9383 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9389 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9391 /* Input mixer2 */
9392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9397 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9399 /* Input mixer3 */
9400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9405 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9407
Takashi Iwaice875f02008-01-28 18:17:43 +01009408 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9409
Kailang Yangcd7509a2007-01-26 18:33:17 +01009410 { }
9411};
9412
Takashi Iwaicb53c622007-08-10 17:21:45 +02009413#ifdef CONFIG_SND_HDA_POWER_SAVE
9414#define alc262_loopbacks alc880_loopbacks
9415#endif
9416
Kailang Yangdf694da2005-12-05 19:42:22 +01009417/* pcm configuration: identiacal with ALC880 */
9418#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9419#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9420#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9421#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9422
9423/*
9424 * BIOS auto configuration
9425 */
9426static int alc262_parse_auto_config(struct hda_codec *codec)
9427{
9428 struct alc_spec *spec = codec->spec;
9429 int err;
9430 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9431
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009432 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9433 alc262_ignore);
9434 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009436 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009437 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009438 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9439 if (err < 0)
9440 return err;
9441 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9442 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 return err;
9444
9445 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9446
9447 if (spec->autocfg.dig_out_pin)
9448 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9449 if (spec->autocfg.dig_in_pin)
9450 spec->dig_in_nid = ALC262_DIGIN_NID;
9451
9452 if (spec->kctl_alloc)
9453 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9454
9455 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009456 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009457 spec->input_mux = &spec->private_imux;
9458
Takashi Iwai776e1842007-08-29 15:07:11 +02009459 err = alc_auto_add_mic_boost(codec);
9460 if (err < 0)
9461 return err;
9462
Kailang Yangdf694da2005-12-05 19:42:22 +01009463 return 1;
9464}
9465
9466#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9467#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9468#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9469
9470
9471/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009472static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009473{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009474 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009475 alc262_auto_init_multi_out(codec);
9476 alc262_auto_init_hp_out(codec);
9477 alc262_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009478 if (spec->unsol_event)
9479 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009480}
9481
9482/*
9483 * configuration and preset
9484 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009485static const char *alc262_models[ALC262_MODEL_LAST] = {
9486 [ALC262_BASIC] = "basic",
9487 [ALC262_HIPPO] = "hippo",
9488 [ALC262_HIPPO_1] = "hippo_1",
9489 [ALC262_FUJITSU] = "fujitsu",
9490 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009491 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009492 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009493 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009494 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009495 [ALC262_BENQ_T31] = "benq-t31",
9496 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009497 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009498 [ALC262_LENOVO_3000] = "lenovo-3000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009499 [ALC262_AUTO] = "auto",
9500};
9501
9502static struct snd_pci_quirk alc262_cfg_tbl[] = {
9503 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9504 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009505 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009506 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9507 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009508 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009509 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009510 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009511 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009512 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009513 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009514 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009515 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009516 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009517 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009518 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009519 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009520 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9521 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9522 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009523 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9524 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009525 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009526 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009527 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009528 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9529 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9530 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009531 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009532 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009533 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009534 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009535 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009536 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009537 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009538 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +01009539 {}
9540};
9541
9542static struct alc_config_preset alc262_presets[] = {
9543 [ALC262_BASIC] = {
9544 .mixers = { alc262_base_mixer },
9545 .init_verbs = { alc262_init_verbs },
9546 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9547 .dac_nids = alc262_dac_nids,
9548 .hp_nid = 0x03,
9549 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9550 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01009551 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01009552 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009553 [ALC262_HIPPO] = {
9554 .mixers = { alc262_base_mixer },
9555 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9557 .dac_nids = alc262_dac_nids,
9558 .hp_nid = 0x03,
9559 .dig_out_nid = ALC262_DIGOUT_NID,
9560 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9561 .channel_mode = alc262_modes,
9562 .input_mux = &alc262_capture_source,
9563 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009564 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009565 },
9566 [ALC262_HIPPO_1] = {
9567 .mixers = { alc262_hippo1_mixer },
9568 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9569 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9570 .dac_nids = alc262_dac_nids,
9571 .hp_nid = 0x02,
9572 .dig_out_nid = ALC262_DIGOUT_NID,
9573 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9574 .channel_mode = alc262_modes,
9575 .input_mux = &alc262_capture_source,
9576 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009577 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009578 },
Takashi Iwai834be882006-03-01 14:16:17 +01009579 [ALC262_FUJITSU] = {
9580 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009581 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9582 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01009583 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9584 .dac_nids = alc262_dac_nids,
9585 .hp_nid = 0x03,
9586 .dig_out_nid = ALC262_DIGOUT_NID,
9587 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9588 .channel_mode = alc262_modes,
9589 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009590 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009591 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +01009592 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009593 [ALC262_HP_BPC] = {
9594 .mixers = { alc262_HP_BPC_mixer },
9595 .init_verbs = { alc262_HP_BPC_init_verbs },
9596 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9597 .dac_nids = alc262_dac_nids,
9598 .hp_nid = 0x03,
9599 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9600 .channel_mode = alc262_modes,
9601 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009602 .unsol_event = alc262_hp_bpc_unsol_event,
9603 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009604 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009605 [ALC262_HP_BPC_D7000_WF] = {
9606 .mixers = { alc262_HP_BPC_WildWest_mixer },
9607 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9608 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9609 .dac_nids = alc262_dac_nids,
9610 .hp_nid = 0x03,
9611 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9612 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009613 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009614 .unsol_event = alc262_hp_wildwest_unsol_event,
9615 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009616 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009617 [ALC262_HP_BPC_D7000_WL] = {
9618 .mixers = { alc262_HP_BPC_WildWest_mixer,
9619 alc262_HP_BPC_WildWest_option_mixer },
9620 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9621 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9622 .dac_nids = alc262_dac_nids,
9623 .hp_nid = 0x03,
9624 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9625 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02009626 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +01009627 .unsol_event = alc262_hp_wildwest_unsol_event,
9628 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009629 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009630 [ALC262_HP_TC_T5735] = {
9631 .mixers = { alc262_hp_t5735_mixer },
9632 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9633 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9634 .dac_nids = alc262_dac_nids,
9635 .hp_nid = 0x03,
9636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9637 .channel_mode = alc262_modes,
9638 .input_mux = &alc262_capture_source,
9639 .unsol_event = alc262_hp_t5735_unsol_event,
9640 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +01009641 },
9642 [ALC262_HP_RP5700] = {
9643 .mixers = { alc262_hp_rp5700_mixer },
9644 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9645 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9646 .dac_nids = alc262_dac_nids,
9647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9648 .channel_mode = alc262_modes,
9649 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009650 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009651 [ALC262_BENQ_ED8] = {
9652 .mixers = { alc262_base_mixer },
9653 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9654 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9655 .dac_nids = alc262_dac_nids,
9656 .hp_nid = 0x03,
9657 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9658 .channel_mode = alc262_modes,
9659 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009660 },
Kailang Yang272a5272007-05-14 11:00:38 +02009661 [ALC262_SONY_ASSAMD] = {
9662 .mixers = { alc262_sony_mixer },
9663 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9664 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9665 .dac_nids = alc262_dac_nids,
9666 .hp_nid = 0x02,
9667 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9668 .channel_mode = alc262_modes,
9669 .input_mux = &alc262_capture_source,
9670 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009671 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02009672 },
9673 [ALC262_BENQ_T31] = {
9674 .mixers = { alc262_benq_t31_mixer },
9675 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9677 .dac_nids = alc262_dac_nids,
9678 .hp_nid = 0x03,
9679 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9680 .channel_mode = alc262_modes,
9681 .input_mux = &alc262_capture_source,
9682 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02009683 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02009684 },
Tobin Davisf651b502007-10-26 12:40:47 +02009685 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009686 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9687 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +02009688 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9689 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +02009690 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9691 .channel_mode = alc262_modes,
9692 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009693 .adc_nids = alc262_adc_nids, /* ADC0 */
9694 .capsrc_nids = alc262_capsrc_nids,
9695 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +02009696 .unsol_event = alc262_ultra_unsol_event,
9697 .init_hook = alc262_ultra_automute,
9698 },
Jiang zhe0e31daf2008-03-20 12:12:39 +01009699 [ALC262_LENOVO_3000] = {
9700 .mixers = { alc262_lenovo_3000_mixer },
9701 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9702 alc262_lenovo_3000_unsol_verbs },
9703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9704 .dac_nids = alc262_dac_nids,
9705 .hp_nid = 0x03,
9706 .dig_out_nid = ALC262_DIGOUT_NID,
9707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9708 .channel_mode = alc262_modes,
9709 .input_mux = &alc262_fujitsu_capture_source,
9710 .unsol_event = alc262_lenovo_3000_unsol_event,
9711 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009712};
9713
9714static int patch_alc262(struct hda_codec *codec)
9715{
9716 struct alc_spec *spec;
9717 int board_config;
9718 int err;
9719
Robert P. J. Daydc041e02006-12-19 14:44:15 +01009720 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01009721 if (spec == NULL)
9722 return -ENOMEM;
9723
9724 codec->spec = spec;
9725#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009726 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9727 * under-run
9728 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009729 {
9730 int tmp;
9731 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9732 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9733 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9734 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9735 }
9736#endif
9737
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009738 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9739 alc262_models,
9740 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01009741
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009742 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009743 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9744 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009745 board_config = ALC262_AUTO;
9746 }
9747
9748 if (board_config == ALC262_AUTO) {
9749 /* automatic parse from the BIOS config */
9750 err = alc262_parse_auto_config(codec);
9751 if (err < 0) {
9752 alc_free(codec);
9753 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009754 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009755 printk(KERN_INFO
9756 "hda_codec: Cannot set up configuration "
9757 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01009758 board_config = ALC262_BASIC;
9759 }
9760 }
9761
9762 if (board_config != ALC262_AUTO)
9763 setup_preset(spec, &alc262_presets[board_config]);
9764
9765 spec->stream_name_analog = "ALC262 Analog";
9766 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9767 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9768
9769 spec->stream_name_digital = "ALC262 Digital";
9770 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9771 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9772
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009773 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009774 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01009775 unsigned int wcap = get_wcaps(codec, 0x07);
9776
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009777 /* get type */
9778 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01009779 if (wcap != AC_WID_AUD_IN) {
9780 spec->adc_nids = alc262_adc_nids_alt;
9781 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009782 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009783 spec->mixers[spec->num_mixers] =
9784 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01009785 spec->num_mixers++;
9786 } else {
9787 spec->adc_nids = alc262_adc_nids;
9788 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +01009789 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01009790 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9791 spec->num_mixers++;
9792 }
9793 }
9794
Takashi Iwai2134ea42008-01-10 16:53:55 +01009795 spec->vmaster_nid = 0x0c;
9796
Kailang Yangdf694da2005-12-05 19:42:22 +01009797 codec->patch_ops = alc_patch_ops;
9798 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009799 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009800#ifdef CONFIG_SND_HDA_POWER_SAVE
9801 if (!spec->loopback.amplist)
9802 spec->loopback.amplist = alc262_loopbacks;
9803#endif
Takashi Iwai834be882006-03-01 14:16:17 +01009804
Kailang Yangdf694da2005-12-05 19:42:22 +01009805 return 0;
9806}
9807
Kailang Yangdf694da2005-12-05 19:42:22 +01009808/*
Kailang Yanga361d842007-06-05 12:30:55 +02009809 * ALC268 channel source setting (2 channel)
9810 */
9811#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9812#define alc268_modes alc260_modes
9813
9814static hda_nid_t alc268_dac_nids[2] = {
9815 /* front, hp */
9816 0x02, 0x03
9817};
9818
9819static hda_nid_t alc268_adc_nids[2] = {
9820 /* ADC0-1 */
9821 0x08, 0x07
9822};
9823
9824static hda_nid_t alc268_adc_nids_alt[1] = {
9825 /* ADC0 */
9826 0x08
9827};
9828
Takashi Iwaie1406342008-02-11 18:32:32 +01009829static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9830
Kailang Yanga361d842007-06-05 12:30:55 +02009831static struct snd_kcontrol_new alc268_base_mixer[] = {
9832 /* output mixer control */
9833 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9834 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9835 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9839 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02009840 { }
9841};
9842
Takashi Iwaiaef9d312008-02-19 13:16:41 +01009843/* bind Beep switches of both NID 0x0f and 0x10 */
9844static struct hda_bind_ctls alc268_bind_beep_sw = {
9845 .ops = &snd_hda_bind_sw,
9846 .values = {
9847 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9848 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
9849 0
9850 },
9851};
9852
9853static struct snd_kcontrol_new alc268_beep_mixer[] = {
9854 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
9855 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
9856 { }
9857};
9858
Kailang Yangd1a991a2007-08-15 16:21:59 +02009859static struct hda_verb alc268_eapd_verbs[] = {
9860 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9861 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9862 { }
9863};
9864
Takashi Iwaid2738092007-08-16 14:59:45 +02009865/* Toshiba specific */
9866#define alc268_toshiba_automute alc262_hippo_automute
9867
9868static struct hda_verb alc268_toshiba_verbs[] = {
9869 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9870 { } /* end */
9871};
9872
9873/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02009874/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02009875static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9876 .ops = &snd_hda_bind_vol,
9877 .values = {
9878 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9879 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9880 0
9881 },
9882};
9883
Takashi Iwai889c4392007-08-23 18:56:52 +02009884/* mute/unmute internal speaker according to the hp jack and mute state */
9885static void alc268_acer_automute(struct hda_codec *codec, int force)
9886{
9887 struct alc_spec *spec = codec->spec;
9888 unsigned int mute;
9889
9890 if (force || !spec->sense_updated) {
9891 unsigned int present;
9892 present = snd_hda_codec_read(codec, 0x14, 0,
9893 AC_VERB_GET_PIN_SENSE, 0);
9894 spec->jack_present = (present & 0x80000000) != 0;
9895 spec->sense_updated = 1;
9896 }
9897 if (spec->jack_present)
9898 mute = HDA_AMP_MUTE; /* mute internal speaker */
9899 else /* unmute internal speaker if necessary */
9900 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9901 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9902 HDA_AMP_MUTE, mute);
9903}
9904
9905
9906/* bind hp and internal speaker mute (with plug check) */
9907static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9908 struct snd_ctl_elem_value *ucontrol)
9909{
9910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9911 long *valp = ucontrol->value.integer.value;
9912 int change;
9913
9914 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9915 HDA_AMP_MUTE,
9916 valp[0] ? 0 : HDA_AMP_MUTE);
9917 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9918 HDA_AMP_MUTE,
9919 valp[1] ? 0 : HDA_AMP_MUTE);
9920 if (change)
9921 alc268_acer_automute(codec, 0);
9922 return change;
9923}
Takashi Iwaid2738092007-08-16 14:59:45 +02009924
9925static struct snd_kcontrol_new alc268_acer_mixer[] = {
9926 /* output mixer control */
9927 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9928 {
9929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9930 .name = "Master Playback Switch",
9931 .info = snd_hda_mixer_amp_switch_info,
9932 .get = snd_hda_mixer_amp_switch_get,
9933 .put = alc268_acer_master_sw_put,
9934 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9935 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02009936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9937 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9938 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02009939 { }
9940};
9941
9942static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +01009943 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
9944 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +02009945 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +01009947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +02009949
9950 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9951 { }
9952};
9953
9954/* unsolicited event for HP jack sensing */
9955static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9956 unsigned int res)
9957{
Takashi Iwai889c4392007-08-23 18:56:52 +02009958 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009959 return;
9960 alc268_toshiba_automute(codec);
9961}
9962
9963static void alc268_acer_unsol_event(struct hda_codec *codec,
9964 unsigned int res)
9965{
Takashi Iwai889c4392007-08-23 18:56:52 +02009966 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02009967 return;
9968 alc268_acer_automute(codec, 1);
9969}
9970
Takashi Iwai889c4392007-08-23 18:56:52 +02009971static void alc268_acer_init_hook(struct hda_codec *codec)
9972{
9973 alc268_acer_automute(codec, 1);
9974}
9975
Takashi Iwai3866f0b2008-01-15 12:37:42 +01009976static struct snd_kcontrol_new alc268_dell_mixer[] = {
9977 /* output mixer control */
9978 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9979 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9980 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9983 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9984 { }
9985};
9986
9987static struct hda_verb alc268_dell_verbs[] = {
9988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9990 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9991 { }
9992};
9993
9994/* mute/unmute internal speaker according to the hp jack and mute state */
9995static void alc268_dell_automute(struct hda_codec *codec)
9996{
9997 unsigned int present;
9998 unsigned int mute;
9999
10000 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10001 if (present & 0x80000000)
10002 mute = HDA_AMP_MUTE;
10003 else
10004 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10005 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10006 HDA_AMP_MUTE, mute);
10007}
10008
10009static void alc268_dell_unsol_event(struct hda_codec *codec,
10010 unsigned int res)
10011{
10012 if ((res >> 26) != ALC880_HP_EVENT)
10013 return;
10014 alc268_dell_automute(codec);
10015}
10016
10017#define alc268_dell_init_hook alc268_dell_automute
10018
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010019static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10020 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10021 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10023 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10024 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10025 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10026 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10027 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10028 { }
10029};
10030
10031static struct hda_verb alc267_quanta_il1_verbs[] = {
10032 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10033 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10034 { }
10035};
10036
10037static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10038{
10039 unsigned int present;
10040
10041 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10042 & AC_PINSENSE_PRESENCE;
10043 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10044 present ? 0 : PIN_OUT);
10045}
10046
10047static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10048{
10049 unsigned int present;
10050
10051 present = snd_hda_codec_read(codec, 0x18, 0,
10052 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10053 snd_hda_codec_write(codec, 0x23, 0,
10054 AC_VERB_SET_CONNECT_SEL,
10055 present ? 0x00 : 0x01);
10056}
10057
10058static void alc267_quanta_il1_automute(struct hda_codec *codec)
10059{
10060 alc267_quanta_il1_hp_automute(codec);
10061 alc267_quanta_il1_mic_automute(codec);
10062}
10063
10064static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10065 unsigned int res)
10066{
10067 switch (res >> 26) {
10068 case ALC880_HP_EVENT:
10069 alc267_quanta_il1_hp_automute(codec);
10070 break;
10071 case ALC880_MIC_EVENT:
10072 alc267_quanta_il1_mic_automute(codec);
10073 break;
10074 }
10075}
10076
Kailang Yanga361d842007-06-05 12:30:55 +020010077/*
10078 * generic initialization of ADC, input mixers and output mixers
10079 */
10080static struct hda_verb alc268_base_init_verbs[] = {
10081 /* Unmute DAC0-1 and set vol = 0 */
10082 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10083 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10084 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10085 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10086 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10087 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10088
10089 /*
10090 * Set up output mixers (0x0c - 0x0e)
10091 */
10092 /* set vol=0 to output mixers */
10093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10095 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10096 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10097
10098 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10099 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10100
10101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10102 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10105 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10106 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10107 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10108 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10109
10110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10112 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10113 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10115 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10116 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010117
10118 /* set PCBEEP vol = 0, mute connections */
10119 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10121 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010122
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010123 /* Unmute Selector 23h,24h and set the default input to mic-in */
10124
10125 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10127 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010129
Kailang Yanga361d842007-06-05 12:30:55 +020010130 { }
10131};
10132
10133/*
10134 * generic initialization of ADC, input mixers and output mixers
10135 */
10136static struct hda_verb alc268_volume_init_verbs[] = {
10137 /* set output DAC */
10138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10139 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10140 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10141 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10142
10143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10146 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10147 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10148
10149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10152 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10153 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10154
10155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10156 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10158 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10159
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010160 /* set PCBEEP vol = 0, mute connections */
10161 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10163 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010164
10165 { }
10166};
10167
10168#define alc268_mux_enum_info alc_mux_enum_info
10169#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010170#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010171
10172static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10173 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10175 {
10176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10177 /* The multiple "Capture Source" controls confuse alsamixer
10178 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010179 */
10180 /* .name = "Capture Source", */
10181 .name = "Input Source",
10182 .count = 1,
10183 .info = alc268_mux_enum_info,
10184 .get = alc268_mux_enum_get,
10185 .put = alc268_mux_enum_put,
10186 },
10187 { } /* end */
10188};
10189
10190static struct snd_kcontrol_new alc268_capture_mixer[] = {
10191 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10192 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10193 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10194 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10195 {
10196 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10197 /* The multiple "Capture Source" controls confuse alsamixer
10198 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010199 */
10200 /* .name = "Capture Source", */
10201 .name = "Input Source",
10202 .count = 2,
10203 .info = alc268_mux_enum_info,
10204 .get = alc268_mux_enum_get,
10205 .put = alc268_mux_enum_put,
10206 },
10207 { } /* end */
10208};
10209
10210static struct hda_input_mux alc268_capture_source = {
10211 .num_items = 4,
10212 .items = {
10213 { "Mic", 0x0 },
10214 { "Front Mic", 0x1 },
10215 { "Line", 0x2 },
10216 { "CD", 0x3 },
10217 },
10218};
10219
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010220static struct hda_input_mux alc268_acer_capture_source = {
10221 .num_items = 3,
10222 .items = {
10223 { "Mic", 0x0 },
10224 { "Internal Mic", 0x6 },
10225 { "Line", 0x2 },
10226 },
10227};
10228
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010229#ifdef CONFIG_SND_DEBUG
10230static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010231 /* Volume widgets */
10232 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10233 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10234 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10235 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10236 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10237 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10238 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10239 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10240 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10241 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10242 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10243 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10244 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010245 /* The below appears problematic on some hardwares */
10246 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010247 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10248 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10249 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10250 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10251
10252 /* Modes for retasking pin widgets */
10253 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10254 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10255 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10256 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10257
10258 /* Controls for GPIO pins, assuming they are configured as outputs */
10259 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10260 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10261 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10262 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10263
10264 /* Switches to allow the digital SPDIF output pin to be enabled.
10265 * The ALC268 does not have an SPDIF input.
10266 */
10267 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10268
10269 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10270 * this output to turn on an external amplifier.
10271 */
10272 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10273 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10274
10275 { } /* end */
10276};
10277#endif
10278
Kailang Yanga361d842007-06-05 12:30:55 +020010279/* create input playback/capture controls for the given pin */
10280static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10281 const char *ctlname, int idx)
10282{
10283 char name[32];
10284 int err;
10285
10286 sprintf(name, "%s Playback Volume", ctlname);
10287 if (nid == 0x14) {
10288 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10289 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10290 HDA_OUTPUT));
10291 if (err < 0)
10292 return err;
10293 } else if (nid == 0x15) {
10294 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10295 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10296 HDA_OUTPUT));
10297 if (err < 0)
10298 return err;
10299 } else
10300 return -1;
10301 sprintf(name, "%s Playback Switch", ctlname);
10302 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10303 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10304 if (err < 0)
10305 return err;
10306 return 0;
10307}
10308
10309/* add playback controls from the parsed DAC table */
10310static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10311 const struct auto_pin_cfg *cfg)
10312{
10313 hda_nid_t nid;
10314 int err;
10315
10316 spec->multiout.num_dacs = 2; /* only use one dac */
10317 spec->multiout.dac_nids = spec->private_dac_nids;
10318 spec->multiout.dac_nids[0] = 2;
10319 spec->multiout.dac_nids[1] = 3;
10320
10321 nid = cfg->line_out_pins[0];
10322 if (nid)
10323 alc268_new_analog_output(spec, nid, "Front", 0);
10324
10325 nid = cfg->speaker_pins[0];
10326 if (nid == 0x1d) {
10327 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10328 "Speaker Playback Volume",
10329 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10330 if (err < 0)
10331 return err;
10332 }
10333 nid = cfg->hp_pins[0];
10334 if (nid)
10335 alc268_new_analog_output(spec, nid, "Headphone", 0);
10336
10337 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10338 if (nid == 0x16) {
10339 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10340 "Mono Playback Switch",
10341 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10342 if (err < 0)
10343 return err;
10344 }
10345 return 0;
10346}
10347
10348/* create playback/capture controls for input pins */
10349static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10350 const struct auto_pin_cfg *cfg)
10351{
10352 struct hda_input_mux *imux = &spec->private_imux;
10353 int i, idx1;
10354
10355 for (i = 0; i < AUTO_PIN_LAST; i++) {
10356 switch(cfg->input_pins[i]) {
10357 case 0x18:
10358 idx1 = 0; /* Mic 1 */
10359 break;
10360 case 0x19:
10361 idx1 = 1; /* Mic 2 */
10362 break;
10363 case 0x1a:
10364 idx1 = 2; /* Line In */
10365 break;
10366 case 0x1c:
10367 idx1 = 3; /* CD */
10368 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010369 case 0x12:
10370 case 0x13:
10371 idx1 = 6; /* digital mics */
10372 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010373 default:
10374 continue;
10375 }
10376 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10377 imux->items[imux->num_items].index = idx1;
10378 imux->num_items++;
10379 }
10380 return 0;
10381}
10382
10383static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10384{
10385 struct alc_spec *spec = codec->spec;
10386 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10387 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10388 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10389 unsigned int dac_vol1, dac_vol2;
10390
10391 if (speaker_nid) {
10392 snd_hda_codec_write(codec, speaker_nid, 0,
10393 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10394 snd_hda_codec_write(codec, 0x0f, 0,
10395 AC_VERB_SET_AMP_GAIN_MUTE,
10396 AMP_IN_UNMUTE(1));
10397 snd_hda_codec_write(codec, 0x10, 0,
10398 AC_VERB_SET_AMP_GAIN_MUTE,
10399 AMP_IN_UNMUTE(1));
10400 } else {
10401 snd_hda_codec_write(codec, 0x0f, 0,
10402 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10403 snd_hda_codec_write(codec, 0x10, 0,
10404 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10405 }
10406
10407 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10408 if (line_nid == 0x14)
10409 dac_vol2 = AMP_OUT_ZERO;
10410 else if (line_nid == 0x15)
10411 dac_vol1 = AMP_OUT_ZERO;
10412 if (hp_nid == 0x14)
10413 dac_vol2 = AMP_OUT_ZERO;
10414 else if (hp_nid == 0x15)
10415 dac_vol1 = AMP_OUT_ZERO;
10416 if (line_nid != 0x16 || hp_nid != 0x16 ||
10417 spec->autocfg.line_out_pins[1] != 0x16 ||
10418 spec->autocfg.line_out_pins[2] != 0x16)
10419 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10420
10421 snd_hda_codec_write(codec, 0x02, 0,
10422 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10423 snd_hda_codec_write(codec, 0x03, 0,
10424 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10425}
10426
10427/* pcm configuration: identiacal with ALC880 */
10428#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10429#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010430#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010431#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10432
10433/*
10434 * BIOS auto configuration
10435 */
10436static int alc268_parse_auto_config(struct hda_codec *codec)
10437{
10438 struct alc_spec *spec = codec->spec;
10439 int err;
10440 static hda_nid_t alc268_ignore[] = { 0 };
10441
10442 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10443 alc268_ignore);
10444 if (err < 0)
10445 return err;
10446 if (!spec->autocfg.line_outs)
10447 return 0; /* can't find valid BIOS pin config */
10448
10449 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10450 if (err < 0)
10451 return err;
10452 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10453 if (err < 0)
10454 return err;
10455
10456 spec->multiout.max_channels = 2;
10457
10458 /* digital only support output */
10459 if (spec->autocfg.dig_out_pin)
10460 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10461
10462 if (spec->kctl_alloc)
10463 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10464
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010465 if (spec->autocfg.speaker_pins[0] != 0x1d)
10466 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10467
Kailang Yanga361d842007-06-05 12:30:55 +020010468 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10469 spec->num_mux_defs = 1;
10470 spec->input_mux = &spec->private_imux;
10471
Takashi Iwai776e1842007-08-29 15:07:11 +020010472 err = alc_auto_add_mic_boost(codec);
10473 if (err < 0)
10474 return err;
10475
Kailang Yanga361d842007-06-05 12:30:55 +020010476 return 1;
10477}
10478
10479#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10480#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10481#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10482
10483/* init callback for auto-configuration model -- overriding the default init */
10484static void alc268_auto_init(struct hda_codec *codec)
10485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010486 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010487 alc268_auto_init_multi_out(codec);
10488 alc268_auto_init_hp_out(codec);
10489 alc268_auto_init_mono_speaker_out(codec);
10490 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010491 if (spec->unsol_event)
10492 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010493}
10494
10495/*
10496 * configuration and preset
10497 */
10498static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010499 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010500 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010501 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010502 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010503 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010504 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010505#ifdef CONFIG_SND_DEBUG
10506 [ALC268_TEST] = "test",
10507#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010508 [ALC268_AUTO] = "auto",
10509};
10510
10511static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010512 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010513 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010010514 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010515 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010010516 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010517 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010518 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020010519 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010520 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020010521 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020010522 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020010523 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010524 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010525 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020010526 {}
10527};
10528
10529static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010530 [ALC267_QUANTA_IL1] = {
10531 .mixers = { alc267_quanta_il1_mixer },
10532 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10533 alc267_quanta_il1_verbs },
10534 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10535 .dac_nids = alc268_dac_nids,
10536 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10537 .adc_nids = alc268_adc_nids_alt,
10538 .hp_nid = 0x03,
10539 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10540 .channel_mode = alc268_modes,
10541 .input_mux = &alc268_capture_source,
10542 .unsol_event = alc267_quanta_il1_unsol_event,
10543 .init_hook = alc267_quanta_il1_automute,
10544 },
Kailang Yanga361d842007-06-05 12:30:55 +020010545 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010546 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10547 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020010548 .init_verbs = { alc268_base_init_verbs },
10549 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10550 .dac_nids = alc268_dac_nids,
10551 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10552 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010553 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020010554 .hp_nid = 0x03,
10555 .dig_out_nid = ALC268_DIGOUT_NID,
10556 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10557 .channel_mode = alc268_modes,
10558 .input_mux = &alc268_capture_source,
10559 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010560 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010561 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10562 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010563 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10564 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010565 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10566 .dac_nids = alc268_dac_nids,
10567 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10568 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010569 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010570 .hp_nid = 0x03,
10571 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10572 .channel_mode = alc268_modes,
10573 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010574 .unsol_event = alc268_toshiba_unsol_event,
10575 .init_hook = alc268_toshiba_automute,
10576 },
10577 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010578 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10579 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020010580 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10581 alc268_acer_verbs },
10582 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10583 .dac_nids = alc268_dac_nids,
10584 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10585 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010586 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020010587 .hp_nid = 0x02,
10588 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10589 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010590 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020010591 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020010592 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010593 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010594 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010595 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010596 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10597 alc268_dell_verbs },
10598 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10599 .dac_nids = alc268_dac_nids,
10600 .hp_nid = 0x02,
10601 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10602 .channel_mode = alc268_modes,
10603 .unsol_event = alc268_dell_unsol_event,
10604 .init_hook = alc268_dell_init_hook,
10605 .input_mux = &alc268_capture_source,
10606 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010607 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010608 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10609 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010610 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10611 alc268_toshiba_verbs },
10612 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10613 .dac_nids = alc268_dac_nids,
10614 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10615 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010616 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010617 .hp_nid = 0x03,
10618 .dig_out_nid = ALC268_DIGOUT_NID,
10619 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10620 .channel_mode = alc268_modes,
10621 .input_mux = &alc268_capture_source,
10622 .unsol_event = alc268_toshiba_unsol_event,
10623 .init_hook = alc268_toshiba_automute
10624 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010625#ifdef CONFIG_SND_DEBUG
10626 [ALC268_TEST] = {
10627 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10628 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10629 alc268_volume_init_verbs },
10630 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10631 .dac_nids = alc268_dac_nids,
10632 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10633 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010010634 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010635 .hp_nid = 0x03,
10636 .dig_out_nid = ALC268_DIGOUT_NID,
10637 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10638 .channel_mode = alc268_modes,
10639 .input_mux = &alc268_capture_source,
10640 },
10641#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010642};
10643
10644static int patch_alc268(struct hda_codec *codec)
10645{
10646 struct alc_spec *spec;
10647 int board_config;
10648 int err;
10649
10650 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10651 if (spec == NULL)
10652 return -ENOMEM;
10653
10654 codec->spec = spec;
10655
10656 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10657 alc268_models,
10658 alc268_cfg_tbl);
10659
10660 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10661 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10662 "trying auto-probe from BIOS...\n");
10663 board_config = ALC268_AUTO;
10664 }
10665
10666 if (board_config == ALC268_AUTO) {
10667 /* automatic parse from the BIOS config */
10668 err = alc268_parse_auto_config(codec);
10669 if (err < 0) {
10670 alc_free(codec);
10671 return err;
10672 } else if (!err) {
10673 printk(KERN_INFO
10674 "hda_codec: Cannot set up configuration "
10675 "from BIOS. Using base mode...\n");
10676 board_config = ALC268_3ST;
10677 }
10678 }
10679
10680 if (board_config != ALC268_AUTO)
10681 setup_preset(spec, &alc268_presets[board_config]);
10682
10683 spec->stream_name_analog = "ALC268 Analog";
10684 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10685 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010010686 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020010687
10688 spec->stream_name_digital = "ALC268 Digital";
10689 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10690
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010691 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10692 /* override the amp caps for beep generator */
10693 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10694 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10695 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10696 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10697 (0 << AC_AMPCAP_MUTE_SHIFT));
10698
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010699 if (!spec->adc_nids && spec->input_mux) {
10700 /* check whether NID 0x07 is valid */
10701 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010010702 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020010703
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010704 /* get type */
10705 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010010706 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010707 spec->adc_nids = alc268_adc_nids_alt;
10708 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10709 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020010710 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010711 spec->num_mixers++;
10712 } else {
10713 spec->adc_nids = alc268_adc_nids;
10714 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10715 spec->mixers[spec->num_mixers] =
10716 alc268_capture_mixer;
10717 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020010718 }
Takashi Iwaie1406342008-02-11 18:32:32 +010010719 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010010720 /* set default input source */
10721 for (i = 0; i < spec->num_adc_nids; i++)
10722 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10723 0, AC_VERB_SET_CONNECT_SEL,
10724 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020010725 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010010726
10727 spec->vmaster_nid = 0x02;
10728
Kailang Yanga361d842007-06-05 12:30:55 +020010729 codec->patch_ops = alc_patch_ops;
10730 if (board_config == ALC268_AUTO)
10731 spec->init_hook = alc268_auto_init;
10732
10733 return 0;
10734}
10735
10736/*
Kailang Yangf6a92242007-12-13 16:52:54 +010010737 * ALC269 channel source setting (2 channel)
10738 */
10739#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10740
10741#define alc269_dac_nids alc260_dac_nids
10742
10743static hda_nid_t alc269_adc_nids[1] = {
10744 /* ADC1 */
10745 0x07,
10746};
10747
10748#define alc269_modes alc260_modes
10749#define alc269_capture_source alc880_lg_lw_capture_source
10750
10751static struct snd_kcontrol_new alc269_base_mixer[] = {
10752 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10753 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10754 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10755 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10759 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10760 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10761 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10763 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10764 { } /* end */
10765};
10766
10767/* capture mixer elements */
10768static struct snd_kcontrol_new alc269_capture_mixer[] = {
10769 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10770 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10771 {
10772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10773 /* The multiple "Capture Source" controls confuse alsamixer
10774 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010010775 */
10776 /* .name = "Capture Source", */
10777 .name = "Input Source",
10778 .count = 1,
10779 .info = alc_mux_enum_info,
10780 .get = alc_mux_enum_get,
10781 .put = alc_mux_enum_put,
10782 },
10783 { } /* end */
10784};
10785
10786/*
10787 * generic initialization of ADC, input mixers and output mixers
10788 */
10789static struct hda_verb alc269_init_verbs[] = {
10790 /*
10791 * Unmute ADC0 and set the default input to mic-in
10792 */
10793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10794
10795 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10796 * analog-loopback mixer widget
10797 * Note: PASD motherboards uses the Line In 2 as the input for
10798 * front panel mic (mic 2)
10799 */
10800 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10806
10807 /*
10808 * Set up output mixers (0x0c - 0x0e)
10809 */
10810 /* set vol=0 to output mixers */
10811 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10812 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10813
10814 /* set up input amps for analog loopback */
10815 /* Amp Indices: DAC = 0, mixer = 1 */
10816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10820 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10822
10823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10825 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10826 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10827 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10830
10831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10838
10839 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10840 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10841
10842 /* FIXME: use matrix-type input source selection */
10843 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10844 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10849
10850 /* set EAPD */
10851 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10852 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10853 { }
10854};
10855
10856/* add playback controls from the parsed DAC table */
10857static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10858 const struct auto_pin_cfg *cfg)
10859{
10860 hda_nid_t nid;
10861 int err;
10862
10863 spec->multiout.num_dacs = 1; /* only use one dac */
10864 spec->multiout.dac_nids = spec->private_dac_nids;
10865 spec->multiout.dac_nids[0] = 2;
10866
10867 nid = cfg->line_out_pins[0];
10868 if (nid) {
10869 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10870 "Front Playback Volume",
10871 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10872 if (err < 0)
10873 return err;
10874 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10875 "Front Playback Switch",
10876 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10877 if (err < 0)
10878 return err;
10879 }
10880
10881 nid = cfg->speaker_pins[0];
10882 if (nid) {
10883 if (!cfg->line_out_pins[0]) {
10884 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10885 "Speaker Playback Volume",
10886 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10887 HDA_OUTPUT));
10888 if (err < 0)
10889 return err;
10890 }
10891 if (nid == 0x16) {
10892 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10893 "Speaker Playback Switch",
10894 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10895 HDA_OUTPUT));
10896 if (err < 0)
10897 return err;
10898 } else {
10899 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10900 "Speaker Playback Switch",
10901 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10902 HDA_OUTPUT));
10903 if (err < 0)
10904 return err;
10905 }
10906 }
10907 nid = cfg->hp_pins[0];
10908 if (nid) {
10909 /* spec->multiout.hp_nid = 2; */
10910 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10911 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10912 "Headphone Playback Volume",
10913 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10914 HDA_OUTPUT));
10915 if (err < 0)
10916 return err;
10917 }
10918 if (nid == 0x16) {
10919 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10920 "Headphone Playback Switch",
10921 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10922 HDA_OUTPUT));
10923 if (err < 0)
10924 return err;
10925 } else {
10926 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10927 "Headphone Playback Switch",
10928 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10929 HDA_OUTPUT));
10930 if (err < 0)
10931 return err;
10932 }
10933 }
10934 return 0;
10935}
10936
10937#define alc269_auto_create_analog_input_ctls \
10938 alc880_auto_create_analog_input_ctls
10939
10940#ifdef CONFIG_SND_HDA_POWER_SAVE
10941#define alc269_loopbacks alc880_loopbacks
10942#endif
10943
10944/* pcm configuration: identiacal with ALC880 */
10945#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10946#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10947#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10948#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10949
10950/*
10951 * BIOS auto configuration
10952 */
10953static int alc269_parse_auto_config(struct hda_codec *codec)
10954{
10955 struct alc_spec *spec = codec->spec;
10956 int err;
10957 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10958
10959 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10960 alc269_ignore);
10961 if (err < 0)
10962 return err;
10963
10964 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10965 if (err < 0)
10966 return err;
10967 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10968 if (err < 0)
10969 return err;
10970
10971 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10972
10973 if (spec->autocfg.dig_out_pin)
10974 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10975
10976 if (spec->kctl_alloc)
10977 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10978
10979 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10980 spec->num_mux_defs = 1;
10981 spec->input_mux = &spec->private_imux;
10982
10983 err = alc_auto_add_mic_boost(codec);
10984 if (err < 0)
10985 return err;
10986
10987 return 1;
10988}
10989
10990#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10991#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10992#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10993
10994
10995/* init callback for auto-configuration model -- overriding the default init */
10996static void alc269_auto_init(struct hda_codec *codec)
10997{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010998 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010010999 alc269_auto_init_multi_out(codec);
11000 alc269_auto_init_hp_out(codec);
11001 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011002 if (spec->unsol_event)
11003 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011004}
11005
11006/*
11007 * configuration and preset
11008 */
11009static const char *alc269_models[ALC269_MODEL_LAST] = {
11010 [ALC269_BASIC] = "basic",
11011};
11012
11013static struct snd_pci_quirk alc269_cfg_tbl[] = {
11014 {}
11015};
11016
11017static struct alc_config_preset alc269_presets[] = {
11018 [ALC269_BASIC] = {
11019 .mixers = { alc269_base_mixer },
11020 .init_verbs = { alc269_init_verbs },
11021 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11022 .dac_nids = alc269_dac_nids,
11023 .hp_nid = 0x03,
11024 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11025 .channel_mode = alc269_modes,
11026 .input_mux = &alc269_capture_source,
11027 },
11028};
11029
11030static int patch_alc269(struct hda_codec *codec)
11031{
11032 struct alc_spec *spec;
11033 int board_config;
11034 int err;
11035
11036 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11037 if (spec == NULL)
11038 return -ENOMEM;
11039
11040 codec->spec = spec;
11041
11042 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11043 alc269_models,
11044 alc269_cfg_tbl);
11045
11046 if (board_config < 0) {
11047 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11048 "trying auto-probe from BIOS...\n");
11049 board_config = ALC269_AUTO;
11050 }
11051
11052 if (board_config == ALC269_AUTO) {
11053 /* automatic parse from the BIOS config */
11054 err = alc269_parse_auto_config(codec);
11055 if (err < 0) {
11056 alc_free(codec);
11057 return err;
11058 } else if (!err) {
11059 printk(KERN_INFO
11060 "hda_codec: Cannot set up configuration "
11061 "from BIOS. Using base mode...\n");
11062 board_config = ALC269_BASIC;
11063 }
11064 }
11065
11066 if (board_config != ALC269_AUTO)
11067 setup_preset(spec, &alc269_presets[board_config]);
11068
11069 spec->stream_name_analog = "ALC269 Analog";
11070 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11071 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11072
11073 spec->stream_name_digital = "ALC269 Digital";
11074 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11075 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11076
11077 spec->adc_nids = alc269_adc_nids;
11078 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11079 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11080 spec->num_mixers++;
11081
11082 codec->patch_ops = alc_patch_ops;
11083 if (board_config == ALC269_AUTO)
11084 spec->init_hook = alc269_auto_init;
11085#ifdef CONFIG_SND_HDA_POWER_SAVE
11086 if (!spec->loopback.amplist)
11087 spec->loopback.amplist = alc269_loopbacks;
11088#endif
11089
11090 return 0;
11091}
11092
11093/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011094 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11095 */
11096
11097/*
11098 * set the path ways for 2 channel output
11099 * need to set the codec line out and mic 1 pin widgets to inputs
11100 */
11101static struct hda_verb alc861_threestack_ch2_init[] = {
11102 /* set pin widget 1Ah (line in) for input */
11103 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011104 /* set pin widget 18h (mic1/2) for input, for mic also enable
11105 * the vref
11106 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011107 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11108
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011109 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11110#if 0
11111 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11112 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11113#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011114 { } /* end */
11115};
11116/*
11117 * 6ch mode
11118 * need to set the codec line out and mic 1 pin widgets to outputs
11119 */
11120static struct hda_verb alc861_threestack_ch6_init[] = {
11121 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11122 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11123 /* set pin widget 18h (mic1) for output (CLFE)*/
11124 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11125
11126 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011127 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011128
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011129 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11130#if 0
11131 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11133#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011134 { } /* end */
11135};
11136
11137static struct hda_channel_mode alc861_threestack_modes[2] = {
11138 { 2, alc861_threestack_ch2_init },
11139 { 6, alc861_threestack_ch6_init },
11140};
Takashi Iwai22309c32006-08-09 16:57:28 +020011141/* Set mic1 as input and unmute the mixer */
11142static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11143 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11144 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11145 { } /* end */
11146};
11147/* Set mic1 as output and mute mixer */
11148static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11149 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11150 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11151 { } /* end */
11152};
11153
11154static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11155 { 2, alc861_uniwill_m31_ch2_init },
11156 { 4, alc861_uniwill_m31_ch4_init },
11157};
Kailang Yangdf694da2005-12-05 19:42:22 +010011158
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011159/* Set mic1 and line-in as input and unmute the mixer */
11160static struct hda_verb alc861_asus_ch2_init[] = {
11161 /* set pin widget 1Ah (line in) for input */
11162 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011163 /* set pin widget 18h (mic1/2) for input, for mic also enable
11164 * the vref
11165 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011166 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11167
11168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11169#if 0
11170 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11171 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11172#endif
11173 { } /* end */
11174};
11175/* Set mic1 nad line-in as output and mute mixer */
11176static struct hda_verb alc861_asus_ch6_init[] = {
11177 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11178 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11179 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11180 /* set pin widget 18h (mic1) for output (CLFE)*/
11181 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11182 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11183 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11184 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11185
11186 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11187#if 0
11188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11189 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11190#endif
11191 { } /* end */
11192};
11193
11194static struct hda_channel_mode alc861_asus_modes[2] = {
11195 { 2, alc861_asus_ch2_init },
11196 { 6, alc861_asus_ch6_init },
11197};
11198
Kailang Yangdf694da2005-12-05 19:42:22 +010011199/* patch-ALC861 */
11200
11201static struct snd_kcontrol_new alc861_base_mixer[] = {
11202 /* output mixer control */
11203 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11204 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11205 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11207 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11208
11209 /*Input mixer control */
11210 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11211 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11212 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11213 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11214 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11215 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11217 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11218 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011220
Kailang Yangdf694da2005-12-05 19:42:22 +010011221 /* Capture mixer control */
11222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11224 {
11225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11226 .name = "Capture Source",
11227 .count = 1,
11228 .info = alc_mux_enum_info,
11229 .get = alc_mux_enum_get,
11230 .put = alc_mux_enum_put,
11231 },
11232 { } /* end */
11233};
11234
11235static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11236 /* output mixer control */
11237 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11238 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11239 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11240 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11241 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11242
11243 /* Input mixer control */
11244 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11245 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11246 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11247 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11248 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11249 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11250 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11251 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11252 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011254
Kailang Yangdf694da2005-12-05 19:42:22 +010011255 /* Capture mixer control */
11256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11258 {
11259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11260 .name = "Capture Source",
11261 .count = 1,
11262 .info = alc_mux_enum_info,
11263 .get = alc_mux_enum_get,
11264 .put = alc_mux_enum_put,
11265 },
11266 {
11267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11268 .name = "Channel Mode",
11269 .info = alc_ch_mode_info,
11270 .get = alc_ch_mode_get,
11271 .put = alc_ch_mode_put,
11272 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11273 },
11274 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011275};
11276
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011277static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011278 /* output mixer control */
11279 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11281 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11282
11283 /*Capture mixer control */
11284 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11285 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11286 {
11287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11288 .name = "Capture Source",
11289 .count = 1,
11290 .info = alc_mux_enum_info,
11291 .get = alc_mux_enum_get,
11292 .put = alc_mux_enum_put,
11293 },
11294
11295 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011296};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011297
Takashi Iwai22309c32006-08-09 16:57:28 +020011298static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11299 /* output mixer control */
11300 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11301 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11302 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11303 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11304 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11305
11306 /* Input mixer control */
11307 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11308 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11309 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11310 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11311 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11312 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11314 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011317
Takashi Iwai22309c32006-08-09 16:57:28 +020011318 /* Capture mixer control */
11319 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11320 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11321 {
11322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11323 .name = "Capture Source",
11324 .count = 1,
11325 .info = alc_mux_enum_info,
11326 .get = alc_mux_enum_get,
11327 .put = alc_mux_enum_put,
11328 },
11329 {
11330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11331 .name = "Channel Mode",
11332 .info = alc_ch_mode_info,
11333 .get = alc_ch_mode_get,
11334 .put = alc_ch_mode_put,
11335 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11336 },
11337 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011338};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011339
11340static struct snd_kcontrol_new alc861_asus_mixer[] = {
11341 /* output mixer control */
11342 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11343 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11344 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11345 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11346 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11347
11348 /* Input mixer control */
11349 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11350 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11351 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11352 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11353 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11354 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11356 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11359
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011360 /* Capture mixer control */
11361 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11362 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11363 {
11364 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11365 .name = "Capture Source",
11366 .count = 1,
11367 .info = alc_mux_enum_info,
11368 .get = alc_mux_enum_get,
11369 .put = alc_mux_enum_put,
11370 },
11371 {
11372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11373 .name = "Channel Mode",
11374 .info = alc_ch_mode_info,
11375 .get = alc_ch_mode_get,
11376 .put = alc_ch_mode_put,
11377 .private_value = ARRAY_SIZE(alc861_asus_modes),
11378 },
11379 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011380};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011381
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011382/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011383static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011384 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11385 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11386 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11387 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11388 { }
11389};
11390
Kailang Yangdf694da2005-12-05 19:42:22 +010011391/*
11392 * generic initialization of ADC, input mixers and output mixers
11393 */
11394static struct hda_verb alc861_base_init_verbs[] = {
11395 /*
11396 * Unmute ADC0 and set the default input to mic-in
11397 */
11398 /* port-A for surround (rear panel) */
11399 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11400 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11401 /* port-B for mic-in (rear panel) with vref */
11402 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11403 /* port-C for line-in (rear panel) */
11404 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11405 /* port-D for Front */
11406 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11407 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11408 /* port-E for HP out (front panel) */
11409 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11410 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011411 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011412 /* port-F for mic-in (front panel) with vref */
11413 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11414 /* port-G for CLFE (rear panel) */
11415 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11416 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11417 /* port-H for side (rear panel) */
11418 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11419 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11420 /* CD-in */
11421 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11422 /* route front mic to ADC1*/
11423 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11425
11426 /* Unmute DAC0~3 & spdif out*/
11427 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11428 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11429 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11430 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11432
11433 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11434 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11435 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11436 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11437 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11438
11439 /* Unmute Stereo Mixer 15 */
11440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011444
11445 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11446 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11447 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11448 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11449 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11451 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011453 /* hp used DAC 3 (Front) */
11454 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011455 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11456
11457 { }
11458};
11459
11460static struct hda_verb alc861_threestack_init_verbs[] = {
11461 /*
11462 * Unmute ADC0 and set the default input to mic-in
11463 */
11464 /* port-A for surround (rear panel) */
11465 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11466 /* port-B for mic-in (rear panel) with vref */
11467 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11468 /* port-C for line-in (rear panel) */
11469 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11470 /* port-D for Front */
11471 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11472 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11473 /* port-E for HP out (front panel) */
11474 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11475 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011476 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011477 /* port-F for mic-in (front panel) with vref */
11478 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11479 /* port-G for CLFE (rear panel) */
11480 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11481 /* port-H for side (rear panel) */
11482 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11483 /* CD-in */
11484 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11485 /* route front mic to ADC1*/
11486 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11488 /* Unmute DAC0~3 & spdif out*/
11489 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11490 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11491 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11492 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11494
11495 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11496 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11497 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11498 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11499 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11500
11501 /* Unmute Stereo Mixer 15 */
11502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010011506
11507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011515 /* hp used DAC 3 (Front) */
11516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11518 { }
11519};
Takashi Iwai22309c32006-08-09 16:57:28 +020011520
11521static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11522 /*
11523 * Unmute ADC0 and set the default input to mic-in
11524 */
11525 /* port-A for surround (rear panel) */
11526 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11527 /* port-B for mic-in (rear panel) with vref */
11528 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11529 /* port-C for line-in (rear panel) */
11530 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11531 /* port-D for Front */
11532 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11533 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11534 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011535 /* this has to be set to VREF80 */
11536 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011537 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011538 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020011539 /* port-F for mic-in (front panel) with vref */
11540 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11541 /* port-G for CLFE (rear panel) */
11542 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11543 /* port-H for side (rear panel) */
11544 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11545 /* CD-in */
11546 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11547 /* route front mic to ADC1*/
11548 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11550 /* Unmute DAC0~3 & spdif out*/
11551 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11552 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11553 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11554 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11556
11557 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11558 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11559 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11560 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11561 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11562
11563 /* Unmute Stereo Mixer 15 */
11564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020011568
11569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11571 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11572 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11573 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011577 /* hp used DAC 3 (Front) */
11578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020011579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11580 { }
11581};
11582
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011583static struct hda_verb alc861_asus_init_verbs[] = {
11584 /*
11585 * Unmute ADC0 and set the default input to mic-in
11586 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011587 /* port-A for surround (rear panel)
11588 * according to codec#0 this is the HP jack
11589 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011590 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11591 /* route front PCM to HP */
11592 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11593 /* port-B for mic-in (rear panel) with vref */
11594 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11595 /* port-C for line-in (rear panel) */
11596 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11597 /* port-D for Front */
11598 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11599 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11600 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011601 /* this has to be set to VREF80 */
11602 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011603 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010011604 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011605 /* port-F for mic-in (front panel) with vref */
11606 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11607 /* port-G for CLFE (rear panel) */
11608 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11609 /* port-H for side (rear panel) */
11610 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11611 /* CD-in */
11612 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11613 /* route front mic to ADC1*/
11614 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11616 /* Unmute DAC0~3 & spdif out*/
11617 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11618 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11619 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11620 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11622 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11623 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11624 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11625 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11626 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11627
11628 /* Unmute Stereo Mixer 15 */
11629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011633
11634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11636 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11637 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11638 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11641 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011642 /* hp used DAC 3 (Front) */
11643 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11645 { }
11646};
11647
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010011648/* additional init verbs for ASUS laptops */
11649static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11650 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11652 { }
11653};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011654
Kailang Yangdf694da2005-12-05 19:42:22 +010011655/*
11656 * generic initialization of ADC, input mixers and output mixers
11657 */
11658static struct hda_verb alc861_auto_init_verbs[] = {
11659 /*
11660 * Unmute ADC0 and set the default input to mic-in
11661 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011662 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010011663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11664
11665 /* Unmute DAC0~3 & spdif out*/
11666 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11667 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11668 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11669 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11671
11672 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11673 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11674 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11675 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11676 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11677
11678 /* Unmute Stereo Mixer 15 */
11679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11683
11684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11688 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11689 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11690 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11691 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11692
11693 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11700 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011701
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011702 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011703
11704 { }
11705};
11706
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011707static struct hda_verb alc861_toshiba_init_verbs[] = {
11708 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011709
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011710 { }
11711};
11712
11713/* toggle speaker-output according to the hp-jack state */
11714static void alc861_toshiba_automute(struct hda_codec *codec)
11715{
11716 unsigned int present;
11717
11718 present = snd_hda_codec_read(codec, 0x0f, 0,
11719 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011720 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11721 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11722 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11723 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011724}
11725
11726static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11727 unsigned int res)
11728{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011729 if ((res >> 26) == ALC880_HP_EVENT)
11730 alc861_toshiba_automute(codec);
11731}
11732
Kailang Yangdf694da2005-12-05 19:42:22 +010011733/* pcm configuration: identiacal with ALC880 */
11734#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11735#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11736#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11737#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11738
11739
11740#define ALC861_DIGOUT_NID 0x07
11741
11742static struct hda_channel_mode alc861_8ch_modes[1] = {
11743 { 8, NULL }
11744};
11745
11746static hda_nid_t alc861_dac_nids[4] = {
11747 /* front, surround, clfe, side */
11748 0x03, 0x06, 0x05, 0x04
11749};
11750
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011751static hda_nid_t alc660_dac_nids[3] = {
11752 /* front, clfe, surround */
11753 0x03, 0x05, 0x06
11754};
11755
Kailang Yangdf694da2005-12-05 19:42:22 +010011756static hda_nid_t alc861_adc_nids[1] = {
11757 /* ADC0-2 */
11758 0x08,
11759};
11760
11761static struct hda_input_mux alc861_capture_source = {
11762 .num_items = 5,
11763 .items = {
11764 { "Mic", 0x0 },
11765 { "Front Mic", 0x3 },
11766 { "Line", 0x1 },
11767 { "CD", 0x4 },
11768 { "Mixer", 0x5 },
11769 },
11770};
11771
11772/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011773static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11774 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011775{
11776 int i;
11777 hda_nid_t nid;
11778
11779 spec->multiout.dac_nids = spec->private_dac_nids;
11780 for (i = 0; i < cfg->line_outs; i++) {
11781 nid = cfg->line_out_pins[i];
11782 if (nid) {
11783 if (i >= ARRAY_SIZE(alc861_dac_nids))
11784 continue;
11785 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11786 }
11787 }
11788 spec->multiout.num_dacs = cfg->line_outs;
11789 return 0;
11790}
11791
11792/* add playback controls from the parsed DAC table */
11793static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11794 const struct auto_pin_cfg *cfg)
11795{
11796 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011797 static const char *chname[4] = {
11798 "Front", "Surround", NULL /*CLFE*/, "Side"
11799 };
Kailang Yangdf694da2005-12-05 19:42:22 +010011800 hda_nid_t nid;
11801 int i, idx, err;
11802
11803 for (i = 0; i < cfg->line_outs; i++) {
11804 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011805 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010011806 continue;
11807 if (nid == 0x05) {
11808 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011809 err = add_control(spec, ALC_CTL_BIND_MUTE,
11810 "Center Playback Switch",
11811 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11812 HDA_OUTPUT));
11813 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011814 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011815 err = add_control(spec, ALC_CTL_BIND_MUTE,
11816 "LFE Playback Switch",
11817 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11818 HDA_OUTPUT));
11819 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011820 return err;
11821 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011822 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11823 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010011824 if (nid == alc861_dac_nids[idx])
11825 break;
11826 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011827 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11828 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11829 HDA_OUTPUT));
11830 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011831 return err;
11832 }
11833 }
11834 return 0;
11835}
11836
11837static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11838{
11839 int err;
11840 hda_nid_t nid;
11841
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011842 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010011843 return 0;
11844
11845 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11846 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011847 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11848 "Headphone Playback Switch",
11849 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11850 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011851 return err;
11852 spec->multiout.hp_nid = nid;
11853 }
11854 return 0;
11855}
11856
11857/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011858static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11859 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011860{
Kailang Yangdf694da2005-12-05 19:42:22 +010011861 struct hda_input_mux *imux = &spec->private_imux;
11862 int i, err, idx, idx1;
11863
11864 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011865 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011866 case 0x0c:
11867 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011868 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011869 break;
11870 case 0x0f:
11871 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011872 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011873 break;
11874 case 0x0d:
11875 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011876 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011877 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011878 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010011879 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011880 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010011881 break;
11882 case 0x11:
11883 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011884 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010011885 break;
11886 default:
11887 continue;
11888 }
11889
Takashi Iwai4a471b72005-12-07 13:56:29 +010011890 err = new_analog_input(spec, cfg->input_pins[i],
11891 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010011892 if (err < 0)
11893 return err;
11894
Takashi Iwai4a471b72005-12-07 13:56:29 +010011895 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010011896 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011897 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010011898 }
11899 return 0;
11900}
11901
11902static struct snd_kcontrol_new alc861_capture_mixer[] = {
11903 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11904 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11905
11906 {
11907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11908 /* The multiple "Capture Source" controls confuse alsamixer
11909 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010011910 */
11911 /* .name = "Capture Source", */
11912 .name = "Input Source",
11913 .count = 1,
11914 .info = alc_mux_enum_info,
11915 .get = alc_mux_enum_get,
11916 .put = alc_mux_enum_put,
11917 },
11918 { } /* end */
11919};
11920
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011921static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11922 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010011923 int pin_type, int dac_idx)
11924{
Jacek Luczak564c5be2008-05-03 18:41:23 +020011925 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11926 pin_type);
11927 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11928 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010011929}
11930
11931static void alc861_auto_init_multi_out(struct hda_codec *codec)
11932{
11933 struct alc_spec *spec = codec->spec;
11934 int i;
11935
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011936 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010011937 for (i = 0; i < spec->autocfg.line_outs; i++) {
11938 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011939 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010011940 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011941 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011942 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011943 }
11944}
11945
11946static void alc861_auto_init_hp_out(struct hda_codec *codec)
11947{
11948 struct alc_spec *spec = codec->spec;
11949 hda_nid_t pin;
11950
Takashi Iwaieb06ed82006-09-20 17:10:27 +020011951 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011952 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011953 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11954 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011955 pin = spec->autocfg.speaker_pins[0];
11956 if (pin)
11957 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010011958}
11959
11960static void alc861_auto_init_analog_input(struct hda_codec *codec)
11961{
11962 struct alc_spec *spec = codec->spec;
11963 int i;
11964
11965 for (i = 0; i < AUTO_PIN_LAST; i++) {
11966 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011967 if (nid >= 0x0c && nid <= 0x11) {
11968 snd_hda_codec_write(codec, nid, 0,
11969 AC_VERB_SET_PIN_WIDGET_CONTROL,
11970 i <= AUTO_PIN_FRONT_MIC ?
11971 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010011972 }
11973 }
11974}
11975
11976/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011977/* return 1 if successful, 0 if the proper config is not found,
11978 * or a negative error code
11979 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011980static int alc861_parse_auto_config(struct hda_codec *codec)
11981{
11982 struct alc_spec *spec = codec->spec;
11983 int err;
11984 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11985
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011986 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11987 alc861_ignore);
11988 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011989 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011990 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010011991 return 0; /* can't find valid BIOS pin config */
11992
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011993 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11994 if (err < 0)
11995 return err;
11996 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11997 if (err < 0)
11998 return err;
11999 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12000 if (err < 0)
12001 return err;
12002 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12003 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012004 return err;
12005
12006 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12007
12008 if (spec->autocfg.dig_out_pin)
12009 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12010
12011 if (spec->kctl_alloc)
12012 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12013
12014 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12015
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012016 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012017 spec->input_mux = &spec->private_imux;
12018
12019 spec->adc_nids = alc861_adc_nids;
12020 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12021 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12022 spec->num_mixers++;
12023
12024 return 1;
12025}
12026
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012027/* additional initialization for auto-configuration model */
12028static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012029{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012030 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012031 alc861_auto_init_multi_out(codec);
12032 alc861_auto_init_hp_out(codec);
12033 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012034 if (spec->unsol_event)
12035 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012036}
12037
Takashi Iwaicb53c622007-08-10 17:21:45 +020012038#ifdef CONFIG_SND_HDA_POWER_SAVE
12039static struct hda_amp_list alc861_loopbacks[] = {
12040 { 0x15, HDA_INPUT, 0 },
12041 { 0x15, HDA_INPUT, 1 },
12042 { 0x15, HDA_INPUT, 2 },
12043 { 0x15, HDA_INPUT, 3 },
12044 { } /* end */
12045};
12046#endif
12047
Kailang Yangdf694da2005-12-05 19:42:22 +010012048
12049/*
12050 * configuration and preset
12051 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012052static const char *alc861_models[ALC861_MODEL_LAST] = {
12053 [ALC861_3ST] = "3stack",
12054 [ALC660_3ST] = "3stack-660",
12055 [ALC861_3ST_DIG] = "3stack-dig",
12056 [ALC861_6ST_DIG] = "6stack-dig",
12057 [ALC861_UNIWILL_M31] = "uniwill-m31",
12058 [ALC861_TOSHIBA] = "toshiba",
12059 [ALC861_ASUS] = "asus",
12060 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12061 [ALC861_AUTO] = "auto",
12062};
12063
12064static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012065 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012066 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12067 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12068 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012069 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012070 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012071 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012072 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12073 * Any other models that need this preset?
12074 */
12075 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012076 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12077 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012078 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12079 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12080 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12081 /* FIXME: the below seems conflict */
12082 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12083 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12084 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012085 {}
12086};
12087
12088static struct alc_config_preset alc861_presets[] = {
12089 [ALC861_3ST] = {
12090 .mixers = { alc861_3ST_mixer },
12091 .init_verbs = { alc861_threestack_init_verbs },
12092 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12093 .dac_nids = alc861_dac_nids,
12094 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12095 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012096 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012097 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12098 .adc_nids = alc861_adc_nids,
12099 .input_mux = &alc861_capture_source,
12100 },
12101 [ALC861_3ST_DIG] = {
12102 .mixers = { alc861_base_mixer },
12103 .init_verbs = { alc861_threestack_init_verbs },
12104 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12105 .dac_nids = alc861_dac_nids,
12106 .dig_out_nid = ALC861_DIGOUT_NID,
12107 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12108 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012109 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012110 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12111 .adc_nids = alc861_adc_nids,
12112 .input_mux = &alc861_capture_source,
12113 },
12114 [ALC861_6ST_DIG] = {
12115 .mixers = { alc861_base_mixer },
12116 .init_verbs = { alc861_base_init_verbs },
12117 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12118 .dac_nids = alc861_dac_nids,
12119 .dig_out_nid = ALC861_DIGOUT_NID,
12120 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12121 .channel_mode = alc861_8ch_modes,
12122 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12123 .adc_nids = alc861_adc_nids,
12124 .input_mux = &alc861_capture_source,
12125 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012126 [ALC660_3ST] = {
12127 .mixers = { alc861_3ST_mixer },
12128 .init_verbs = { alc861_threestack_init_verbs },
12129 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12130 .dac_nids = alc660_dac_nids,
12131 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12132 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012133 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012134 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12135 .adc_nids = alc861_adc_nids,
12136 .input_mux = &alc861_capture_source,
12137 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012138 [ALC861_UNIWILL_M31] = {
12139 .mixers = { alc861_uniwill_m31_mixer },
12140 .init_verbs = { alc861_uniwill_m31_init_verbs },
12141 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12142 .dac_nids = alc861_dac_nids,
12143 .dig_out_nid = ALC861_DIGOUT_NID,
12144 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12145 .channel_mode = alc861_uniwill_m31_modes,
12146 .need_dac_fix = 1,
12147 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12148 .adc_nids = alc861_adc_nids,
12149 .input_mux = &alc861_capture_source,
12150 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012151 [ALC861_TOSHIBA] = {
12152 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012153 .init_verbs = { alc861_base_init_verbs,
12154 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012155 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12156 .dac_nids = alc861_dac_nids,
12157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12158 .channel_mode = alc883_3ST_2ch_modes,
12159 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12160 .adc_nids = alc861_adc_nids,
12161 .input_mux = &alc861_capture_source,
12162 .unsol_event = alc861_toshiba_unsol_event,
12163 .init_hook = alc861_toshiba_automute,
12164 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012165 [ALC861_ASUS] = {
12166 .mixers = { alc861_asus_mixer },
12167 .init_verbs = { alc861_asus_init_verbs },
12168 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12169 .dac_nids = alc861_dac_nids,
12170 .dig_out_nid = ALC861_DIGOUT_NID,
12171 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12172 .channel_mode = alc861_asus_modes,
12173 .need_dac_fix = 1,
12174 .hp_nid = 0x06,
12175 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12176 .adc_nids = alc861_adc_nids,
12177 .input_mux = &alc861_capture_source,
12178 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012179 [ALC861_ASUS_LAPTOP] = {
12180 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12181 .init_verbs = { alc861_asus_init_verbs,
12182 alc861_asus_laptop_init_verbs },
12183 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12184 .dac_nids = alc861_dac_nids,
12185 .dig_out_nid = ALC861_DIGOUT_NID,
12186 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12187 .channel_mode = alc883_3ST_2ch_modes,
12188 .need_dac_fix = 1,
12189 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12190 .adc_nids = alc861_adc_nids,
12191 .input_mux = &alc861_capture_source,
12192 },
12193};
Kailang Yangdf694da2005-12-05 19:42:22 +010012194
12195
12196static int patch_alc861(struct hda_codec *codec)
12197{
12198 struct alc_spec *spec;
12199 int board_config;
12200 int err;
12201
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012202 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012203 if (spec == NULL)
12204 return -ENOMEM;
12205
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012206 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012207
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012208 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12209 alc861_models,
12210 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012211
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012212 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012213 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12214 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012215 board_config = ALC861_AUTO;
12216 }
12217
12218 if (board_config == ALC861_AUTO) {
12219 /* automatic parse from the BIOS config */
12220 err = alc861_parse_auto_config(codec);
12221 if (err < 0) {
12222 alc_free(codec);
12223 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012224 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012225 printk(KERN_INFO
12226 "hda_codec: Cannot set up configuration "
12227 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012228 board_config = ALC861_3ST_DIG;
12229 }
12230 }
12231
12232 if (board_config != ALC861_AUTO)
12233 setup_preset(spec, &alc861_presets[board_config]);
12234
12235 spec->stream_name_analog = "ALC861 Analog";
12236 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12237 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12238
12239 spec->stream_name_digital = "ALC861 Digital";
12240 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12241 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12242
Takashi Iwai2134ea42008-01-10 16:53:55 +010012243 spec->vmaster_nid = 0x03;
12244
Kailang Yangdf694da2005-12-05 19:42:22 +010012245 codec->patch_ops = alc_patch_ops;
12246 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012247 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012248#ifdef CONFIG_SND_HDA_POWER_SAVE
12249 if (!spec->loopback.amplist)
12250 spec->loopback.amplist = alc861_loopbacks;
12251#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012252
12253 return 0;
12254}
12255
12256/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012257 * ALC861-VD support
12258 *
12259 * Based on ALC882
12260 *
12261 * In addition, an independent DAC
12262 */
12263#define ALC861VD_DIGOUT_NID 0x06
12264
12265static hda_nid_t alc861vd_dac_nids[4] = {
12266 /* front, surr, clfe, side surr */
12267 0x02, 0x03, 0x04, 0x05
12268};
12269
12270/* dac_nids for ALC660vd are in a different order - according to
12271 * Realtek's driver.
12272 * This should probably tesult in a different mixer for 6stack models
12273 * of ALC660vd codecs, but for now there is only 3stack mixer
12274 * - and it is the same as in 861vd.
12275 * adc_nids in ALC660vd are (is) the same as in 861vd
12276 */
12277static hda_nid_t alc660vd_dac_nids[3] = {
12278 /* front, rear, clfe, rear_surr */
12279 0x02, 0x04, 0x03
12280};
12281
12282static hda_nid_t alc861vd_adc_nids[1] = {
12283 /* ADC0 */
12284 0x09,
12285};
12286
Takashi Iwaie1406342008-02-11 18:32:32 +010012287static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12288
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012289/* input MUX */
12290/* FIXME: should be a matrix-type input source selection */
12291static struct hda_input_mux alc861vd_capture_source = {
12292 .num_items = 4,
12293 .items = {
12294 { "Mic", 0x0 },
12295 { "Front Mic", 0x1 },
12296 { "Line", 0x2 },
12297 { "CD", 0x4 },
12298 },
12299};
12300
Kailang Yang272a5272007-05-14 11:00:38 +020012301static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012302 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012303 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012304 { "Ext Mic", 0x0 },
12305 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012306 },
12307};
12308
Kailang Yangd1a991a2007-08-15 16:21:59 +020012309static struct hda_input_mux alc861vd_hp_capture_source = {
12310 .num_items = 2,
12311 .items = {
12312 { "Front Mic", 0x0 },
12313 { "ATAPI Mic", 0x1 },
12314 },
12315};
12316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012317#define alc861vd_mux_enum_info alc_mux_enum_info
12318#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010012319/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12320#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012321
12322/*
12323 * 2ch mode
12324 */
12325static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12326 { 2, NULL }
12327};
12328
12329/*
12330 * 6ch mode
12331 */
12332static struct hda_verb alc861vd_6stack_ch6_init[] = {
12333 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12334 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12335 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12336 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12337 { } /* end */
12338};
12339
12340/*
12341 * 8ch mode
12342 */
12343static struct hda_verb alc861vd_6stack_ch8_init[] = {
12344 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12345 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12346 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12347 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12348 { } /* end */
12349};
12350
12351static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12352 { 6, alc861vd_6stack_ch6_init },
12353 { 8, alc861vd_6stack_ch8_init },
12354};
12355
12356static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12357 {
12358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12359 .name = "Channel Mode",
12360 .info = alc_ch_mode_info,
12361 .get = alc_ch_mode_get,
12362 .put = alc_ch_mode_put,
12363 },
12364 { } /* end */
12365};
12366
12367static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12368 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12369 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12370
12371 {
12372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12373 /* The multiple "Capture Source" controls confuse alsamixer
12374 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012375 */
12376 /* .name = "Capture Source", */
12377 .name = "Input Source",
12378 .count = 1,
12379 .info = alc861vd_mux_enum_info,
12380 .get = alc861vd_mux_enum_get,
12381 .put = alc861vd_mux_enum_put,
12382 },
12383 { } /* end */
12384};
12385
12386/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12387 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12388 */
12389static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12390 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12391 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12392
12393 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12394 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12395
12396 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12397 HDA_OUTPUT),
12398 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12399 HDA_OUTPUT),
12400 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12401 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12402
12403 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12404 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12405
12406 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12407
12408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12411
12412 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12413 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12414 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12415
12416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12418
12419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12421
12422 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12423 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12424
12425 { } /* end */
12426};
12427
12428static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12429 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12430 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12431
12432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12433
12434 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12437
12438 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12439 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12440 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12441
12442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12444
12445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12447
12448 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12449 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12450
12451 { } /* end */
12452};
12453
Kailang Yangbdd148a2007-05-08 15:19:08 +020012454static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12455 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12456 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12457 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12458
12459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12460
12461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12464
12465 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12468
12469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12471
12472 { } /* end */
12473};
12474
Tobin Davisb419f342008-03-07 11:57:51 +010012475/* Pin assignment: Speaker=0x14, HP = 0x15,
12476 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020012477 */
12478static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010012479 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12480 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012481 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12482 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010012483 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12484 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12485 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12486 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12487 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12488 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12489 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12490 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020012491 { } /* end */
12492};
12493
Kailang Yangd1a991a2007-08-15 16:21:59 +020012494/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12495 * Front Mic=0x18, ATAPI Mic = 0x19,
12496 */
12497static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12498 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12499 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12501 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12502 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12503 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12504 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12505 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12506
12507 { } /* end */
12508};
12509
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012510/*
12511 * generic initialization of ADC, input mixers and output mixers
12512 */
12513static struct hda_verb alc861vd_volume_init_verbs[] = {
12514 /*
12515 * Unmute ADC0 and set the default input to mic-in
12516 */
12517 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12519
12520 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12521 * the analog-loopback mixer widget
12522 */
12523 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012529
12530 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020012531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012535
12536 /*
12537 * Set up output mixers (0x02 - 0x05)
12538 */
12539 /* set vol=0 to output mixers */
12540 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12541 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12542 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12543 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12544
12545 /* set up input amps for analog loopback */
12546 /* Amp Indices: DAC = 0, mixer = 1 */
12547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12553 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12555
12556 { }
12557};
12558
12559/*
12560 * 3-stack pin configuration:
12561 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12562 */
12563static struct hda_verb alc861vd_3stack_init_verbs[] = {
12564 /*
12565 * Set pin mode and muting
12566 */
12567 /* set front pin widgets 0x14 for output */
12568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12571
12572 /* Mic (rear) pin: input vref at 80% */
12573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12575 /* Front Mic pin: input vref at 80% */
12576 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12578 /* Line In pin: input */
12579 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12581 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12584 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12585 /* CD pin widget for input */
12586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12587
12588 { }
12589};
12590
12591/*
12592 * 6-stack pin configuration:
12593 */
12594static struct hda_verb alc861vd_6stack_init_verbs[] = {
12595 /*
12596 * Set pin mode and muting
12597 */
12598 /* set front pin widgets 0x14 for output */
12599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12602
12603 /* Rear Pin: output 1 (0x0d) */
12604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12607 /* CLFE Pin: output 2 (0x0e) */
12608 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12610 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12611 /* Side Pin: output 3 (0x0f) */
12612 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12613 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12614 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12615
12616 /* Mic (rear) pin: input vref at 80% */
12617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12619 /* Front Mic pin: input vref at 80% */
12620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12621 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12622 /* Line In pin: input */
12623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12625 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12628 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12629 /* CD pin widget for input */
12630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12631
12632 { }
12633};
12634
Kailang Yangbdd148a2007-05-08 15:19:08 +020012635static struct hda_verb alc861vd_eapd_verbs[] = {
12636 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12637 { }
12638};
12639
12640static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12644 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12645 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12646 {}
12647};
12648
12649/* toggle speaker-output according to the hp-jack state */
12650static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12651{
12652 unsigned int present;
12653 unsigned char bits;
12654
12655 present = snd_hda_codec_read(codec, 0x1b, 0,
12656 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012657 bits = present ? HDA_AMP_MUTE : 0;
12658 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12659 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012660}
12661
12662static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12663{
12664 unsigned int present;
12665 unsigned char bits;
12666
12667 present = snd_hda_codec_read(codec, 0x18, 0,
12668 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012669 bits = present ? HDA_AMP_MUTE : 0;
12670 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12671 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020012672}
12673
12674static void alc861vd_lenovo_automute(struct hda_codec *codec)
12675{
12676 alc861vd_lenovo_hp_automute(codec);
12677 alc861vd_lenovo_mic_automute(codec);
12678}
12679
12680static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12681 unsigned int res)
12682{
12683 switch (res >> 26) {
12684 case ALC880_HP_EVENT:
12685 alc861vd_lenovo_hp_automute(codec);
12686 break;
12687 case ALC880_MIC_EVENT:
12688 alc861vd_lenovo_mic_automute(codec);
12689 break;
12690 }
12691}
12692
Kailang Yang272a5272007-05-14 11:00:38 +020012693static struct hda_verb alc861vd_dallas_verbs[] = {
12694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12698
12699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12707
12708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12714 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12716
12717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12721 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12722 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12723 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12724 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12725
12726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12730
12731 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12732 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12733 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12734
12735 { } /* end */
12736};
12737
12738/* toggle speaker-output according to the hp-jack state */
12739static void alc861vd_dallas_automute(struct hda_codec *codec)
12740{
12741 unsigned int present;
12742
12743 present = snd_hda_codec_read(codec, 0x15, 0,
12744 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012745 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12746 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020012747}
12748
12749static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12750{
12751 if ((res >> 26) == ALC880_HP_EVENT)
12752 alc861vd_dallas_automute(codec);
12753}
12754
Takashi Iwaicb53c622007-08-10 17:21:45 +020012755#ifdef CONFIG_SND_HDA_POWER_SAVE
12756#define alc861vd_loopbacks alc880_loopbacks
12757#endif
12758
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012759/* pcm configuration: identiacal with ALC880 */
12760#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12761#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12762#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12763#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12764
12765/*
12766 * configuration and preset
12767 */
12768static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12769 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012770 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012771 [ALC861VD_3ST] = "3stack",
12772 [ALC861VD_3ST_DIG] = "3stack-digout",
12773 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020012774 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020012775 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012776 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012777 [ALC861VD_AUTO] = "auto",
12778};
12779
12780static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012781 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12782 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010012783 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012784 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020012785 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012786 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012787 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020012788 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020012789 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020012790 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010012791 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020012792 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012793 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12794 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020012795 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012796 {}
12797};
12798
12799static struct alc_config_preset alc861vd_presets[] = {
12800 [ALC660VD_3ST] = {
12801 .mixers = { alc861vd_3st_mixer },
12802 .init_verbs = { alc861vd_volume_init_verbs,
12803 alc861vd_3stack_init_verbs },
12804 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12805 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012806 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12807 .channel_mode = alc861vd_3stack_2ch_modes,
12808 .input_mux = &alc861vd_capture_source,
12809 },
Mike Crash6963f842007-06-25 12:12:51 +020012810 [ALC660VD_3ST_DIG] = {
12811 .mixers = { alc861vd_3st_mixer },
12812 .init_verbs = { alc861vd_volume_init_verbs,
12813 alc861vd_3stack_init_verbs },
12814 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12815 .dac_nids = alc660vd_dac_nids,
12816 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020012817 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12818 .channel_mode = alc861vd_3stack_2ch_modes,
12819 .input_mux = &alc861vd_capture_source,
12820 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012821 [ALC861VD_3ST] = {
12822 .mixers = { alc861vd_3st_mixer },
12823 .init_verbs = { alc861vd_volume_init_verbs,
12824 alc861vd_3stack_init_verbs },
12825 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12826 .dac_nids = alc861vd_dac_nids,
12827 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12828 .channel_mode = alc861vd_3stack_2ch_modes,
12829 .input_mux = &alc861vd_capture_source,
12830 },
12831 [ALC861VD_3ST_DIG] = {
12832 .mixers = { alc861vd_3st_mixer },
12833 .init_verbs = { alc861vd_volume_init_verbs,
12834 alc861vd_3stack_init_verbs },
12835 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12836 .dac_nids = alc861vd_dac_nids,
12837 .dig_out_nid = ALC861VD_DIGOUT_NID,
12838 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12839 .channel_mode = alc861vd_3stack_2ch_modes,
12840 .input_mux = &alc861vd_capture_source,
12841 },
12842 [ALC861VD_6ST_DIG] = {
12843 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12844 .init_verbs = { alc861vd_volume_init_verbs,
12845 alc861vd_6stack_init_verbs },
12846 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12847 .dac_nids = alc861vd_dac_nids,
12848 .dig_out_nid = ALC861VD_DIGOUT_NID,
12849 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12850 .channel_mode = alc861vd_6stack_modes,
12851 .input_mux = &alc861vd_capture_source,
12852 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020012853 [ALC861VD_LENOVO] = {
12854 .mixers = { alc861vd_lenovo_mixer },
12855 .init_verbs = { alc861vd_volume_init_verbs,
12856 alc861vd_3stack_init_verbs,
12857 alc861vd_eapd_verbs,
12858 alc861vd_lenovo_unsol_verbs },
12859 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12860 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020012861 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12862 .channel_mode = alc861vd_3stack_2ch_modes,
12863 .input_mux = &alc861vd_capture_source,
12864 .unsol_event = alc861vd_lenovo_unsol_event,
12865 .init_hook = alc861vd_lenovo_automute,
12866 },
Kailang Yang272a5272007-05-14 11:00:38 +020012867 [ALC861VD_DALLAS] = {
12868 .mixers = { alc861vd_dallas_mixer },
12869 .init_verbs = { alc861vd_dallas_verbs },
12870 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12871 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020012872 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12873 .channel_mode = alc861vd_3stack_2ch_modes,
12874 .input_mux = &alc861vd_dallas_capture_source,
12875 .unsol_event = alc861vd_dallas_unsol_event,
12876 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012877 },
12878 [ALC861VD_HP] = {
12879 .mixers = { alc861vd_hp_mixer },
12880 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12881 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12882 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012883 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012884 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12885 .channel_mode = alc861vd_3stack_2ch_modes,
12886 .input_mux = &alc861vd_hp_capture_source,
12887 .unsol_event = alc861vd_dallas_unsol_event,
12888 .init_hook = alc861vd_dallas_automute,
12889 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012890};
12891
12892/*
12893 * BIOS auto configuration
12894 */
12895static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12896 hda_nid_t nid, int pin_type, int dac_idx)
12897{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012898 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012899}
12900
12901static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12902{
12903 struct alc_spec *spec = codec->spec;
12904 int i;
12905
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012906 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012907 for (i = 0; i <= HDA_SIDE; i++) {
12908 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012909 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012910 if (nid)
12911 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012912 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012913 }
12914}
12915
12916
12917static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12918{
12919 struct alc_spec *spec = codec->spec;
12920 hda_nid_t pin;
12921
12922 pin = spec->autocfg.hp_pins[0];
12923 if (pin) /* connect to front and use dac 0 */
12924 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012925 pin = spec->autocfg.speaker_pins[0];
12926 if (pin)
12927 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012928}
12929
12930#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12931#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12932
12933static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12934{
12935 struct alc_spec *spec = codec->spec;
12936 int i;
12937
12938 for (i = 0; i < AUTO_PIN_LAST; i++) {
12939 hda_nid_t nid = spec->autocfg.input_pins[i];
12940 if (alc861vd_is_input_pin(nid)) {
12941 snd_hda_codec_write(codec, nid, 0,
12942 AC_VERB_SET_PIN_WIDGET_CONTROL,
12943 i <= AUTO_PIN_FRONT_MIC ?
12944 PIN_VREF80 : PIN_IN);
12945 if (nid != ALC861VD_PIN_CD_NID)
12946 snd_hda_codec_write(codec, nid, 0,
12947 AC_VERB_SET_AMP_GAIN_MUTE,
12948 AMP_OUT_MUTE);
12949 }
12950 }
12951}
12952
12953#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12954#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12955
12956/* add playback controls from the parsed DAC table */
12957/* Based on ALC880 version. But ALC861VD has separate,
12958 * different NIDs for mute/unmute switch and volume control */
12959static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12960 const struct auto_pin_cfg *cfg)
12961{
12962 char name[32];
12963 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12964 hda_nid_t nid_v, nid_s;
12965 int i, err;
12966
12967 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012968 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012969 continue;
12970 nid_v = alc861vd_idx_to_mixer_vol(
12971 alc880_dac_to_idx(
12972 spec->multiout.dac_nids[i]));
12973 nid_s = alc861vd_idx_to_mixer_switch(
12974 alc880_dac_to_idx(
12975 spec->multiout.dac_nids[i]));
12976
12977 if (i == 2) {
12978 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012979 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12980 "Center Playback Volume",
12981 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12982 HDA_OUTPUT));
12983 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012984 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012985 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12986 "LFE Playback Volume",
12987 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12988 HDA_OUTPUT));
12989 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012990 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012991 err = add_control(spec, ALC_CTL_BIND_MUTE,
12992 "Center Playback Switch",
12993 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12994 HDA_INPUT));
12995 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012996 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012997 err = add_control(spec, ALC_CTL_BIND_MUTE,
12998 "LFE Playback Switch",
12999 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13000 HDA_INPUT));
13001 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013002 return err;
13003 } else {
13004 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013005 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13006 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13007 HDA_OUTPUT));
13008 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013009 return err;
13010 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013011 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013012 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013013 HDA_INPUT));
13014 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013015 return err;
13016 }
13017 }
13018 return 0;
13019}
13020
13021/* add playback controls for speaker and HP outputs */
13022/* Based on ALC880 version. But ALC861VD has separate,
13023 * different NIDs for mute/unmute switch and volume control */
13024static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13025 hda_nid_t pin, const char *pfx)
13026{
13027 hda_nid_t nid_v, nid_s;
13028 int err;
13029 char name[32];
13030
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013031 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013032 return 0;
13033
13034 if (alc880_is_fixed_pin(pin)) {
13035 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13036 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013037 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013038 spec->multiout.hp_nid = nid_v;
13039 else
13040 spec->multiout.extra_out_nid[0] = nid_v;
13041 /* control HP volume/switch on the output mixer amp */
13042 nid_v = alc861vd_idx_to_mixer_vol(
13043 alc880_fixed_pin_idx(pin));
13044 nid_s = alc861vd_idx_to_mixer_switch(
13045 alc880_fixed_pin_idx(pin));
13046
13047 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013048 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13049 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13050 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013051 return err;
13052 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013053 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13054 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13055 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013056 return err;
13057 } else if (alc880_is_multi_pin(pin)) {
13058 /* set manual connection */
13059 /* we have only a switch on HP-out PIN */
13060 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013061 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13062 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13063 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013064 return err;
13065 }
13066 return 0;
13067}
13068
13069/* parse the BIOS configuration and set up the alc_spec
13070 * return 1 if successful, 0 if the proper config is not found,
13071 * or a negative error code
13072 * Based on ALC880 version - had to change it to override
13073 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13074static int alc861vd_parse_auto_config(struct hda_codec *codec)
13075{
13076 struct alc_spec *spec = codec->spec;
13077 int err;
13078 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13079
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013080 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13081 alc861vd_ignore);
13082 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013083 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013084 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013085 return 0; /* can't find valid BIOS pin config */
13086
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013087 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13088 if (err < 0)
13089 return err;
13090 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13091 if (err < 0)
13092 return err;
13093 err = alc861vd_auto_create_extra_out(spec,
13094 spec->autocfg.speaker_pins[0],
13095 "Speaker");
13096 if (err < 0)
13097 return err;
13098 err = alc861vd_auto_create_extra_out(spec,
13099 spec->autocfg.hp_pins[0],
13100 "Headphone");
13101 if (err < 0)
13102 return err;
13103 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13104 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013105 return err;
13106
13107 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13108
13109 if (spec->autocfg.dig_out_pin)
13110 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13111
13112 if (spec->kctl_alloc)
13113 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13114
13115 spec->init_verbs[spec->num_init_verbs++]
13116 = alc861vd_volume_init_verbs;
13117
13118 spec->num_mux_defs = 1;
13119 spec->input_mux = &spec->private_imux;
13120
Takashi Iwai776e1842007-08-29 15:07:11 +020013121 err = alc_auto_add_mic_boost(codec);
13122 if (err < 0)
13123 return err;
13124
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013125 return 1;
13126}
13127
13128/* additional initialization for auto-configuration model */
13129static void alc861vd_auto_init(struct hda_codec *codec)
13130{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013131 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013132 alc861vd_auto_init_multi_out(codec);
13133 alc861vd_auto_init_hp_out(codec);
13134 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013135 if (spec->unsol_event)
13136 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013137}
13138
13139static int patch_alc861vd(struct hda_codec *codec)
13140{
13141 struct alc_spec *spec;
13142 int err, board_config;
13143
13144 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13145 if (spec == NULL)
13146 return -ENOMEM;
13147
13148 codec->spec = spec;
13149
13150 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13151 alc861vd_models,
13152 alc861vd_cfg_tbl);
13153
13154 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13155 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13156 "ALC861VD, trying auto-probe from BIOS...\n");
13157 board_config = ALC861VD_AUTO;
13158 }
13159
13160 if (board_config == ALC861VD_AUTO) {
13161 /* automatic parse from the BIOS config */
13162 err = alc861vd_parse_auto_config(codec);
13163 if (err < 0) {
13164 alc_free(codec);
13165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013166 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013167 printk(KERN_INFO
13168 "hda_codec: Cannot set up configuration "
13169 "from BIOS. Using base mode...\n");
13170 board_config = ALC861VD_3ST;
13171 }
13172 }
13173
13174 if (board_config != ALC861VD_AUTO)
13175 setup_preset(spec, &alc861vd_presets[board_config]);
13176
13177 spec->stream_name_analog = "ALC861VD Analog";
13178 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13179 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13180
13181 spec->stream_name_digital = "ALC861VD Digital";
13182 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13183 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13184
13185 spec->adc_nids = alc861vd_adc_nids;
13186 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013187 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013188
13189 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13190 spec->num_mixers++;
13191
Takashi Iwai2134ea42008-01-10 16:53:55 +010013192 spec->vmaster_nid = 0x02;
13193
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013194 codec->patch_ops = alc_patch_ops;
13195
13196 if (board_config == ALC861VD_AUTO)
13197 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013198#ifdef CONFIG_SND_HDA_POWER_SAVE
13199 if (!spec->loopback.amplist)
13200 spec->loopback.amplist = alc861vd_loopbacks;
13201#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013202
13203 return 0;
13204}
13205
13206/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013207 * ALC662 support
13208 *
13209 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13210 * configuration. Each pin widget can choose any input DACs and a mixer.
13211 * Each ADC is connected from a mixer of all inputs. This makes possible
13212 * 6-channel independent captures.
13213 *
13214 * In addition, an independent DAC for the multi-playback (not used in this
13215 * driver yet).
13216 */
13217#define ALC662_DIGOUT_NID 0x06
13218#define ALC662_DIGIN_NID 0x0a
13219
13220static hda_nid_t alc662_dac_nids[4] = {
13221 /* front, rear, clfe, rear_surr */
13222 0x02, 0x03, 0x04
13223};
13224
13225static hda_nid_t alc662_adc_nids[1] = {
13226 /* ADC1-2 */
13227 0x09,
13228};
Takashi Iwaie1406342008-02-11 18:32:32 +010013229
Kailang Yang77a261b2008-02-19 11:38:05 +010013230static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013231
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013232/* input MUX */
13233/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013234static struct hda_input_mux alc662_capture_source = {
13235 .num_items = 4,
13236 .items = {
13237 { "Mic", 0x0 },
13238 { "Front Mic", 0x1 },
13239 { "Line", 0x2 },
13240 { "CD", 0x4 },
13241 },
13242};
13243
13244static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13245 .num_items = 2,
13246 .items = {
13247 { "Mic", 0x1 },
13248 { "Line", 0x2 },
13249 },
13250};
Kailang Yang291702f2007-10-16 14:28:03 +020013251
13252static struct hda_input_mux alc662_eeepc_capture_source = {
13253 .num_items = 2,
13254 .items = {
13255 { "i-Mic", 0x1 },
13256 { "e-Mic", 0x0 },
13257 },
13258};
13259
Kailang Yang6dda9f42008-05-27 12:05:31 +020013260static struct hda_input_mux alc663_capture_source = {
13261 .num_items = 3,
13262 .items = {
13263 { "Mic", 0x0 },
13264 { "Front Mic", 0x1 },
13265 { "Line", 0x2 },
13266 },
13267};
13268
13269static struct hda_input_mux alc663_m51va_capture_source = {
13270 .num_items = 2,
13271 .items = {
13272 { "Ext-Mic", 0x0 },
13273 { "D-Mic", 0x9 },
13274 },
13275};
13276
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013277#define alc662_mux_enum_info alc_mux_enum_info
13278#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013279#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013280
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013281/*
13282 * 2ch mode
13283 */
13284static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13285 { 2, NULL }
13286};
13287
13288/*
13289 * 2ch mode
13290 */
13291static struct hda_verb alc662_3ST_ch2_init[] = {
13292 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13293 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13296 { } /* end */
13297};
13298
13299/*
13300 * 6ch mode
13301 */
13302static struct hda_verb alc662_3ST_ch6_init[] = {
13303 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13304 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13305 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13306 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13307 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13308 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13309 { } /* end */
13310};
13311
13312static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13313 { 2, alc662_3ST_ch2_init },
13314 { 6, alc662_3ST_ch6_init },
13315};
13316
13317/*
13318 * 2ch mode
13319 */
13320static struct hda_verb alc662_sixstack_ch6_init[] = {
13321 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13322 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13323 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13324 { } /* end */
13325};
13326
13327/*
13328 * 6ch mode
13329 */
13330static struct hda_verb alc662_sixstack_ch8_init[] = {
13331 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13332 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13333 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13334 { } /* end */
13335};
13336
13337static struct hda_channel_mode alc662_5stack_modes[2] = {
13338 { 2, alc662_sixstack_ch6_init },
13339 { 6, alc662_sixstack_ch8_init },
13340};
13341
13342/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13343 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13344 */
13345
13346static struct snd_kcontrol_new alc662_base_mixer[] = {
13347 /* output mixer control */
13348 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013349 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013350 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013351 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013352 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13353 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013354 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13355 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013356 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13357
13358 /*Input mixer control */
13359 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13360 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13361 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13362 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13363 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13364 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13365 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13366 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013367 { } /* end */
13368};
13369
13370static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13371 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013372 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13377 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13380 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13381 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13382 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13383 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013384 { } /* end */
13385};
13386
13387static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13388 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013389 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013390 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013391 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013392 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13393 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010013394 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13395 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13400 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13403 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13405 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13406 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013407 { } /* end */
13408};
13409
13410static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13411 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13412 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013413 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13414 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013420 { } /* end */
13421};
13422
Kailang Yang291702f2007-10-16 14:28:03 +020013423static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010013424 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013425
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010013426 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13427 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020013428
13429 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13430 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13431 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13432
13433 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13434 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13435 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13436 { } /* end */
13437};
13438
Kailang Yang8c427222008-01-10 13:03:59 +010013439static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010013440 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13441 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13443 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13445 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010013448 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010013449 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13454 { } /* end */
13455};
13456
Kailang Yang6dda9f42008-05-27 12:05:31 +020013457static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13459 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13460 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13463 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13464 { } /* end */
13465};
13466
13467static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13469 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13470 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13471 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13473
13474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13476 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13477 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13478 { } /* end */
13479};
13480
13481static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13482 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13483 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13485
13486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13488 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13489 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13490 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13491 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13492 { } /* end */
13493};
13494
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013495static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13496 {
13497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13498 .name = "Channel Mode",
13499 .info = alc_ch_mode_info,
13500 .get = alc_ch_mode_get,
13501 .put = alc_ch_mode_put,
13502 },
13503 { } /* end */
13504};
13505
13506static struct hda_verb alc662_init_verbs[] = {
13507 /* ADC: mute amp left and right */
13508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13509 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13510 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13511
Takashi Iwaicb53c622007-08-10 17:21:45 +020013512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013517
Kailang Yangb60dd392007-09-20 12:50:29 +020013518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013524
13525 /* Front Pin: output 0 (0x0c) */
13526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13528
13529 /* Rear Pin: output 1 (0x0d) */
13530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13532
13533 /* CLFE Pin: output 2 (0x0e) */
13534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13536
13537 /* Mic (rear) pin: input vref at 80% */
13538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13540 /* Front Mic pin: input vref at 80% */
13541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13543 /* Line In pin: input */
13544 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13545 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13546 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13547 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13548 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13549 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13550 /* CD pin widget for input */
13551 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13552
13553 /* FIXME: use matrix-type input source selection */
13554 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13555 /* Input mixer */
13556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13558 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13559 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020013560
13561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020013565
13566 /* always trun on EAPD */
13567 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13568 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13569
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013570 { }
13571};
13572
13573static struct hda_verb alc662_sue_init_verbs[] = {
13574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13575 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020013576 {}
13577};
13578
13579static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13580 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13582 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013583};
13584
Kailang Yang8c427222008-01-10 13:03:59 +010013585/* Set Unsolicited Event*/
13586static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13588 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13589 {}
13590};
13591
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013592/*
13593 * generic initialization of ADC, input mixers and output mixers
13594 */
13595static struct hda_verb alc662_auto_init_verbs[] = {
13596 /*
13597 * Unmute ADC and set the default input to mic-in
13598 */
13599 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13600 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13601
13602 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13603 * mixer widget
13604 * Note: PASD motherboards uses the Line In 2 as the input for front
13605 * panel mic (mic 2)
13606 */
13607 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013613
13614 /*
13615 * Set up output mixers (0x0c - 0x0f)
13616 */
13617 /* set vol=0 to output mixers */
13618 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13619 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13620 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13621
13622 /* set up input amps for analog loopback */
13623 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020013624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013630
13631
13632 /* FIXME: use matrix-type input source selection */
13633 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13634 /* Input mixer */
13635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020013636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013637 { }
13638};
13639
Kailang Yang6dda9f42008-05-27 12:05:31 +020013640static struct hda_verb alc663_m51va_init_verbs[] = {
13641 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13642 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13643 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13644
13645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
13646
13647 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13648 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13649 {}
13650};
13651
13652static struct hda_verb alc663_g71v_init_verbs[] = {
13653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13654 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
13655 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
13656
13657 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13658 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13659 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13660
13661 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13662 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
13663 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13664 {}
13665};
13666
13667static struct hda_verb alc663_g50v_init_verbs[] = {
13668 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13669 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13670 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13671
13672 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13673 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13674 {}
13675};
13676
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013677/* capture mixer elements */
13678static struct snd_kcontrol_new alc662_capture_mixer[] = {
13679 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13680 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13681 {
13682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13683 /* The multiple "Capture Source" controls confuse alsamixer
13684 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013685 */
13686 /* .name = "Capture Source", */
13687 .name = "Input Source",
13688 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010013689 .info = alc662_mux_enum_info,
13690 .get = alc662_mux_enum_get,
13691 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013692 },
13693 { } /* end */
13694};
13695
13696static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13697{
13698 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013699 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013700
13701 present = snd_hda_codec_read(codec, 0x14, 0,
13702 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013703 bits = present ? HDA_AMP_MUTE : 0;
13704 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13705 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013706}
13707
13708static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13709{
13710 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013711 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013712
13713 present = snd_hda_codec_read(codec, 0x1b, 0,
13714 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013715 bits = present ? HDA_AMP_MUTE : 0;
13716 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13717 HDA_AMP_MUTE, bits);
13718 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13719 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013720}
13721
13722static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13723 unsigned int res)
13724{
13725 if ((res >> 26) == ALC880_HP_EVENT)
13726 alc662_lenovo_101e_all_automute(codec);
13727 if ((res >> 26) == ALC880_FRONT_EVENT)
13728 alc662_lenovo_101e_ispeaker_automute(codec);
13729}
13730
Kailang Yang291702f2007-10-16 14:28:03 +020013731static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13732{
13733 unsigned int present;
13734
13735 present = snd_hda_codec_read(codec, 0x18, 0,
13736 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13737 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13738 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13739 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13740 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13741 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13742 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13743 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13744 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13745}
13746
13747/* unsolicited event for HP jack sensing */
13748static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13749 unsigned int res)
13750{
13751 if ((res >> 26) == ALC880_HP_EVENT)
13752 alc262_hippo1_automute( codec );
13753
13754 if ((res >> 26) == ALC880_MIC_EVENT)
13755 alc662_eeepc_mic_automute(codec);
13756}
13757
13758static void alc662_eeepc_inithook(struct hda_codec *codec)
13759{
13760 alc262_hippo1_automute( codec );
13761 alc662_eeepc_mic_automute(codec);
13762}
13763
Kailang Yang8c427222008-01-10 13:03:59 +010013764static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13765{
13766 unsigned int mute;
13767 unsigned int present;
13768
13769 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13770 present = snd_hda_codec_read(codec, 0x14, 0,
13771 AC_VERB_GET_PIN_SENSE, 0);
13772 present = (present & 0x80000000) != 0;
13773 if (present) {
13774 /* mute internal speaker */
13775 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13776 HDA_AMP_MUTE, HDA_AMP_MUTE);
13777 } else {
13778 /* unmute internal speaker if necessary */
13779 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13780 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13781 HDA_AMP_MUTE, mute);
13782 }
13783}
13784
13785/* unsolicited event for HP jack sensing */
13786static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13787 unsigned int res)
13788{
13789 if ((res >> 26) == ALC880_HP_EVENT)
13790 alc662_eeepc_ep20_automute(codec);
13791}
13792
13793static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13794{
13795 alc662_eeepc_ep20_automute(codec);
13796}
13797
Kailang Yang6dda9f42008-05-27 12:05:31 +020013798static void alc663_m51va_speaker_automute(struct hda_codec *codec)
13799{
13800 unsigned int present;
13801 unsigned char bits;
13802
13803 present = snd_hda_codec_read(codec, 0x21, 0,
13804 AC_VERB_GET_PIN_SENSE, 0)
13805 & AC_PINSENSE_PRESENCE;
13806 bits = present ? HDA_AMP_MUTE : 0;
13807 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13808 HDA_AMP_MUTE, bits);
13809}
13810
13811static void alc663_m51va_mic_automute(struct hda_codec *codec)
13812{
13813 unsigned int present;
13814
13815 present = snd_hda_codec_read(codec, 0x18, 0,
13816 AC_VERB_GET_PIN_SENSE, 0)
13817 & AC_PINSENSE_PRESENCE;
13818 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13819 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13820 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13821 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13822 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13823 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
13824 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13825 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
13826}
13827
13828static void alc663_m51va_unsol_event(struct hda_codec *codec,
13829 unsigned int res)
13830{
13831 switch (res >> 26) {
13832 case ALC880_HP_EVENT:
13833 alc663_m51va_speaker_automute(codec);
13834 break;
13835 case ALC880_MIC_EVENT:
13836 alc663_m51va_mic_automute(codec);
13837 break;
13838 }
13839}
13840
13841static void alc663_m51va_inithook(struct hda_codec *codec)
13842{
13843 alc663_m51va_speaker_automute(codec);
13844 alc663_m51va_mic_automute(codec);
13845}
13846
13847static void alc663_g71v_hp_automute(struct hda_codec *codec)
13848{
13849 unsigned int present;
13850 unsigned char bits;
13851
13852 present = snd_hda_codec_read(codec, 0x21, 0,
13853 AC_VERB_GET_PIN_SENSE, 0)
13854 & AC_PINSENSE_PRESENCE;
13855 bits = present ? HDA_AMP_MUTE : 0;
13856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13857 HDA_AMP_MUTE, bits);
13858 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13859 HDA_AMP_MUTE, bits);
13860}
13861
13862static void alc663_g71v_front_automute(struct hda_codec *codec)
13863{
13864 unsigned int present;
13865 unsigned char bits;
13866
13867 present = snd_hda_codec_read(codec, 0x15, 0,
13868 AC_VERB_GET_PIN_SENSE, 0)
13869 & AC_PINSENSE_PRESENCE;
13870 bits = present ? HDA_AMP_MUTE : 0;
13871 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13872 HDA_AMP_MUTE, bits);
13873}
13874
13875static void alc663_g71v_unsol_event(struct hda_codec *codec,
13876 unsigned int res)
13877{
13878 switch (res >> 26) {
13879 case ALC880_HP_EVENT:
13880 alc663_g71v_hp_automute(codec);
13881 break;
13882 case ALC880_FRONT_EVENT:
13883 alc663_g71v_front_automute(codec);
13884 break;
13885 case ALC880_MIC_EVENT:
13886 alc662_eeepc_mic_automute(codec);
13887 break;
13888 }
13889}
13890
13891static void alc663_g71v_inithook(struct hda_codec *codec)
13892{
13893 alc663_g71v_front_automute(codec);
13894 alc663_g71v_hp_automute(codec);
13895 alc662_eeepc_mic_automute(codec);
13896}
13897
13898static void alc663_g50v_unsol_event(struct hda_codec *codec,
13899 unsigned int res)
13900{
13901 switch (res >> 26) {
13902 case ALC880_HP_EVENT:
13903 alc663_m51va_speaker_automute(codec);
13904 break;
13905 case ALC880_MIC_EVENT:
13906 alc662_eeepc_mic_automute(codec);
13907 break;
13908 }
13909}
13910
13911static void alc663_g50v_inithook(struct hda_codec *codec)
13912{
13913 alc663_m51va_speaker_automute(codec);
13914 alc662_eeepc_mic_automute(codec);
13915}
13916
Takashi Iwaicb53c622007-08-10 17:21:45 +020013917#ifdef CONFIG_SND_HDA_POWER_SAVE
13918#define alc662_loopbacks alc880_loopbacks
13919#endif
13920
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013921
13922/* pcm configuration: identiacal with ALC880 */
13923#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13924#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13925#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13926#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13927
13928/*
13929 * configuration and preset
13930 */
13931static const char *alc662_models[ALC662_MODEL_LAST] = {
13932 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13933 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13934 [ALC662_3ST_6ch] = "3stack-6ch",
13935 [ALC662_5ST_DIG] = "6stack-dig",
13936 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020013937 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010013938 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020013939 [ALC663_ASUS_M51VA] = "m51va",
13940 [ALC663_ASUS_G71V] = "g71v",
13941 [ALC663_ASUS_H13] = "h13",
13942 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013943 [ALC662_AUTO] = "auto",
13944};
13945
13946static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020013947 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
13948 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
13949 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010013950 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020013951 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010013952 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013953 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020013954 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
13955 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
13956 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013957 {}
13958};
13959
13960static struct alc_config_preset alc662_presets[] = {
13961 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013962 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013963 .init_verbs = { alc662_init_verbs },
13964 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13965 .dac_nids = alc662_dac_nids,
13966 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013967 .dig_in_nid = ALC662_DIGIN_NID,
13968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13969 .channel_mode = alc662_3ST_2ch_modes,
13970 .input_mux = &alc662_capture_source,
13971 },
13972 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013973 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13974 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013975 .init_verbs = { alc662_init_verbs },
13976 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13977 .dac_nids = alc662_dac_nids,
13978 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013979 .dig_in_nid = ALC662_DIGIN_NID,
13980 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13981 .channel_mode = alc662_3ST_6ch_modes,
13982 .need_dac_fix = 1,
13983 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013984 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013985 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013986 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13987 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013988 .init_verbs = { alc662_init_verbs },
13989 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13990 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013991 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13992 .channel_mode = alc662_3ST_6ch_modes,
13993 .need_dac_fix = 1,
13994 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013995 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013996 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020013997 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13998 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013999 .init_verbs = { alc662_init_verbs },
14000 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14001 .dac_nids = alc662_dac_nids,
14002 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014003 .dig_in_nid = ALC662_DIGIN_NID,
14004 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14005 .channel_mode = alc662_5stack_modes,
14006 .input_mux = &alc662_capture_source,
14007 },
14008 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014009 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014010 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14011 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14012 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014013 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14014 .channel_mode = alc662_3ST_2ch_modes,
14015 .input_mux = &alc662_lenovo_101e_capture_source,
14016 .unsol_event = alc662_lenovo_101e_unsol_event,
14017 .init_hook = alc662_lenovo_101e_all_automute,
14018 },
Kailang Yang291702f2007-10-16 14:28:03 +020014019 [ALC662_ASUS_EEEPC_P701] = {
14020 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14021 .init_verbs = { alc662_init_verbs,
14022 alc662_eeepc_sue_init_verbs },
14023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14024 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014025 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14026 .channel_mode = alc662_3ST_2ch_modes,
14027 .input_mux = &alc662_eeepc_capture_source,
14028 .unsol_event = alc662_eeepc_unsol_event,
14029 .init_hook = alc662_eeepc_inithook,
14030 },
Kailang Yang8c427222008-01-10 13:03:59 +010014031 [ALC662_ASUS_EEEPC_EP20] = {
14032 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14033 alc662_chmode_mixer },
14034 .init_verbs = { alc662_init_verbs,
14035 alc662_eeepc_ep20_sue_init_verbs },
14036 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14037 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14039 .channel_mode = alc662_3ST_6ch_modes,
14040 .input_mux = &alc662_lenovo_101e_capture_source,
14041 .unsol_event = alc662_eeepc_ep20_unsol_event,
14042 .init_hook = alc662_eeepc_ep20_inithook,
14043 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014044 [ALC663_ASUS_M51VA] = {
14045 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14046 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14047 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14048 .dac_nids = alc662_dac_nids,
14049 .dig_out_nid = ALC662_DIGOUT_NID,
14050 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14051 .channel_mode = alc662_3ST_2ch_modes,
14052 .input_mux = &alc663_m51va_capture_source,
14053 .unsol_event = alc663_m51va_unsol_event,
14054 .init_hook = alc663_m51va_inithook,
14055 },
14056 [ALC663_ASUS_G71V] = {
14057 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14058 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14059 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14060 .dac_nids = alc662_dac_nids,
14061 .dig_out_nid = ALC662_DIGOUT_NID,
14062 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14063 .channel_mode = alc662_3ST_2ch_modes,
14064 .input_mux = &alc662_eeepc_capture_source,
14065 .unsol_event = alc663_g71v_unsol_event,
14066 .init_hook = alc663_g71v_inithook,
14067 },
14068 [ALC663_ASUS_H13] = {
14069 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14070 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14071 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14072 .dac_nids = alc662_dac_nids,
14073 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14074 .channel_mode = alc662_3ST_2ch_modes,
14075 .input_mux = &alc663_m51va_capture_source,
14076 .unsol_event = alc663_m51va_unsol_event,
14077 .init_hook = alc663_m51va_inithook,
14078 },
14079 [ALC663_ASUS_G50V] = {
14080 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14081 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14082 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14083 .dac_nids = alc662_dac_nids,
14084 .dig_out_nid = ALC662_DIGOUT_NID,
14085 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14086 .channel_mode = alc662_3ST_6ch_modes,
14087 .input_mux = &alc663_capture_source,
14088 .unsol_event = alc663_g50v_unsol_event,
14089 .init_hook = alc663_g50v_inithook,
14090 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014091};
14092
14093
14094/*
14095 * BIOS auto configuration
14096 */
14097
14098/* add playback controls from the parsed DAC table */
14099static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14100 const struct auto_pin_cfg *cfg)
14101{
14102 char name[32];
14103 static const char *chname[4] = {
14104 "Front", "Surround", NULL /*CLFE*/, "Side"
14105 };
14106 hda_nid_t nid;
14107 int i, err;
14108
14109 for (i = 0; i < cfg->line_outs; i++) {
14110 if (!spec->multiout.dac_nids[i])
14111 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014112 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014113 if (i == 2) {
14114 /* Center/LFE */
14115 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14116 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014117 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14118 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014119 if (err < 0)
14120 return err;
14121 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14122 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014123 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14124 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014125 if (err < 0)
14126 return err;
14127 err = add_control(spec, ALC_CTL_BIND_MUTE,
14128 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014129 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14130 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014131 if (err < 0)
14132 return err;
14133 err = add_control(spec, ALC_CTL_BIND_MUTE,
14134 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014135 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14136 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014137 if (err < 0)
14138 return err;
14139 } else {
14140 sprintf(name, "%s Playback Volume", chname[i]);
14141 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014142 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14143 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014144 if (err < 0)
14145 return err;
14146 sprintf(name, "%s Playback Switch", chname[i]);
14147 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014148 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14149 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014150 if (err < 0)
14151 return err;
14152 }
14153 }
14154 return 0;
14155}
14156
14157/* add playback controls for speaker and HP outputs */
14158static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14159 const char *pfx)
14160{
14161 hda_nid_t nid;
14162 int err;
14163 char name[32];
14164
14165 if (!pin)
14166 return 0;
14167
14168 if (alc880_is_fixed_pin(pin)) {
14169 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14170 /* printk("DAC nid=%x\n",nid); */
14171 /* specify the DAC as the extra output */
14172 if (!spec->multiout.hp_nid)
14173 spec->multiout.hp_nid = nid;
14174 else
14175 spec->multiout.extra_out_nid[0] = nid;
14176 /* control HP volume/switch on the output mixer amp */
14177 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14178 sprintf(name, "%s Playback Volume", pfx);
14179 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14180 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14181 if (err < 0)
14182 return err;
14183 sprintf(name, "%s Playback Switch", pfx);
14184 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14185 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14186 if (err < 0)
14187 return err;
14188 } else if (alc880_is_multi_pin(pin)) {
14189 /* set manual connection */
14190 /* we have only a switch on HP-out PIN */
14191 sprintf(name, "%s Playback Switch", pfx);
14192 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14193 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14194 if (err < 0)
14195 return err;
14196 }
14197 return 0;
14198}
14199
14200/* create playback/capture controls for input pins */
14201static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14202 const struct auto_pin_cfg *cfg)
14203{
14204 struct hda_input_mux *imux = &spec->private_imux;
14205 int i, err, idx;
14206
14207 for (i = 0; i < AUTO_PIN_LAST; i++) {
14208 if (alc880_is_input_pin(cfg->input_pins[i])) {
14209 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14210 err = new_analog_input(spec, cfg->input_pins[i],
14211 auto_pin_cfg_labels[i],
14212 idx, 0x0b);
14213 if (err < 0)
14214 return err;
14215 imux->items[imux->num_items].label =
14216 auto_pin_cfg_labels[i];
14217 imux->items[imux->num_items].index =
14218 alc880_input_pin_idx(cfg->input_pins[i]);
14219 imux->num_items++;
14220 }
14221 }
14222 return 0;
14223}
14224
14225static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14226 hda_nid_t nid, int pin_type,
14227 int dac_idx)
14228{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014229 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014230 /* need the manual connection? */
14231 if (alc880_is_multi_pin(nid)) {
14232 struct alc_spec *spec = codec->spec;
14233 int idx = alc880_multi_pin_idx(nid);
14234 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14235 AC_VERB_SET_CONNECT_SEL,
14236 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14237 }
14238}
14239
14240static void alc662_auto_init_multi_out(struct hda_codec *codec)
14241{
14242 struct alc_spec *spec = codec->spec;
14243 int i;
14244
Kailang Yang8c427222008-01-10 13:03:59 +010014245 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014246 for (i = 0; i <= HDA_SIDE; i++) {
14247 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014248 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014249 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014250 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014251 i);
14252 }
14253}
14254
14255static void alc662_auto_init_hp_out(struct hda_codec *codec)
14256{
14257 struct alc_spec *spec = codec->spec;
14258 hda_nid_t pin;
14259
14260 pin = spec->autocfg.hp_pins[0];
14261 if (pin) /* connect to front */
14262 /* use dac 0 */
14263 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014264 pin = spec->autocfg.speaker_pins[0];
14265 if (pin)
14266 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014267}
14268
14269#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14270#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14271
14272static void alc662_auto_init_analog_input(struct hda_codec *codec)
14273{
14274 struct alc_spec *spec = codec->spec;
14275 int i;
14276
14277 for (i = 0; i < AUTO_PIN_LAST; i++) {
14278 hda_nid_t nid = spec->autocfg.input_pins[i];
14279 if (alc662_is_input_pin(nid)) {
14280 snd_hda_codec_write(codec, nid, 0,
14281 AC_VERB_SET_PIN_WIDGET_CONTROL,
14282 (i <= AUTO_PIN_FRONT_MIC ?
14283 PIN_VREF80 : PIN_IN));
14284 if (nid != ALC662_PIN_CD_NID)
14285 snd_hda_codec_write(codec, nid, 0,
14286 AC_VERB_SET_AMP_GAIN_MUTE,
14287 AMP_OUT_MUTE);
14288 }
14289 }
14290}
14291
14292static int alc662_parse_auto_config(struct hda_codec *codec)
14293{
14294 struct alc_spec *spec = codec->spec;
14295 int err;
14296 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14297
14298 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14299 alc662_ignore);
14300 if (err < 0)
14301 return err;
14302 if (!spec->autocfg.line_outs)
14303 return 0; /* can't find valid BIOS pin config */
14304
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014305 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14306 if (err < 0)
14307 return err;
14308 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14309 if (err < 0)
14310 return err;
14311 err = alc662_auto_create_extra_out(spec,
14312 spec->autocfg.speaker_pins[0],
14313 "Speaker");
14314 if (err < 0)
14315 return err;
14316 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14317 "Headphone");
14318 if (err < 0)
14319 return err;
14320 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14321 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014322 return err;
14323
14324 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14325
14326 if (spec->autocfg.dig_out_pin)
14327 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14328
14329 if (spec->kctl_alloc)
14330 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14331
14332 spec->num_mux_defs = 1;
14333 spec->input_mux = &spec->private_imux;
14334
Takashi Iwai8c872862007-06-19 12:11:16 +020014335 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014336 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14337 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020014338 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014339}
14340
14341/* additional initialization for auto-configuration model */
14342static void alc662_auto_init(struct hda_codec *codec)
14343{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014344 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014345 alc662_auto_init_multi_out(codec);
14346 alc662_auto_init_hp_out(codec);
14347 alc662_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014348 if (spec->unsol_event)
14349 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014350}
14351
14352static int patch_alc662(struct hda_codec *codec)
14353{
14354 struct alc_spec *spec;
14355 int err, board_config;
14356
14357 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14358 if (!spec)
14359 return -ENOMEM;
14360
14361 codec->spec = spec;
14362
14363 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14364 alc662_models,
14365 alc662_cfg_tbl);
14366 if (board_config < 0) {
14367 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14368 "trying auto-probe from BIOS...\n");
14369 board_config = ALC662_AUTO;
14370 }
14371
14372 if (board_config == ALC662_AUTO) {
14373 /* automatic parse from the BIOS config */
14374 err = alc662_parse_auto_config(codec);
14375 if (err < 0) {
14376 alc_free(codec);
14377 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020014378 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014379 printk(KERN_INFO
14380 "hda_codec: Cannot set up configuration "
14381 "from BIOS. Using base mode...\n");
14382 board_config = ALC662_3ST_2ch_DIG;
14383 }
14384 }
14385
14386 if (board_config != ALC662_AUTO)
14387 setup_preset(spec, &alc662_presets[board_config]);
14388
Kailang Yang6dda9f42008-05-27 12:05:31 +020014389 if (codec->vendor_id == 0x10ec0663) {
14390 spec->stream_name_analog = "ALC663 Analog";
14391 spec->stream_name_digital = "ALC663 Digital";
14392 } else {
14393 spec->stream_name_analog = "ALC662 Analog";
14394 spec->stream_name_digital = "ALC662 Digital";
14395 }
14396
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014397 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14398 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14399
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014400 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14401 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14402
Takashi Iwaie1406342008-02-11 18:32:32 +010014403 spec->adc_nids = alc662_adc_nids;
14404 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14405 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014406
Takashi Iwai2134ea42008-01-10 16:53:55 +010014407 spec->vmaster_nid = 0x02;
14408
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014409 codec->patch_ops = alc_patch_ops;
14410 if (board_config == ALC662_AUTO)
14411 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014412#ifdef CONFIG_SND_HDA_POWER_SAVE
14413 if (!spec->loopback.amplist)
14414 spec->loopback.amplist = alc662_loopbacks;
14415#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014416
14417 return 0;
14418}
14419
14420/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070014421 * patch entries
14422 */
14423struct hda_codec_preset snd_hda_preset_realtek[] = {
14424 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014425 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014426 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020014427 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014428 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014429 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014430 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014431 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14432 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14433 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014434 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14435 .patch = patch_alc883 },
14436 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14437 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014438 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014439 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014440 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014441 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020014442 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020014443 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010014444 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014445 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014446 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070014447 {} /* terminator */
14448};