blob: e558264d1f59965de3ebb27a33109830c15b6158 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100116 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100117 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100118#ifdef CONFIG_SND_DEBUG
119 ALC268_TEST,
120#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200121 ALC268_AUTO,
122 ALC268_MODEL_LAST /* last tag */
123};
124
Kailang Yangf6a92242007-12-13 16:52:54 +0100125/* ALC269 models */
126enum {
127 ALC269_BASIC,
Kailang Yangf53281e2008-07-18 12:36:43 +0200128 ALC269_ASUS_EEEPC_P703,
129 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100130 ALC269_AUTO,
131 ALC269_MODEL_LAST /* last tag */
132};
133
Kailang Yangdf694da2005-12-05 19:42:22 +0100134/* ALC861 models */
135enum {
136 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200137 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100138 ALC861_3ST_DIG,
139 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200140 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200141 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200142 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100143 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100144 ALC861_AUTO,
145 ALC861_MODEL_LAST,
146};
147
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100148/* ALC861-VD models */
149enum {
150 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200151 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100152 ALC861VD_3ST,
153 ALC861VD_3ST_DIG,
154 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200155 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200157 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158 ALC861VD_AUTO,
159 ALC861VD_MODEL_LAST,
160};
161
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200162/* ALC662 models */
163enum {
164 ALC662_3ST_2ch_DIG,
165 ALC662_3ST_6ch_DIG,
166 ALC662_3ST_6ch,
167 ALC662_5ST_DIG,
168 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200169 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100170 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200171 ALC663_ASUS_M51VA,
172 ALC663_ASUS_G71V,
173 ALC663_ASUS_H13,
174 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175 ALC662_AUTO,
176 ALC662_MODEL_LAST,
177};
178
Kailang Yangdf694da2005-12-05 19:42:22 +0100179/* ALC882 models */
180enum {
181 ALC882_3ST_DIG,
182 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200183 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200184 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200185 ALC882_TARGA,
186 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200187 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100188 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200189 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200190 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200191 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100192 ALC882_MODEL_LAST,
193};
194
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200195/* ALC883 models */
196enum {
197 ALC883_3ST_2ch_DIG,
198 ALC883_3ST_6ch_DIG,
199 ALC883_3ST_6ch,
200 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200201 ALC883_TARGA_DIG,
202 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200203 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200204 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200205 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200206 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100207 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200208 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200209 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200210 ALC888_LENOVO_MS7195_DIG,
Kailang Yangea1fb292008-08-26 12:58:38 +0200211 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200212 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100213 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100214 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100215 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100216 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200217 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_AUTO,
219 ALC883_MODEL_LAST,
220};
221
Kailang Yangdf694da2005-12-05 19:42:22 +0100222/* for GPIO Poll */
223#define GPIO_MASK 0x03
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225struct alc_spec {
226 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100227 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 unsigned int num_mixers;
229
Kailang Yangdf694da2005-12-05 19:42:22 +0100230 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200231 * don't forget NULL
232 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200233 */
234 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Takashi Iwai16ded522005-06-10 19:58:24 +0200236 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 struct hda_pcm_stream *stream_analog_playback;
238 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100239 struct hda_pcm_stream *stream_analog_alt_playback;
240 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200242 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 struct hda_pcm_stream *stream_digital_playback;
244 struct hda_pcm_stream *stream_digital_capture;
245
246 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200247 struct hda_multi_out multiout; /* playback set-up
248 * max_channels, dacs must be set
249 * dig_out_nid and hp_nid are optional
250 */
Takashi Iwai63300792008-01-24 15:31:36 +0100251 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 /* capture */
254 unsigned int num_adc_nids;
255 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100256 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200257 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
259 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200260 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 const struct hda_input_mux *input_mux;
262 unsigned int cur_mux[3];
263
264 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100265 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200267 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100270 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200271
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200272 /* dynamic controls, init_verbs and input_mux */
273 struct auto_pin_cfg autocfg;
274 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100275 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200276 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200277 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100278
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100279 /* hooks */
280 void (*init_hook)(struct hda_codec *codec);
281 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
282
Takashi Iwai834be882006-03-01 14:16:17 +0100283 /* for pin sensing */
284 unsigned int sense_updated: 1;
285 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100286 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200287
Takashi Iwai2134ea42008-01-10 16:53:55 +0100288 /* for virtual master */
289 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200290#ifdef CONFIG_SND_HDA_POWER_SAVE
291 struct hda_loopback_check loopback;
292#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200293
294 /* for PLL fix */
295 hda_nid_t pll_nid;
296 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100297};
298
299/*
300 * configuration template - to be copied to the spec instance
301 */
302struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200303 struct snd_kcontrol_new *mixers[5]; /* should be identical size
304 * with spec
305 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100306 const struct hda_verb *init_verbs[5];
307 unsigned int num_dacs;
308 hda_nid_t *dac_nids;
309 hda_nid_t dig_out_nid; /* optional */
310 hda_nid_t hp_nid; /* optional */
311 unsigned int num_adc_nids;
312 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100313 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100314 hda_nid_t dig_in_nid;
315 unsigned int num_channel_mode;
316 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200317 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200318 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100319 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100320 void (*unsol_event)(struct hda_codec *, unsigned int);
321 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200322#ifdef CONFIG_SND_HDA_POWER_SAVE
323 struct hda_amp_list *loopbacks;
324#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325};
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
328/*
329 * input MUX handling
330 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200331static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
335 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200336 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
337 if (mux_idx >= spec->num_mux_defs)
338 mux_idx = 0;
339 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200342static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344{
345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 struct alc_spec *spec = codec->spec;
347 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
348
349 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
350 return 0;
351}
352
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200353static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
356 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
357 struct alc_spec *spec = codec->spec;
358 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200359 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100360 hda_nid_t nid = spec->capsrc_nids ?
361 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200362 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100363 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200366
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367/*
368 * channel mode setting
369 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200370static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100375 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
376 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200379static int alc_ch_mode_get(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 Iwaid2a6d7d2005-11-17 11:06:29 +0100384 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200385 spec->num_channel_mode,
386 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387}
388
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200389static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
390 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
393 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200394 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
395 spec->num_channel_mode,
396 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200397 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200398 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
399 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100403 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200404 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 * being part of a format specifier. Maximum allowed length of a value is
406 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100407 *
408 * Note: some retasking pin complexes seem to ignore requests for input
409 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
410 * are requested. Therefore order this list so that this behaviour will not
411 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200412 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
413 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200414 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100415static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100416 "Mic 50pc bias", "Mic 80pc bias",
417 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418};
419static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100420 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100421};
422/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200423 * in the pin being assumed to be exclusively an input or an output pin. In
424 * addition, "input" pins may or may not process the mic bias option
425 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
426 * accept requests for bias as of chip versions up to March 2006) and/or
427 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200429#define ALC_PIN_DIR_IN 0x00
430#define ALC_PIN_DIR_OUT 0x01
431#define ALC_PIN_DIR_INOUT 0x02
432#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
433#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434
Kailang Yangea1fb292008-08-26 12:58:38 +0200435/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100436 * For each direction the minimum and maximum values are given.
437 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200438static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100439 { 0, 2 }, /* ALC_PIN_DIR_IN */
440 { 3, 4 }, /* ALC_PIN_DIR_OUT */
441 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200442 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
443 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100444};
445#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
446#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
447#define alc_pin_mode_n_items(_dir) \
448 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
449
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200450static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200452{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 unsigned int item_num = uinfo->value.enumerated.item;
454 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
455
456 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200457 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100458 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
459
460 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
461 item_num = alc_pin_mode_min(dir);
462 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200463 return 0;
464}
465
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200468{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200473 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
475 AC_VERB_GET_PIN_WIDGET_CONTROL,
476 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200477
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 /* Find enumerated value for current pinctl setting */
479 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200482 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 return 0;
484}
485
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100488{
489 signed int change;
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 hda_nid_t nid = kcontrol->private_value & 0xffff;
492 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
493 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
495 AC_VERB_GET_PIN_WIDGET_CONTROL,
496 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200498 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499 val = alc_pin_mode_min(dir);
500
501 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100502 if (change) {
503 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200504 snd_hda_codec_write_cache(codec, nid, 0,
505 AC_VERB_SET_PIN_WIDGET_CONTROL,
506 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100507
Kailang Yangea1fb292008-08-26 12:58:38 +0200508 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100509 * for the requested pin mode. Enum values of 2 or less are
510 * input modes.
511 *
512 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200513 * reduces noise slightly (particularly on input) so we'll
514 * do it. However, having both input and output buffers
515 * enabled simultaneously doesn't seem to be problematic if
516 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100517 */
518 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200519 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
520 HDA_AMP_MUTE, HDA_AMP_MUTE);
521 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
522 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100523 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200524 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
525 HDA_AMP_MUTE, HDA_AMP_MUTE);
526 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
527 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100528 }
529 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530 return change;
531}
532
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 .info = alc_pin_mode_info, \
536 .get = alc_pin_mode_get, \
537 .put = alc_pin_mode_put, \
538 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100539
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100540/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
541 * together using a mask with more than one bit set. This control is
542 * currently used only by the ALC260 test model. At this stage they are not
543 * needed for any "production" models.
544 */
545#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200546#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200547
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100550{
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 hda_nid_t nid = kcontrol->private_value & 0xffff;
553 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
554 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555 unsigned int val = snd_hda_codec_read(codec, nid, 0,
556 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100557
558 *valp = (val & mask) != 0;
559 return 0;
560}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100563{
564 signed int change;
565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
566 hda_nid_t nid = kcontrol->private_value & 0xffff;
567 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
568 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
570 AC_VERB_GET_GPIO_DATA,
571 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100572
573 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
575 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100576 gpio_data &= ~mask;
577 else
578 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200579 snd_hda_codec_write_cache(codec, nid, 0,
580 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100581
582 return change;
583}
584#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
585 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
586 .info = alc_gpio_data_info, \
587 .get = alc_gpio_data_get, \
588 .put = alc_gpio_data_put, \
589 .private_value = nid | (mask<<16) }
590#endif /* CONFIG_SND_DEBUG */
591
Jonathan Woithe92621f12006-02-28 11:47:47 +0100592/* A switch control to allow the enabling of the digital IO pins on the
593 * ALC260. This is incredibly simplistic; the intention of this control is
594 * to provide something in the test model allowing digital outputs to be
595 * identified if present. If models are found which can utilise these
596 * outputs a more complete mixer control can be devised for those models if
597 * necessary.
598 */
599#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200600#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200601
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 hda_nid_t nid = kcontrol->private_value & 0xffff;
607 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
608 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100610 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100611
612 *valp = (val & mask) != 0;
613 return 0;
614}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100617{
618 signed int change;
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
621 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
622 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100624 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100626
627 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200628 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100629 if (val==0)
630 ctrl_data &= ~mask;
631 else
632 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200633 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
634 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100635
636 return change;
637}
638#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
639 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
640 .info = alc_spdif_ctrl_info, \
641 .get = alc_spdif_ctrl_get, \
642 .put = alc_spdif_ctrl_put, \
643 .private_value = nid | (mask<<16) }
644#endif /* CONFIG_SND_DEBUG */
645
Jonathan Woithef8225f62008-01-08 12:16:54 +0100646/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
647 * Again, this is only used in the ALC26x test models to help identify when
648 * the EAPD line must be asserted for features to work.
649 */
650#ifdef CONFIG_SND_DEBUG
651#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
652
653static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
655{
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 hda_nid_t nid = kcontrol->private_value & 0xffff;
658 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
659 long *valp = ucontrol->value.integer.value;
660 unsigned int val = snd_hda_codec_read(codec, nid, 0,
661 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
662
663 *valp = (val & mask) != 0;
664 return 0;
665}
666
667static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
668 struct snd_ctl_elem_value *ucontrol)
669{
670 int change;
671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
672 hda_nid_t nid = kcontrol->private_value & 0xffff;
673 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
674 long val = *ucontrol->value.integer.value;
675 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_EAPD_BTLENABLE,
677 0x00);
678
679 /* Set/unset the masked control bit(s) as needed */
680 change = (!val ? 0 : mask) != (ctrl_data & mask);
681 if (!val)
682 ctrl_data &= ~mask;
683 else
684 ctrl_data |= mask;
685 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
686 ctrl_data);
687
688 return change;
689}
690
691#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
692 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
693 .info = alc_eapd_ctrl_info, \
694 .get = alc_eapd_ctrl_get, \
695 .put = alc_eapd_ctrl_put, \
696 .private_value = nid | (mask<<16) }
697#endif /* CONFIG_SND_DEBUG */
698
Kailang Yangdf694da2005-12-05 19:42:22 +0100699/*
700 * set up from the preset table
701 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200702static void setup_preset(struct alc_spec *spec,
703 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100704{
705 int i;
706
707 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
708 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
710 i++)
711 spec->init_verbs[spec->num_init_verbs++] =
712 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200713
Kailang Yangdf694da2005-12-05 19:42:22 +0100714 spec->channel_mode = preset->channel_mode;
715 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200716 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100717
718 spec->multiout.max_channels = spec->channel_mode[0].channels;
719
720 spec->multiout.num_dacs = preset->num_dacs;
721 spec->multiout.dac_nids = preset->dac_nids;
722 spec->multiout.dig_out_nid = preset->dig_out_nid;
723 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200724
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200725 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200726 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200727 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100728 spec->input_mux = preset->input_mux;
729
730 spec->num_adc_nids = preset->num_adc_nids;
731 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100732 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100733 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100734
735 spec->unsol_event = preset->unsol_event;
736 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200737#ifdef CONFIG_SND_HDA_POWER_SAVE
738 spec->loopback.amplist = preset->loopbacks;
739#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100740}
741
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200742/* Enable GPIO mask and set output */
743static struct hda_verb alc_gpio1_init_verbs[] = {
744 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
745 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
746 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
747 { }
748};
749
750static struct hda_verb alc_gpio2_init_verbs[] = {
751 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
752 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
753 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
754 { }
755};
756
Kailang Yangbdd148a2007-05-08 15:19:08 +0200757static struct hda_verb alc_gpio3_init_verbs[] = {
758 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
759 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
760 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
761 { }
762};
763
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200764/*
765 * Fix hardware PLL issue
766 * On some codecs, the analog PLL gating control must be off while
767 * the default value is 1.
768 */
769static void alc_fix_pll(struct hda_codec *codec)
770{
771 struct alc_spec *spec = codec->spec;
772 unsigned int val;
773
774 if (!spec->pll_nid)
775 return;
776 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
777 spec->pll_coef_idx);
778 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
779 AC_VERB_GET_PROC_COEF, 0);
780 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
781 spec->pll_coef_idx);
782 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
783 val & ~(1 << spec->pll_coef_bit));
784}
785
786static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
787 unsigned int coef_idx, unsigned int coef_bit)
788{
789 struct alc_spec *spec = codec->spec;
790 spec->pll_nid = nid;
791 spec->pll_coef_idx = coef_idx;
792 spec->pll_coef_bit = coef_bit;
793 alc_fix_pll(codec);
794}
795
Kailang Yangc9b58002007-10-16 14:30:01 +0200796static void alc_sku_automute(struct hda_codec *codec)
797{
798 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200799 unsigned int present;
800 unsigned int hp_nid = spec->autocfg.hp_pins[0];
801 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
802
803 /* need to execute and sync at first */
804 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
805 present = snd_hda_codec_read(codec, hp_nid, 0,
806 AC_VERB_GET_PIN_SENSE, 0);
807 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100808 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
809 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200810}
811
812/* unsolicited event for HP jack sensing */
813static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
814{
815 if (codec->vendor_id == 0x10ec0880)
816 res >>= 28;
817 else
818 res >>= 26;
819 if (res != ALC880_HP_EVENT)
820 return;
821
822 alc_sku_automute(codec);
823}
824
Kailang Yangf9423e72008-05-27 12:32:25 +0200825/* additional initialization for ALC888 variants */
826static void alc888_coef_init(struct hda_codec *codec)
827{
828 unsigned int tmp;
829
830 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
831 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
832 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
833 if ((tmp & 0xf0) == 2)
834 /* alc888S-VC */
835 snd_hda_codec_read(codec, 0x20, 0,
836 AC_VERB_SET_PROC_COEF, 0x830);
837 else
838 /* alc888-VB */
839 snd_hda_codec_read(codec, 0x20, 0,
840 AC_VERB_SET_PROC_COEF, 0x3030);
841}
842
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200843/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
844 * 31 ~ 16 : Manufacture ID
845 * 15 ~ 8 : SKU ID
846 * 7 ~ 0 : Assembly ID
847 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
848 */
849static void alc_subsystem_id(struct hda_codec *codec,
850 unsigned int porta, unsigned int porte,
851 unsigned int portd)
852{
Kailang Yangc9b58002007-10-16 14:30:01 +0200853 unsigned int ass, tmp, i;
854 unsigned nid;
855 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200856
Kailang Yangc9b58002007-10-16 14:30:01 +0200857 ass = codec->subsystem_id & 0xffff;
858 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
859 goto do_sku;
860
Kailang Yangea1fb292008-08-26 12:58:38 +0200861 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200862 * 31~30 : port conetcivity
863 * 29~21 : reserve
864 * 20 : PCBEEP input
865 * 19~16 : Check sum (15:1)
866 * 15~1 : Custom
867 * 0 : override
868 */
869 nid = 0x1d;
870 if (codec->vendor_id == 0x10ec0260)
871 nid = 0x17;
872 ass = snd_hda_codec_read(codec, nid, 0,
873 AC_VERB_GET_CONFIG_DEFAULT, 0);
874 if (!(ass & 1) && !(ass & 0x100000))
875 return;
876 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200877 return;
878
Kailang Yangc9b58002007-10-16 14:30:01 +0200879 /* check sum */
880 tmp = 0;
881 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100882 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200883 tmp++;
884 }
885 if (((ass >> 16) & 0xf) != tmp)
886 return;
887do_sku:
888 /*
889 * 0 : override
890 * 1 : Swap Jack
891 * 2 : 0 --> Desktop, 1 --> Laptop
892 * 3~5 : External Amplifier control
893 * 7~6 : Reserved
894 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200895 tmp = (ass & 0x38) >> 3; /* external Amp control */
896 switch (tmp) {
897 case 1:
898 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
899 break;
900 case 3:
901 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
902 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200903 case 7:
904 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
905 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200907 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200908 case 0x10ec0260:
909 snd_hda_codec_write(codec, 0x0f, 0,
910 AC_VERB_SET_EAPD_BTLENABLE, 2);
911 snd_hda_codec_write(codec, 0x10, 0,
912 AC_VERB_SET_EAPD_BTLENABLE, 2);
913 break;
914 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200915 case 0x10ec0267:
916 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200917 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200918 case 0x10ec0660:
919 case 0x10ec0662:
920 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200921 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200922 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200923 snd_hda_codec_write(codec, 0x14, 0,
924 AC_VERB_SET_EAPD_BTLENABLE, 2);
925 snd_hda_codec_write(codec, 0x15, 0,
926 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200927 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200928 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200929 switch (codec->vendor_id) {
930 case 0x10ec0260:
931 snd_hda_codec_write(codec, 0x1a, 0,
932 AC_VERB_SET_COEF_INDEX, 7);
933 tmp = snd_hda_codec_read(codec, 0x1a, 0,
934 AC_VERB_GET_PROC_COEF, 0);
935 snd_hda_codec_write(codec, 0x1a, 0,
936 AC_VERB_SET_COEF_INDEX, 7);
937 snd_hda_codec_write(codec, 0x1a, 0,
938 AC_VERB_SET_PROC_COEF,
939 tmp | 0x2010);
940 break;
941 case 0x10ec0262:
942 case 0x10ec0880:
943 case 0x10ec0882:
944 case 0x10ec0883:
945 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200946 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200947 snd_hda_codec_write(codec, 0x20, 0,
948 AC_VERB_SET_COEF_INDEX, 7);
949 tmp = snd_hda_codec_read(codec, 0x20, 0,
950 AC_VERB_GET_PROC_COEF, 0);
951 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200952 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200953 snd_hda_codec_write(codec, 0x20, 0,
954 AC_VERB_SET_PROC_COEF,
955 tmp | 0x2010);
956 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200957 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200958 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200959 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200960 case 0x10ec0267:
961 case 0x10ec0268:
962 snd_hda_codec_write(codec, 0x20, 0,
963 AC_VERB_SET_COEF_INDEX, 7);
964 tmp = snd_hda_codec_read(codec, 0x20, 0,
965 AC_VERB_GET_PROC_COEF, 0);
966 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200967 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200968 snd_hda_codec_write(codec, 0x20, 0,
969 AC_VERB_SET_PROC_COEF,
970 tmp | 0x3000);
971 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200972 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974 break;
975 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200976
Kailang Yang8c427222008-01-10 13:03:59 +0100977 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200978 * when the external headphone out jack is plugged"
979 */
Kailang Yang8c427222008-01-10 13:03:59 +0100980 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200981 return;
982 /*
983 * 10~8 : Jack location
984 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
985 * 14~13: Resvered
986 * 15 : 1 --> enable the function "Mute internal speaker
987 * when the external headphone out jack is plugged"
988 */
989 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100990 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200991 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100992 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200993 else
994 return;
995 }
996
997 if (!spec->autocfg.hp_pins[0]) {
998 tmp = (ass >> 11) & 0x3; /* HP to chassis */
999 if (tmp == 0)
1000 spec->autocfg.hp_pins[0] = porta;
1001 else if (tmp == 1)
1002 spec->autocfg.hp_pins[0] = porte;
1003 else if (tmp == 2)
1004 spec->autocfg.hp_pins[0] = portd;
1005 else
1006 return;
1007 }
1008
1009 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1010 AC_VERB_SET_UNSOLICITED_ENABLE,
1011 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001012
Kailang Yangc9b58002007-10-16 14:30:01 +02001013 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001014}
1015
Takashi Iwai41e41f12005-06-08 14:48:49 +02001016/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001017 * Fix-up pin default configurations
1018 */
1019
1020struct alc_pincfg {
1021 hda_nid_t nid;
1022 u32 val;
1023};
1024
1025static void alc_fix_pincfg(struct hda_codec *codec,
1026 const struct snd_pci_quirk *quirk,
1027 const struct alc_pincfg **pinfix)
1028{
1029 const struct alc_pincfg *cfg;
1030
1031 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1032 if (!quirk)
1033 return;
1034
1035 cfg = pinfix[quirk->value];
1036 for (; cfg->nid; cfg++) {
1037 int i;
1038 u32 val = cfg->val;
1039 for (i = 0; i < 4; i++) {
1040 snd_hda_codec_write(codec, cfg->nid, 0,
1041 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1042 val & 0xff);
1043 val >>= 8;
1044 }
1045 }
1046}
1047
1048/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001049 * ALC880 3-stack model
1050 *
1051 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001052 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1053 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 */
1055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001056static hda_nid_t alc880_dac_nids[4] = {
1057 /* front, rear, clfe, rear_surr */
1058 0x02, 0x05, 0x04, 0x03
1059};
1060
1061static hda_nid_t alc880_adc_nids[3] = {
1062 /* ADC0-2 */
1063 0x07, 0x08, 0x09,
1064};
1065
1066/* The datasheet says the node 0x07 is connected from inputs,
1067 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001068 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001070static hda_nid_t alc880_adc_nids_alt[2] = {
1071 /* ADC1-2 */
1072 0x08, 0x09,
1073};
1074
1075#define ALC880_DIGOUT_NID 0x06
1076#define ALC880_DIGIN_NID 0x0a
1077
1078static struct hda_input_mux alc880_capture_source = {
1079 .num_items = 4,
1080 .items = {
1081 { "Mic", 0x0 },
1082 { "Front Mic", 0x3 },
1083 { "Line", 0x2 },
1084 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001086};
1087
1088/* channel source setting (2/6 channel selection for 3-stack) */
1089/* 2ch mode */
1090static struct hda_verb alc880_threestack_ch2_init[] = {
1091 /* set line-in to input, mute it */
1092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1094 /* set mic-in to input vref 80%, mute it */
1095 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1096 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 { } /* end */
1098};
1099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001100/* 6ch mode */
1101static struct hda_verb alc880_threestack_ch6_init[] = {
1102 /* set line-in to output, unmute it */
1103 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1104 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1105 /* set mic-in to output, unmute it */
1106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1108 { } /* end */
1109};
1110
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001111static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001112 { 2, alc880_threestack_ch2_init },
1113 { 6, alc880_threestack_ch6_init },
1114};
1115
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001116static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001120 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1133 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1134 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001136 {
1137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1138 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001139 .info = alc_ch_mode_info,
1140 .get = alc_ch_mode_get,
1141 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001142 },
1143 { } /* end */
1144};
1145
1146/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001147static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1154 {
1155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1156 /* The multiple "Capture Source" controls confuse alsamixer
1157 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001158 */
1159 /* .name = "Capture Source", */
1160 .name = "Input Source",
1161 .count = 3,
1162 .info = alc_mux_enum_info,
1163 .get = alc_mux_enum_get,
1164 .put = alc_mux_enum_put,
1165 },
1166 { } /* end */
1167};
1168
1169/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001170static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001171 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 {
1176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1177 /* The multiple "Capture Source" controls confuse alsamixer
1178 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 */
1180 /* .name = "Capture Source", */
1181 .name = "Input Source",
1182 .count = 2,
1183 .info = alc_mux_enum_info,
1184 .get = alc_mux_enum_get,
1185 .put = alc_mux_enum_put,
1186 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 { } /* end */
1188};
1189
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001190
1191
1192/*
1193 * ALC880 5-stack model
1194 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001195 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1196 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001197 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1198 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1199 */
1200
1201/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001202static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001203 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001204 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 { } /* end */
1206};
1207
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001208/* channel source setting (6/8 channel selection for 5-stack) */
1209/* 6ch mode */
1210static struct hda_verb alc880_fivestack_ch6_init[] = {
1211 /* set line-in to input, mute it */
1212 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1213 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001214 { } /* end */
1215};
1216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001217/* 8ch mode */
1218static struct hda_verb alc880_fivestack_ch8_init[] = {
1219 /* set line-in to output, unmute it */
1220 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1221 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1222 { } /* end */
1223};
1224
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001225static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001226 { 6, alc880_fivestack_ch6_init },
1227 { 8, alc880_fivestack_ch8_init },
1228};
1229
1230
1231/*
1232 * ALC880 6-stack model
1233 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001234 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1235 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001236 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1237 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1238 */
1239
1240static hda_nid_t alc880_6st_dac_nids[4] = {
1241 /* front, rear, clfe, rear_surr */
1242 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001243};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001244
1245static struct hda_input_mux alc880_6stack_capture_source = {
1246 .num_items = 4,
1247 .items = {
1248 { "Mic", 0x0 },
1249 { "Front Mic", 0x1 },
1250 { "Line", 0x2 },
1251 { "CD", 0x4 },
1252 },
1253};
1254
1255/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001256static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257 { 8, NULL },
1258};
1259
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001260static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001262 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001263 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001265 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1266 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001267 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1268 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001269 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001270 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001271 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1272 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1273 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1274 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1277 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1278 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1279 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1280 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001281 {
1282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1283 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001284 .info = alc_ch_mode_info,
1285 .get = alc_ch_mode_get,
1286 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001287 },
1288 { } /* end */
1289};
1290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291
1292/*
1293 * ALC880 W810 model
1294 *
1295 * W810 has rear IO for:
1296 * Front (DAC 02)
1297 * Surround (DAC 03)
1298 * Center/LFE (DAC 04)
1299 * Digital out (06)
1300 *
1301 * The system also has a pair of internal speakers, and a headphone jack.
1302 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001303 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304 * There is a variable resistor to control the speaker or headphone
1305 * volume. This is a hardware-only device without a software API.
1306 *
1307 * Plugging headphones in will disable the internal speakers. This is
1308 * implemented in hardware, not via the driver using jack sense. In
1309 * a similar fashion, plugging into the rear socket marked "front" will
1310 * disable both the speakers and headphones.
1311 *
1312 * For input, there's a microphone jack, and an "audio in" jack.
1313 * These may not do anything useful with this driver yet, because I
1314 * haven't setup any initialization verbs for these yet...
1315 */
1316
1317static hda_nid_t alc880_w810_dac_nids[3] = {
1318 /* front, rear/surround, clfe */
1319 0x02, 0x03, 0x04
1320};
1321
1322/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001323static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001324 { 6, NULL }
1325};
1326
1327/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001328static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001330 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001331 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001332 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001333 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1334 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001335 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1336 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1338 { } /* end */
1339};
1340
1341
1342/*
1343 * Z710V model
1344 *
1345 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001346 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1347 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001348 */
1349
1350static hda_nid_t alc880_z71v_dac_nids[1] = {
1351 0x02
1352};
1353#define ALC880_Z71V_HP_DAC 0x03
1354
1355/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001356static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001357 { 2, NULL }
1358};
1359
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001360static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001361 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001362 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001364 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001365 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1366 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1369 { } /* end */
1370};
1371
1372
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001373/*
1374 * ALC880 F1734 model
1375 *
1376 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1377 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1378 */
1379
1380static hda_nid_t alc880_f1734_dac_nids[1] = {
1381 0x03
1382};
1383#define ALC880_F1734_HP_DAC 0x02
1384
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001385static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001386 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001387 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001388 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1389 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001394 { } /* end */
1395};
1396
Takashi Iwai937b4162008-02-11 14:52:36 +01001397static struct hda_input_mux alc880_f1734_capture_source = {
1398 .num_items = 2,
1399 .items = {
1400 { "Mic", 0x1 },
1401 { "CD", 0x4 },
1402 },
1403};
1404
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001406/*
1407 * ALC880 ASUS model
1408 *
1409 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1410 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1411 * Mic = 0x18, Line = 0x1a
1412 */
1413
1414#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1415#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1416
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001417static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001418 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001419 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001420 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001421 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001422 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1423 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001424 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1425 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 {
1433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1434 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001435 .info = alc_ch_mode_info,
1436 .get = alc_ch_mode_get,
1437 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001438 },
1439 { } /* end */
1440};
1441
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442/*
1443 * ALC880 ASUS W1V model
1444 *
1445 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1446 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1447 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1448 */
1449
1450/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001451static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001452 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1453 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001454 { } /* end */
1455};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001457/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001458static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001459 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1460 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1461 { } /* end */
1462};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001463
Kailang Yangdf694da2005-12-05 19:42:22 +01001464/* TCL S700 */
1465static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1466 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1467 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1470 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1473 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1474 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1475 {
1476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1477 /* The multiple "Capture Source" controls confuse alsamixer
1478 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001479 */
1480 /* .name = "Capture Source", */
1481 .name = "Input Source",
1482 .count = 1,
1483 .info = alc_mux_enum_info,
1484 .get = alc_mux_enum_get,
1485 .put = alc_mux_enum_put,
1486 },
1487 { } /* end */
1488};
1489
Kailang Yangccc656c2006-10-17 12:32:26 +02001490/* Uniwill */
1491static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001492 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1493 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1494 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1495 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001496 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1497 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1498 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1499 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1500 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1501 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1502 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1503 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1506 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1507 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1508 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1509 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1510 {
1511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1512 .name = "Channel Mode",
1513 .info = alc_ch_mode_info,
1514 .get = alc_ch_mode_get,
1515 .put = alc_ch_mode_put,
1516 },
1517 { } /* end */
1518};
1519
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001520static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1522 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1523 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1524 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1525 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1526 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1527 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1528 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1529 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1530 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1531 { } /* end */
1532};
1533
Kailang Yangccc656c2006-10-17 12:32:26 +02001534static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001535 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1536 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1537 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1538 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1541 { } /* end */
1542};
1543
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001545 * virtual master controls
1546 */
1547
1548/*
1549 * slave controls for virtual master
1550 */
1551static const char *alc_slave_vols[] = {
1552 "Front Playback Volume",
1553 "Surround Playback Volume",
1554 "Center Playback Volume",
1555 "LFE Playback Volume",
1556 "Side Playback Volume",
1557 "Headphone Playback Volume",
1558 "Speaker Playback Volume",
1559 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001560 "Line-Out Playback Volume",
1561 NULL,
1562};
1563
1564static const char *alc_slave_sws[] = {
1565 "Front Playback Switch",
1566 "Surround Playback Switch",
1567 "Center Playback Switch",
1568 "LFE Playback Switch",
1569 "Side Playback Switch",
1570 "Headphone Playback Switch",
1571 "Speaker Playback Switch",
1572 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001573 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001574 NULL,
1575};
1576
1577/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001578 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579 */
1580static int alc_build_controls(struct hda_codec *codec)
1581{
1582 struct alc_spec *spec = codec->spec;
1583 int err;
1584 int i;
1585
1586 for (i = 0; i < spec->num_mixers; i++) {
1587 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1588 if (err < 0)
1589 return err;
1590 }
1591
1592 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001593 err = snd_hda_create_spdif_out_ctls(codec,
1594 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595 if (err < 0)
1596 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001597 err = snd_hda_create_spdif_share_sw(codec,
1598 &spec->multiout);
1599 if (err < 0)
1600 return err;
1601 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 }
1603 if (spec->dig_in_nid) {
1604 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1605 if (err < 0)
1606 return err;
1607 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001608
1609 /* if we have no master control, let's create it */
1610 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001611 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001612 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001613 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001614 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001615 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001616 if (err < 0)
1617 return err;
1618 }
1619 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1620 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1621 NULL, alc_slave_sws);
1622 if (err < 0)
1623 return err;
1624 }
1625
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 return 0;
1627}
1628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630/*
1631 * initialize the codec volumes, etc
1632 */
1633
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001634/*
1635 * generic initialization of ADC, input mixers and output mixers
1636 */
1637static struct hda_verb alc880_volume_init_verbs[] = {
1638 /*
1639 * Unmute ADC0-2 and set the default input to mic-in
1640 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001641 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001643 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001645 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1649 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001650 * Note: PASD motherboards uses the Line In 2 as the input for front
1651 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001653 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 /*
1663 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001665 /* set vol=0 to output mixers */
1666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1667 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1669 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1670 /* set up input amps for analog loopback */
1671 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1675 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1677 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001678 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680
1681 { }
1682};
1683
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001684/*
1685 * 3-stack pin configuration:
1686 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1687 */
1688static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1689 /*
1690 * preset connection lists of input pins
1691 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1692 */
1693 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1694 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1695 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1696
1697 /*
1698 * Set pin mode and muting
1699 */
1700 /* set front pin widgets 0x14 for output */
1701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1704 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1705 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1706 /* Mic2 (as headphone out) for HP output */
1707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 /* Line In pin widget for input */
1710 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1712 /* Line2 (as front mic) pin widget for input and vref at 80% */
1713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1715 /* CD pin widget for input */
1716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1717
1718 { }
1719};
1720
1721/*
1722 * 5-stack pin configuration:
1723 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1724 * line-in/side = 0x1a, f-mic = 0x1b
1725 */
1726static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1727 /*
1728 * preset connection lists of input pins
1729 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1730 */
1731 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1732 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1733
1734 /*
1735 * Set pin mode and muting
1736 */
1737 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1741 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001742 /* unmute pins for output (no gain on this amp) */
1743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1747
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001749 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1751 /* Mic2 (as headphone out) for HP output */
1752 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754 /* Line In pin widget for input */
1755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1757 /* Line2 (as front mic) pin widget for input and vref at 80% */
1758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1759 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1760 /* CD pin widget for input */
1761 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762
1763 { }
1764};
1765
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766/*
1767 * W810 pin configuration:
1768 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1769 */
1770static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771 /* hphone/speaker input selector: front DAC */
1772 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1773
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1779 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1780
1781 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 { }
1785};
1786
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001787/*
1788 * Z71V pin configuration:
1789 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1790 */
1791static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001796
Takashi Iwai16ded522005-06-10 19:58:24 +02001797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001798 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001801
1802 { }
1803};
1804
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805/*
1806 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001807 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1808 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001809 */
1810static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1811 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1812
Takashi Iwai16ded522005-06-10 19:58:24 +02001813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001817 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001819 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1821
Takashi Iwai16ded522005-06-10 19:58:24 +02001822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001824 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001826 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001828 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001830 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 { }
1833};
Takashi Iwai16ded522005-06-10 19:58:24 +02001834
Kailang Yangccc656c2006-10-17 12:32:26 +02001835/*
1836 * Uniwill pin configuration:
1837 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1838 * line = 0x1a
1839 */
1840static struct hda_verb alc880_uniwill_init_verbs[] = {
1841 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1842
1843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1849 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1853 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1857
1858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1864 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1865 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1866 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1867
1868 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1870
1871 { }
1872};
1873
1874/*
1875* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001876* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001877 */
1878static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1879 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1880
1881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1885 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1893
1894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1895 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1896 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1900
1901 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1902 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1903
1904 { }
1905};
1906
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001907static struct hda_verb alc880_beep_init_verbs[] = {
1908 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1909 { }
1910};
1911
Kailang Yangccc656c2006-10-17 12:32:26 +02001912/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001913static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001914{
1915 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001916 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001917
1918 present = snd_hda_codec_read(codec, 0x14, 0,
1919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001920 bits = present ? HDA_AMP_MUTE : 0;
1921 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1922 HDA_AMP_MUTE, bits);
1923 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1924 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001925}
1926
1927/* auto-toggle front mic */
1928static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1929{
1930 unsigned int present;
1931 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001932
1933 present = snd_hda_codec_read(codec, 0x18, 0,
1934 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001935 bits = present ? HDA_AMP_MUTE : 0;
1936 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001937}
1938
1939static void alc880_uniwill_automute(struct hda_codec *codec)
1940{
1941 alc880_uniwill_hp_automute(codec);
1942 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001943}
1944
1945static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1946 unsigned int res)
1947{
1948 /* Looks like the unsol event is incompatible with the standard
1949 * definition. 4bit tag is placed at 28 bit!
1950 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001951 switch (res >> 28) {
1952 case ALC880_HP_EVENT:
1953 alc880_uniwill_hp_automute(codec);
1954 break;
1955 case ALC880_MIC_EVENT:
1956 alc880_uniwill_mic_automute(codec);
1957 break;
1958 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001959}
1960
1961static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1962{
1963 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001964 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001965
1966 present = snd_hda_codec_read(codec, 0x14, 0,
1967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001968 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001969 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001970}
1971
1972static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1973{
1974 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001975
Kailang Yangccc656c2006-10-17 12:32:26 +02001976 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001977 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1978 present &= HDA_AMP_VOLMASK;
1979 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1980 HDA_AMP_VOLMASK, present);
1981 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1982 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001983}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001984
Kailang Yangccc656c2006-10-17 12:32:26 +02001985static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1986 unsigned int res)
1987{
1988 /* Looks like the unsol event is incompatible with the standard
1989 * definition. 4bit tag is placed at 28 bit!
1990 */
1991 if ((res >> 28) == ALC880_HP_EVENT)
1992 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001993 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001994 alc880_uniwill_p53_dcvol_automute(codec);
1995}
1996
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997/*
1998 * F1734 pin configuration:
1999 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2000 */
2001static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002002 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002003 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2004 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2005 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2006 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2007
2008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012
2013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002015 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2017 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2020 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002022
Takashi Iwai937b4162008-02-11 14:52:36 +01002023 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2024 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2025
Takashi Iwai16ded522005-06-10 19:58:24 +02002026 { }
2027};
2028
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029/*
2030 * ASUS pin configuration:
2031 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2032 */
2033static struct hda_verb alc880_pin_asus_init_verbs[] = {
2034 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2035 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2036 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2037 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2038
2039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2043 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2044 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2045 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2046 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2047
2048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2050 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2051 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2054 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002057
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002058 { }
2059};
2060
2061/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002062#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2063#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064
Kailang Yangdf694da2005-12-05 19:42:22 +01002065/* Clevo m520g init */
2066static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2067 /* headphone output */
2068 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2069 /* line-out */
2070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 /* Line-in */
2073 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2074 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2075 /* CD */
2076 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2077 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 /* Mic1 (rear panel) */
2079 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 /* Mic2 (front panel) */
2082 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2083 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2084 /* headphone */
2085 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2086 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 /* change to EAPD mode */
2088 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2089 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2090
2091 { }
2092};
2093
2094static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002095 /* change to EAPD mode */
2096 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2097 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2098
Kailang Yangdf694da2005-12-05 19:42:22 +01002099 /* Headphone output */
2100 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2101 /* Front output*/
2102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2103 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2104
2105 /* Line In pin widget for input */
2106 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2107 /* CD pin widget for input */
2108 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2109 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2110 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2111
2112 /* change to EAPD mode */
2113 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2114 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2115
2116 { }
2117};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002118
2119/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002120 * LG m1 express dual
2121 *
2122 * Pin assignment:
2123 * Rear Line-In/Out (blue): 0x14
2124 * Build-in Mic-In: 0x15
2125 * Speaker-out: 0x17
2126 * HP-Out (green): 0x1b
2127 * Mic-In/Out (red): 0x19
2128 * SPDIF-Out: 0x1e
2129 */
2130
2131/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2132static hda_nid_t alc880_lg_dac_nids[3] = {
2133 0x05, 0x02, 0x03
2134};
2135
2136/* seems analog CD is not working */
2137static struct hda_input_mux alc880_lg_capture_source = {
2138 .num_items = 3,
2139 .items = {
2140 { "Mic", 0x1 },
2141 { "Line", 0x5 },
2142 { "Internal Mic", 0x6 },
2143 },
2144};
2145
2146/* 2,4,6 channel modes */
2147static struct hda_verb alc880_lg_ch2_init[] = {
2148 /* set line-in and mic-in to input */
2149 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2150 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2151 { }
2152};
2153
2154static struct hda_verb alc880_lg_ch4_init[] = {
2155 /* set line-in to out and mic-in to input */
2156 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2157 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2158 { }
2159};
2160
2161static struct hda_verb alc880_lg_ch6_init[] = {
2162 /* set line-in and mic-in to output */
2163 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2164 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2165 { }
2166};
2167
2168static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2169 { 2, alc880_lg_ch2_init },
2170 { 4, alc880_lg_ch4_init },
2171 { 6, alc880_lg_ch6_init },
2172};
2173
2174static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2176 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2179 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2181 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2182 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2188 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2189 {
2190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2191 .name = "Channel Mode",
2192 .info = alc_ch_mode_info,
2193 .get = alc_ch_mode_get,
2194 .put = alc_ch_mode_put,
2195 },
2196 { } /* end */
2197};
2198
2199static struct hda_verb alc880_lg_init_verbs[] = {
2200 /* set capture source to mic-in */
2201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2204 /* mute all amp mixer inputs */
2205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002208 /* line-in to input */
2209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2211 /* built-in mic */
2212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2214 /* speaker-out */
2215 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2217 /* mic-in to input */
2218 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2219 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2221 /* HP-out */
2222 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* jack sense */
2226 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2227 { }
2228};
2229
2230/* toggle speaker-output according to the hp-jack state */
2231static void alc880_lg_automute(struct hda_codec *codec)
2232{
2233 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002234 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002235
2236 present = snd_hda_codec_read(codec, 0x1b, 0,
2237 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002238 bits = present ? HDA_AMP_MUTE : 0;
2239 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2240 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002241}
2242
2243static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2244{
2245 /* Looks like the unsol event is incompatible with the standard
2246 * definition. 4bit tag is placed at 28 bit!
2247 */
2248 if ((res >> 28) == 0x01)
2249 alc880_lg_automute(codec);
2250}
2251
2252/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002253 * LG LW20
2254 *
2255 * Pin assignment:
2256 * Speaker-out: 0x14
2257 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002258 * Built-in Mic-In: 0x19
2259 * Line-In: 0x1b
2260 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002261 * SPDIF-Out: 0x1e
2262 */
2263
Takashi Iwaid6815182006-03-23 16:06:23 +01002264static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002265 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002266 .items = {
2267 { "Mic", 0x0 },
2268 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002269 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002270 },
2271};
2272
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002273#define alc880_lg_lw_modes alc880_threestack_modes
2274
Takashi Iwaid6815182006-03-23 16:06:23 +01002275static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2277 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2279 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2280 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2281 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2282 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2283 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2288 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2289 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002290 {
2291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2292 .name = "Channel Mode",
2293 .info = alc_ch_mode_info,
2294 .get = alc_ch_mode_get,
2295 .put = alc_ch_mode_put,
2296 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002297 { } /* end */
2298};
2299
2300static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002301 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2302 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2303 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2304
Takashi Iwaid6815182006-03-23 16:06:23 +01002305 /* set capture source to mic-in */
2306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2307 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002310 /* speaker-out */
2311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 /* mic-in to input */
2317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2319 /* built-in mic */
2320 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2322 /* jack sense */
2323 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2324 { }
2325};
2326
2327/* toggle speaker-output according to the hp-jack state */
2328static void alc880_lg_lw_automute(struct hda_codec *codec)
2329{
2330 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002331 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002332
2333 present = snd_hda_codec_read(codec, 0x1b, 0,
2334 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002335 bits = present ? HDA_AMP_MUTE : 0;
2336 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2337 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002338}
2339
2340static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2341{
2342 /* Looks like the unsol event is incompatible with the standard
2343 * definition. 4bit tag is placed at 28 bit!
2344 */
2345 if ((res >> 28) == 0x01)
2346 alc880_lg_lw_automute(codec);
2347}
2348
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002349static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2350 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2355 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2356 { } /* end */
2357};
2358
2359static struct hda_input_mux alc880_medion_rim_capture_source = {
2360 .num_items = 2,
2361 .items = {
2362 { "Mic", 0x0 },
2363 { "Internal Mic", 0x1 },
2364 },
2365};
2366
2367static struct hda_verb alc880_medion_rim_init_verbs[] = {
2368 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2369
2370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2371 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2372
2373 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2376 /* Mic2 (as headphone out) for HP output */
2377 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2379 /* Internal Speaker */
2380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2382
2383 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2384 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2385
2386 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2387 { }
2388};
2389
2390/* toggle speaker-output according to the hp-jack state */
2391static void alc880_medion_rim_automute(struct hda_codec *codec)
2392{
2393 unsigned int present;
2394 unsigned char bits;
2395
2396 present = snd_hda_codec_read(codec, 0x14, 0,
2397 AC_VERB_GET_PIN_SENSE, 0)
2398 & AC_PINSENSE_PRESENCE;
2399 bits = present ? HDA_AMP_MUTE : 0;
2400 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2401 HDA_AMP_MUTE, bits);
2402 if (present)
2403 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2404 else
2405 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2406}
2407
2408static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2409 unsigned int res)
2410{
2411 /* Looks like the unsol event is incompatible with the standard
2412 * definition. 4bit tag is placed at 28 bit!
2413 */
2414 if ((res >> 28) == ALC880_HP_EVENT)
2415 alc880_medion_rim_automute(codec);
2416}
2417
Takashi Iwaicb53c622007-08-10 17:21:45 +02002418#ifdef CONFIG_SND_HDA_POWER_SAVE
2419static struct hda_amp_list alc880_loopbacks[] = {
2420 { 0x0b, HDA_INPUT, 0 },
2421 { 0x0b, HDA_INPUT, 1 },
2422 { 0x0b, HDA_INPUT, 2 },
2423 { 0x0b, HDA_INPUT, 3 },
2424 { 0x0b, HDA_INPUT, 4 },
2425 { } /* end */
2426};
2427
2428static struct hda_amp_list alc880_lg_loopbacks[] = {
2429 { 0x0b, HDA_INPUT, 1 },
2430 { 0x0b, HDA_INPUT, 6 },
2431 { 0x0b, HDA_INPUT, 7 },
2432 { } /* end */
2433};
2434#endif
2435
Takashi Iwaid6815182006-03-23 16:06:23 +01002436/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002437 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002439
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440static int alc_init(struct hda_codec *codec)
2441{
2442 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 unsigned int i;
2444
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002445 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002446 if (codec->vendor_id == 0x10ec0888)
2447 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449 for (i = 0; i < spec->num_init_verbs; i++)
2450 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002451
2452 if (spec->init_hook)
2453 spec->init_hook(codec);
2454
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455 return 0;
2456}
2457
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002458static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2459{
2460 struct alc_spec *spec = codec->spec;
2461
2462 if (spec->unsol_event)
2463 spec->unsol_event(codec, res);
2464}
2465
Takashi Iwaicb53c622007-08-10 17:21:45 +02002466#ifdef CONFIG_SND_HDA_POWER_SAVE
2467static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2468{
2469 struct alc_spec *spec = codec->spec;
2470 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2471}
2472#endif
2473
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474/*
2475 * Analog playback callbacks
2476 */
2477static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2478 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002479 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480{
2481 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002482 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2483 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484}
2485
2486static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2487 struct hda_codec *codec,
2488 unsigned int stream_tag,
2489 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002490 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491{
2492 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002493 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2494 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495}
2496
2497static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2498 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002499 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500{
2501 struct alc_spec *spec = codec->spec;
2502 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2503}
2504
2505/*
2506 * Digital out
2507 */
2508static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2509 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002510 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511{
2512 struct alc_spec *spec = codec->spec;
2513 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2514}
2515
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002516static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2517 struct hda_codec *codec,
2518 unsigned int stream_tag,
2519 unsigned int format,
2520 struct snd_pcm_substream *substream)
2521{
2522 struct alc_spec *spec = codec->spec;
2523 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2524 stream_tag, format, substream);
2525}
2526
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2528 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002529 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530{
2531 struct alc_spec *spec = codec->spec;
2532 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2533}
2534
2535/*
2536 * Analog capture
2537 */
Takashi Iwai63300792008-01-24 15:31:36 +01002538static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 struct hda_codec *codec,
2540 unsigned int stream_tag,
2541 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002542 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543{
2544 struct alc_spec *spec = codec->spec;
2545
Takashi Iwai63300792008-01-24 15:31:36 +01002546 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 stream_tag, 0, format);
2548 return 0;
2549}
2550
Takashi Iwai63300792008-01-24 15:31:36 +01002551static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002553 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554{
2555 struct alc_spec *spec = codec->spec;
2556
Takashi Iwai888afa12008-03-18 09:57:50 +01002557 snd_hda_codec_cleanup_stream(codec,
2558 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 return 0;
2560}
2561
2562
2563/*
2564 */
2565static struct hda_pcm_stream alc880_pcm_analog_playback = {
2566 .substreams = 1,
2567 .channels_min = 2,
2568 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 .ops = {
2571 .open = alc880_playback_pcm_open,
2572 .prepare = alc880_playback_pcm_prepare,
2573 .cleanup = alc880_playback_pcm_cleanup
2574 },
2575};
2576
2577static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002578 .substreams = 1,
2579 .channels_min = 2,
2580 .channels_max = 2,
2581 /* NID is set in alc_build_pcms */
2582};
2583
2584static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2585 .substreams = 1,
2586 .channels_min = 2,
2587 .channels_max = 2,
2588 /* NID is set in alc_build_pcms */
2589};
2590
2591static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2592 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 .channels_min = 2,
2594 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002597 .prepare = alc880_alt_capture_pcm_prepare,
2598 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 },
2600};
2601
2602static struct hda_pcm_stream alc880_pcm_digital_playback = {
2603 .substreams = 1,
2604 .channels_min = 2,
2605 .channels_max = 2,
2606 /* NID is set in alc_build_pcms */
2607 .ops = {
2608 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002609 .close = alc880_dig_playback_pcm_close,
2610 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 },
2612};
2613
2614static struct hda_pcm_stream alc880_pcm_digital_capture = {
2615 .substreams = 1,
2616 .channels_min = 2,
2617 .channels_max = 2,
2618 /* NID is set in alc_build_pcms */
2619};
2620
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002621/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002622static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002623 .substreams = 0,
2624 .channels_min = 0,
2625 .channels_max = 0,
2626};
2627
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628static int alc_build_pcms(struct hda_codec *codec)
2629{
2630 struct alc_spec *spec = codec->spec;
2631 struct hda_pcm *info = spec->pcm_rec;
2632 int i;
2633
2634 codec->num_pcms = 1;
2635 codec->pcm_info = info;
2636
2637 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002638 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002639 if (snd_BUG_ON(!spec->multiout.dac_nids))
2640 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002641 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2642 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2643 }
2644 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002645 if (snd_BUG_ON(!spec->adc_nids))
2646 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002647 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2648 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2649 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650
Takashi Iwai4a471b72005-12-07 13:56:29 +01002651 if (spec->channel_mode) {
2652 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2653 for (i = 0; i < spec->num_channel_mode; i++) {
2654 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2655 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2656 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 }
2658 }
2659
Takashi Iwaie08a0072006-09-07 17:52:14 +02002660 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002662 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002663 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002665 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002666 if (spec->multiout.dig_out_nid &&
2667 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2669 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2670 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002671 if (spec->dig_in_nid &&
2672 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2674 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2675 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002676 /* FIXME: do we need this for all Realtek codec models? */
2677 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 }
2679
Takashi Iwaie08a0072006-09-07 17:52:14 +02002680 /* If the use of more than one ADC is requested for the current
2681 * model, configure a second analog capture-only PCM.
2682 */
2683 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002684 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2685 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002686 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002687 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002688 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002689 if (spec->alt_dac_nid) {
2690 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2691 *spec->stream_analog_alt_playback;
2692 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2693 spec->alt_dac_nid;
2694 } else {
2695 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2696 alc_pcm_null_stream;
2697 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2698 }
2699 if (spec->num_adc_nids > 1) {
2700 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2701 *spec->stream_analog_alt_capture;
2702 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2703 spec->adc_nids[1];
2704 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2705 spec->num_adc_nids - 1;
2706 } else {
2707 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2708 alc_pcm_null_stream;
2709 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002710 }
2711 }
2712
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 return 0;
2714}
2715
2716static void alc_free(struct hda_codec *codec)
2717{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 struct alc_spec *spec = codec->spec;
2719 unsigned int i;
2720
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002721 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 return;
2723
2724 if (spec->kctl_alloc) {
2725 for (i = 0; i < spec->num_kctl_used; i++)
2726 kfree(spec->kctl_alloc[i].name);
2727 kfree(spec->kctl_alloc);
2728 }
2729 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002730 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731}
2732
2733/*
2734 */
2735static struct hda_codec_ops alc_patch_ops = {
2736 .build_controls = alc_build_controls,
2737 .build_pcms = alc_build_pcms,
2738 .init = alc_init,
2739 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002740 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002741#ifdef CONFIG_SND_HDA_POWER_SAVE
2742 .check_power_status = alc_check_power_status,
2743#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744};
2745
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002746
2747/*
2748 * Test configuration for debugging
2749 *
2750 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2751 * enum controls.
2752 */
2753#ifdef CONFIG_SND_DEBUG
2754static hda_nid_t alc880_test_dac_nids[4] = {
2755 0x02, 0x03, 0x04, 0x05
2756};
2757
2758static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002759 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002760 .items = {
2761 { "In-1", 0x0 },
2762 { "In-2", 0x1 },
2763 { "In-3", 0x2 },
2764 { "In-4", 0x3 },
2765 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002766 { "Front", 0x5 },
2767 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002768 },
2769};
2770
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002771static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002772 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002773 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002774 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002775 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002776};
2777
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002778static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2779 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002780{
2781 static char *texts[] = {
2782 "N/A", "Line Out", "HP Out",
2783 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2784 };
2785 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2786 uinfo->count = 1;
2787 uinfo->value.enumerated.items = 8;
2788 if (uinfo->value.enumerated.item >= 8)
2789 uinfo->value.enumerated.item = 7;
2790 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2791 return 0;
2792}
2793
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002794static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2795 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002796{
2797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2798 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2799 unsigned int pin_ctl, item = 0;
2800
2801 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2802 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2803 if (pin_ctl & AC_PINCTL_OUT_EN) {
2804 if (pin_ctl & AC_PINCTL_HP_EN)
2805 item = 2;
2806 else
2807 item = 1;
2808 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2809 switch (pin_ctl & AC_PINCTL_VREFEN) {
2810 case AC_PINCTL_VREF_HIZ: item = 3; break;
2811 case AC_PINCTL_VREF_50: item = 4; break;
2812 case AC_PINCTL_VREF_GRD: item = 5; break;
2813 case AC_PINCTL_VREF_80: item = 6; break;
2814 case AC_PINCTL_VREF_100: item = 7; break;
2815 }
2816 }
2817 ucontrol->value.enumerated.item[0] = item;
2818 return 0;
2819}
2820
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002821static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2822 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002823{
2824 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2825 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2826 static unsigned int ctls[] = {
2827 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2828 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2829 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2830 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2831 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2832 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2833 };
2834 unsigned int old_ctl, new_ctl;
2835
2836 old_ctl = snd_hda_codec_read(codec, nid, 0,
2837 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2838 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2839 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002840 int val;
2841 snd_hda_codec_write_cache(codec, nid, 0,
2842 AC_VERB_SET_PIN_WIDGET_CONTROL,
2843 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002844 val = ucontrol->value.enumerated.item[0] >= 3 ?
2845 HDA_AMP_MUTE : 0;
2846 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2847 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002848 return 1;
2849 }
2850 return 0;
2851}
2852
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002853static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2854 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002855{
2856 static char *texts[] = {
2857 "Front", "Surround", "CLFE", "Side"
2858 };
2859 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2860 uinfo->count = 1;
2861 uinfo->value.enumerated.items = 4;
2862 if (uinfo->value.enumerated.item >= 4)
2863 uinfo->value.enumerated.item = 3;
2864 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2865 return 0;
2866}
2867
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002868static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2869 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002870{
2871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2872 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2873 unsigned int sel;
2874
2875 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2876 ucontrol->value.enumerated.item[0] = sel & 3;
2877 return 0;
2878}
2879
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002880static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2881 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002882{
2883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2884 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2885 unsigned int sel;
2886
2887 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2888 if (ucontrol->value.enumerated.item[0] != sel) {
2889 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002890 snd_hda_codec_write_cache(codec, nid, 0,
2891 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002892 return 1;
2893 }
2894 return 0;
2895}
2896
2897#define PIN_CTL_TEST(xname,nid) { \
2898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2899 .name = xname, \
2900 .info = alc_test_pin_ctl_info, \
2901 .get = alc_test_pin_ctl_get, \
2902 .put = alc_test_pin_ctl_put, \
2903 .private_value = nid \
2904 }
2905
2906#define PIN_SRC_TEST(xname,nid) { \
2907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2908 .name = xname, \
2909 .info = alc_test_pin_src_info, \
2910 .get = alc_test_pin_src_get, \
2911 .put = alc_test_pin_src_put, \
2912 .private_value = nid \
2913 }
2914
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002915static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002916 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2918 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2919 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002920 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2921 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2922 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2923 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002924 PIN_CTL_TEST("Front Pin Mode", 0x14),
2925 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2926 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2927 PIN_CTL_TEST("Side Pin Mode", 0x17),
2928 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2929 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2930 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2931 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2932 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2933 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2934 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2935 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2936 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2937 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2938 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2939 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2940 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2941 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2942 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2943 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002946 {
2947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2948 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002949 .info = alc_ch_mode_info,
2950 .get = alc_ch_mode_get,
2951 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002952 },
2953 { } /* end */
2954};
2955
2956static struct hda_verb alc880_test_init_verbs[] = {
2957 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002966 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002971 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2974 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2975 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002976 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002981 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002984 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2986 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002987 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2991 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002992 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002994 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002995 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002996 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002997 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002998 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002999 /* Analog input/passthru */
3000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003005 { }
3006};
3007#endif
3008
Linus Torvalds1da177e2005-04-16 15:20:36 -07003009/*
3010 */
3011
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003012static const char *alc880_models[ALC880_MODEL_LAST] = {
3013 [ALC880_3ST] = "3stack",
3014 [ALC880_TCL_S700] = "tcl",
3015 [ALC880_3ST_DIG] = "3stack-digout",
3016 [ALC880_CLEVO] = "clevo",
3017 [ALC880_5ST] = "5stack",
3018 [ALC880_5ST_DIG] = "5stack-digout",
3019 [ALC880_W810] = "w810",
3020 [ALC880_Z71V] = "z71v",
3021 [ALC880_6ST] = "6stack",
3022 [ALC880_6ST_DIG] = "6stack-digout",
3023 [ALC880_ASUS] = "asus",
3024 [ALC880_ASUS_W1V] = "asus-w1v",
3025 [ALC880_ASUS_DIG] = "asus-dig",
3026 [ALC880_ASUS_DIG2] = "asus-dig2",
3027 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003028 [ALC880_UNIWILL_P53] = "uniwill-p53",
3029 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003030 [ALC880_F1734] = "F1734",
3031 [ALC880_LG] = "lg",
3032 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003033 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003034#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003035 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003036#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003037 [ALC880_AUTO] = "auto",
3038};
3039
3040static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003041 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003042 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3043 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3044 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3045 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3046 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3047 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3048 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3049 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003050 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3051 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003052 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3053 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3054 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3055 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3057 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3058 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3059 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3060 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3061 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003062 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003063 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3064 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3065 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003066 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003067 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003068 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3069 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003070 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3071 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003072 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3073 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3074 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3075 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003076 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3077 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003078 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003079 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003080 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003081 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3083 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003084 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003085 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003086 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003087 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003088 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003089 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003090 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003091 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003092 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003093 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3094 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003095 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003096 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3097 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3098 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3099 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003100 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3101 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003102 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003103 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003104 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3105 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003106 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3107 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3108 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003109 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3110 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3111 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003112 {}
3113};
3114
Takashi Iwai16ded522005-06-10 19:58:24 +02003115/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003116 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003117 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003118static struct alc_config_preset alc880_presets[] = {
3119 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 .init_verbs = { alc880_volume_init_verbs,
3122 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3126 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003127 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003128 .input_mux = &alc880_capture_source,
3129 },
3130 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003132 .init_verbs = { alc880_volume_init_verbs,
3133 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003134 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .dac_nids = alc880_dac_nids,
3136 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003137 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3138 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003139 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 .input_mux = &alc880_capture_source,
3141 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003142 [ALC880_TCL_S700] = {
3143 .mixers = { alc880_tcl_s700_mixer },
3144 .init_verbs = { alc880_volume_init_verbs,
3145 alc880_pin_tcl_S700_init_verbs,
3146 alc880_gpio2_init_verbs },
3147 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3148 .dac_nids = alc880_dac_nids,
3149 .hp_nid = 0x03,
3150 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3151 .channel_mode = alc880_2_jack_modes,
3152 .input_mux = &alc880_capture_source,
3153 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003154 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003155 .mixers = { alc880_three_stack_mixer,
3156 alc880_five_stack_mixer},
3157 .init_verbs = { alc880_volume_init_verbs,
3158 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003159 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3160 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003161 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3162 .channel_mode = alc880_fivestack_modes,
3163 .input_mux = &alc880_capture_source,
3164 },
3165 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003166 .mixers = { alc880_three_stack_mixer,
3167 alc880_five_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003173 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3174 .channel_mode = alc880_fivestack_modes,
3175 .input_mux = &alc880_capture_source,
3176 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003177 [ALC880_6ST] = {
3178 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003179 .init_verbs = { alc880_volume_init_verbs,
3180 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003181 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3182 .dac_nids = alc880_6st_dac_nids,
3183 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3184 .channel_mode = alc880_sixstack_modes,
3185 .input_mux = &alc880_6stack_capture_source,
3186 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003187 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003189 .init_verbs = { alc880_volume_init_verbs,
3190 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003191 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3192 .dac_nids = alc880_6st_dac_nids,
3193 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003194 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3195 .channel_mode = alc880_sixstack_modes,
3196 .input_mux = &alc880_6stack_capture_source,
3197 },
3198 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003200 .init_verbs = { alc880_volume_init_verbs,
3201 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003202 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003203 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3204 .dac_nids = alc880_w810_dac_nids,
3205 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003206 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3207 .channel_mode = alc880_w810_modes,
3208 .input_mux = &alc880_capture_source,
3209 },
3210 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003212 .init_verbs = { alc880_volume_init_verbs,
3213 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003214 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3215 .dac_nids = alc880_z71v_dac_nids,
3216 .dig_out_nid = ALC880_DIGOUT_NID,
3217 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003218 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3219 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003220 .input_mux = &alc880_capture_source,
3221 },
3222 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003226 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3227 .dac_nids = alc880_f1734_dac_nids,
3228 .hp_nid = 0x02,
3229 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3230 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003231 .input_mux = &alc880_f1734_capture_source,
3232 .unsol_event = alc880_uniwill_p53_unsol_event,
3233 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003234 },
3235 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239 alc880_gpio1_init_verbs },
3240 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3241 .dac_nids = alc880_asus_dac_nids,
3242 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3243 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003244 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003245 .input_mux = &alc880_capture_source,
3246 },
3247 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 .init_verbs = { alc880_volume_init_verbs,
3250 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 alc880_gpio1_init_verbs },
3252 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3253 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003254 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3256 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003257 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 .input_mux = &alc880_capture_source,
3259 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003260 [ALC880_ASUS_DIG2] = {
3261 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262 .init_verbs = { alc880_volume_init_verbs,
3263 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003264 alc880_gpio2_init_verbs }, /* use GPIO2 */
3265 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3266 .dac_nids = alc880_asus_dac_nids,
3267 .dig_out_nid = ALC880_DIGOUT_NID,
3268 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3269 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003270 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003271 .input_mux = &alc880_capture_source,
3272 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003275 .init_verbs = { alc880_volume_init_verbs,
3276 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 alc880_gpio1_init_verbs },
3278 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3279 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003280 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3282 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003283 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003284 .input_mux = &alc880_capture_source,
3285 },
3286 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003287 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003288 .init_verbs = { alc880_volume_init_verbs,
3289 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3291 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003292 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3294 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003295 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003296 .input_mux = &alc880_capture_source,
3297 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003298 [ALC880_UNIWILL] = {
3299 .mixers = { alc880_uniwill_mixer },
3300 .init_verbs = { alc880_volume_init_verbs,
3301 alc880_uniwill_init_verbs },
3302 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3303 .dac_nids = alc880_asus_dac_nids,
3304 .dig_out_nid = ALC880_DIGOUT_NID,
3305 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3306 .channel_mode = alc880_threestack_modes,
3307 .need_dac_fix = 1,
3308 .input_mux = &alc880_capture_source,
3309 .unsol_event = alc880_uniwill_unsol_event,
3310 .init_hook = alc880_uniwill_automute,
3311 },
3312 [ALC880_UNIWILL_P53] = {
3313 .mixers = { alc880_uniwill_p53_mixer },
3314 .init_verbs = { alc880_volume_init_verbs,
3315 alc880_uniwill_p53_init_verbs },
3316 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3317 .dac_nids = alc880_asus_dac_nids,
3318 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003319 .channel_mode = alc880_threestack_modes,
3320 .input_mux = &alc880_capture_source,
3321 .unsol_event = alc880_uniwill_p53_unsol_event,
3322 .init_hook = alc880_uniwill_p53_hp_automute,
3323 },
3324 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003325 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003326 alc880_pcbeep_mixer, },
3327 .init_verbs = { alc880_volume_init_verbs,
3328 alc880_uniwill_p53_init_verbs,
3329 alc880_beep_init_verbs },
3330 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3331 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003332 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003333 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3334 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003335 .input_mux = &alc880_capture_source,
3336 .unsol_event = alc880_uniwill_p53_unsol_event,
3337 .init_hook = alc880_uniwill_p53_hp_automute,
3338 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003339 [ALC880_CLEVO] = {
3340 .mixers = { alc880_three_stack_mixer },
3341 .init_verbs = { alc880_volume_init_verbs,
3342 alc880_pin_clevo_init_verbs },
3343 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3344 .dac_nids = alc880_dac_nids,
3345 .hp_nid = 0x03,
3346 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3347 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003348 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003349 .input_mux = &alc880_capture_source,
3350 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003351 [ALC880_LG] = {
3352 .mixers = { alc880_lg_mixer },
3353 .init_verbs = { alc880_volume_init_verbs,
3354 alc880_lg_init_verbs },
3355 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3356 .dac_nids = alc880_lg_dac_nids,
3357 .dig_out_nid = ALC880_DIGOUT_NID,
3358 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3359 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003360 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003361 .input_mux = &alc880_lg_capture_source,
3362 .unsol_event = alc880_lg_unsol_event,
3363 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003364#ifdef CONFIG_SND_HDA_POWER_SAVE
3365 .loopbacks = alc880_lg_loopbacks,
3366#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003367 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003368 [ALC880_LG_LW] = {
3369 .mixers = { alc880_lg_lw_mixer },
3370 .init_verbs = { alc880_volume_init_verbs,
3371 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003372 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003373 .dac_nids = alc880_dac_nids,
3374 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003375 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3376 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003377 .input_mux = &alc880_lg_lw_capture_source,
3378 .unsol_event = alc880_lg_lw_unsol_event,
3379 .init_hook = alc880_lg_lw_automute,
3380 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003381 [ALC880_MEDION_RIM] = {
3382 .mixers = { alc880_medion_rim_mixer },
3383 .init_verbs = { alc880_volume_init_verbs,
3384 alc880_medion_rim_init_verbs,
3385 alc_gpio2_init_verbs },
3386 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3387 .dac_nids = alc880_dac_nids,
3388 .dig_out_nid = ALC880_DIGOUT_NID,
3389 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3390 .channel_mode = alc880_2_jack_modes,
3391 .input_mux = &alc880_medion_rim_capture_source,
3392 .unsol_event = alc880_medion_rim_unsol_event,
3393 .init_hook = alc880_medion_rim_automute,
3394 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003395#ifdef CONFIG_SND_DEBUG
3396 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003397 .mixers = { alc880_test_mixer },
3398 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003399 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3400 .dac_nids = alc880_test_dac_nids,
3401 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003402 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3403 .channel_mode = alc880_test_modes,
3404 .input_mux = &alc880_test_capture_source,
3405 },
3406#endif
3407};
3408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409/*
3410 * Automatic parse of I/O pins from the BIOS configuration
3411 */
3412
3413#define NUM_CONTROL_ALLOC 32
3414#define NUM_VERB_ALLOC 32
3415
3416enum {
3417 ALC_CTL_WIDGET_VOL,
3418 ALC_CTL_WIDGET_MUTE,
3419 ALC_CTL_BIND_MUTE,
3420};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003421static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003422 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3423 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003424 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003425};
3426
3427/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003428static int add_control(struct alc_spec *spec, int type, const char *name,
3429 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003431 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432
3433 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3434 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3435
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003436 /* array + terminator */
3437 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3438 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 return -ENOMEM;
3440 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441 memcpy(knew, spec->kctl_alloc,
3442 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003443 kfree(spec->kctl_alloc);
3444 }
3445 spec->kctl_alloc = knew;
3446 spec->num_kctl_alloc = num;
3447 }
3448
3449 knew = &spec->kctl_alloc[spec->num_kctl_used];
3450 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003451 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003453 return -ENOMEM;
3454 knew->private_value = val;
3455 spec->num_kctl_used++;
3456 return 0;
3457}
3458
3459#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3460#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3461#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3462#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3463#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3464#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3465#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3466#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3467#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3468#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3469#define ALC880_PIN_CD_NID 0x1c
3470
3471/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003472static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3473 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474{
3475 hda_nid_t nid;
3476 int assigned[4];
3477 int i, j;
3478
3479 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003480 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003481
3482 /* check the pins hardwired to audio widget */
3483 for (i = 0; i < cfg->line_outs; i++) {
3484 nid = cfg->line_out_pins[i];
3485 if (alc880_is_fixed_pin(nid)) {
3486 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003487 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488 assigned[idx] = 1;
3489 }
3490 }
3491 /* left pins can be connect to any audio widget */
3492 for (i = 0; i < cfg->line_outs; i++) {
3493 nid = cfg->line_out_pins[i];
3494 if (alc880_is_fixed_pin(nid))
3495 continue;
3496 /* search for an empty channel */
3497 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003498 if (!assigned[j]) {
3499 spec->multiout.dac_nids[i] =
3500 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 assigned[j] = 1;
3502 break;
3503 }
3504 }
3505 }
3506 spec->multiout.num_dacs = cfg->line_outs;
3507 return 0;
3508}
3509
3510/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003511static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3512 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513{
3514 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003515 static const char *chname[4] = {
3516 "Front", "Surround", NULL /*CLFE*/, "Side"
3517 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003518 hda_nid_t nid;
3519 int i, err;
3520
3521 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003522 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523 continue;
3524 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3525 if (i == 2) {
3526 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003527 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3528 "Center Playback Volume",
3529 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3530 HDA_OUTPUT));
3531 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003532 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003533 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3534 "LFE Playback Volume",
3535 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3536 HDA_OUTPUT));
3537 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003539 err = add_control(spec, ALC_CTL_BIND_MUTE,
3540 "Center Playback Switch",
3541 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3542 HDA_INPUT));
3543 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003545 err = add_control(spec, ALC_CTL_BIND_MUTE,
3546 "LFE Playback Switch",
3547 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3548 HDA_INPUT));
3549 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 return err;
3551 } else {
3552 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003553 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3554 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3555 HDA_OUTPUT));
3556 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 return err;
3558 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003559 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3560 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3561 HDA_INPUT));
3562 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563 return err;
3564 }
3565 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566 return 0;
3567}
3568
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003569/* add playback controls for speaker and HP outputs */
3570static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3571 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572{
3573 hda_nid_t nid;
3574 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003575 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003576
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003577 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578 return 0;
3579
3580 if (alc880_is_fixed_pin(pin)) {
3581 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003582 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003583 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003584 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003585 else
3586 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003587 /* control HP volume/switch on the output mixer amp */
3588 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003589 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3591 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003593 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003594 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003595 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3596 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3597 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003598 return err;
3599 } else if (alc880_is_multi_pin(pin)) {
3600 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003601 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003602 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003603 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3604 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3605 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003606 return err;
3607 }
3608 return 0;
3609}
3610
3611/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003612static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3613 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003614 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003615{
3616 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003617 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618
3619 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003620 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3621 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3622 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003623 return err;
3624 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003625 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3626 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3627 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628 return err;
3629 return 0;
3630}
3631
3632/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003633static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3634 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003636 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003637 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638
3639 for (i = 0; i < AUTO_PIN_LAST; i++) {
3640 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003641 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003642 err = new_analog_input(spec, cfg->input_pins[i],
3643 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003644 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003645 if (err < 0)
3646 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003647 imux->items[imux->num_items].label =
3648 auto_pin_cfg_labels[i];
3649 imux->items[imux->num_items].index =
3650 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003651 imux->num_items++;
3652 }
3653 }
3654 return 0;
3655}
3656
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003657static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3658 unsigned int pin_type)
3659{
3660 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3661 pin_type);
3662 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003663 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3664 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003665}
3666
Kailang Yangdf694da2005-12-05 19:42:22 +01003667static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3668 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003669 int dac_idx)
3670{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003671 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003672 /* need the manual connection? */
3673 if (alc880_is_multi_pin(nid)) {
3674 struct alc_spec *spec = codec->spec;
3675 int idx = alc880_multi_pin_idx(nid);
3676 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3677 AC_VERB_SET_CONNECT_SEL,
3678 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3679 }
3680}
3681
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003682static int get_pin_type(int line_out_type)
3683{
3684 if (line_out_type == AUTO_PIN_HP_OUT)
3685 return PIN_HP;
3686 else
3687 return PIN_OUT;
3688}
3689
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003690static void alc880_auto_init_multi_out(struct hda_codec *codec)
3691{
3692 struct alc_spec *spec = codec->spec;
3693 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003694
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003695 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 for (i = 0; i < spec->autocfg.line_outs; i++) {
3697 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003698 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3699 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003700 }
3701}
3702
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003703static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003704{
3705 struct alc_spec *spec = codec->spec;
3706 hda_nid_t pin;
3707
Takashi Iwai82bc9552006-03-21 11:24:42 +01003708 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003709 if (pin) /* connect to front */
3710 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003711 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003712 if (pin) /* connect to front */
3713 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3714}
3715
3716static void alc880_auto_init_analog_input(struct hda_codec *codec)
3717{
3718 struct alc_spec *spec = codec->spec;
3719 int i;
3720
3721 for (i = 0; i < AUTO_PIN_LAST; i++) {
3722 hda_nid_t nid = spec->autocfg.input_pins[i];
3723 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724 snd_hda_codec_write(codec, nid, 0,
3725 AC_VERB_SET_PIN_WIDGET_CONTROL,
3726 i <= AUTO_PIN_FRONT_MIC ?
3727 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003728 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003729 snd_hda_codec_write(codec, nid, 0,
3730 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003731 AMP_OUT_MUTE);
3732 }
3733 }
3734}
3735
3736/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737/* return 1 if successful, 0 if the proper config is not found,
3738 * or a negative error code
3739 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740static int alc880_parse_auto_config(struct hda_codec *codec)
3741{
3742 struct alc_spec *spec = codec->spec;
3743 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003744 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003745
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003746 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3747 alc880_ignore);
3748 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003749 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003750 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003752
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003753 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3754 if (err < 0)
3755 return err;
3756 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3757 if (err < 0)
3758 return err;
3759 err = alc880_auto_create_extra_out(spec,
3760 spec->autocfg.speaker_pins[0],
3761 "Speaker");
3762 if (err < 0)
3763 return err;
3764 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3765 "Headphone");
3766 if (err < 0)
3767 return err;
3768 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3769 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003770 return err;
3771
3772 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3773
3774 if (spec->autocfg.dig_out_pin)
3775 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3776 if (spec->autocfg.dig_in_pin)
3777 spec->dig_in_nid = ALC880_DIGIN_NID;
3778
3779 if (spec->kctl_alloc)
3780 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3781
3782 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3783
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003784 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 spec->input_mux = &spec->private_imux;
3786
3787 return 1;
3788}
3789
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003790/* additional initialization for auto-configuration model */
3791static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003793 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003794 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003795 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003797 if (spec->unsol_event)
3798 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799}
3800
3801/*
3802 * OK, here we have finally the patch for ALC880
3803 */
3804
Linus Torvalds1da177e2005-04-16 15:20:36 -07003805static int patch_alc880(struct hda_codec *codec)
3806{
3807 struct alc_spec *spec;
3808 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003810
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003811 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003812 if (spec == NULL)
3813 return -ENOMEM;
3814
3815 codec->spec = spec;
3816
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003817 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3818 alc880_models,
3819 alc880_cfg_tbl);
3820 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003821 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3822 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003824 }
3825
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003826 if (board_config == ALC880_AUTO) {
3827 /* automatic parse from the BIOS config */
3828 err = alc880_parse_auto_config(codec);
3829 if (err < 0) {
3830 alc_free(codec);
3831 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003832 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003833 printk(KERN_INFO
3834 "hda_codec: Cannot set up configuration "
3835 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003836 board_config = ALC880_3ST;
3837 }
3838 }
3839
Kailang Yangdf694da2005-12-05 19:42:22 +01003840 if (board_config != ALC880_AUTO)
3841 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842
3843 spec->stream_name_analog = "ALC880 Analog";
3844 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3845 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003846 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003847
3848 spec->stream_name_digital = "ALC880 Digital";
3849 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3850 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3851
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003852 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003854 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003855 /* get type */
3856 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 if (wcap != AC_WID_AUD_IN) {
3858 spec->adc_nids = alc880_adc_nids_alt;
3859 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003860 spec->mixers[spec->num_mixers] =
3861 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003862 spec->num_mixers++;
3863 } else {
3864 spec->adc_nids = alc880_adc_nids;
3865 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3866 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3867 spec->num_mixers++;
3868 }
3869 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870
Takashi Iwai2134ea42008-01-10 16:53:55 +01003871 spec->vmaster_nid = 0x0c;
3872
Linus Torvalds1da177e2005-04-16 15:20:36 -07003873 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003874 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003875 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003876#ifdef CONFIG_SND_HDA_POWER_SAVE
3877 if (!spec->loopback.amplist)
3878 spec->loopback.amplist = alc880_loopbacks;
3879#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003880
3881 return 0;
3882}
3883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003884
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885/*
3886 * ALC260 support
3887 */
3888
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003889static hda_nid_t alc260_dac_nids[1] = {
3890 /* front */
3891 0x02,
3892};
3893
3894static hda_nid_t alc260_adc_nids[1] = {
3895 /* ADC0 */
3896 0x04,
3897};
3898
Kailang Yangdf694da2005-12-05 19:42:22 +01003899static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003900 /* ADC1 */
3901 0x05,
3902};
3903
Kailang Yangdf694da2005-12-05 19:42:22 +01003904static hda_nid_t alc260_hp_adc_nids[2] = {
3905 /* ADC1, 0 */
3906 0x05, 0x04
3907};
3908
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003909/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3910 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3911 */
3912static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003913 /* ADC0, ADC1 */
3914 0x04, 0x05
3915};
3916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003917#define ALC260_DIGOUT_NID 0x03
3918#define ALC260_DIGIN_NID 0x06
3919
3920static struct hda_input_mux alc260_capture_source = {
3921 .num_items = 4,
3922 .items = {
3923 { "Mic", 0x0 },
3924 { "Front Mic", 0x1 },
3925 { "Line", 0x2 },
3926 { "CD", 0x4 },
3927 },
3928};
3929
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003930/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003931 * headphone jack and the internal CD lines since these are the only pins at
3932 * which audio can appear. For flexibility, also allow the option of
3933 * recording the mixer output on the second ADC (ADC0 doesn't have a
3934 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003935 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003936static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3937 {
3938 .num_items = 3,
3939 .items = {
3940 { "Mic/Line", 0x0 },
3941 { "CD", 0x4 },
3942 { "Headphone", 0x2 },
3943 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003944 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003945 {
3946 .num_items = 4,
3947 .items = {
3948 { "Mic/Line", 0x0 },
3949 { "CD", 0x4 },
3950 { "Headphone", 0x2 },
3951 { "Mixer", 0x5 },
3952 },
3953 },
3954
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003955};
3956
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003957/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3958 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003959 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003960static struct hda_input_mux alc260_acer_capture_sources[2] = {
3961 {
3962 .num_items = 4,
3963 .items = {
3964 { "Mic", 0x0 },
3965 { "Line", 0x2 },
3966 { "CD", 0x4 },
3967 { "Headphone", 0x5 },
3968 },
3969 },
3970 {
3971 .num_items = 5,
3972 .items = {
3973 { "Mic", 0x0 },
3974 { "Line", 0x2 },
3975 { "CD", 0x4 },
3976 { "Headphone", 0x6 },
3977 { "Mixer", 0x5 },
3978 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003979 },
3980};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003981/*
3982 * This is just place-holder, so there's something for alc_build_pcms to look
3983 * at when it calculates the maximum number of channels. ALC260 has no mixer
3984 * element which allows changing the channel mode, so the verb list is
3985 * never used.
3986 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003987static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003988 { 2, NULL },
3989};
3990
Kailang Yangdf694da2005-12-05 19:42:22 +01003991
3992/* Mixer combinations
3993 *
3994 * basic: base_output + input + pc_beep + capture
3995 * HP: base_output + input + capture_alt
3996 * HP_3013: hp_3013 + input + capture
3997 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003998 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003999 */
4000
4001static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004002 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004003 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4005 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4006 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4007 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4008 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004009};
Kailang Yangdf694da2005-12-05 19:42:22 +01004010
4011static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4014 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4015 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4017 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4018 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4019 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004020 { } /* end */
4021};
4022
Kailang Yangdf694da2005-12-05 19:42:22 +01004023static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4024 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4025 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4026 { } /* end */
4027};
4028
Takashi Iwaibec15c32008-01-28 18:16:30 +01004029/* update HP, line and mono out pins according to the master switch */
4030static void alc260_hp_master_update(struct hda_codec *codec,
4031 hda_nid_t hp, hda_nid_t line,
4032 hda_nid_t mono)
4033{
4034 struct alc_spec *spec = codec->spec;
4035 unsigned int val = spec->master_sw ? PIN_HP : 0;
4036 /* change HP and line-out pins */
4037 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4038 val);
4039 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4040 val);
4041 /* mono (speaker) depending on the HP jack sense */
4042 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4043 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4044 val);
4045}
4046
4047static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4048 struct snd_ctl_elem_value *ucontrol)
4049{
4050 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4051 struct alc_spec *spec = codec->spec;
4052 *ucontrol->value.integer.value = spec->master_sw;
4053 return 0;
4054}
4055
4056static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4057 struct snd_ctl_elem_value *ucontrol)
4058{
4059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4060 struct alc_spec *spec = codec->spec;
4061 int val = !!*ucontrol->value.integer.value;
4062 hda_nid_t hp, line, mono;
4063
4064 if (val == spec->master_sw)
4065 return 0;
4066 spec->master_sw = val;
4067 hp = (kcontrol->private_value >> 16) & 0xff;
4068 line = (kcontrol->private_value >> 8) & 0xff;
4069 mono = kcontrol->private_value & 0xff;
4070 alc260_hp_master_update(codec, hp, line, mono);
4071 return 1;
4072}
4073
4074static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4075 {
4076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4077 .name = "Master Playback Switch",
4078 .info = snd_ctl_boolean_mono_info,
4079 .get = alc260_hp_master_sw_get,
4080 .put = alc260_hp_master_sw_put,
4081 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4082 },
4083 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4084 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4086 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4087 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4088 HDA_OUTPUT),
4089 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4090 { } /* end */
4091};
4092
4093static struct hda_verb alc260_hp_unsol_verbs[] = {
4094 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4095 {},
4096};
4097
4098static void alc260_hp_automute(struct hda_codec *codec)
4099{
4100 struct alc_spec *spec = codec->spec;
4101 unsigned int present;
4102
4103 present = snd_hda_codec_read(codec, 0x10, 0,
4104 AC_VERB_GET_PIN_SENSE, 0);
4105 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4106 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4107}
4108
4109static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4110{
4111 if ((res >> 26) == ALC880_HP_EVENT)
4112 alc260_hp_automute(codec);
4113}
4114
Kailang Yangdf694da2005-12-05 19:42:22 +01004115static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004116 {
4117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4118 .name = "Master Playback Switch",
4119 .info = snd_ctl_boolean_mono_info,
4120 .get = alc260_hp_master_sw_get,
4121 .put = alc260_hp_master_sw_put,
4122 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4123 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004124 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4125 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4126 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4127 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4128 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004130 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4131 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004132 { } /* end */
4133};
4134
Kailang Yang3f878302008-08-26 13:02:23 +02004135static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4136 .ops = &snd_hda_bind_vol,
4137 .values = {
4138 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4139 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4140 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4141 0
4142 },
4143};
4144
4145static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4146 .ops = &snd_hda_bind_sw,
4147 .values = {
4148 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4149 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4150 0
4151 },
4152};
4153
4154static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4155 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4156 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4157 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4159 { } /* end */
4160};
4161
Takashi Iwaibec15c32008-01-28 18:16:30 +01004162static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4163 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4164 {},
4165};
4166
4167static void alc260_hp_3013_automute(struct hda_codec *codec)
4168{
4169 struct alc_spec *spec = codec->spec;
4170 unsigned int present;
4171
4172 present = snd_hda_codec_read(codec, 0x15, 0,
4173 AC_VERB_GET_PIN_SENSE, 0);
4174 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4175 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4176}
4177
4178static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4179 unsigned int res)
4180{
4181 if ((res >> 26) == ALC880_HP_EVENT)
4182 alc260_hp_3013_automute(codec);
4183}
4184
Kailang Yang3f878302008-08-26 13:02:23 +02004185static void alc260_hp_3012_automute(struct hda_codec *codec)
4186{
4187 unsigned int present, bits;
4188
4189 present = snd_hda_codec_read(codec, 0x10, 0,
4190 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4191
4192 bits = present ? 0 : PIN_OUT;
4193 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4194 bits);
4195 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4196 bits);
4197 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4198 bits);
4199}
4200
4201static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4202 unsigned int res)
4203{
4204 if ((res >> 26) == ALC880_HP_EVENT)
4205 alc260_hp_3012_automute(codec);
4206}
4207
4208/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004209 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4210 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004211static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004213 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004214 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004215 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4216 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4217 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4218 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004219 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004220 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4221 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004222 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4223 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004224 { } /* end */
4225};
4226
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004227/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4228 * versions of the ALC260 don't act on requests to enable mic bias from NID
4229 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4230 * datasheet doesn't mention this restriction. At this stage it's not clear
4231 * whether this behaviour is intentional or is a hardware bug in chip
4232 * revisions available in early 2006. Therefore for now allow the
4233 * "Headphone Jack Mode" control to span all choices, but if it turns out
4234 * that the lack of mic bias for this NID is intentional we could change the
4235 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4236 *
4237 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4238 * don't appear to make the mic bias available from the "line" jack, even
4239 * though the NID used for this jack (0x14) can supply it. The theory is
4240 * that perhaps Acer have included blocking capacitors between the ALC260
4241 * and the output jack. If this turns out to be the case for all such
4242 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4243 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004244 *
4245 * The C20x Tablet series have a mono internal speaker which is controlled
4246 * via the chip's Mono sum widget and pin complex, so include the necessary
4247 * controls for such models. On models without a "mono speaker" the control
4248 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004249 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004250static struct snd_kcontrol_new alc260_acer_mixer[] = {
4251 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4252 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004253 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004254 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004255 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004256 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004257 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004258 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4259 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4261 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4262 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4263 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4264 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4265 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4266 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4267 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4268 { } /* end */
4269};
4270
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004271/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4272 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4273 */
4274static struct snd_kcontrol_new alc260_will_mixer[] = {
4275 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4276 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4278 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4279 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4280 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4281 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4282 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4283 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4284 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4285 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4286 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4287 { } /* end */
4288};
4289
4290/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4291 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4292 */
4293static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4294 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4295 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4297 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4298 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4299 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4300 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4301 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4302 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4303 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4304 { } /* end */
4305};
4306
Kailang Yangdf694da2005-12-05 19:42:22 +01004307/* capture mixer elements */
4308static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004309 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4310 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004311 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4312 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004313 {
4314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004315 /* The multiple "Capture Source" controls confuse alsamixer
4316 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004317 */
4318 /* .name = "Capture Source", */
4319 .name = "Input Source",
4320 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004321 .info = alc_mux_enum_info,
4322 .get = alc_mux_enum_get,
4323 .put = alc_mux_enum_put,
4324 },
4325 { } /* end */
4326};
4327
Kailang Yangdf694da2005-12-05 19:42:22 +01004328static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4329 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4330 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4331 {
4332 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4333 /* The multiple "Capture Source" controls confuse alsamixer
4334 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004335 */
4336 /* .name = "Capture Source", */
4337 .name = "Input Source",
4338 .count = 1,
4339 .info = alc_mux_enum_info,
4340 .get = alc_mux_enum_get,
4341 .put = alc_mux_enum_put,
4342 },
4343 { } /* end */
4344};
4345
4346/*
4347 * initialization verbs
4348 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004349static struct hda_verb alc260_init_verbs[] = {
4350 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004352 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004355 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004356 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004357 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004358 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004360 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004361 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004362 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004363 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004364 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004365 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004367 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4368 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004369 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004370 /* set connection select to line in (default select for this ADC) */
4371 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004372 /* mute capture amp left and right */
4373 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4374 /* set connection select to line in (default select for this ADC) */
4375 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004376 /* set vol=0 Line-Out mixer amp left and right */
4377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4378 /* unmute pin widget amp left and right (no gain on this amp) */
4379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4380 /* set vol=0 HP mixer amp left and right */
4381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4382 /* unmute pin widget amp left and right (no gain on this amp) */
4383 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4384 /* set vol=0 Mono mixer amp left and right */
4385 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4386 /* unmute pin widget amp left and right (no gain on this amp) */
4387 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4388 /* unmute LINE-2 out pin */
4389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4391 * Line In 2 = 0x03
4392 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004393 /* mute analog inputs */
4394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004399 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004400 /* mute Front out path */
4401 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4402 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4403 /* mute Headphone out path */
4404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4406 /* mute Mono out path */
4407 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4408 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004409 { }
4410};
4411
Takashi Iwai474167d2006-05-17 17:17:43 +02004412#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004413static struct hda_verb alc260_hp_init_verbs[] = {
4414 /* Headphone and output */
4415 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4416 /* mono output */
4417 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4418 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4419 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4420 /* Mic2 (front panel) pin widget for input and vref at 80% */
4421 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4422 /* Line In pin widget for input */
4423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4424 /* Line-2 pin widget for output */
4425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4426 /* CD pin widget for input */
4427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4428 /* unmute amp left and right */
4429 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4430 /* set connection select to line in (default select for this ADC) */
4431 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4432 /* unmute Line-Out mixer amp left and right (volume = 0) */
4433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4434 /* mute pin widget amp left and right (no gain on this amp) */
4435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4436 /* unmute HP mixer amp left and right (volume = 0) */
4437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4438 /* mute pin widget amp left and right (no gain on this amp) */
4439 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004440 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4441 * Line In 2 = 0x03
4442 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004443 /* mute analog inputs */
4444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004449 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4450 /* Unmute Front out path */
4451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4453 /* Unmute Headphone out path */
4454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4456 /* Unmute Mono out path */
4457 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4459 { }
4460};
Takashi Iwai474167d2006-05-17 17:17:43 +02004461#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004462
4463static struct hda_verb alc260_hp_3013_init_verbs[] = {
4464 /* Line out and output */
4465 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4466 /* mono output */
4467 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4468 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4469 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4470 /* Mic2 (front panel) pin widget for input and vref at 80% */
4471 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4472 /* Line In pin widget for input */
4473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4474 /* Headphone pin widget for output */
4475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4476 /* CD pin widget for input */
4477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4478 /* unmute amp left and right */
4479 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4480 /* set connection select to line in (default select for this ADC) */
4481 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4482 /* unmute Line-Out mixer amp left and right (volume = 0) */
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4484 /* mute pin widget amp left and right (no gain on this amp) */
4485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4486 /* unmute HP mixer amp left and right (volume = 0) */
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4488 /* mute pin widget amp left and right (no gain on this amp) */
4489 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4491 * Line In 2 = 0x03
4492 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004493 /* mute analog inputs */
4494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004499 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4500 /* Unmute Front out path */
4501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4503 /* Unmute Headphone out path */
4504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4506 /* Unmute Mono out path */
4507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4509 { }
4510};
4511
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004512/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004513 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4514 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004515 */
4516static struct hda_verb alc260_fujitsu_init_verbs[] = {
4517 /* Disable all GPIOs */
4518 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4519 /* Internal speaker is connected to headphone pin */
4520 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4521 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004523 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4524 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4525 /* Ensure all other unused pins are disabled and muted. */
4526 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004528 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004529 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004530 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004531 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004534
Jonathan Woithef7ace402006-02-28 11:46:14 +01004535 /* Disable digital (SPDIF) pins */
4536 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4537 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004538
Kailang Yangea1fb292008-08-26 12:58:38 +02004539 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004540 * when acting as an output.
4541 */
4542 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4543
4544 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004545 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4548 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4551 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4552 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4553 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004554
Jonathan Woithef7ace402006-02-28 11:46:14 +01004555 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4556 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4557 /* Unmute Line1 pin widget output buffer since it starts as an output.
4558 * If the pin mode is changed by the user the pin mode control will
4559 * take care of enabling the pin's input/output buffers as needed.
4560 * Therefore there's no need to enable the input buffer at this
4561 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004562 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004563 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004564 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004565 * mixer ctrl)
4566 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004567 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004568
Jonathan Woithef7ace402006-02-28 11:46:14 +01004569 /* Mute capture amp left and right */
4570 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004571 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004572 * in (on mic1 pin)
4573 */
4574 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004575
Jonathan Woithef7ace402006-02-28 11:46:14 +01004576 /* Do the same for the second ADC: mute capture input amp and
4577 * set ADC connection to line in (on mic1 pin)
4578 */
4579 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4580 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004581
Jonathan Woithef7ace402006-02-28 11:46:14 +01004582 /* Mute all inputs to mixer widget (even unconnected ones) */
4583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004591
4592 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004593};
4594
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004595/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4596 * similar laptops (adapted from Fujitsu init verbs).
4597 */
4598static struct hda_verb alc260_acer_init_verbs[] = {
4599 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4600 * the headphone jack. Turn this on and rely on the standard mute
4601 * methods whenever the user wants to turn these outputs off.
4602 */
4603 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4604 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4605 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4606 /* Internal speaker/Headphone jack is connected to Line-out pin */
4607 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4608 /* Internal microphone/Mic jack is connected to Mic1 pin */
4609 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4610 /* Line In jack is connected to Line1 pin */
4611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004612 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4613 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004614 /* Ensure all other unused pins are disabled and muted. */
4615 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4616 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004617 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4618 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4621 /* Disable digital (SPDIF) pins */
4622 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4623 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4624
Kailang Yangea1fb292008-08-26 12:58:38 +02004625 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004626 * bus when acting as outputs.
4627 */
4628 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4629 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4630
4631 /* Start with output sum widgets muted and their output gains at min */
4632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4641
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004642 /* Unmute Line-out pin widget amp left and right
4643 * (no equiv mixer ctrl)
4644 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004646 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4647 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004648 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4649 * inputs. If the pin mode is changed by the user the pin mode control
4650 * will take care of enabling the pin's input/output buffers as needed.
4651 * Therefore there's no need to enable the input buffer at this
4652 * stage.
4653 */
4654 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4656
4657 /* Mute capture amp left and right */
4658 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4659 /* Set ADC connection select to match default mixer setting - mic
4660 * (on mic1 pin)
4661 */
4662 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4663
4664 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004665 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004666 */
4667 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004668 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004669
4670 /* Mute all inputs to mixer widget (even unconnected ones) */
4671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4679
4680 { }
4681};
4682
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004683static struct hda_verb alc260_will_verbs[] = {
4684 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4685 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4686 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4687 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4688 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4689 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4690 {}
4691};
4692
4693static struct hda_verb alc260_replacer_672v_verbs[] = {
4694 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4695 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4696 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4697
4698 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4699 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4700 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4701
4702 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4703 {}
4704};
4705
4706/* toggle speaker-output according to the hp-jack state */
4707static void alc260_replacer_672v_automute(struct hda_codec *codec)
4708{
4709 unsigned int present;
4710
4711 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4712 present = snd_hda_codec_read(codec, 0x0f, 0,
4713 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4714 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004715 snd_hda_codec_write_cache(codec, 0x01, 0,
4716 AC_VERB_SET_GPIO_DATA, 1);
4717 snd_hda_codec_write_cache(codec, 0x0f, 0,
4718 AC_VERB_SET_PIN_WIDGET_CONTROL,
4719 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004720 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004721 snd_hda_codec_write_cache(codec, 0x01, 0,
4722 AC_VERB_SET_GPIO_DATA, 0);
4723 snd_hda_codec_write_cache(codec, 0x0f, 0,
4724 AC_VERB_SET_PIN_WIDGET_CONTROL,
4725 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004726 }
4727}
4728
4729static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4730 unsigned int res)
4731{
4732 if ((res >> 26) == ALC880_HP_EVENT)
4733 alc260_replacer_672v_automute(codec);
4734}
4735
Kailang Yang3f878302008-08-26 13:02:23 +02004736static struct hda_verb alc260_hp_dc7600_verbs[] = {
4737 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4739 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4740 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4741 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4742 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4743 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4744 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4745 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4746 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4747 {}
4748};
4749
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004750/* Test configuration for debugging, modelled after the ALC880 test
4751 * configuration.
4752 */
4753#ifdef CONFIG_SND_DEBUG
4754static hda_nid_t alc260_test_dac_nids[1] = {
4755 0x02,
4756};
4757static hda_nid_t alc260_test_adc_nids[2] = {
4758 0x04, 0x05,
4759};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004760/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004761 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004762 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004763 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004764static struct hda_input_mux alc260_test_capture_sources[2] = {
4765 {
4766 .num_items = 7,
4767 .items = {
4768 { "MIC1 pin", 0x0 },
4769 { "MIC2 pin", 0x1 },
4770 { "LINE1 pin", 0x2 },
4771 { "LINE2 pin", 0x3 },
4772 { "CD pin", 0x4 },
4773 { "LINE-OUT pin", 0x5 },
4774 { "HP-OUT pin", 0x6 },
4775 },
4776 },
4777 {
4778 .num_items = 8,
4779 .items = {
4780 { "MIC1 pin", 0x0 },
4781 { "MIC2 pin", 0x1 },
4782 { "LINE1 pin", 0x2 },
4783 { "LINE2 pin", 0x3 },
4784 { "CD pin", 0x4 },
4785 { "Mixer", 0x5 },
4786 { "LINE-OUT pin", 0x6 },
4787 { "HP-OUT pin", 0x7 },
4788 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004789 },
4790};
4791static struct snd_kcontrol_new alc260_test_mixer[] = {
4792 /* Output driver widgets */
4793 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4794 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4795 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4796 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4797 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4798 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4799
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004800 /* Modes for retasking pin widgets
4801 * Note: the ALC260 doesn't seem to act on requests to enable mic
4802 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4803 * mention this restriction. At this stage it's not clear whether
4804 * this behaviour is intentional or is a hardware bug in chip
4805 * revisions available at least up until early 2006. Therefore for
4806 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4807 * choices, but if it turns out that the lack of mic bias for these
4808 * NIDs is intentional we could change their modes from
4809 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4810 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004811 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4812 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4813 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4814 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4815 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4816 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4817
4818 /* Loopback mixer controls */
4819 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4820 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4821 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4822 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4823 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4824 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4825 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4826 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4827 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4828 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4829 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4830 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4831 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4832 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4833 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4834 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004835
4836 /* Controls for GPIO pins, assuming they are configured as outputs */
4837 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4838 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4839 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4840 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4841
Jonathan Woithe92621f12006-02-28 11:47:47 +01004842 /* Switches to allow the digital IO pins to be enabled. The datasheet
4843 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004844 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004845 */
4846 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4847 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4848
Jonathan Woithef8225f62008-01-08 12:16:54 +01004849 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4850 * this output to turn on an external amplifier.
4851 */
4852 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4853 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4854
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004855 { } /* end */
4856};
4857static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004858 /* Enable all GPIOs as outputs with an initial value of 0 */
4859 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4860 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4861 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4862
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004863 /* Enable retasking pins as output, initially without power amp */
4864 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4865 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4868 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4870
Jonathan Woithe92621f12006-02-28 11:47:47 +01004871 /* Disable digital (SPDIF) pins initially, but users can enable
4872 * them via a mixer switch. In the case of SPDIF-out, this initverb
4873 * payload also sets the generation to 0, output to be in "consumer"
4874 * PCM format, copyright asserted, no pre-emphasis and no validity
4875 * control.
4876 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004877 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4878 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4879
Kailang Yangea1fb292008-08-26 12:58:38 +02004880 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004881 * OUT1 sum bus when acting as an output.
4882 */
4883 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4884 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4885 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4886 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4887
4888 /* Start with output sum widgets muted and their output gains at min */
4889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4890 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4891 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4892 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4893 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4894 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4895 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4896 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4898
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004899 /* Unmute retasking pin widget output buffers since the default
4900 * state appears to be output. As the pin mode is changed by the
4901 * user the pin mode control will take care of enabling the pin's
4902 * input/output buffers as needed.
4903 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004904 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4905 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4906 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4908 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4909 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4910 /* Also unmute the mono-out pin widget */
4911 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4912
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004913 /* Mute capture amp left and right */
4914 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004915 /* Set ADC connection select to match default mixer setting (mic1
4916 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004917 */
4918 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4919
4920 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004921 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01004922 */
4923 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4924 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4925
4926 /* Mute all inputs to mixer widget (even unconnected ones) */
4927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4935
4936 { }
4937};
4938#endif
4939
Takashi Iwai63300792008-01-24 15:31:36 +01004940#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4941#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004942
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004943#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4944#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4945
Kailang Yangdf694da2005-12-05 19:42:22 +01004946/*
4947 * for BIOS auto-configuration
4948 */
4949
4950static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4951 const char *pfx)
4952{
4953 hda_nid_t nid_vol;
4954 unsigned long vol_val, sw_val;
4955 char name[32];
4956 int err;
4957
4958 if (nid >= 0x0f && nid < 0x11) {
4959 nid_vol = nid - 0x7;
4960 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4961 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4962 } else if (nid == 0x11) {
4963 nid_vol = nid - 0x7;
4964 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4965 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4966 } else if (nid >= 0x12 && nid <= 0x15) {
4967 nid_vol = 0x08;
4968 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4969 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4970 } else
4971 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004972
Kailang Yangdf694da2005-12-05 19:42:22 +01004973 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004974 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4975 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004976 return err;
4977 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004978 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4979 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004980 return err;
4981 return 1;
4982}
4983
4984/* add playback controls from the parsed DAC table */
4985static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4986 const struct auto_pin_cfg *cfg)
4987{
4988 hda_nid_t nid;
4989 int err;
4990
4991 spec->multiout.num_dacs = 1;
4992 spec->multiout.dac_nids = spec->private_dac_nids;
4993 spec->multiout.dac_nids[0] = 0x02;
4994
4995 nid = cfg->line_out_pins[0];
4996 if (nid) {
4997 err = alc260_add_playback_controls(spec, nid, "Front");
4998 if (err < 0)
4999 return err;
5000 }
5001
Takashi Iwai82bc9552006-03-21 11:24:42 +01005002 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005003 if (nid) {
5004 err = alc260_add_playback_controls(spec, nid, "Speaker");
5005 if (err < 0)
5006 return err;
5007 }
5008
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005009 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005010 if (nid) {
5011 err = alc260_add_playback_controls(spec, nid, "Headphone");
5012 if (err < 0)
5013 return err;
5014 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005015 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005016}
5017
5018/* create playback/capture controls for input pins */
5019static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5020 const struct auto_pin_cfg *cfg)
5021{
Kailang Yangdf694da2005-12-05 19:42:22 +01005022 struct hda_input_mux *imux = &spec->private_imux;
5023 int i, err, idx;
5024
5025 for (i = 0; i < AUTO_PIN_LAST; i++) {
5026 if (cfg->input_pins[i] >= 0x12) {
5027 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005028 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005029 auto_pin_cfg_labels[i], idx,
5030 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005031 if (err < 0)
5032 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005033 imux->items[imux->num_items].label =
5034 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005035 imux->items[imux->num_items].index = idx;
5036 imux->num_items++;
5037 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005038 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005039 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005040 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005041 auto_pin_cfg_labels[i], idx,
5042 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005043 if (err < 0)
5044 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045 imux->items[imux->num_items].label =
5046 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005047 imux->items[imux->num_items].index = idx;
5048 imux->num_items++;
5049 }
5050 }
5051 return 0;
5052}
5053
5054static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5055 hda_nid_t nid, int pin_type,
5056 int sel_idx)
5057{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005058 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005059 /* need the manual connection? */
5060 if (nid >= 0x12) {
5061 int idx = nid - 0x12;
5062 snd_hda_codec_write(codec, idx + 0x0b, 0,
5063 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005064 }
5065}
5066
5067static void alc260_auto_init_multi_out(struct hda_codec *codec)
5068{
5069 struct alc_spec *spec = codec->spec;
5070 hda_nid_t nid;
5071
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005072 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005073 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005074 if (nid) {
5075 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5076 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5077 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005078
Takashi Iwai82bc9552006-03-21 11:24:42 +01005079 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005080 if (nid)
5081 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5082
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005083 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005084 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005085 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086}
Kailang Yangdf694da2005-12-05 19:42:22 +01005087
5088#define ALC260_PIN_CD_NID 0x16
5089static void alc260_auto_init_analog_input(struct hda_codec *codec)
5090{
5091 struct alc_spec *spec = codec->spec;
5092 int i;
5093
5094 for (i = 0; i < AUTO_PIN_LAST; i++) {
5095 hda_nid_t nid = spec->autocfg.input_pins[i];
5096 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005097 snd_hda_codec_write(codec, nid, 0,
5098 AC_VERB_SET_PIN_WIDGET_CONTROL,
5099 i <= AUTO_PIN_FRONT_MIC ?
5100 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005101 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005102 snd_hda_codec_write(codec, nid, 0,
5103 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005104 AMP_OUT_MUTE);
5105 }
5106 }
5107}
5108
5109/*
5110 * generic initialization of ADC, input mixers and output mixers
5111 */
5112static struct hda_verb alc260_volume_init_verbs[] = {
5113 /*
5114 * Unmute ADC0-1 and set the default input to mic-in
5115 */
5116 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5117 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5118 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5119 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005120
Kailang Yangdf694da2005-12-05 19:42:22 +01005121 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5122 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005123 * Note: PASD motherboards uses the Line In 2 as the input for
5124 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005125 */
5126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005127 /* mute analog inputs */
5128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005133
5134 /*
5135 * Set up output mixers (0x08 - 0x0a)
5136 */
5137 /* set vol=0 to output mixers */
5138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5140 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5141 /* set up input amps for analog loopback */
5142 /* Amp Indices: DAC = 0, mixer = 1 */
5143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005149
Kailang Yangdf694da2005-12-05 19:42:22 +01005150 { }
5151};
5152
5153static int alc260_parse_auto_config(struct hda_codec *codec)
5154{
5155 struct alc_spec *spec = codec->spec;
5156 unsigned int wcap;
5157 int err;
5158 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5161 alc260_ignore);
5162 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005163 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005164 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5165 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005166 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005167 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005168 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005169 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5170 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005171 return err;
5172
5173 spec->multiout.max_channels = 2;
5174
5175 if (spec->autocfg.dig_out_pin)
5176 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5177 if (spec->kctl_alloc)
5178 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5179
5180 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5181
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005182 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005183 spec->input_mux = &spec->private_imux;
5184
5185 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005186 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005187 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005188 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005189 spec->adc_nids = alc260_adc_nids_alt;
5190 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5191 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005192 } else {
5193 spec->adc_nids = alc260_adc_nids;
5194 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5195 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005197 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005198
5199 return 1;
5200}
5201
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005202/* additional initialization for auto-configuration model */
5203static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005204{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005205 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005206 alc260_auto_init_multi_out(codec);
5207 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005208 if (spec->unsol_event)
5209 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005210}
5211
Takashi Iwaicb53c622007-08-10 17:21:45 +02005212#ifdef CONFIG_SND_HDA_POWER_SAVE
5213static struct hda_amp_list alc260_loopbacks[] = {
5214 { 0x07, HDA_INPUT, 0 },
5215 { 0x07, HDA_INPUT, 1 },
5216 { 0x07, HDA_INPUT, 2 },
5217 { 0x07, HDA_INPUT, 3 },
5218 { 0x07, HDA_INPUT, 4 },
5219 { } /* end */
5220};
5221#endif
5222
Kailang Yangdf694da2005-12-05 19:42:22 +01005223/*
5224 * ALC260 configurations
5225 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005226static const char *alc260_models[ALC260_MODEL_LAST] = {
5227 [ALC260_BASIC] = "basic",
5228 [ALC260_HP] = "hp",
5229 [ALC260_HP_3013] = "hp-3013",
5230 [ALC260_FUJITSU_S702X] = "fujitsu",
5231 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005232 [ALC260_WILL] = "will",
5233 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005234#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005235 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005236#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005237 [ALC260_AUTO] = "auto",
5238};
5239
5240static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005241 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005242 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005243 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005244 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005245 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005246 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005247 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005248 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5249 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5250 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5251 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5252 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5253 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5254 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5255 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5256 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005257 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005258 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005259 {}
5260};
5261
Kailang Yangdf694da2005-12-05 19:42:22 +01005262static struct alc_config_preset alc260_presets[] = {
5263 [ALC260_BASIC] = {
5264 .mixers = { alc260_base_output_mixer,
5265 alc260_input_mixer,
5266 alc260_pc_beep_mixer,
5267 alc260_capture_mixer },
5268 .init_verbs = { alc260_init_verbs },
5269 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5270 .dac_nids = alc260_dac_nids,
5271 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5272 .adc_nids = alc260_adc_nids,
5273 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5274 .channel_mode = alc260_modes,
5275 .input_mux = &alc260_capture_source,
5276 },
5277 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005278 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005279 alc260_input_mixer,
5280 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005281 .init_verbs = { alc260_init_verbs,
5282 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005283 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5284 .dac_nids = alc260_dac_nids,
5285 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5286 .adc_nids = alc260_hp_adc_nids,
5287 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5288 .channel_mode = alc260_modes,
5289 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005290 .unsol_event = alc260_hp_unsol_event,
5291 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005292 },
Kailang Yang3f878302008-08-26 13:02:23 +02005293 [ALC260_HP_DC7600] = {
5294 .mixers = { alc260_hp_dc7600_mixer,
5295 alc260_input_mixer,
5296 alc260_capture_alt_mixer },
5297 .init_verbs = { alc260_init_verbs,
5298 alc260_hp_dc7600_verbs },
5299 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5300 .dac_nids = alc260_dac_nids,
5301 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5302 .adc_nids = alc260_hp_adc_nids,
5303 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5304 .channel_mode = alc260_modes,
5305 .input_mux = &alc260_capture_source,
5306 .unsol_event = alc260_hp_3012_unsol_event,
5307 .init_hook = alc260_hp_3012_automute,
5308 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005309 [ALC260_HP_3013] = {
5310 .mixers = { alc260_hp_3013_mixer,
5311 alc260_input_mixer,
5312 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005313 .init_verbs = { alc260_hp_3013_init_verbs,
5314 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005315 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5316 .dac_nids = alc260_dac_nids,
5317 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5318 .adc_nids = alc260_hp_adc_nids,
5319 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5320 .channel_mode = alc260_modes,
5321 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005322 .unsol_event = alc260_hp_3013_unsol_event,
5323 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005324 },
5325 [ALC260_FUJITSU_S702X] = {
5326 .mixers = { alc260_fujitsu_mixer,
5327 alc260_capture_mixer },
5328 .init_verbs = { alc260_fujitsu_init_verbs },
5329 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5330 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005331 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5332 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005333 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5334 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005335 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5336 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005337 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005338 [ALC260_ACER] = {
5339 .mixers = { alc260_acer_mixer,
5340 alc260_capture_mixer },
5341 .init_verbs = { alc260_acer_init_verbs },
5342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5343 .dac_nids = alc260_dac_nids,
5344 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5345 .adc_nids = alc260_dual_adc_nids,
5346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5347 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005348 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5349 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005350 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005351 [ALC260_WILL] = {
5352 .mixers = { alc260_will_mixer,
5353 alc260_capture_mixer },
5354 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5356 .dac_nids = alc260_dac_nids,
5357 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5358 .adc_nids = alc260_adc_nids,
5359 .dig_out_nid = ALC260_DIGOUT_NID,
5360 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5361 .channel_mode = alc260_modes,
5362 .input_mux = &alc260_capture_source,
5363 },
5364 [ALC260_REPLACER_672V] = {
5365 .mixers = { alc260_replacer_672v_mixer,
5366 alc260_capture_mixer },
5367 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5368 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5369 .dac_nids = alc260_dac_nids,
5370 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5371 .adc_nids = alc260_adc_nids,
5372 .dig_out_nid = ALC260_DIGOUT_NID,
5373 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5374 .channel_mode = alc260_modes,
5375 .input_mux = &alc260_capture_source,
5376 .unsol_event = alc260_replacer_672v_unsol_event,
5377 .init_hook = alc260_replacer_672v_automute,
5378 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005379#ifdef CONFIG_SND_DEBUG
5380 [ALC260_TEST] = {
5381 .mixers = { alc260_test_mixer,
5382 alc260_capture_mixer },
5383 .init_verbs = { alc260_test_init_verbs },
5384 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5385 .dac_nids = alc260_test_dac_nids,
5386 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5387 .adc_nids = alc260_test_adc_nids,
5388 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5389 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005390 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5391 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005392 },
5393#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005394};
5395
Linus Torvalds1da177e2005-04-16 15:20:36 -07005396static int patch_alc260(struct hda_codec *codec)
5397{
5398 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005399 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005400
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005401 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005402 if (spec == NULL)
5403 return -ENOMEM;
5404
5405 codec->spec = spec;
5406
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005407 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5408 alc260_models,
5409 alc260_cfg_tbl);
5410 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005411 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5412 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005413 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005414 }
5415
Kailang Yangdf694da2005-12-05 19:42:22 +01005416 if (board_config == ALC260_AUTO) {
5417 /* automatic parse from the BIOS config */
5418 err = alc260_parse_auto_config(codec);
5419 if (err < 0) {
5420 alc_free(codec);
5421 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005422 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005423 printk(KERN_INFO
5424 "hda_codec: Cannot set up configuration "
5425 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005426 board_config = ALC260_BASIC;
5427 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005429
Kailang Yangdf694da2005-12-05 19:42:22 +01005430 if (board_config != ALC260_AUTO)
5431 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005432
5433 spec->stream_name_analog = "ALC260 Analog";
5434 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5435 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5436
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005437 spec->stream_name_digital = "ALC260 Digital";
5438 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5439 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5440
Takashi Iwai2134ea42008-01-10 16:53:55 +01005441 spec->vmaster_nid = 0x08;
5442
Linus Torvalds1da177e2005-04-16 15:20:36 -07005443 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005444 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005445 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005446#ifdef CONFIG_SND_HDA_POWER_SAVE
5447 if (!spec->loopback.amplist)
5448 spec->loopback.amplist = alc260_loopbacks;
5449#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005450
5451 return 0;
5452}
5453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005454
Linus Torvalds1da177e2005-04-16 15:20:36 -07005455/*
5456 * ALC882 support
5457 *
5458 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5459 * configuration. Each pin widget can choose any input DACs and a mixer.
5460 * Each ADC is connected from a mixer of all inputs. This makes possible
5461 * 6-channel independent captures.
5462 *
5463 * In addition, an independent DAC for the multi-playback (not used in this
5464 * driver yet).
5465 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005466#define ALC882_DIGOUT_NID 0x06
5467#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005468
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005469static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005470 { 8, NULL }
5471};
5472
5473static hda_nid_t alc882_dac_nids[4] = {
5474 /* front, rear, clfe, rear_surr */
5475 0x02, 0x03, 0x04, 0x05
5476};
5477
Kailang Yangdf694da2005-12-05 19:42:22 +01005478/* identical with ALC880 */
5479#define alc882_adc_nids alc880_adc_nids
5480#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005481
Takashi Iwaie1406342008-02-11 18:32:32 +01005482static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5483static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5484
Linus Torvalds1da177e2005-04-16 15:20:36 -07005485/* input MUX */
5486/* FIXME: should be a matrix-type input source selection */
5487
5488static struct hda_input_mux alc882_capture_source = {
5489 .num_items = 4,
5490 .items = {
5491 { "Mic", 0x0 },
5492 { "Front Mic", 0x1 },
5493 { "Line", 0x2 },
5494 { "CD", 0x4 },
5495 },
5496};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005497#define alc882_mux_enum_info alc_mux_enum_info
5498#define alc882_mux_enum_get alc_mux_enum_get
5499
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005500static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5501 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005502{
5503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5504 struct alc_spec *spec = codec->spec;
5505 const struct hda_input_mux *imux = spec->input_mux;
5506 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005507 hda_nid_t nid = spec->capsrc_nids ?
5508 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005509 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5510 unsigned int i, idx;
5511
5512 idx = ucontrol->value.enumerated.item[0];
5513 if (idx >= imux->num_items)
5514 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005515 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516 return 0;
5517 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005518 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5519 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005520 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005521 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522 }
5523 *cur_val = idx;
5524 return 1;
5525}
5526
Kailang Yangdf694da2005-12-05 19:42:22 +01005527/*
Kailang Yang272a5272007-05-14 11:00:38 +02005528 * 2ch mode
5529 */
5530static struct hda_verb alc882_3ST_ch2_init[] = {
5531 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5532 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5533 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5534 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5535 { } /* end */
5536};
5537
5538/*
5539 * 6ch mode
5540 */
5541static struct hda_verb alc882_3ST_ch6_init[] = {
5542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5544 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5545 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5546 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5547 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5548 { } /* end */
5549};
5550
5551static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5552 { 2, alc882_3ST_ch2_init },
5553 { 6, alc882_3ST_ch6_init },
5554};
5555
5556/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005557 * 6ch mode
5558 */
5559static struct hda_verb alc882_sixstack_ch6_init[] = {
5560 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5561 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5562 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5563 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5564 { } /* end */
5565};
5566
5567/*
5568 * 8ch mode
5569 */
5570static struct hda_verb alc882_sixstack_ch8_init[] = {
5571 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5572 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5573 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5574 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5575 { } /* end */
5576};
5577
5578static struct hda_channel_mode alc882_sixstack_modes[2] = {
5579 { 6, alc882_sixstack_ch6_init },
5580 { 8, alc882_sixstack_ch8_init },
5581};
5582
Takashi Iwai87350ad2007-08-16 18:19:38 +02005583/*
5584 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5585 */
5586
5587/*
5588 * 2ch mode
5589 */
5590static struct hda_verb alc885_mbp_ch2_init[] = {
5591 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5592 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5593 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5594 { } /* end */
5595};
5596
5597/*
5598 * 6ch mode
5599 */
5600static struct hda_verb alc885_mbp_ch6_init[] = {
5601 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5602 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5603 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5604 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5605 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5606 { } /* end */
5607};
5608
5609static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5610 { 2, alc885_mbp_ch2_init },
5611 { 6, alc885_mbp_ch6_init },
5612};
5613
5614
Linus Torvalds1da177e2005-04-16 15:20:36 -07005615/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5616 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5617 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005618static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005621 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005622 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005623 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5624 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005625 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5626 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005627 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005628 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5637 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005638 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5640 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5641 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005642 { } /* end */
5643};
5644
Takashi Iwai87350ad2007-08-16 18:19:38 +02005645static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005646 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5647 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5648 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5649 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5650 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5651 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5653 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005654 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5656 { } /* end */
5657};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005658static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5659 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5660 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5661 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5662 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5666 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5668 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5669 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5670 { } /* end */
5671};
5672
Kailang Yang272a5272007-05-14 11:00:38 +02005673static struct snd_kcontrol_new alc882_targa_mixer[] = {
5674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5677 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5678 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5679 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5680 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005683 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005686 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005687 { } /* end */
5688};
5689
5690/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5691 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5692 */
5693static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5694 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5695 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5697 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5698 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5699 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5702 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5703 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005707 { } /* end */
5708};
5709
Takashi Iwai914759b2007-09-06 14:52:04 +02005710static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5712 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5721 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5722 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5723 { } /* end */
5724};
5725
Kailang Yangdf694da2005-12-05 19:42:22 +01005726static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5727 {
5728 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5729 .name = "Channel Mode",
5730 .info = alc_ch_mode_info,
5731 .get = alc_ch_mode_get,
5732 .put = alc_ch_mode_put,
5733 },
5734 { } /* end */
5735};
5736
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737static struct hda_verb alc882_init_verbs[] = {
5738 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005742 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005746 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005750 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005754
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005755 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005758 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005759 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005763 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005764 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005765 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005766 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005767 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005768 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005770 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005771 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5774 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5777 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5780 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5781 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5783 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005784 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005785 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005786
5787 /* FIXME: use matrix-type input source selection */
5788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5789 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005794 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005799 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5804 /* ADC1: mute amp left and right */
5805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005806 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005807 /* ADC2: mute amp left and right */
5808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005809 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005810 /* ADC3: mute amp left and right */
5811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005812 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005813
5814 { }
5815};
5816
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005817static struct hda_verb alc882_eapd_verbs[] = {
5818 /* change to EAPD mode */
5819 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005820 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005821 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005822};
5823
Tobin Davis9102cd12006-12-15 10:02:12 +01005824/* Mac Pro test */
5825static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5826 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5827 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5831 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5832 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5833 { } /* end */
5834};
5835
5836static struct hda_verb alc882_macpro_init_verbs[] = {
5837 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5841 /* Front Pin: output 0 (0x0c) */
5842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5844 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5845 /* Front Mic pin: input vref at 80% */
5846 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5848 /* Speaker: output */
5849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5851 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5852 /* Headphone output (output 0 - 0x0c) */
5853 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5854 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5855 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5856
5857 /* FIXME: use matrix-type input source selection */
5858 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5859 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5864 /* Input mixer2 */
5865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5869 /* Input mixer3 */
5870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5874 /* ADC1: mute amp left and right */
5875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5876 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5877 /* ADC2: mute amp left and right */
5878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5879 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5880 /* ADC3: mute amp left and right */
5881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5882 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5883
5884 { }
5885};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005886
Takashi Iwai87350ad2007-08-16 18:19:38 +02005887/* Macbook Pro rev3 */
5888static struct hda_verb alc885_mbp3_init_verbs[] = {
5889 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5893 /* Rear mixer */
5894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5897 /* Front Pin: output 0 (0x0c) */
5898 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5900 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5901 /* HP Pin: output 0 (0x0d) */
5902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5904 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5906 /* Mic (rear) pin: input vref at 80% */
5907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5909 /* Front Mic pin: input vref at 80% */
5910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5912 /* Line In pin: use output 1 when in LineOut mode */
5913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5915 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5916
5917 /* FIXME: use matrix-type input source selection */
5918 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5919 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5924 /* Input mixer2 */
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5929 /* Input mixer3 */
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5934 /* ADC1: mute amp left and right */
5935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5936 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5937 /* ADC2: mute amp left and right */
5938 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5939 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5940 /* ADC3: mute amp left and right */
5941 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5942 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5943
5944 { }
5945};
5946
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005947/* iMac 24 mixer. */
5948static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5949 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5950 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5951 { } /* end */
5952};
5953
5954/* iMac 24 init verbs. */
5955static struct hda_verb alc885_imac24_init_verbs[] = {
5956 /* Internal speakers: output 0 (0x0c) */
5957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5959 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5960 /* Internal speakers: output 0 (0x0c) */
5961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5963 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5964 /* Headphone: output 0 (0x0c) */
5965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5967 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5968 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5969 /* Front Mic: input vref at 80% */
5970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5972 { }
5973};
5974
5975/* Toggle speaker-output according to the hp-jack state */
5976static void alc885_imac24_automute(struct hda_codec *codec)
5977{
5978 unsigned int present;
5979
5980 present = snd_hda_codec_read(codec, 0x14, 0,
5981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005982 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5983 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5984 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5985 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005986}
5987
5988/* Processes unsolicited events. */
5989static void alc885_imac24_unsol_event(struct hda_codec *codec,
5990 unsigned int res)
5991{
5992 /* Headphone insertion or removal. */
5993 if ((res >> 26) == ALC880_HP_EVENT)
5994 alc885_imac24_automute(codec);
5995}
5996
Takashi Iwai87350ad2007-08-16 18:19:38 +02005997static void alc885_mbp3_automute(struct hda_codec *codec)
5998{
5999 unsigned int present;
6000
6001 present = snd_hda_codec_read(codec, 0x15, 0,
6002 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6003 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6004 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6005 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6006 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6007
6008}
6009static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6010 unsigned int res)
6011{
6012 /* Headphone insertion or removal. */
6013 if ((res >> 26) == ALC880_HP_EVENT)
6014 alc885_mbp3_automute(codec);
6015}
6016
6017
Kailang Yang272a5272007-05-14 11:00:38 +02006018static struct hda_verb alc882_targa_verbs[] = {
6019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6021
6022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006024
Kailang Yang272a5272007-05-14 11:00:38 +02006025 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6026 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6027 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6028
6029 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6030 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6031 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6032 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6033 { } /* end */
6034};
6035
6036/* toggle speaker-output according to the hp-jack state */
6037static void alc882_targa_automute(struct hda_codec *codec)
6038{
6039 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006040
Kailang Yang272a5272007-05-14 11:00:38 +02006041 present = snd_hda_codec_read(codec, 0x14, 0,
6042 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006043 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6044 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006045 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6046 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006047}
6048
6049static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6050{
6051 /* Looks like the unsol event is incompatible with the standard
6052 * definition. 4bit tag is placed at 26 bit!
6053 */
6054 if (((res >> 26) == ALC880_HP_EVENT)) {
6055 alc882_targa_automute(codec);
6056 }
6057}
6058
6059static struct hda_verb alc882_asus_a7j_verbs[] = {
6060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6062
6063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6065 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006066
Kailang Yang272a5272007-05-14 11:00:38 +02006067 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6069 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6070
6071 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6072 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6074 { } /* end */
6075};
6076
Takashi Iwai914759b2007-09-06 14:52:04 +02006077static struct hda_verb alc882_asus_a7m_verbs[] = {
6078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6080
6081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6082 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006084
Takashi Iwai914759b2007-09-06 14:52:04 +02006085 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6087 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6088
6089 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6090 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6091 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6092 { } /* end */
6093};
6094
Tobin Davis9102cd12006-12-15 10:02:12 +01006095static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6096{
6097 unsigned int gpiostate, gpiomask, gpiodir;
6098
6099 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6100 AC_VERB_GET_GPIO_DATA, 0);
6101
6102 if (!muted)
6103 gpiostate |= (1 << pin);
6104 else
6105 gpiostate &= ~(1 << pin);
6106
6107 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6108 AC_VERB_GET_GPIO_MASK, 0);
6109 gpiomask |= (1 << pin);
6110
6111 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6112 AC_VERB_GET_GPIO_DIRECTION, 0);
6113 gpiodir |= (1 << pin);
6114
6115
6116 snd_hda_codec_write(codec, codec->afg, 0,
6117 AC_VERB_SET_GPIO_MASK, gpiomask);
6118 snd_hda_codec_write(codec, codec->afg, 0,
6119 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6120
6121 msleep(1);
6122
6123 snd_hda_codec_write(codec, codec->afg, 0,
6124 AC_VERB_SET_GPIO_DATA, gpiostate);
6125}
6126
Takashi Iwai7debbe52007-08-16 15:01:03 +02006127/* set up GPIO at initialization */
6128static void alc885_macpro_init_hook(struct hda_codec *codec)
6129{
6130 alc882_gpio_mute(codec, 0, 0);
6131 alc882_gpio_mute(codec, 1, 0);
6132}
6133
6134/* set up GPIO and update auto-muting at initialization */
6135static void alc885_imac24_init_hook(struct hda_codec *codec)
6136{
6137 alc885_macpro_init_hook(codec);
6138 alc885_imac24_automute(codec);
6139}
6140
Kailang Yangdf694da2005-12-05 19:42:22 +01006141/*
6142 * generic initialization of ADC, input mixers and output mixers
6143 */
6144static struct hda_verb alc882_auto_init_verbs[] = {
6145 /*
6146 * Unmute ADC0-2 and set the default input to mic-in
6147 */
6148 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6150 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6152 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6154
Takashi Iwaicb53c622007-08-10 17:21:45 +02006155 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006156 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006157 * Note: PASD motherboards uses the Line In 2 as the input for
6158 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006159 */
6160 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006166
6167 /*
6168 * Set up output mixers (0x0c - 0x0f)
6169 */
6170 /* set vol=0 to output mixers */
6171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6174 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175 /* set up input amps for analog loopback */
6176 /* Amp Indices: DAC = 0, mixer = 1 */
6177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6185 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6187
6188 /* FIXME: use matrix-type input source selection */
6189 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6190 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6195 /* Input mixer2 */
6196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6199 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6200 /* Input mixer3 */
6201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6205
6206 { }
6207};
6208
6209/* capture mixer elements */
6210static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6211 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6212 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6213 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6214 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6215 {
6216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6217 /* The multiple "Capture Source" controls confuse alsamixer
6218 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 */
6220 /* .name = "Capture Source", */
6221 .name = "Input Source",
6222 .count = 2,
6223 .info = alc882_mux_enum_info,
6224 .get = alc882_mux_enum_get,
6225 .put = alc882_mux_enum_put,
6226 },
6227 { } /* end */
6228};
6229
6230static struct snd_kcontrol_new alc882_capture_mixer[] = {
6231 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6232 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6233 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6234 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6235 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6236 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6237 {
6238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6239 /* The multiple "Capture Source" controls confuse alsamixer
6240 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006241 */
6242 /* .name = "Capture Source", */
6243 .name = "Input Source",
6244 .count = 3,
6245 .info = alc882_mux_enum_info,
6246 .get = alc882_mux_enum_get,
6247 .put = alc882_mux_enum_put,
6248 },
6249 { } /* end */
6250};
6251
Takashi Iwaicb53c622007-08-10 17:21:45 +02006252#ifdef CONFIG_SND_HDA_POWER_SAVE
6253#define alc882_loopbacks alc880_loopbacks
6254#endif
6255
Kailang Yangdf694da2005-12-05 19:42:22 +01006256/* pcm configuration: identiacal with ALC880 */
6257#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6258#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6259#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6260#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6261
6262/*
6263 * configuration and preset
6264 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006265static const char *alc882_models[ALC882_MODEL_LAST] = {
6266 [ALC882_3ST_DIG] = "3stack-dig",
6267 [ALC882_6ST_DIG] = "6stack-dig",
6268 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006269 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006270 [ALC882_TARGA] = "targa",
6271 [ALC882_ASUS_A7J] = "asus-a7j",
6272 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006273 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006274 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006275 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006276 [ALC882_AUTO] = "auto",
6277};
6278
6279static struct snd_pci_quirk alc882_cfg_tbl[] = {
6280 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006281 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006282 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006283 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006284 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006285 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006286 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006287 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006288 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006289 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6290 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6291 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 {}
6293};
6294
6295static struct alc_config_preset alc882_presets[] = {
6296 [ALC882_3ST_DIG] = {
6297 .mixers = { alc882_base_mixer },
6298 .init_verbs = { alc882_init_verbs },
6299 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6300 .dac_nids = alc882_dac_nids,
6301 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006302 .dig_in_nid = ALC882_DIGIN_NID,
6303 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6304 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006305 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006306 .input_mux = &alc882_capture_source,
6307 },
6308 [ALC882_6ST_DIG] = {
6309 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6310 .init_verbs = { alc882_init_verbs },
6311 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6312 .dac_nids = alc882_dac_nids,
6313 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006314 .dig_in_nid = ALC882_DIGIN_NID,
6315 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6316 .channel_mode = alc882_sixstack_modes,
6317 .input_mux = &alc882_capture_source,
6318 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006319 [ALC882_ARIMA] = {
6320 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6321 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6322 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6323 .dac_nids = alc882_dac_nids,
6324 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6325 .channel_mode = alc882_sixstack_modes,
6326 .input_mux = &alc882_capture_source,
6327 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006328 [ALC882_W2JC] = {
6329 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6330 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6331 alc880_gpio1_init_verbs },
6332 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6333 .dac_nids = alc882_dac_nids,
6334 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6335 .channel_mode = alc880_threestack_modes,
6336 .need_dac_fix = 1,
6337 .input_mux = &alc882_capture_source,
6338 .dig_out_nid = ALC882_DIGOUT_NID,
6339 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006340 [ALC885_MBP3] = {
6341 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6342 .init_verbs = { alc885_mbp3_init_verbs,
6343 alc880_gpio1_init_verbs },
6344 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6345 .dac_nids = alc882_dac_nids,
6346 .channel_mode = alc885_mbp_6ch_modes,
6347 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6348 .input_mux = &alc882_capture_source,
6349 .dig_out_nid = ALC882_DIGOUT_NID,
6350 .dig_in_nid = ALC882_DIGIN_NID,
6351 .unsol_event = alc885_mbp3_unsol_event,
6352 .init_hook = alc885_mbp3_automute,
6353 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006354 [ALC885_MACPRO] = {
6355 .mixers = { alc882_macpro_mixer },
6356 .init_verbs = { alc882_macpro_init_verbs },
6357 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6358 .dac_nids = alc882_dac_nids,
6359 .dig_out_nid = ALC882_DIGOUT_NID,
6360 .dig_in_nid = ALC882_DIGIN_NID,
6361 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6362 .channel_mode = alc882_ch_modes,
6363 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006364 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006365 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006366 [ALC885_IMAC24] = {
6367 .mixers = { alc885_imac24_mixer },
6368 .init_verbs = { alc885_imac24_init_verbs },
6369 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6370 .dac_nids = alc882_dac_nids,
6371 .dig_out_nid = ALC882_DIGOUT_NID,
6372 .dig_in_nid = ALC882_DIGIN_NID,
6373 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6374 .channel_mode = alc882_ch_modes,
6375 .input_mux = &alc882_capture_source,
6376 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006377 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006378 },
Kailang Yang272a5272007-05-14 11:00:38 +02006379 [ALC882_TARGA] = {
6380 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6381 alc882_capture_mixer },
6382 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6383 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6384 .dac_nids = alc882_dac_nids,
6385 .dig_out_nid = ALC882_DIGOUT_NID,
6386 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6387 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006388 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006389 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6390 .channel_mode = alc882_3ST_6ch_modes,
6391 .need_dac_fix = 1,
6392 .input_mux = &alc882_capture_source,
6393 .unsol_event = alc882_targa_unsol_event,
6394 .init_hook = alc882_targa_automute,
6395 },
6396 [ALC882_ASUS_A7J] = {
6397 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6398 alc882_capture_mixer },
6399 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6400 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6401 .dac_nids = alc882_dac_nids,
6402 .dig_out_nid = ALC882_DIGOUT_NID,
6403 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6404 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006405 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006406 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6407 .channel_mode = alc882_3ST_6ch_modes,
6408 .need_dac_fix = 1,
6409 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006410 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006411 [ALC882_ASUS_A7M] = {
6412 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6413 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6414 alc880_gpio1_init_verbs,
6415 alc882_asus_a7m_verbs },
6416 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6417 .dac_nids = alc882_dac_nids,
6418 .dig_out_nid = ALC882_DIGOUT_NID,
6419 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6420 .channel_mode = alc880_threestack_modes,
6421 .need_dac_fix = 1,
6422 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006423 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006424};
6425
6426
6427/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006428 * Pin config fixes
6429 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006430enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006431 PINFIX_ABIT_AW9D_MAX
6432};
6433
6434static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6435 { 0x15, 0x01080104 }, /* side */
6436 { 0x16, 0x01011012 }, /* rear */
6437 { 0x17, 0x01016011 }, /* clfe */
6438 { }
6439};
6440
6441static const struct alc_pincfg *alc882_pin_fixes[] = {
6442 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6443};
6444
6445static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6446 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6447 {}
6448};
6449
6450/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006451 * BIOS auto configuration
6452 */
6453static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6454 hda_nid_t nid, int pin_type,
6455 int dac_idx)
6456{
6457 /* set as output */
6458 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006459 int idx;
6460
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006461 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006462 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6463 idx = 4;
6464 else
6465 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006466 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6467
6468}
6469
6470static void alc882_auto_init_multi_out(struct hda_codec *codec)
6471{
6472 struct alc_spec *spec = codec->spec;
6473 int i;
6474
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006475 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006477 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006478 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006479 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006480 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006481 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 }
6483}
6484
6485static void alc882_auto_init_hp_out(struct hda_codec *codec)
6486{
6487 struct alc_spec *spec = codec->spec;
6488 hda_nid_t pin;
6489
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006490 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006491 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006492 /* use dac 0 */
6493 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006494 pin = spec->autocfg.speaker_pins[0];
6495 if (pin)
6496 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006497}
6498
6499#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6500#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6501
6502static void alc882_auto_init_analog_input(struct hda_codec *codec)
6503{
6504 struct alc_spec *spec = codec->spec;
6505 int i;
6506
6507 for (i = 0; i < AUTO_PIN_LAST; i++) {
6508 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006509 unsigned int vref;
6510 if (!nid)
6511 continue;
6512 vref = PIN_IN;
6513 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006514 unsigned int pincap;
6515 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6516 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006517 AC_PINCAP_VREF_80)
6518 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006519 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006520 snd_hda_codec_write(codec, nid, 0,
6521 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6522 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6523 snd_hda_codec_write(codec, nid, 0,
6524 AC_VERB_SET_AMP_GAIN_MUTE,
6525 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006526 }
6527}
6528
Takashi Iwaif511b012008-08-15 16:46:42 +02006529static void alc882_auto_init_input_src(struct hda_codec *codec)
6530{
6531 struct alc_spec *spec = codec->spec;
6532 const struct hda_input_mux *imux = spec->input_mux;
6533 int c;
6534
6535 for (c = 0; c < spec->num_adc_nids; c++) {
6536 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6537 hda_nid_t nid = spec->capsrc_nids[c];
6538 int conns, mute, idx, item;
6539
6540 conns = snd_hda_get_connections(codec, nid, conn_list,
6541 ARRAY_SIZE(conn_list));
6542 if (conns < 0)
6543 continue;
6544 for (idx = 0; idx < conns; idx++) {
6545 /* if the current connection is the selected one,
6546 * unmute it as default - otherwise mute it
6547 */
6548 mute = AMP_IN_MUTE(idx);
6549 for (item = 0; item < imux->num_items; item++) {
6550 if (imux->items[item].index == idx) {
6551 if (spec->cur_mux[c] == item)
6552 mute = AMP_IN_UNMUTE(idx);
6553 break;
6554 }
6555 }
6556 snd_hda_codec_write(codec, nid, 0,
6557 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6558 }
6559 }
6560}
6561
Takashi Iwai776e1842007-08-29 15:07:11 +02006562/* add mic boosts if needed */
6563static int alc_auto_add_mic_boost(struct hda_codec *codec)
6564{
6565 struct alc_spec *spec = codec->spec;
6566 int err;
6567 hda_nid_t nid;
6568
6569 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006570 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006571 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6572 "Mic Boost",
6573 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6574 if (err < 0)
6575 return err;
6576 }
6577 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006578 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006579 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6580 "Front Mic Boost",
6581 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6582 if (err < 0)
6583 return err;
6584 }
6585 return 0;
6586}
6587
Kailang Yangdf694da2005-12-05 19:42:22 +01006588/* almost identical with ALC880 parser... */
6589static int alc882_parse_auto_config(struct hda_codec *codec)
6590{
6591 struct alc_spec *spec = codec->spec;
6592 int err = alc880_parse_auto_config(codec);
6593
6594 if (err < 0)
6595 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006596 else if (!err)
6597 return 0; /* no config found */
6598
6599 err = alc_auto_add_mic_boost(codec);
6600 if (err < 0)
6601 return err;
6602
6603 /* hack - override the init verbs */
6604 spec->init_verbs[0] = alc882_auto_init_verbs;
6605
6606 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006607}
6608
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006609/* additional initialization for auto-configuration model */
6610static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006611{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006612 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006613 alc882_auto_init_multi_out(codec);
6614 alc882_auto_init_hp_out(codec);
6615 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006616 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006617 if (spec->unsol_event)
6618 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006619}
6620
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006621static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6622
Linus Torvalds1da177e2005-04-16 15:20:36 -07006623static int patch_alc882(struct hda_codec *codec)
6624{
6625 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006627
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006628 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006629 if (spec == NULL)
6630 return -ENOMEM;
6631
Linus Torvalds1da177e2005-04-16 15:20:36 -07006632 codec->spec = spec;
6633
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006634 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6635 alc882_models,
6636 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006637
Kailang Yangdf694da2005-12-05 19:42:22 +01006638 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006639 /* Pick up systems that don't supply PCI SSID */
6640 switch (codec->subsystem_id) {
6641 case 0x106b0c00: /* Mac Pro */
6642 board_config = ALC885_MACPRO;
6643 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006644 case 0x106b1000: /* iMac 24 */
6645 board_config = ALC885_IMAC24;
6646 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006647 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006648 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006649 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006650 board_config = ALC885_MBP3;
6651 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006652 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006653 /* ALC889A is handled better as ALC888-compatible */
6654 if (codec->revision_id == 0x100103) {
6655 alc_free(codec);
6656 return patch_alc883(codec);
6657 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006658 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6659 "trying auto-probe from BIOS...\n");
6660 board_config = ALC882_AUTO;
6661 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006662 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006663
Takashi Iwaif95474e2007-07-10 00:47:43 +02006664 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6665
Kailang Yangdf694da2005-12-05 19:42:22 +01006666 if (board_config == ALC882_AUTO) {
6667 /* automatic parse from the BIOS config */
6668 err = alc882_parse_auto_config(codec);
6669 if (err < 0) {
6670 alc_free(codec);
6671 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006672 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006673 printk(KERN_INFO
6674 "hda_codec: Cannot set up configuration "
6675 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 board_config = ALC882_3ST_DIG;
6677 }
6678 }
6679
6680 if (board_config != ALC882_AUTO)
6681 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006682
Kailang Yang2f893282008-05-27 12:14:47 +02006683 if (codec->vendor_id == 0x10ec0885) {
6684 spec->stream_name_analog = "ALC885 Analog";
6685 spec->stream_name_digital = "ALC885 Digital";
6686 } else {
6687 spec->stream_name_analog = "ALC882 Analog";
6688 spec->stream_name_digital = "ALC882 Digital";
6689 }
6690
Kailang Yangdf694da2005-12-05 19:42:22 +01006691 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6692 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006693 /* FIXME: setup DAC5 */
6694 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6695 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006696
Kailang Yangdf694da2005-12-05 19:42:22 +01006697 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6698 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006699
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006700 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006701 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006702 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006703 /* get type */
6704 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006705 if (wcap != AC_WID_AUD_IN) {
6706 spec->adc_nids = alc882_adc_nids_alt;
6707 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006708 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006709 spec->mixers[spec->num_mixers] =
6710 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006711 spec->num_mixers++;
6712 } else {
6713 spec->adc_nids = alc882_adc_nids;
6714 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006715 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006716 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6717 spec->num_mixers++;
6718 }
6719 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006720
Takashi Iwai2134ea42008-01-10 16:53:55 +01006721 spec->vmaster_nid = 0x0c;
6722
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006725 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006726#ifdef CONFIG_SND_HDA_POWER_SAVE
6727 if (!spec->loopback.amplist)
6728 spec->loopback.amplist = alc882_loopbacks;
6729#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006730
6731 return 0;
6732}
6733
6734/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006735 * ALC883 support
6736 *
6737 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6738 * configuration. Each pin widget can choose any input DACs and a mixer.
6739 * Each ADC is connected from a mixer of all inputs. This makes possible
6740 * 6-channel independent captures.
6741 *
6742 * In addition, an independent DAC for the multi-playback (not used in this
6743 * driver yet).
6744 */
6745#define ALC883_DIGOUT_NID 0x06
6746#define ALC883_DIGIN_NID 0x0a
6747
6748static hda_nid_t alc883_dac_nids[4] = {
6749 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006750 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006751};
6752
6753static hda_nid_t alc883_adc_nids[2] = {
6754 /* ADC1-2 */
6755 0x08, 0x09,
6756};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006757
Takashi Iwaie1406342008-02-11 18:32:32 +01006758static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6759
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006760/* input MUX */
6761/* FIXME: should be a matrix-type input source selection */
6762
6763static struct hda_input_mux alc883_capture_source = {
6764 .num_items = 4,
6765 .items = {
6766 { "Mic", 0x0 },
6767 { "Front Mic", 0x1 },
6768 { "Line", 0x2 },
6769 { "CD", 0x4 },
6770 },
6771};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006772
Jiang zhe17bba1b2008-06-04 12:11:07 +02006773static struct hda_input_mux alc883_3stack_6ch_intel = {
6774 .num_items = 4,
6775 .items = {
6776 { "Mic", 0x1 },
6777 { "Front Mic", 0x0 },
6778 { "Line", 0x2 },
6779 { "CD", 0x4 },
6780 },
6781};
6782
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006783static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6784 .num_items = 2,
6785 .items = {
6786 { "Mic", 0x1 },
6787 { "Line", 0x2 },
6788 },
6789};
6790
Kailang Yang272a5272007-05-14 11:00:38 +02006791static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6792 .num_items = 4,
6793 .items = {
6794 { "Mic", 0x0 },
6795 { "iMic", 0x1 },
6796 { "Line", 0x2 },
6797 { "CD", 0x4 },
6798 },
6799};
6800
Jiang zhefb97dc62008-03-06 11:07:11 +01006801static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6802 .num_items = 2,
6803 .items = {
6804 { "Mic", 0x0 },
6805 { "Int Mic", 0x1 },
6806 },
6807};
6808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006809#define alc883_mux_enum_info alc_mux_enum_info
6810#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006811/* ALC883 has the ALC882-type input selection */
6812#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006813
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006814/*
6815 * 2ch mode
6816 */
6817static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6818 { 2, NULL }
6819};
6820
6821/*
6822 * 2ch mode
6823 */
6824static struct hda_verb alc883_3ST_ch2_init[] = {
6825 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6826 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6827 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6828 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6829 { } /* end */
6830};
6831
6832/*
Tobin Davisb2011312007-09-17 12:45:11 +02006833 * 4ch mode
6834 */
6835static struct hda_verb alc883_3ST_ch4_init[] = {
6836 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6837 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6841 { } /* end */
6842};
6843
6844/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006845 * 6ch mode
6846 */
6847static struct hda_verb alc883_3ST_ch6_init[] = {
6848 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6849 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6850 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6853 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6854 { } /* end */
6855};
6856
Tobin Davisb2011312007-09-17 12:45:11 +02006857static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006858 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006859 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006860 { 6, alc883_3ST_ch6_init },
6861};
6862
6863/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006864 * 2ch mode
6865 */
6866static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6867 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6868 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6869 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6870 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6871 { } /* end */
6872};
6873
6874/*
6875 * 4ch mode
6876 */
6877static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6878 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6879 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6880 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6881 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6882 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6883 { } /* end */
6884};
6885
6886/*
6887 * 6ch mode
6888 */
6889static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6890 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6891 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6892 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6895 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6896 { } /* end */
6897};
6898
6899static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6900 { 2, alc883_3ST_ch2_intel_init },
6901 { 4, alc883_3ST_ch4_intel_init },
6902 { 6, alc883_3ST_ch6_intel_init },
6903};
6904
6905/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006906 * 6ch mode
6907 */
6908static struct hda_verb alc883_sixstack_ch6_init[] = {
6909 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6910 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6911 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6913 { } /* end */
6914};
6915
6916/*
6917 * 8ch mode
6918 */
6919static struct hda_verb alc883_sixstack_ch8_init[] = {
6920 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6922 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6923 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6924 { } /* end */
6925};
6926
6927static struct hda_channel_mode alc883_sixstack_modes[2] = {
6928 { 6, alc883_sixstack_ch6_init },
6929 { 8, alc883_sixstack_ch8_init },
6930};
6931
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006932static struct hda_verb alc883_medion_eapd_verbs[] = {
6933 /* eanable EAPD on medion laptop */
6934 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6935 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6936 { }
6937};
6938
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006939/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6940 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6941 */
6942
6943static struct snd_kcontrol_new alc883_base_mixer[] = {
6944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6946 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6947 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6949 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6950 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6951 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6952 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6953 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006963 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6965 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6966 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6967 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6968 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6969 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6970 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6971 {
6972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6973 /* .name = "Capture Source", */
6974 .name = "Input Source",
6975 .count = 2,
6976 .info = alc883_mux_enum_info,
6977 .get = alc883_mux_enum_get,
6978 .put = alc883_mux_enum_put,
6979 },
6980 { } /* end */
6981};
6982
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006983static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6984 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6985 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6986 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6987 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6988 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6989 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6996 HDA_CODEC_MUTE("Front 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 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7000 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7001 {
7002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7003 /* .name = "Capture Source", */
7004 .name = "Input Source",
7005 .count = 2,
7006 .info = alc883_mux_enum_info,
7007 .get = alc883_mux_enum_get,
7008 .put = alc883_mux_enum_put,
7009 },
7010 { } /* end */
7011};
7012
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007013static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7015 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7016 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7017 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7019 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7021 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7023 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7025 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7026 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7027 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7028 {
7029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7030 /* .name = "Capture Source", */
7031 .name = "Input Source",
7032 .count = 2,
7033 .info = alc883_mux_enum_info,
7034 .get = alc883_mux_enum_get,
7035 .put = alc883_mux_enum_put,
7036 },
7037 { } /* end */
7038};
7039
Jiang zhefb97dc62008-03-06 11:07:11 +01007040static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7042 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7043 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7044 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7050 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7051 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7052 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7053 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7054 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7055 {
7056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7057 /* .name = "Capture Source", */
7058 .name = "Input Source",
7059 .count = 2,
7060 .info = alc883_mux_enum_info,
7061 .get = alc883_mux_enum_get,
7062 .put = alc883_mux_enum_put,
7063 },
7064 { } /* end */
7065};
7066
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007067static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007080 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7081 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7082 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7083 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7084 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7085 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7086 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7087 {
7088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7089 /* .name = "Capture Source", */
7090 .name = "Input Source",
7091 .count = 2,
7092 .info = alc883_mux_enum_info,
7093 .get = alc883_mux_enum_get,
7094 .put = alc883_mux_enum_put,
7095 },
7096 { } /* end */
7097};
7098
7099static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7101 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7102 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7103 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7104 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7105 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7106 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7107 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7119 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7120 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7121 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7122 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7123 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7124 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7125 {
7126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7127 /* .name = "Capture Source", */
7128 .name = "Input Source",
7129 .count = 2,
7130 .info = alc883_mux_enum_info,
7131 .get = alc883_mux_enum_get,
7132 .put = alc883_mux_enum_put,
7133 },
7134 { } /* end */
7135};
7136
Jiang zhe17bba1b2008-06-04 12:11:07 +02007137static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7141 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7143 HDA_OUTPUT),
7144 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7145 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7146 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7148 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7149 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7153 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7156 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7157 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7158 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7159 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7162 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7164 {
7165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7166 /* .name = "Capture Source", */
7167 .name = "Input Source",
7168 .count = 2,
7169 .info = alc883_mux_enum_info,
7170 .get = alc883_mux_enum_get,
7171 .put = alc883_mux_enum_put,
7172 },
7173 { } /* end */
7174};
7175
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007176static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7193 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7196 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7197 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7199 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7200
7201 {
7202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7203 /* .name = "Capture Source", */
7204 .name = "Input Source",
7205 .count = 1,
7206 .info = alc883_mux_enum_info,
7207 .get = alc883_mux_enum_get,
7208 .put = alc883_mux_enum_put,
7209 },
7210 { } /* end */
7211};
7212
Kailang Yangccc656c2006-10-17 12:32:26 +02007213static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7230 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7231 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7233 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7234 {
7235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7236 /* .name = "Capture Source", */
7237 .name = "Input Source",
7238 .count = 2,
7239 .info = alc883_mux_enum_info,
7240 .get = alc883_mux_enum_get,
7241 .put = alc883_mux_enum_put,
7242 },
7243 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007244};
Kailang Yangccc656c2006-10-17 12:32:26 +02007245
7246static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7249 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7250 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7251 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007255 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7256 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7257 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007258 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7259 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7260 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7261 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7262 {
7263 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7264 /* .name = "Capture Source", */
7265 .name = "Input Source",
7266 .count = 2,
7267 .info = alc883_mux_enum_info,
7268 .get = alc883_mux_enum_get,
7269 .put = alc883_mux_enum_put,
7270 },
7271 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007272};
Kailang Yangccc656c2006-10-17 12:32:26 +02007273
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007274static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7275 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7276 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007277 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7278 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7284 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7285 {
7286 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7287 /* .name = "Capture Source", */
7288 .name = "Input Source",
7289 .count = 1,
7290 .info = alc883_mux_enum_info,
7291 .get = alc883_mux_enum_get,
7292 .put = alc883_mux_enum_put,
7293 },
7294 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007295};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007296
Kailang Yang272a5272007-05-14 11:00:38 +02007297static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7298 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7299 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7301 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7302 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7305 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7306 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7307 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7308 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7309 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7311 {
7312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7313 /* .name = "Capture Source", */
7314 .name = "Input Source",
7315 .count = 2,
7316 .info = alc883_mux_enum_info,
7317 .get = alc883_mux_enum_get,
7318 .put = alc883_mux_enum_put,
7319 },
7320 { } /* end */
7321};
7322
7323static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7331 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7332 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7333 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7334 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7335 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7336 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7337 {
7338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7339 /* .name = "Capture Source", */
7340 .name = "Input Source",
7341 .count = 2,
7342 .info = alc883_mux_enum_info,
7343 .get = alc883_mux_enum_get,
7344 .put = alc883_mux_enum_put,
7345 },
7346 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007347};
Kailang Yang272a5272007-05-14 11:00:38 +02007348
Tobin Davis2880a862007-08-07 11:50:26 +02007349static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7351 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007358 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7359 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7360 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7361 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7362 {
7363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7364 /* .name = "Capture Source", */
7365 .name = "Input Source",
7366 .count = 2,
7367 .info = alc883_mux_enum_info,
7368 .get = alc883_mux_enum_get,
7369 .put = alc883_mux_enum_put,
7370 },
7371 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007372};
Tobin Davis2880a862007-08-07 11:50:26 +02007373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007374static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7375 {
7376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7377 .name = "Channel Mode",
7378 .info = alc_ch_mode_info,
7379 .get = alc_ch_mode_get,
7380 .put = alc_ch_mode_put,
7381 },
7382 { } /* end */
7383};
7384
7385static struct hda_verb alc883_init_verbs[] = {
7386 /* ADC1: mute amp left and right */
7387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* ADC2: mute amp left and right */
7390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7392 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7396 /* Rear mixer */
7397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7400 /* CLFE mixer */
7401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7404 /* Side mixer */
7405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7408
Takashi Iwaicb53c622007-08-10 17:21:45 +02007409 /* mute analog input loopbacks */
7410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007415
7416 /* Front Pin: output 0 (0x0c) */
7417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7419 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7420 /* Rear Pin: output 1 (0x0d) */
7421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7423 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7424 /* CLFE Pin: output 2 (0x0e) */
7425 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7427 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7428 /* Side Pin: output 3 (0x0f) */
7429 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7430 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7431 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7432 /* Mic (rear) pin: input vref at 80% */
7433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7434 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7435 /* Front Mic pin: input vref at 80% */
7436 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7437 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7438 /* Line In pin: input */
7439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7441 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7443 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7444 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7445 /* CD pin widget for input */
7446 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7447
7448 /* FIXME: use matrix-type input source selection */
7449 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7450 /* Input mixer2 */
7451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7455 /* Input mixer3 */
7456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7460 { }
7461};
7462
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007463/* toggle speaker-output according to the hp-jack state */
7464static void alc883_mitac_hp_automute(struct hda_codec *codec)
7465{
7466 unsigned int present;
7467
7468 present = snd_hda_codec_read(codec, 0x15, 0,
7469 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7470 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7472 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7473 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7474}
7475
7476/* auto-toggle front mic */
7477/*
7478static void alc883_mitac_mic_automute(struct hda_codec *codec)
7479{
7480 unsigned int present;
7481 unsigned char bits;
7482
7483 present = snd_hda_codec_read(codec, 0x18, 0,
7484 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7485 bits = present ? HDA_AMP_MUTE : 0;
7486 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7487}
7488*/
7489
7490static void alc883_mitac_automute(struct hda_codec *codec)
7491{
7492 alc883_mitac_hp_automute(codec);
7493 /* alc883_mitac_mic_automute(codec); */
7494}
7495
7496static void alc883_mitac_unsol_event(struct hda_codec *codec,
7497 unsigned int res)
7498{
7499 switch (res >> 26) {
7500 case ALC880_HP_EVENT:
7501 alc883_mitac_hp_automute(codec);
7502 break;
7503 case ALC880_MIC_EVENT:
7504 /* alc883_mitac_mic_automute(codec); */
7505 break;
7506 }
7507}
7508
7509static struct hda_verb alc883_mitac_verbs[] = {
7510 /* HP */
7511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7513 /* Subwoofer */
7514 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7515 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7516
7517 /* enable unsolicited event */
7518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7519 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7520
7521 { } /* end */
7522};
7523
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007524static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007525 /* HP */
7526 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7527 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7528 /* Int speaker */
7529 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7531
7532 /* enable unsolicited event */
7533 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007534 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007535
7536 { } /* end */
7537};
7538
Jiang zhefb97dc62008-03-06 11:07:11 +01007539static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7540 /* HP */
7541 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7543 /* Subwoofer */
7544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7546
7547 /* enable unsolicited event */
7548 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7549
7550 { } /* end */
7551};
7552
Kailang Yangccc656c2006-10-17 12:32:26 +02007553static struct hda_verb alc883_tagra_verbs[] = {
7554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7556
7557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007559
Kailang Yangccc656c2006-10-17 12:32:26 +02007560 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7561 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7563
7564 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007565 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7566 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7567 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007568
7569 { } /* end */
7570};
7571
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007572static struct hda_verb alc883_lenovo_101e_verbs[] = {
7573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7575 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7576 { } /* end */
7577};
7578
Kailang Yang272a5272007-05-14 11:00:38 +02007579static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7580 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7582 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7584 { } /* end */
7585};
7586
7587static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7591 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7592 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7593 { } /* end */
7594};
7595
Kailang Yang189609a2007-08-20 11:31:23 +02007596static struct hda_verb alc883_haier_w66_verbs[] = {
7597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7599
7600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7601
7602 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7604 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7605 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7606 { } /* end */
7607};
7608
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007609static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007610 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007611 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7612 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007613 { }
7614};
7615
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007616static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007617 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7618 { }
7619};
7620
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007621static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007622 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7623 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7624 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7625 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7626 { }
7627};
7628
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007629static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7632 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7634 { }
7635};
7636
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007637static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7638 { 2, alc888_3st_hp_2ch_init },
7639 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007640};
7641
Kailang Yang272a5272007-05-14 11:00:38 +02007642/* toggle front-jack and RCA according to the hp-jack state */
7643static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7644{
7645 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007646
Kailang Yang272a5272007-05-14 11:00:38 +02007647 present = snd_hda_codec_read(codec, 0x1b, 0,
7648 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007649 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7650 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7651 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7652 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007653}
7654
7655/* toggle RCA according to the front-jack state */
7656static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7657{
7658 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007659
Kailang Yang272a5272007-05-14 11:00:38 +02007660 present = snd_hda_codec_read(codec, 0x14, 0,
7661 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007662 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7663 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007664}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007665
Kailang Yang272a5272007-05-14 11:00:38 +02007666static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7667 unsigned int res)
7668{
7669 if ((res >> 26) == ALC880_HP_EVENT)
7670 alc888_lenovo_ms7195_front_automute(codec);
7671 if ((res >> 26) == ALC880_FRONT_EVENT)
7672 alc888_lenovo_ms7195_rca_automute(codec);
7673}
7674
7675static struct hda_verb alc883_medion_md2_verbs[] = {
7676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7678
7679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7680
7681 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7682 { } /* end */
7683};
7684
7685/* toggle speaker-output according to the hp-jack state */
7686static void alc883_medion_md2_automute(struct hda_codec *codec)
7687{
7688 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007689
Kailang Yang272a5272007-05-14 11:00:38 +02007690 present = snd_hda_codec_read(codec, 0x14, 0,
7691 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007692 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7693 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007694}
7695
7696static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7697 unsigned int res)
7698{
7699 if ((res >> 26) == ALC880_HP_EVENT)
7700 alc883_medion_md2_automute(codec);
7701}
7702
Kailang Yangccc656c2006-10-17 12:32:26 +02007703/* toggle speaker-output according to the hp-jack state */
7704static void alc883_tagra_automute(struct hda_codec *codec)
7705{
7706 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007707 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007708
7709 present = snd_hda_codec_read(codec, 0x14, 0,
7710 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007711 bits = present ? HDA_AMP_MUTE : 0;
7712 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7713 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007714 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7715 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007716}
7717
7718static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7719{
7720 if ((res >> 26) == ALC880_HP_EVENT)
7721 alc883_tagra_automute(codec);
7722}
7723
Jiang zhe368c7a92008-03-04 11:20:33 +01007724/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007725static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007726{
7727 unsigned int present;
7728 unsigned char bits;
7729
7730 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7731 & AC_PINSENSE_PRESENCE;
7732 bits = present ? HDA_AMP_MUTE : 0;
7733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7734 HDA_AMP_MUTE, bits);
7735}
7736
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007737static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7738{
7739 unsigned int present;
7740
7741 present = snd_hda_codec_read(codec, 0x18, 0,
7742 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7743 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7744 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7745}
7746
7747static void alc883_clevo_m720_automute(struct hda_codec *codec)
7748{
7749 alc883_clevo_m720_hp_automute(codec);
7750 alc883_clevo_m720_mic_automute(codec);
7751}
7752
7753static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007754 unsigned int res)
7755{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007756 switch (res >> 26) {
7757 case ALC880_HP_EVENT:
7758 alc883_clevo_m720_hp_automute(codec);
7759 break;
7760 case ALC880_MIC_EVENT:
7761 alc883_clevo_m720_mic_automute(codec);
7762 break;
7763 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007764}
7765
Jiang zhefb97dc62008-03-06 11:07:11 +01007766/* toggle speaker-output according to the hp-jack state */
7767static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7768{
7769 unsigned int present;
7770 unsigned char bits;
7771
7772 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7773 & AC_PINSENSE_PRESENCE;
7774 bits = present ? HDA_AMP_MUTE : 0;
7775 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7776 HDA_AMP_MUTE, bits);
7777}
7778
7779static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7780 unsigned int res)
7781{
7782 if ((res >> 26) == ALC880_HP_EVENT)
7783 alc883_2ch_fujitsu_pi2515_automute(codec);
7784}
7785
Kailang Yang189609a2007-08-20 11:31:23 +02007786static void alc883_haier_w66_automute(struct hda_codec *codec)
7787{
7788 unsigned int present;
7789 unsigned char bits;
7790
7791 present = snd_hda_codec_read(codec, 0x1b, 0,
7792 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7793 bits = present ? 0x80 : 0;
7794 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7795 0x80, bits);
7796}
7797
7798static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7799 unsigned int res)
7800{
7801 if ((res >> 26) == ALC880_HP_EVENT)
7802 alc883_haier_w66_automute(codec);
7803}
7804
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007805static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7806{
7807 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007808 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007809
7810 present = snd_hda_codec_read(codec, 0x14, 0,
7811 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007812 bits = present ? HDA_AMP_MUTE : 0;
7813 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7814 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007815}
7816
7817static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7818{
7819 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007820 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007821
7822 present = snd_hda_codec_read(codec, 0x1b, 0,
7823 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007824 bits = present ? HDA_AMP_MUTE : 0;
7825 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7826 HDA_AMP_MUTE, bits);
7827 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7828 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007829}
7830
7831static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7832 unsigned int res)
7833{
7834 if ((res >> 26) == ALC880_HP_EVENT)
7835 alc883_lenovo_101e_all_automute(codec);
7836 if ((res >> 26) == ALC880_FRONT_EVENT)
7837 alc883_lenovo_101e_ispeaker_automute(codec);
7838}
7839
Takashi Iwai676a9b52007-08-16 15:23:35 +02007840/* toggle speaker-output according to the hp-jack state */
7841static void alc883_acer_aspire_automute(struct hda_codec *codec)
7842{
7843 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007844
Takashi Iwai676a9b52007-08-16 15:23:35 +02007845 present = snd_hda_codec_read(codec, 0x14, 0,
7846 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7847 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7848 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7849 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7851}
7852
7853static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7854 unsigned int res)
7855{
7856 if ((res >> 26) == ALC880_HP_EVENT)
7857 alc883_acer_aspire_automute(codec);
7858}
7859
Kailang Yangd1a991a2007-08-15 16:21:59 +02007860static struct hda_verb alc883_acer_eapd_verbs[] = {
7861 /* HP Pin: output 0 (0x0c) */
7862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7864 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7865 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7867 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007869 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7870 /* eanable EAPD on medion laptop */
7871 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7872 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007873 /* enable unsolicited event */
7874 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007875 { }
7876};
7877
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007878static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7879{
7880 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007881
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007882 present = snd_hda_codec_read(codec, 0x1b, 0,
7883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7884 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7885 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7886 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7887 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7888 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7889 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7890 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7891 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7892}
7893
7894static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7895 unsigned int res)
7896{
7897 switch (res >> 26) {
7898 case ALC880_HP_EVENT:
7899 printk("hp_event\n");
7900 alc888_6st_dell_front_automute(codec);
7901 break;
7902 }
7903}
7904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007905/*
7906 * generic initialization of ADC, input mixers and output mixers
7907 */
7908static struct hda_verb alc883_auto_init_verbs[] = {
7909 /*
7910 * Unmute ADC0-2 and set the default input to mic-in
7911 */
7912 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7913 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7914 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7915 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7916
Takashi Iwaicb53c622007-08-10 17:21:45 +02007917 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007918 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007919 * Note: PASD motherboards uses the Line In 2 as the input for
7920 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007921 */
7922 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007928
7929 /*
7930 * Set up output mixers (0x0c - 0x0f)
7931 */
7932 /* set vol=0 to output mixers */
7933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7936 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7937 /* set up input amps for analog loopback */
7938 /* Amp Indices: DAC = 0, mixer = 1 */
7939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7947 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7948 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7949
7950 /* FIXME: use matrix-type input source selection */
7951 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7952 /* Input mixer1 */
7953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007956 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7958 /* Input mixer2 */
7959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007962 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007963 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007964
7965 { }
7966};
7967
7968/* capture mixer elements */
7969static struct snd_kcontrol_new alc883_capture_mixer[] = {
7970 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7972 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7973 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7974 {
7975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7976 /* The multiple "Capture Source" controls confuse alsamixer
7977 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007978 */
7979 /* .name = "Capture Source", */
7980 .name = "Input Source",
7981 .count = 2,
7982 .info = alc882_mux_enum_info,
7983 .get = alc882_mux_enum_get,
7984 .put = alc882_mux_enum_put,
7985 },
7986 { } /* end */
7987};
7988
Takashi Iwaicb53c622007-08-10 17:21:45 +02007989#ifdef CONFIG_SND_HDA_POWER_SAVE
7990#define alc883_loopbacks alc880_loopbacks
7991#endif
7992
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007993/* pcm configuration: identiacal with ALC880 */
7994#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7995#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007996#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007997#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7998#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7999
8000/*
8001 * configuration and preset
8002 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008003static const char *alc883_models[ALC883_MODEL_LAST] = {
8004 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8005 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8006 [ALC883_3ST_6ch] = "3stack-6ch",
8007 [ALC883_6ST_DIG] = "6stack-dig",
8008 [ALC883_TARGA_DIG] = "targa-dig",
8009 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008010 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008011 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008012 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008013 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008014 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008015 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008016 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8017 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02008018 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008019 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008020 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008021 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008022 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008023 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008024 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008025 [ALC883_AUTO] = "auto",
8026};
8027
8028static struct snd_pci_quirk alc883_cfg_tbl[] = {
8029 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008030 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8031 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8032 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008033 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008034 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008035 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008036 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008037 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8038 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008039 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008040 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02008041 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008042 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008043 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8044 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8045 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008046 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008047 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8048 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8049 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008050 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008051 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008052 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008053 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8054 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8055 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8056 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8057 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8058 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8059 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8060 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8061 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008062 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8063 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008064 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008065 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008066 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008067 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008068 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008069 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008070 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8071 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008072 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008073 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008074 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008075 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008076 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008077 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008078 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8079 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02008080 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008081 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008082 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008083 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8084 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008085 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008086 {}
8087};
8088
8089static struct alc_config_preset alc883_presets[] = {
8090 [ALC883_3ST_2ch_DIG] = {
8091 .mixers = { alc883_3ST_2ch_mixer },
8092 .init_verbs = { alc883_init_verbs },
8093 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8094 .dac_nids = alc883_dac_nids,
8095 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008096 .dig_in_nid = ALC883_DIGIN_NID,
8097 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8098 .channel_mode = alc883_3ST_2ch_modes,
8099 .input_mux = &alc883_capture_source,
8100 },
8101 [ALC883_3ST_6ch_DIG] = {
8102 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8103 .init_verbs = { alc883_init_verbs },
8104 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8105 .dac_nids = alc883_dac_nids,
8106 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008107 .dig_in_nid = ALC883_DIGIN_NID,
8108 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8109 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008110 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008111 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008112 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008113 [ALC883_3ST_6ch] = {
8114 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8115 .init_verbs = { alc883_init_verbs },
8116 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8117 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008118 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8119 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008120 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008121 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008122 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008123 [ALC883_3ST_6ch_INTEL] = {
8124 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8125 .init_verbs = { alc883_init_verbs },
8126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8127 .dac_nids = alc883_dac_nids,
8128 .dig_out_nid = ALC883_DIGOUT_NID,
8129 .dig_in_nid = ALC883_DIGIN_NID,
8130 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8131 .channel_mode = alc883_3ST_6ch_intel_modes,
8132 .need_dac_fix = 1,
8133 .input_mux = &alc883_3stack_6ch_intel,
8134 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008135 [ALC883_6ST_DIG] = {
8136 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8137 .init_verbs = { alc883_init_verbs },
8138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8139 .dac_nids = alc883_dac_nids,
8140 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008141 .dig_in_nid = ALC883_DIGIN_NID,
8142 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8143 .channel_mode = alc883_sixstack_modes,
8144 .input_mux = &alc883_capture_source,
8145 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008146 [ALC883_TARGA_DIG] = {
8147 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8148 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8149 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8150 .dac_nids = alc883_dac_nids,
8151 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008152 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8153 .channel_mode = alc883_3ST_6ch_modes,
8154 .need_dac_fix = 1,
8155 .input_mux = &alc883_capture_source,
8156 .unsol_event = alc883_tagra_unsol_event,
8157 .init_hook = alc883_tagra_automute,
8158 },
8159 [ALC883_TARGA_2ch_DIG] = {
8160 .mixers = { alc883_tagra_2ch_mixer},
8161 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8163 .dac_nids = alc883_dac_nids,
8164 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008165 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8166 .channel_mode = alc883_3ST_2ch_modes,
8167 .input_mux = &alc883_capture_source,
8168 .unsol_event = alc883_tagra_unsol_event,
8169 .init_hook = alc883_tagra_automute,
8170 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008171 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008172 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008173 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8174 * and the headphone jack. Turn this on and rely on the
8175 * standard mute methods whenever the user wants to turn
8176 * these outputs off.
8177 */
8178 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8179 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8180 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008181 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8182 .channel_mode = alc883_3ST_2ch_modes,
8183 .input_mux = &alc883_capture_source,
8184 },
Tobin Davis2880a862007-08-07 11:50:26 +02008185 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008186 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008187 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8189 .dac_nids = alc883_dac_nids,
8190 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8192 .channel_mode = alc883_3ST_2ch_modes,
8193 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008194 .unsol_event = alc883_acer_aspire_unsol_event,
8195 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008196 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008197 [ALC883_MEDION] = {
8198 .mixers = { alc883_fivestack_mixer,
8199 alc883_chmode_mixer },
8200 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008201 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8203 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008204 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8205 .channel_mode = alc883_sixstack_modes,
8206 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008207 },
Kailang Yang272a5272007-05-14 11:00:38 +02008208 [ALC883_MEDION_MD2] = {
8209 .mixers = { alc883_medion_md2_mixer},
8210 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8212 .dac_nids = alc883_dac_nids,
8213 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8215 .channel_mode = alc883_3ST_2ch_modes,
8216 .input_mux = &alc883_capture_source,
8217 .unsol_event = alc883_medion_md2_unsol_event,
8218 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008219 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008220 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008221 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008222 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8224 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008225 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8226 .channel_mode = alc883_3ST_2ch_modes,
8227 .input_mux = &alc883_capture_source,
8228 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008229 [ALC883_CLEVO_M720] = {
8230 .mixers = { alc883_clevo_m720_mixer },
8231 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008232 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8233 .dac_nids = alc883_dac_nids,
8234 .dig_out_nid = ALC883_DIGOUT_NID,
8235 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8236 .channel_mode = alc883_3ST_2ch_modes,
8237 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008238 .unsol_event = alc883_clevo_m720_unsol_event,
8239 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008240 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008241 [ALC883_LENOVO_101E_2ch] = {
8242 .mixers = { alc883_lenovo_101e_2ch_mixer},
8243 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8244 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8245 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008246 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8247 .channel_mode = alc883_3ST_2ch_modes,
8248 .input_mux = &alc883_lenovo_101e_capture_source,
8249 .unsol_event = alc883_lenovo_101e_unsol_event,
8250 .init_hook = alc883_lenovo_101e_all_automute,
8251 },
Kailang Yang272a5272007-05-14 11:00:38 +02008252 [ALC883_LENOVO_NB0763] = {
8253 .mixers = { alc883_lenovo_nb0763_mixer },
8254 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8256 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8258 .channel_mode = alc883_3ST_2ch_modes,
8259 .need_dac_fix = 1,
8260 .input_mux = &alc883_lenovo_nb0763_capture_source,
8261 .unsol_event = alc883_medion_md2_unsol_event,
8262 .init_hook = alc883_medion_md2_automute,
8263 },
8264 [ALC888_LENOVO_MS7195_DIG] = {
8265 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8266 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8268 .dac_nids = alc883_dac_nids,
8269 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008270 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8271 .channel_mode = alc883_3ST_6ch_modes,
8272 .need_dac_fix = 1,
8273 .input_mux = &alc883_capture_source,
8274 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8275 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008276 },
8277 [ALC883_HAIER_W66] = {
8278 .mixers = { alc883_tagra_2ch_mixer},
8279 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8280 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8281 .dac_nids = alc883_dac_nids,
8282 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008283 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8284 .channel_mode = alc883_3ST_2ch_modes,
8285 .input_mux = &alc883_capture_source,
8286 .unsol_event = alc883_haier_w66_unsol_event,
8287 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008288 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008289 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008290 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008291 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008292 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8293 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008294 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8295 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008296 .need_dac_fix = 1,
8297 .input_mux = &alc883_capture_source,
8298 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008299 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008300 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008301 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8303 .dac_nids = alc883_dac_nids,
8304 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008305 .dig_in_nid = ALC883_DIGIN_NID,
8306 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8307 .channel_mode = alc883_sixstack_modes,
8308 .input_mux = &alc883_capture_source,
8309 .unsol_event = alc888_6st_dell_unsol_event,
8310 .init_hook = alc888_6st_dell_front_automute,
8311 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008312 [ALC883_MITAC] = {
8313 .mixers = { alc883_mitac_mixer },
8314 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8316 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8318 .channel_mode = alc883_3ST_2ch_modes,
8319 .input_mux = &alc883_capture_source,
8320 .unsol_event = alc883_mitac_unsol_event,
8321 .init_hook = alc883_mitac_automute,
8322 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008323 [ALC883_FUJITSU_PI2515] = {
8324 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8325 .init_verbs = { alc883_init_verbs,
8326 alc883_2ch_fujitsu_pi2515_verbs},
8327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8328 .dac_nids = alc883_dac_nids,
8329 .dig_out_nid = ALC883_DIGOUT_NID,
8330 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8331 .channel_mode = alc883_3ST_2ch_modes,
8332 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8333 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8334 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8335 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008336};
8337
8338
8339/*
8340 * BIOS auto configuration
8341 */
8342static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8343 hda_nid_t nid, int pin_type,
8344 int dac_idx)
8345{
8346 /* set as output */
8347 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008348 int idx;
8349
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008350 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008351 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8352 idx = 4;
8353 else
8354 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008355 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8356
8357}
8358
8359static void alc883_auto_init_multi_out(struct hda_codec *codec)
8360{
8361 struct alc_spec *spec = codec->spec;
8362 int i;
8363
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008364 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008365 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008366 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008367 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008368 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008369 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008370 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008371 }
8372}
8373
8374static void alc883_auto_init_hp_out(struct hda_codec *codec)
8375{
8376 struct alc_spec *spec = codec->spec;
8377 hda_nid_t pin;
8378
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008379 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 if (pin) /* connect to front */
8381 /* use dac 0 */
8382 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008383 pin = spec->autocfg.speaker_pins[0];
8384 if (pin)
8385 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008386}
8387
8388#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8389#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8390
8391static void alc883_auto_init_analog_input(struct hda_codec *codec)
8392{
8393 struct alc_spec *spec = codec->spec;
8394 int i;
8395
8396 for (i = 0; i < AUTO_PIN_LAST; i++) {
8397 hda_nid_t nid = spec->autocfg.input_pins[i];
8398 if (alc883_is_input_pin(nid)) {
8399 snd_hda_codec_write(codec, nid, 0,
8400 AC_VERB_SET_PIN_WIDGET_CONTROL,
8401 (i <= AUTO_PIN_FRONT_MIC ?
8402 PIN_VREF80 : PIN_IN));
8403 if (nid != ALC883_PIN_CD_NID)
8404 snd_hda_codec_write(codec, nid, 0,
8405 AC_VERB_SET_AMP_GAIN_MUTE,
8406 AMP_OUT_MUTE);
8407 }
8408 }
8409}
8410
Takashi Iwaif511b012008-08-15 16:46:42 +02008411#define alc883_auto_init_input_src alc882_auto_init_input_src
8412
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008413/* almost identical with ALC880 parser... */
8414static int alc883_parse_auto_config(struct hda_codec *codec)
8415{
8416 struct alc_spec *spec = codec->spec;
8417 int err = alc880_parse_auto_config(codec);
8418
8419 if (err < 0)
8420 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008421 else if (!err)
8422 return 0; /* no config found */
8423
8424 err = alc_auto_add_mic_boost(codec);
8425 if (err < 0)
8426 return err;
8427
8428 /* hack - override the init verbs */
8429 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008430 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8431 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008432
8433 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008434}
8435
8436/* additional initialization for auto-configuration model */
8437static void alc883_auto_init(struct hda_codec *codec)
8438{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008439 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008440 alc883_auto_init_multi_out(codec);
8441 alc883_auto_init_hp_out(codec);
8442 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008443 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008444 if (spec->unsol_event)
8445 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008446}
8447
8448static int patch_alc883(struct hda_codec *codec)
8449{
8450 struct alc_spec *spec;
8451 int err, board_config;
8452
8453 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8454 if (spec == NULL)
8455 return -ENOMEM;
8456
8457 codec->spec = spec;
8458
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008459 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8460
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008461 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8462 alc883_models,
8463 alc883_cfg_tbl);
8464 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008465 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8466 "trying auto-probe from BIOS...\n");
8467 board_config = ALC883_AUTO;
8468 }
8469
8470 if (board_config == ALC883_AUTO) {
8471 /* automatic parse from the BIOS config */
8472 err = alc883_parse_auto_config(codec);
8473 if (err < 0) {
8474 alc_free(codec);
8475 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008476 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008477 printk(KERN_INFO
8478 "hda_codec: Cannot set up configuration "
8479 "from BIOS. Using base mode...\n");
8480 board_config = ALC883_3ST_2ch_DIG;
8481 }
8482 }
8483
8484 if (board_config != ALC883_AUTO)
8485 setup_preset(spec, &alc883_presets[board_config]);
8486
Kailang Yang2f893282008-05-27 12:14:47 +02008487 switch (codec->vendor_id) {
8488 case 0x10ec0888:
8489 spec->stream_name_analog = "ALC888 Analog";
8490 spec->stream_name_digital = "ALC888 Digital";
8491 break;
8492 case 0x10ec0889:
8493 spec->stream_name_analog = "ALC889 Analog";
8494 spec->stream_name_digital = "ALC889 Digital";
8495 break;
8496 default:
8497 spec->stream_name_analog = "ALC883 Analog";
8498 spec->stream_name_digital = "ALC883 Digital";
8499 break;
8500 }
8501
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008502 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8503 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008504 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008505
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008506 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8507 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8508
Takashi Iwaie1406342008-02-11 18:32:32 +01008509 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8510 spec->adc_nids = alc883_adc_nids;
8511 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008512
Takashi Iwai2134ea42008-01-10 16:53:55 +01008513 spec->vmaster_nid = 0x0c;
8514
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008515 codec->patch_ops = alc_patch_ops;
8516 if (board_config == ALC883_AUTO)
8517 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008518
Takashi Iwaicb53c622007-08-10 17:21:45 +02008519#ifdef CONFIG_SND_HDA_POWER_SAVE
8520 if (!spec->loopback.amplist)
8521 spec->loopback.amplist = alc883_loopbacks;
8522#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008523
8524 return 0;
8525}
8526
8527/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008528 * ALC262 support
8529 */
8530
8531#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8532#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8533
8534#define alc262_dac_nids alc260_dac_nids
8535#define alc262_adc_nids alc882_adc_nids
8536#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008537#define alc262_capsrc_nids alc882_capsrc_nids
8538#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008539
8540#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008541#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008542
Kailang Yang4e555fe2008-08-26 13:05:55 +02008543static hda_nid_t alc262_dmic_adc_nids[1] = {
8544 /* ADC0 */
8545 0x09
8546};
8547
8548static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8549
Kailang Yangdf694da2005-12-05 19:42:22 +01008550static struct snd_kcontrol_new alc262_base_mixer[] = {
8551 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8552 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8553 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8554 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8555 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008559 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008562 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008563 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008564 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8567 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8568 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008569 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008570};
8571
Kailang Yangccc656c2006-10-17 12:32:26 +02008572static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8573 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8574 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008581 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008582 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8583 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008584 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008585 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008586 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008587 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8589 { } /* end */
8590};
8591
Takashi Iwaice875f02008-01-28 18:17:43 +01008592/* update HP, line and mono-out pins according to the master switch */
8593static void alc262_hp_master_update(struct hda_codec *codec)
8594{
8595 struct alc_spec *spec = codec->spec;
8596 int val = spec->master_sw;
8597
8598 /* HP & line-out */
8599 snd_hda_codec_write_cache(codec, 0x1b, 0,
8600 AC_VERB_SET_PIN_WIDGET_CONTROL,
8601 val ? PIN_HP : 0);
8602 snd_hda_codec_write_cache(codec, 0x15, 0,
8603 AC_VERB_SET_PIN_WIDGET_CONTROL,
8604 val ? PIN_HP : 0);
8605 /* mono (speaker) depending on the HP jack sense */
8606 val = val && !spec->jack_present;
8607 snd_hda_codec_write_cache(codec, 0x16, 0,
8608 AC_VERB_SET_PIN_WIDGET_CONTROL,
8609 val ? PIN_OUT : 0);
8610}
8611
8612static void alc262_hp_bpc_automute(struct hda_codec *codec)
8613{
8614 struct alc_spec *spec = codec->spec;
8615 unsigned int presence;
8616 presence = snd_hda_codec_read(codec, 0x1b, 0,
8617 AC_VERB_GET_PIN_SENSE, 0);
8618 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8619 alc262_hp_master_update(codec);
8620}
8621
8622static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8623{
8624 if ((res >> 26) != ALC880_HP_EVENT)
8625 return;
8626 alc262_hp_bpc_automute(codec);
8627}
8628
8629static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8630{
8631 struct alc_spec *spec = codec->spec;
8632 unsigned int presence;
8633 presence = snd_hda_codec_read(codec, 0x15, 0,
8634 AC_VERB_GET_PIN_SENSE, 0);
8635 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8636 alc262_hp_master_update(codec);
8637}
8638
8639static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8640 unsigned int res)
8641{
8642 if ((res >> 26) != ALC880_HP_EVENT)
8643 return;
8644 alc262_hp_wildwest_automute(codec);
8645}
8646
8647static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8648 struct snd_ctl_elem_value *ucontrol)
8649{
8650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8651 struct alc_spec *spec = codec->spec;
8652 *ucontrol->value.integer.value = spec->master_sw;
8653 return 0;
8654}
8655
8656static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8657 struct snd_ctl_elem_value *ucontrol)
8658{
8659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8660 struct alc_spec *spec = codec->spec;
8661 int val = !!*ucontrol->value.integer.value;
8662
8663 if (val == spec->master_sw)
8664 return 0;
8665 spec->master_sw = val;
8666 alc262_hp_master_update(codec);
8667 return 1;
8668}
8669
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008670static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008671 {
8672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8673 .name = "Master Playback Switch",
8674 .info = snd_ctl_boolean_mono_info,
8675 .get = alc262_hp_master_sw_get,
8676 .put = alc262_hp_master_sw_put,
8677 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008678 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8679 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8680 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008681 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8682 HDA_OUTPUT),
8683 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8684 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008687 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008688 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8689 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008690 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8692 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8693 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8694 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8695 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8696 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8697 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8698 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8699 { } /* end */
8700};
8701
Kailang Yangcd7509a2007-01-26 18:33:17 +01008702static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008703 {
8704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8705 .name = "Master Playback Switch",
8706 .info = snd_ctl_boolean_mono_info,
8707 .get = alc262_hp_master_sw_get,
8708 .put = alc262_hp_master_sw_put,
8709 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008710 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8711 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8712 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008714 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8715 HDA_OUTPUT),
8716 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8717 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008718 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8719 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008720 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8723 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8724 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8725 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8726 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8727 { } /* end */
8728};
8729
8730static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8731 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8732 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008733 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008734 { } /* end */
8735};
8736
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008737/* mute/unmute internal speaker according to the hp jack and mute state */
8738static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8739{
8740 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008741
8742 if (force || !spec->sense_updated) {
8743 unsigned int present;
8744 present = snd_hda_codec_read(codec, 0x15, 0,
8745 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008746 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008747 spec->sense_updated = 1;
8748 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008749 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8750 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008751}
8752
8753static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8754 unsigned int res)
8755{
8756 if ((res >> 26) != ALC880_HP_EVENT)
8757 return;
8758 alc262_hp_t5735_automute(codec, 1);
8759}
8760
8761static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8762{
8763 alc262_hp_t5735_automute(codec, 1);
8764}
8765
8766static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008767 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008769 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8774 { } /* end */
8775};
8776
8777static struct hda_verb alc262_hp_t5735_verbs[] = {
8778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8780
8781 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8782 { }
8783};
8784
Kailang Yang8c427222008-01-10 13:03:59 +01008785static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008786 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8787 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008788 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8789 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8792 { } /* end */
8793};
8794
8795static struct hda_verb alc262_hp_rp5700_verbs[] = {
8796 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8801 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8806 {}
8807};
8808
8809static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8810 .num_items = 1,
8811 .items = {
8812 { "Line", 0x1 },
8813 },
8814};
8815
Takashi Iwai0724ea22007-08-23 00:31:43 +02008816/* bind hp and internal speaker mute (with plug check) */
8817static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8818 struct snd_ctl_elem_value *ucontrol)
8819{
8820 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8821 long *valp = ucontrol->value.integer.value;
8822 int change;
8823
8824 /* change hp mute */
8825 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8826 HDA_AMP_MUTE,
8827 valp[0] ? 0 : HDA_AMP_MUTE);
8828 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8829 HDA_AMP_MUTE,
8830 valp[1] ? 0 : HDA_AMP_MUTE);
8831 if (change) {
8832 /* change speaker according to HP jack state */
8833 struct alc_spec *spec = codec->spec;
8834 unsigned int mute;
8835 if (spec->jack_present)
8836 mute = HDA_AMP_MUTE;
8837 else
8838 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8839 HDA_OUTPUT, 0);
8840 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8841 HDA_AMP_MUTE, mute);
8842 }
8843 return change;
8844}
Takashi Iwai5b319542007-07-26 11:49:22 +02008845
Kailang Yang272a5272007-05-14 11:00:38 +02008846static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008847 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8848 {
8849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8850 .name = "Master Playback Switch",
8851 .info = snd_hda_mixer_amp_switch_info,
8852 .get = snd_hda_mixer_amp_switch_get,
8853 .put = alc262_sony_master_sw_put,
8854 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8855 },
Kailang Yang272a5272007-05-14 11:00:38 +02008856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8859 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8860 { } /* end */
8861};
8862
Kailang Yang83c34212007-07-05 11:43:05 +02008863static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8869 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8870 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8871 { } /* end */
8872};
Kailang Yang272a5272007-05-14 11:00:38 +02008873
Kailang Yangdf694da2005-12-05 19:42:22 +01008874#define alc262_capture_mixer alc882_capture_mixer
8875#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8876
8877/*
8878 * generic initialization of ADC, input mixers and output mixers
8879 */
8880static struct hda_verb alc262_init_verbs[] = {
8881 /*
8882 * Unmute ADC0-2 and set the default input to mic-in
8883 */
8884 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8886 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890
Takashi Iwaicb53c622007-08-10 17:21:45 +02008891 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008892 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008893 * Note: PASD motherboards uses the Line In 2 as the input for
8894 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008895 */
8896 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008902
8903 /*
8904 * Set up output mixers (0x0c - 0x0e)
8905 */
8906 /* set vol=0 to output mixers */
8907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910 /* set up input amps for analog loopback */
8911 /* Amp Indices: DAC = 0, mixer = 1 */
8912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918
8919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8922 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8923 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8924 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8925
8926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02008931
Kailang Yangdf694da2005-12-05 19:42:22 +01008932 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02008934
Kailang Yangdf694da2005-12-05 19:42:22 +01008935 /* FIXME: use matrix-type input source selection */
8936 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8937 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8938 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8942 /* Input mixer2 */
8943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8947 /* Input mixer3 */
8948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008952
8953 { }
8954};
8955
Kailang Yang4e555fe2008-08-26 13:05:55 +02008956static struct hda_verb alc262_eapd_verbs[] = {
8957 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8958 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8959 { }
8960};
8961
Kailang Yangccc656c2006-10-17 12:32:26 +02008962static struct hda_verb alc262_hippo_unsol_verbs[] = {
8963 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8965 {}
8966};
8967
8968static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8969 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8970 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8971 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8972
8973 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8975 {}
8976};
8977
Kailang Yang272a5272007-05-14 11:00:38 +02008978static struct hda_verb alc262_sony_unsol_verbs[] = {
8979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8981 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8982
8983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008985 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008986};
8987
Kailang Yang4e555fe2008-08-26 13:05:55 +02008988static struct hda_input_mux alc262_dmic_capture_source = {
8989 .num_items = 2,
8990 .items = {
8991 { "Int DMic", 0x9 },
8992 { "Mic", 0x0 },
8993 },
8994};
8995
8996static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
8997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9002 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9003 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9004 {
9005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9006 /* The multiple "Capture Source" controls confuse alsamixer
9007 * So call somewhat different..
9008 */
9009 /* .name = "Capture Source", */
9010 .name = "Input Source",
9011 .count = 1,
9012 .info = alc_mux_enum_info,
9013 .get = alc_mux_enum_get,
9014 .put = alc_mux_enum_put,
9015 },
9016 { } /* end */
9017};
9018
9019static struct hda_verb alc262_toshiba_s06_verbs[] = {
9020 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9023 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9024 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9026 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9027 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9028 {}
9029};
9030
9031static void alc262_dmic_automute(struct hda_codec *codec)
9032{
9033 unsigned int present;
9034
9035 present = snd_hda_codec_read(codec, 0x18, 0,
9036 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9037 snd_hda_codec_write(codec, 0x22, 0,
9038 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9039}
9040
9041/* toggle speaker-output according to the hp-jack state */
9042static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9043{
9044 unsigned int present;
9045 unsigned char bits;
9046
9047 present = snd_hda_codec_read(codec, 0x15, 0,
9048 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9049 bits = present ? 0 : PIN_OUT;
9050 snd_hda_codec_write(codec, 0x14, 0,
9051 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9052}
9053
9054
9055
9056/* unsolicited event for HP jack sensing */
9057static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9058 unsigned int res)
9059{
9060 if ((res >> 26) == ALC880_HP_EVENT)
9061 alc262_toshiba_s06_speaker_automute(codec);
9062 if ((res >> 26) == ALC880_MIC_EVENT)
9063 alc262_dmic_automute(codec);
9064
9065}
9066
9067static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9068{
9069 alc262_toshiba_s06_speaker_automute(codec);
9070 alc262_dmic_automute(codec);
9071}
9072
Kailang Yangccc656c2006-10-17 12:32:26 +02009073/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009074static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009075{
9076 struct alc_spec *spec = codec->spec;
9077 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009078 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009079
Takashi Iwai5b319542007-07-26 11:49:22 +02009080 /* need to execute and sync at first */
9081 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9082 present = snd_hda_codec_read(codec, 0x15, 0,
9083 AC_VERB_GET_PIN_SENSE, 0);
9084 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009085 if (spec->jack_present) {
9086 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009087 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9088 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009089 } else {
9090 /* unmute internal speaker if necessary */
9091 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009092 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9093 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009094 }
9095}
9096
9097/* unsolicited event for HP jack sensing */
9098static void alc262_hippo_unsol_event(struct hda_codec *codec,
9099 unsigned int res)
9100{
9101 if ((res >> 26) != ALC880_HP_EVENT)
9102 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009103 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009104}
9105
Takashi Iwai5b319542007-07-26 11:49:22 +02009106static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009107{
Kailang Yangccc656c2006-10-17 12:32:26 +02009108 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009109 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009110
Takashi Iwai5b319542007-07-26 11:49:22 +02009111 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9112 present = snd_hda_codec_read(codec, 0x1b, 0,
9113 AC_VERB_GET_PIN_SENSE, 0);
9114 present = (present & 0x80000000) != 0;
9115 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009116 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009117 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9118 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009119 } else {
9120 /* unmute internal speaker if necessary */
9121 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009122 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9123 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009124 }
9125}
9126
9127/* unsolicited event for HP jack sensing */
9128static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9129 unsigned int res)
9130{
9131 if ((res >> 26) != ALC880_HP_EVENT)
9132 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009133 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009134}
9135
Takashi Iwai834be882006-03-01 14:16:17 +01009136/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009137 * nec model
9138 * 0x15 = headphone
9139 * 0x16 = internal speaker
9140 * 0x18 = external mic
9141 */
9142
9143static struct snd_kcontrol_new alc262_nec_mixer[] = {
9144 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9145 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9146
9147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9148 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9149 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9150
9151 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9153 { } /* end */
9154};
9155
9156static struct hda_verb alc262_nec_verbs[] = {
9157 /* Unmute Speaker */
9158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9159
9160 /* Headphone */
9161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9163
9164 /* External mic to headphone */
9165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9166 /* External mic to speaker */
9167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9168 {}
9169};
9170
9171/*
Takashi Iwai834be882006-03-01 14:16:17 +01009172 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009173 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9174 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009175 */
9176
9177#define ALC_HP_EVENT 0x37
9178
9179static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9180 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009182 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009184 {}
9185};
9186
Jiang zhe0e31daf2008-03-20 12:12:39 +01009187static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9188 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9189 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9190 {}
9191};
9192
Takashi Iwai834be882006-03-01 14:16:17 +01009193static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009194 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009195 .items = {
9196 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009197 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009198 { "CD", 0x4 },
9199 },
9200};
9201
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009202static struct hda_input_mux alc262_HP_capture_source = {
9203 .num_items = 5,
9204 .items = {
9205 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009206 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009207 { "Line", 0x2 },
9208 { "CD", 0x4 },
9209 { "AUX IN", 0x6 },
9210 },
9211};
9212
zhejiangaccbe492007-08-31 12:36:05 +02009213static struct hda_input_mux alc262_HP_D7000_capture_source = {
9214 .num_items = 4,
9215 .items = {
9216 { "Mic", 0x0 },
9217 { "Front Mic", 0x2 },
9218 { "Line", 0x1 },
9219 { "CD", 0x4 },
9220 },
9221};
9222
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009223/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009224static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9225{
9226 struct alc_spec *spec = codec->spec;
9227 unsigned int mute;
9228
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009229 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009230 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009231 /* need to execute and sync at first */
9232 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009233 /* check laptop HP jack */
9234 present = snd_hda_codec_read(codec, 0x14, 0,
9235 AC_VERB_GET_PIN_SENSE, 0);
9236 /* need to execute and sync at first */
9237 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9238 /* check docking HP jack */
9239 present |= snd_hda_codec_read(codec, 0x1b, 0,
9240 AC_VERB_GET_PIN_SENSE, 0);
9241 if (present & AC_PINSENSE_PRESENCE)
9242 spec->jack_present = 1;
9243 else
9244 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009245 spec->sense_updated = 1;
9246 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009247 /* unmute internal speaker only if both HPs are unplugged and
9248 * master switch is on
9249 */
9250 if (spec->jack_present)
9251 mute = HDA_AMP_MUTE;
9252 else
Takashi Iwai834be882006-03-01 14:16:17 +01009253 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009254 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9255 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009256}
9257
9258/* unsolicited event for HP jack sensing */
9259static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9260 unsigned int res)
9261{
9262 if ((res >> 26) != ALC_HP_EVENT)
9263 return;
9264 alc262_fujitsu_automute(codec, 1);
9265}
9266
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009267static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9268{
9269 alc262_fujitsu_automute(codec, 1);
9270}
9271
Takashi Iwai834be882006-03-01 14:16:17 +01009272/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009273static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9274 .ops = &snd_hda_bind_vol,
9275 .values = {
9276 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9277 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9278 0
9279 },
9280};
Takashi Iwai834be882006-03-01 14:16:17 +01009281
Jiang zhe0e31daf2008-03-20 12:12:39 +01009282/* mute/unmute internal speaker according to the hp jack and mute state */
9283static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9284{
9285 struct alc_spec *spec = codec->spec;
9286 unsigned int mute;
9287
9288 if (force || !spec->sense_updated) {
9289 unsigned int present_int_hp;
9290 /* need to execute and sync at first */
9291 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9292 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9293 AC_VERB_GET_PIN_SENSE, 0);
9294 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9295 spec->sense_updated = 1;
9296 }
9297 if (spec->jack_present) {
9298 /* mute internal speaker */
9299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9300 HDA_AMP_MUTE, HDA_AMP_MUTE);
9301 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9302 HDA_AMP_MUTE, HDA_AMP_MUTE);
9303 } else {
9304 /* unmute internal speaker if necessary */
9305 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9306 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9307 HDA_AMP_MUTE, mute);
9308 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9309 HDA_AMP_MUTE, mute);
9310 }
9311}
9312
9313/* unsolicited event for HP jack sensing */
9314static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9315 unsigned int res)
9316{
9317 if ((res >> 26) != ALC_HP_EVENT)
9318 return;
9319 alc262_lenovo_3000_automute(codec, 1);
9320}
9321
Takashi Iwai834be882006-03-01 14:16:17 +01009322/* bind hp and internal speaker mute (with plug check) */
9323static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9324 struct snd_ctl_elem_value *ucontrol)
9325{
9326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9327 long *valp = ucontrol->value.integer.value;
9328 int change;
9329
Tony Vroon5d9fab22008-03-14 17:09:18 +01009330 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9331 HDA_AMP_MUTE,
9332 valp ? 0 : HDA_AMP_MUTE);
9333 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9334 HDA_AMP_MUTE,
9335 valp ? 0 : HDA_AMP_MUTE);
9336
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009337 if (change)
9338 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009339 return change;
9340}
9341
9342static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009343 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009344 {
9345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9346 .name = "Master Playback Switch",
9347 .info = snd_hda_mixer_amp_switch_info,
9348 .get = snd_hda_mixer_amp_switch_get,
9349 .put = alc262_fujitsu_master_sw_put,
9350 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9351 },
9352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009354 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9355 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009359 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9360 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9361 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009362 { } /* end */
9363};
9364
Jiang zhe0e31daf2008-03-20 12:12:39 +01009365/* bind hp and internal speaker mute (with plug check) */
9366static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9367 struct snd_ctl_elem_value *ucontrol)
9368{
9369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9370 long *valp = ucontrol->value.integer.value;
9371 int change;
9372
9373 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9374 HDA_AMP_MUTE,
9375 valp ? 0 : HDA_AMP_MUTE);
9376
9377 if (change)
9378 alc262_lenovo_3000_automute(codec, 0);
9379 return change;
9380}
9381
9382static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9383 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9384 {
9385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9386 .name = "Master Playback Switch",
9387 .info = snd_hda_mixer_amp_switch_info,
9388 .get = snd_hda_mixer_amp_switch_get,
9389 .put = alc262_lenovo_3000_master_sw_put,
9390 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9391 },
9392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9397 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9398 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9399 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9400 { } /* end */
9401};
9402
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009403/* additional init verbs for Benq laptops */
9404static struct hda_verb alc262_EAPD_verbs[] = {
9405 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9406 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9407 {}
9408};
9409
Kailang Yang83c34212007-07-05 11:43:05 +02009410static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9412 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9413
9414 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9415 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9416 {}
9417};
9418
Tobin Davisf651b502007-10-26 12:40:47 +02009419/* Samsung Q1 Ultra Vista model setup */
9420static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009421 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9422 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9425 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009426 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009427 { } /* end */
9428};
9429
9430static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009431 /* output mixer */
9432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9435 /* speaker */
9436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9439 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9440 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9444 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9445 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9446 /* internal mic */
9447 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9449 /* ADC, choose mic */
9450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009460 {}
9461};
9462
Tobin Davisf651b502007-10-26 12:40:47 +02009463/* mute/unmute internal speaker according to the hp jack and mute state */
9464static void alc262_ultra_automute(struct hda_codec *codec)
9465{
9466 struct alc_spec *spec = codec->spec;
9467 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009468
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009469 mute = 0;
9470 /* auto-mute only when HP is used as HP */
9471 if (!spec->cur_mux[0]) {
9472 unsigned int present;
9473 /* need to execute and sync at first */
9474 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9475 present = snd_hda_codec_read(codec, 0x15, 0,
9476 AC_VERB_GET_PIN_SENSE, 0);
9477 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9478 if (spec->jack_present)
9479 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009480 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009481 /* mute/unmute internal speaker */
9482 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9483 HDA_AMP_MUTE, mute);
9484 /* mute/unmute HP */
9485 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9486 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009487}
9488
9489/* unsolicited event for HP jack sensing */
9490static void alc262_ultra_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) != ALC880_HP_EVENT)
9494 return;
9495 alc262_ultra_automute(codec);
9496}
9497
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009498static struct hda_input_mux alc262_ultra_capture_source = {
9499 .num_items = 2,
9500 .items = {
9501 { "Mic", 0x1 },
9502 { "Headphone", 0x7 },
9503 },
9504};
9505
9506static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9507 struct snd_ctl_elem_value *ucontrol)
9508{
9509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9510 struct alc_spec *spec = codec->spec;
9511 int ret;
9512
9513 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9514 if (!ret)
9515 return 0;
9516 /* reprogram the HP pin as mic or HP according to the input source */
9517 snd_hda_codec_write_cache(codec, 0x15, 0,
9518 AC_VERB_SET_PIN_WIDGET_CONTROL,
9519 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9520 alc262_ultra_automute(codec); /* mute/unmute HP */
9521 return ret;
9522}
9523
9524static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9525 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9526 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9527 {
9528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9529 .name = "Capture Source",
9530 .info = alc882_mux_enum_info,
9531 .get = alc882_mux_enum_get,
9532 .put = alc262_ultra_mux_enum_put,
9533 },
9534 { } /* end */
9535};
9536
Kailang Yangdf694da2005-12-05 19:42:22 +01009537/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009538static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9539 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009540{
9541 hda_nid_t nid;
9542 int err;
9543
9544 spec->multiout.num_dacs = 1; /* only use one dac */
9545 spec->multiout.dac_nids = spec->private_dac_nids;
9546 spec->multiout.dac_nids[0] = 2;
9547
9548 nid = cfg->line_out_pins[0];
9549 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009550 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9551 "Front Playback Volume",
9552 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9553 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009555 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9556 "Front Playback Switch",
9557 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9558 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009559 return err;
9560 }
9561
Takashi Iwai82bc9552006-03-21 11:24:42 +01009562 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009563 if (nid) {
9564 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009565 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9566 "Speaker Playback Volume",
9567 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9568 HDA_OUTPUT));
9569 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009570 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009571 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9572 "Speaker Playback Switch",
9573 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9574 HDA_OUTPUT));
9575 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009576 return err;
9577 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9579 "Speaker Playback Switch",
9580 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9581 HDA_OUTPUT));
9582 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009583 return err;
9584 }
9585 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009586 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009587 if (nid) {
9588 /* spec->multiout.hp_nid = 2; */
9589 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009590 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9591 "Headphone Playback Volume",
9592 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9593 HDA_OUTPUT));
9594 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009596 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9597 "Headphone Playback Switch",
9598 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9599 HDA_OUTPUT));
9600 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009601 return err;
9602 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009603 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9604 "Headphone Playback Switch",
9605 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9606 HDA_OUTPUT));
9607 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009608 return err;
9609 }
9610 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009611 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009612}
9613
9614/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009615#define alc262_auto_create_analog_input_ctls \
9616 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009617
9618/*
9619 * generic initialization of ADC, input mixers and output mixers
9620 */
9621static struct hda_verb alc262_volume_init_verbs[] = {
9622 /*
9623 * Unmute ADC0-2 and set the default input to mic-in
9624 */
9625 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9627 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631
Takashi Iwaicb53c622007-08-10 17:21:45 +02009632 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009633 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009634 * Note: PASD motherboards uses the Line In 2 as the input for
9635 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009636 */
9637 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009643
9644 /*
9645 * Set up output mixers (0x0c - 0x0f)
9646 */
9647 /* set vol=0 to output mixers */
9648 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009651
Kailang Yangdf694da2005-12-05 19:42:22 +01009652 /* set up input amps for analog loopback */
9653 /* Amp Indices: DAC = 0, mixer = 1 */
9654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9660
9661 /* FIXME: use matrix-type input source selection */
9662 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9663 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9668 /* Input mixer2 */
9669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9673 /* Input mixer3 */
9674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9678
9679 { }
9680};
9681
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009682static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9683 /*
9684 * Unmute ADC0-2 and set the default input to mic-in
9685 */
9686 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9688 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9689 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9690 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9691 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9692
Takashi Iwaicb53c622007-08-10 17:21:45 +02009693 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009694 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009695 * Note: PASD motherboards uses the Line In 2 as the input for
9696 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009697 */
9698 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009706
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009707 /*
9708 * Set up output mixers (0x0c - 0x0e)
9709 */
9710 /* set vol=0 to output mixers */
9711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9714
9715 /* set up input amps for analog loopback */
9716 /* Amp Indices: DAC = 0, mixer = 1 */
9717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9719 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9721 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9723
Takashi Iwaice875f02008-01-28 18:17:43 +01009724 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9726 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9727
9728 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9730
9731 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9732 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9733
9734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9738 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9739
9740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9744 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9745 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9746
9747
9748 /* FIXME: use matrix-type input source selection */
9749 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9750 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9755 /* Input mixer2 */
9756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9760 /* Input mixer3 */
9761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9765
Takashi Iwaice875f02008-01-28 18:17:43 +01009766 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9767
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009768 { }
9769};
9770
Kailang Yangcd7509a2007-01-26 18:33:17 +01009771static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9772 /*
9773 * Unmute ADC0-2 and set the default input to mic-in
9774 */
9775 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9776 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9777 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9779 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9780 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9781
Takashi Iwaicb53c622007-08-10 17:21:45 +02009782 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009783 * mixer widget
9784 * Note: PASD motherboards uses the Line In 2 as the input for front
9785 * panel mic (mic 2)
9786 */
9787 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9789 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9790 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009796 /*
9797 * Set up output mixers (0x0c - 0x0e)
9798 */
9799 /* set vol=0 to output mixers */
9800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9803
9804 /* set up input amps for analog loopback */
9805 /* Amp Indices: DAC = 0, mixer = 1 */
9806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9810 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9812
9813
9814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9817 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9818 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9819 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9820 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9821
9822 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9824
9825 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9827
9828 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9830 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9832 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9833 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9834
9835 /* FIXME: use matrix-type input source selection */
9836 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9837 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9843 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9845 /* Input mixer2 */
9846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9851 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9853 /* Input mixer3 */
9854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9859 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9861
Takashi Iwaice875f02008-01-28 18:17:43 +01009862 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9863
Kailang Yangcd7509a2007-01-26 18:33:17 +01009864 { }
9865};
9866
Takashi Iwaicb53c622007-08-10 17:21:45 +02009867#ifdef CONFIG_SND_HDA_POWER_SAVE
9868#define alc262_loopbacks alc880_loopbacks
9869#endif
9870
Kailang Yangdf694da2005-12-05 19:42:22 +01009871/* pcm configuration: identiacal with ALC880 */
9872#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9873#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9874#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9875#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9876
9877/*
9878 * BIOS auto configuration
9879 */
9880static int alc262_parse_auto_config(struct hda_codec *codec)
9881{
9882 struct alc_spec *spec = codec->spec;
9883 int err;
9884 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9885
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009886 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9887 alc262_ignore);
9888 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009889 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009890 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009891 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009892 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9893 if (err < 0)
9894 return err;
9895 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9896 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009897 return err;
9898
9899 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9900
9901 if (spec->autocfg.dig_out_pin)
9902 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9903 if (spec->autocfg.dig_in_pin)
9904 spec->dig_in_nid = ALC262_DIGIN_NID;
9905
9906 if (spec->kctl_alloc)
9907 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9908
9909 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009910 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009911 spec->input_mux = &spec->private_imux;
9912
Takashi Iwai776e1842007-08-29 15:07:11 +02009913 err = alc_auto_add_mic_boost(codec);
9914 if (err < 0)
9915 return err;
9916
Kailang Yangdf694da2005-12-05 19:42:22 +01009917 return 1;
9918}
9919
9920#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9921#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9922#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +02009923#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +01009924
9925
9926/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009927static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009928{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009929 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009930 alc262_auto_init_multi_out(codec);
9931 alc262_auto_init_hp_out(codec);
9932 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009933 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009934 if (spec->unsol_event)
9935 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009936}
9937
9938/*
9939 * configuration and preset
9940 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009941static const char *alc262_models[ALC262_MODEL_LAST] = {
9942 [ALC262_BASIC] = "basic",
9943 [ALC262_HIPPO] = "hippo",
9944 [ALC262_HIPPO_1] = "hippo_1",
9945 [ALC262_FUJITSU] = "fujitsu",
9946 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009947 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009948 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009949 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009950 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009951 [ALC262_BENQ_T31] = "benq-t31",
9952 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009953 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009954 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009955 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009956 [ALC262_AUTO] = "auto",
9957};
9958
9959static struct snd_pci_quirk alc262_cfg_tbl[] = {
9960 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009961 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009962 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009963 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009964 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9965 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009966 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009967 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009968 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009969 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009970 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009971 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009972 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009973 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009974 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009975 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009976 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009977 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009978 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9979 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9980 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009981 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9982 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009983 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009984 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009985 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009986 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9987 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9988 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009989 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9990 ALC262_SONY_ASSAMD),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009991 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009992 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009993 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009994 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009995 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009996 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009997 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009998 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009999 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010000 {}
10001};
10002
10003static struct alc_config_preset alc262_presets[] = {
10004 [ALC262_BASIC] = {
10005 .mixers = { alc262_base_mixer },
10006 .init_verbs = { alc262_init_verbs },
10007 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10008 .dac_nids = alc262_dac_nids,
10009 .hp_nid = 0x03,
10010 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10011 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010012 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010013 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010014 [ALC262_HIPPO] = {
10015 .mixers = { alc262_base_mixer },
10016 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10018 .dac_nids = alc262_dac_nids,
10019 .hp_nid = 0x03,
10020 .dig_out_nid = ALC262_DIGOUT_NID,
10021 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10022 .channel_mode = alc262_modes,
10023 .input_mux = &alc262_capture_source,
10024 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010025 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010026 },
10027 [ALC262_HIPPO_1] = {
10028 .mixers = { alc262_hippo1_mixer },
10029 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10030 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10031 .dac_nids = alc262_dac_nids,
10032 .hp_nid = 0x02,
10033 .dig_out_nid = ALC262_DIGOUT_NID,
10034 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10035 .channel_mode = alc262_modes,
10036 .input_mux = &alc262_capture_source,
10037 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010038 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010039 },
Takashi Iwai834be882006-03-01 14:16:17 +010010040 [ALC262_FUJITSU] = {
10041 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010042 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10043 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010044 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10045 .dac_nids = alc262_dac_nids,
10046 .hp_nid = 0x03,
10047 .dig_out_nid = ALC262_DIGOUT_NID,
10048 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10049 .channel_mode = alc262_modes,
10050 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010051 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010052 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010053 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054 [ALC262_HP_BPC] = {
10055 .mixers = { alc262_HP_BPC_mixer },
10056 .init_verbs = { alc262_HP_BPC_init_verbs },
10057 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10058 .dac_nids = alc262_dac_nids,
10059 .hp_nid = 0x03,
10060 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10061 .channel_mode = alc262_modes,
10062 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010063 .unsol_event = alc262_hp_bpc_unsol_event,
10064 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010065 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010066 [ALC262_HP_BPC_D7000_WF] = {
10067 .mixers = { alc262_HP_BPC_WildWest_mixer },
10068 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10069 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10070 .dac_nids = alc262_dac_nids,
10071 .hp_nid = 0x03,
10072 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10073 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010074 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010075 .unsol_event = alc262_hp_wildwest_unsol_event,
10076 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010077 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010078 [ALC262_HP_BPC_D7000_WL] = {
10079 .mixers = { alc262_HP_BPC_WildWest_mixer,
10080 alc262_HP_BPC_WildWest_option_mixer },
10081 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10082 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10083 .dac_nids = alc262_dac_nids,
10084 .hp_nid = 0x03,
10085 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10086 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010087 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010088 .unsol_event = alc262_hp_wildwest_unsol_event,
10089 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010090 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010091 [ALC262_HP_TC_T5735] = {
10092 .mixers = { alc262_hp_t5735_mixer },
10093 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10094 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10095 .dac_nids = alc262_dac_nids,
10096 .hp_nid = 0x03,
10097 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10098 .channel_mode = alc262_modes,
10099 .input_mux = &alc262_capture_source,
10100 .unsol_event = alc262_hp_t5735_unsol_event,
10101 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010102 },
10103 [ALC262_HP_RP5700] = {
10104 .mixers = { alc262_hp_rp5700_mixer },
10105 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10106 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10107 .dac_nids = alc262_dac_nids,
10108 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10109 .channel_mode = alc262_modes,
10110 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010111 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010112 [ALC262_BENQ_ED8] = {
10113 .mixers = { alc262_base_mixer },
10114 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10115 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10116 .dac_nids = alc262_dac_nids,
10117 .hp_nid = 0x03,
10118 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10119 .channel_mode = alc262_modes,
10120 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010121 },
Kailang Yang272a5272007-05-14 11:00:38 +020010122 [ALC262_SONY_ASSAMD] = {
10123 .mixers = { alc262_sony_mixer },
10124 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10125 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10126 .dac_nids = alc262_dac_nids,
10127 .hp_nid = 0x02,
10128 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10129 .channel_mode = alc262_modes,
10130 .input_mux = &alc262_capture_source,
10131 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010132 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010133 },
10134 [ALC262_BENQ_T31] = {
10135 .mixers = { alc262_benq_t31_mixer },
10136 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10137 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10138 .dac_nids = alc262_dac_nids,
10139 .hp_nid = 0x03,
10140 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10141 .channel_mode = alc262_modes,
10142 .input_mux = &alc262_capture_source,
10143 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010144 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010145 },
Tobin Davisf651b502007-10-26 12:40:47 +020010146 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010147 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10148 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010149 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10150 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010151 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10152 .channel_mode = alc262_modes,
10153 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010154 .adc_nids = alc262_adc_nids, /* ADC0 */
10155 .capsrc_nids = alc262_capsrc_nids,
10156 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010157 .unsol_event = alc262_ultra_unsol_event,
10158 .init_hook = alc262_ultra_automute,
10159 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010160 [ALC262_LENOVO_3000] = {
10161 .mixers = { alc262_lenovo_3000_mixer },
10162 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10163 alc262_lenovo_3000_unsol_verbs },
10164 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10165 .dac_nids = alc262_dac_nids,
10166 .hp_nid = 0x03,
10167 .dig_out_nid = ALC262_DIGOUT_NID,
10168 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10169 .channel_mode = alc262_modes,
10170 .input_mux = &alc262_fujitsu_capture_source,
10171 .unsol_event = alc262_lenovo_3000_unsol_event,
10172 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010173 [ALC262_NEC] = {
10174 .mixers = { alc262_nec_mixer },
10175 .init_verbs = { alc262_nec_verbs },
10176 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10177 .dac_nids = alc262_dac_nids,
10178 .hp_nid = 0x03,
10179 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10180 .channel_mode = alc262_modes,
10181 .input_mux = &alc262_capture_source,
10182 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010183 [ALC262_TOSHIBA_S06] = {
10184 .mixers = { alc262_toshiba_s06_mixer },
10185 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10186 alc262_eapd_verbs },
10187 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10188 .capsrc_nids = alc262_dmic_capsrc_nids,
10189 .dac_nids = alc262_dac_nids,
10190 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10191 .dig_out_nid = ALC262_DIGOUT_NID,
10192 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10193 .channel_mode = alc262_modes,
10194 .input_mux = &alc262_dmic_capture_source,
10195 .unsol_event = alc262_toshiba_s06_unsol_event,
10196 .init_hook = alc262_toshiba_s06_init_hook,
10197 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010198};
10199
10200static int patch_alc262(struct hda_codec *codec)
10201{
10202 struct alc_spec *spec;
10203 int board_config;
10204 int err;
10205
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010206 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010207 if (spec == NULL)
10208 return -ENOMEM;
10209
10210 codec->spec = spec;
10211#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010212 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10213 * under-run
10214 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010215 {
10216 int tmp;
10217 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10218 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10219 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10220 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10221 }
10222#endif
10223
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010224 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10225
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010226 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10227 alc262_models,
10228 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010229
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010230 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010231 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10232 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010233 board_config = ALC262_AUTO;
10234 }
10235
10236 if (board_config == ALC262_AUTO) {
10237 /* automatic parse from the BIOS config */
10238 err = alc262_parse_auto_config(codec);
10239 if (err < 0) {
10240 alc_free(codec);
10241 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010242 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010243 printk(KERN_INFO
10244 "hda_codec: Cannot set up configuration "
10245 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010246 board_config = ALC262_BASIC;
10247 }
10248 }
10249
10250 if (board_config != ALC262_AUTO)
10251 setup_preset(spec, &alc262_presets[board_config]);
10252
10253 spec->stream_name_analog = "ALC262 Analog";
10254 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10255 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010256
Kailang Yangdf694da2005-12-05 19:42:22 +010010257 spec->stream_name_digital = "ALC262 Digital";
10258 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10259 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10260
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010261 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010262 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010263 unsigned int wcap = get_wcaps(codec, 0x07);
10264
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010265 /* get type */
10266 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010267 if (wcap != AC_WID_AUD_IN) {
10268 spec->adc_nids = alc262_adc_nids_alt;
10269 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010270 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010271 spec->mixers[spec->num_mixers] =
10272 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010273 spec->num_mixers++;
10274 } else {
10275 spec->adc_nids = alc262_adc_nids;
10276 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010277 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010278 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10279 spec->num_mixers++;
10280 }
10281 }
10282
Takashi Iwai2134ea42008-01-10 16:53:55 +010010283 spec->vmaster_nid = 0x0c;
10284
Kailang Yangdf694da2005-12-05 19:42:22 +010010285 codec->patch_ops = alc_patch_ops;
10286 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010287 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010288#ifdef CONFIG_SND_HDA_POWER_SAVE
10289 if (!spec->loopback.amplist)
10290 spec->loopback.amplist = alc262_loopbacks;
10291#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010292
Kailang Yangdf694da2005-12-05 19:42:22 +010010293 return 0;
10294}
10295
Kailang Yangdf694da2005-12-05 19:42:22 +010010296/*
Kailang Yanga361d842007-06-05 12:30:55 +020010297 * ALC268 channel source setting (2 channel)
10298 */
10299#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10300#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010301
Kailang Yanga361d842007-06-05 12:30:55 +020010302static hda_nid_t alc268_dac_nids[2] = {
10303 /* front, hp */
10304 0x02, 0x03
10305};
10306
10307static hda_nid_t alc268_adc_nids[2] = {
10308 /* ADC0-1 */
10309 0x08, 0x07
10310};
10311
10312static hda_nid_t alc268_adc_nids_alt[1] = {
10313 /* ADC0 */
10314 0x08
10315};
10316
Takashi Iwaie1406342008-02-11 18:32:32 +010010317static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10318
Kailang Yanga361d842007-06-05 12:30:55 +020010319static struct snd_kcontrol_new alc268_base_mixer[] = {
10320 /* output mixer control */
10321 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10322 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10326 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10327 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010328 { }
10329};
10330
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010331/* bind Beep switches of both NID 0x0f and 0x10 */
10332static struct hda_bind_ctls alc268_bind_beep_sw = {
10333 .ops = &snd_hda_bind_sw,
10334 .values = {
10335 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10336 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10337 0
10338 },
10339};
10340
10341static struct snd_kcontrol_new alc268_beep_mixer[] = {
10342 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10343 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10344 { }
10345};
10346
Kailang Yangd1a991a2007-08-15 16:21:59 +020010347static struct hda_verb alc268_eapd_verbs[] = {
10348 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10349 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10350 { }
10351};
10352
Takashi Iwaid2738092007-08-16 14:59:45 +020010353/* Toshiba specific */
10354#define alc268_toshiba_automute alc262_hippo_automute
10355
10356static struct hda_verb alc268_toshiba_verbs[] = {
10357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10358 { } /* end */
10359};
10360
10361/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010362/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010363static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10364 .ops = &snd_hda_bind_vol,
10365 .values = {
10366 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10367 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10368 0
10369 },
10370};
10371
Takashi Iwai889c4392007-08-23 18:56:52 +020010372/* mute/unmute internal speaker according to the hp jack and mute state */
10373static void alc268_acer_automute(struct hda_codec *codec, int force)
10374{
10375 struct alc_spec *spec = codec->spec;
10376 unsigned int mute;
10377
10378 if (force || !spec->sense_updated) {
10379 unsigned int present;
10380 present = snd_hda_codec_read(codec, 0x14, 0,
10381 AC_VERB_GET_PIN_SENSE, 0);
10382 spec->jack_present = (present & 0x80000000) != 0;
10383 spec->sense_updated = 1;
10384 }
10385 if (spec->jack_present)
10386 mute = HDA_AMP_MUTE; /* mute internal speaker */
10387 else /* unmute internal speaker if necessary */
10388 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10389 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10390 HDA_AMP_MUTE, mute);
10391}
10392
10393
10394/* bind hp and internal speaker mute (with plug check) */
10395static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10396 struct snd_ctl_elem_value *ucontrol)
10397{
10398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10399 long *valp = ucontrol->value.integer.value;
10400 int change;
10401
10402 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10403 HDA_AMP_MUTE,
10404 valp[0] ? 0 : HDA_AMP_MUTE);
10405 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10406 HDA_AMP_MUTE,
10407 valp[1] ? 0 : HDA_AMP_MUTE);
10408 if (change)
10409 alc268_acer_automute(codec, 0);
10410 return change;
10411}
Takashi Iwaid2738092007-08-16 14:59:45 +020010412
10413static struct snd_kcontrol_new alc268_acer_mixer[] = {
10414 /* output mixer control */
10415 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10416 {
10417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10418 .name = "Master Playback Switch",
10419 .info = snd_hda_mixer_amp_switch_info,
10420 .get = snd_hda_mixer_amp_switch_get,
10421 .put = alc268_acer_master_sw_put,
10422 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10423 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010424 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10425 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10426 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010427 { }
10428};
10429
10430static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010431 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10432 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010437 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10438 { }
10439};
10440
10441/* unsolicited event for HP jack sensing */
10442static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10443 unsigned int res)
10444{
Takashi Iwai889c4392007-08-23 18:56:52 +020010445 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010446 return;
10447 alc268_toshiba_automute(codec);
10448}
10449
10450static void alc268_acer_unsol_event(struct hda_codec *codec,
10451 unsigned int res)
10452{
Takashi Iwai889c4392007-08-23 18:56:52 +020010453 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010454 return;
10455 alc268_acer_automute(codec, 1);
10456}
10457
Takashi Iwai889c4392007-08-23 18:56:52 +020010458static void alc268_acer_init_hook(struct hda_codec *codec)
10459{
10460 alc268_acer_automute(codec, 1);
10461}
10462
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010463static struct snd_kcontrol_new alc268_dell_mixer[] = {
10464 /* output mixer control */
10465 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10466 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10467 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10469 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10470 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10471 { }
10472};
10473
10474static struct hda_verb alc268_dell_verbs[] = {
10475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10477 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10478 { }
10479};
10480
10481/* mute/unmute internal speaker according to the hp jack and mute state */
10482static void alc268_dell_automute(struct hda_codec *codec)
10483{
10484 unsigned int present;
10485 unsigned int mute;
10486
10487 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10488 if (present & 0x80000000)
10489 mute = HDA_AMP_MUTE;
10490 else
10491 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10492 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10493 HDA_AMP_MUTE, mute);
10494}
10495
10496static void alc268_dell_unsol_event(struct hda_codec *codec,
10497 unsigned int res)
10498{
10499 if ((res >> 26) != ALC880_HP_EVENT)
10500 return;
10501 alc268_dell_automute(codec);
10502}
10503
10504#define alc268_dell_init_hook alc268_dell_automute
10505
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010506static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10507 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10508 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10509 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10511 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10512 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10513 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10514 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10515 { }
10516};
10517
10518static struct hda_verb alc267_quanta_il1_verbs[] = {
10519 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10521 { }
10522};
10523
10524static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10525{
10526 unsigned int present;
10527
10528 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10529 & AC_PINSENSE_PRESENCE;
10530 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10531 present ? 0 : PIN_OUT);
10532}
10533
10534static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10535{
10536 unsigned int present;
10537
10538 present = snd_hda_codec_read(codec, 0x18, 0,
10539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10540 snd_hda_codec_write(codec, 0x23, 0,
10541 AC_VERB_SET_CONNECT_SEL,
10542 present ? 0x00 : 0x01);
10543}
10544
10545static void alc267_quanta_il1_automute(struct hda_codec *codec)
10546{
10547 alc267_quanta_il1_hp_automute(codec);
10548 alc267_quanta_il1_mic_automute(codec);
10549}
10550
10551static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10552 unsigned int res)
10553{
10554 switch (res >> 26) {
10555 case ALC880_HP_EVENT:
10556 alc267_quanta_il1_hp_automute(codec);
10557 break;
10558 case ALC880_MIC_EVENT:
10559 alc267_quanta_il1_mic_automute(codec);
10560 break;
10561 }
10562}
10563
Kailang Yanga361d842007-06-05 12:30:55 +020010564/*
10565 * generic initialization of ADC, input mixers and output mixers
10566 */
10567static struct hda_verb alc268_base_init_verbs[] = {
10568 /* Unmute DAC0-1 and set vol = 0 */
10569 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10570 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10571 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10572 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10573 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10574 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10575
10576 /*
10577 * Set up output mixers (0x0c - 0x0e)
10578 */
10579 /* set vol=0 to output mixers */
10580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10583 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10584
10585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10586 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10587
10588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10590 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10591 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10593 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10594 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10595 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10596
10597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10600 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10603 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010604
10605 /* set PCBEEP vol = 0, mute connections */
10606 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10608 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010609
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010610 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010611
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010612 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10614 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10615 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010616
Kailang Yanga361d842007-06-05 12:30:55 +020010617 { }
10618};
10619
10620/*
10621 * generic initialization of ADC, input mixers and output mixers
10622 */
10623static struct hda_verb alc268_volume_init_verbs[] = {
10624 /* set output DAC */
10625 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10626 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10628 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10629
10630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10631 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10632 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10633 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10634 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10635
10636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10639 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10640 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10641
10642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10645 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10646
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010647 /* set PCBEEP vol = 0, mute connections */
10648 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10650 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010651
10652 { }
10653};
10654
10655#define alc268_mux_enum_info alc_mux_enum_info
10656#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010657#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010658
10659static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10660 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10661 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10662 {
10663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10664 /* The multiple "Capture Source" controls confuse alsamixer
10665 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010666 */
10667 /* .name = "Capture Source", */
10668 .name = "Input Source",
10669 .count = 1,
10670 .info = alc268_mux_enum_info,
10671 .get = alc268_mux_enum_get,
10672 .put = alc268_mux_enum_put,
10673 },
10674 { } /* end */
10675};
10676
10677static struct snd_kcontrol_new alc268_capture_mixer[] = {
10678 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10679 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10680 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10681 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10682 {
10683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10684 /* The multiple "Capture Source" controls confuse alsamixer
10685 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010686 */
10687 /* .name = "Capture Source", */
10688 .name = "Input Source",
10689 .count = 2,
10690 .info = alc268_mux_enum_info,
10691 .get = alc268_mux_enum_get,
10692 .put = alc268_mux_enum_put,
10693 },
10694 { } /* end */
10695};
10696
10697static struct hda_input_mux alc268_capture_source = {
10698 .num_items = 4,
10699 .items = {
10700 { "Mic", 0x0 },
10701 { "Front Mic", 0x1 },
10702 { "Line", 0x2 },
10703 { "CD", 0x3 },
10704 },
10705};
10706
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010707static struct hda_input_mux alc268_acer_capture_source = {
10708 .num_items = 3,
10709 .items = {
10710 { "Mic", 0x0 },
10711 { "Internal Mic", 0x6 },
10712 { "Line", 0x2 },
10713 },
10714};
10715
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010716#ifdef CONFIG_SND_DEBUG
10717static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010718 /* Volume widgets */
10719 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10720 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10721 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10722 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10723 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10724 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10725 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10726 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10727 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10728 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10729 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10730 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10731 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010732 /* The below appears problematic on some hardwares */
10733 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010734 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10735 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10736 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10737 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10738
10739 /* Modes for retasking pin widgets */
10740 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10741 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10742 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10743 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10744
10745 /* Controls for GPIO pins, assuming they are configured as outputs */
10746 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10747 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10748 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10749 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10750
10751 /* Switches to allow the digital SPDIF output pin to be enabled.
10752 * The ALC268 does not have an SPDIF input.
10753 */
10754 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10755
10756 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10757 * this output to turn on an external amplifier.
10758 */
10759 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10760 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10761
10762 { } /* end */
10763};
10764#endif
10765
Kailang Yanga361d842007-06-05 12:30:55 +020010766/* create input playback/capture controls for the given pin */
10767static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10768 const char *ctlname, int idx)
10769{
10770 char name[32];
10771 int err;
10772
10773 sprintf(name, "%s Playback Volume", ctlname);
10774 if (nid == 0x14) {
10775 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10776 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10777 HDA_OUTPUT));
10778 if (err < 0)
10779 return err;
10780 } else if (nid == 0x15) {
10781 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10782 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10783 HDA_OUTPUT));
10784 if (err < 0)
10785 return err;
10786 } else
10787 return -1;
10788 sprintf(name, "%s Playback Switch", ctlname);
10789 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10790 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10791 if (err < 0)
10792 return err;
10793 return 0;
10794}
10795
10796/* add playback controls from the parsed DAC table */
10797static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10798 const struct auto_pin_cfg *cfg)
10799{
10800 hda_nid_t nid;
10801 int err;
10802
10803 spec->multiout.num_dacs = 2; /* only use one dac */
10804 spec->multiout.dac_nids = spec->private_dac_nids;
10805 spec->multiout.dac_nids[0] = 2;
10806 spec->multiout.dac_nids[1] = 3;
10807
10808 nid = cfg->line_out_pins[0];
10809 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020010810 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020010811
10812 nid = cfg->speaker_pins[0];
10813 if (nid == 0x1d) {
10814 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10815 "Speaker Playback Volume",
10816 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10817 if (err < 0)
10818 return err;
10819 }
10820 nid = cfg->hp_pins[0];
10821 if (nid)
10822 alc268_new_analog_output(spec, nid, "Headphone", 0);
10823
10824 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10825 if (nid == 0x16) {
10826 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10827 "Mono Playback Switch",
10828 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10829 if (err < 0)
10830 return err;
10831 }
Kailang Yangea1fb292008-08-26 12:58:38 +020010832 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020010833}
10834
10835/* create playback/capture controls for input pins */
10836static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10837 const struct auto_pin_cfg *cfg)
10838{
10839 struct hda_input_mux *imux = &spec->private_imux;
10840 int i, idx1;
10841
10842 for (i = 0; i < AUTO_PIN_LAST; i++) {
10843 switch(cfg->input_pins[i]) {
10844 case 0x18:
10845 idx1 = 0; /* Mic 1 */
10846 break;
10847 case 0x19:
10848 idx1 = 1; /* Mic 2 */
10849 break;
10850 case 0x1a:
10851 idx1 = 2; /* Line In */
10852 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020010853 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020010854 idx1 = 3; /* CD */
10855 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010856 case 0x12:
10857 case 0x13:
10858 idx1 = 6; /* digital mics */
10859 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010860 default:
10861 continue;
10862 }
10863 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10864 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020010865 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020010866 }
10867 return 0;
10868}
10869
10870static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10871{
10872 struct alc_spec *spec = codec->spec;
10873 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10874 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10875 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10876 unsigned int dac_vol1, dac_vol2;
10877
10878 if (speaker_nid) {
10879 snd_hda_codec_write(codec, speaker_nid, 0,
10880 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10881 snd_hda_codec_write(codec, 0x0f, 0,
10882 AC_VERB_SET_AMP_GAIN_MUTE,
10883 AMP_IN_UNMUTE(1));
10884 snd_hda_codec_write(codec, 0x10, 0,
10885 AC_VERB_SET_AMP_GAIN_MUTE,
10886 AMP_IN_UNMUTE(1));
10887 } else {
10888 snd_hda_codec_write(codec, 0x0f, 0,
10889 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10890 snd_hda_codec_write(codec, 0x10, 0,
10891 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10892 }
10893
10894 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020010895 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010896 dac_vol2 = AMP_OUT_ZERO;
10897 else if (line_nid == 0x15)
10898 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020010899 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010900 dac_vol2 = AMP_OUT_ZERO;
10901 else if (hp_nid == 0x15)
10902 dac_vol1 = AMP_OUT_ZERO;
10903 if (line_nid != 0x16 || hp_nid != 0x16 ||
10904 spec->autocfg.line_out_pins[1] != 0x16 ||
10905 spec->autocfg.line_out_pins[2] != 0x16)
10906 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10907
10908 snd_hda_codec_write(codec, 0x02, 0,
10909 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10910 snd_hda_codec_write(codec, 0x03, 0,
10911 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10912}
10913
10914/* pcm configuration: identiacal with ALC880 */
10915#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10916#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010917#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010918#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10919
10920/*
10921 * BIOS auto configuration
10922 */
10923static int alc268_parse_auto_config(struct hda_codec *codec)
10924{
10925 struct alc_spec *spec = codec->spec;
10926 int err;
10927 static hda_nid_t alc268_ignore[] = { 0 };
10928
10929 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10930 alc268_ignore);
10931 if (err < 0)
10932 return err;
10933 if (!spec->autocfg.line_outs)
10934 return 0; /* can't find valid BIOS pin config */
10935
10936 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10937 if (err < 0)
10938 return err;
10939 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10940 if (err < 0)
10941 return err;
10942
10943 spec->multiout.max_channels = 2;
10944
10945 /* digital only support output */
10946 if (spec->autocfg.dig_out_pin)
10947 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10948
10949 if (spec->kctl_alloc)
10950 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10951
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010952 if (spec->autocfg.speaker_pins[0] != 0x1d)
10953 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10954
Kailang Yanga361d842007-06-05 12:30:55 +020010955 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10956 spec->num_mux_defs = 1;
10957 spec->input_mux = &spec->private_imux;
10958
Takashi Iwai776e1842007-08-29 15:07:11 +020010959 err = alc_auto_add_mic_boost(codec);
10960 if (err < 0)
10961 return err;
10962
Kailang Yanga361d842007-06-05 12:30:55 +020010963 return 1;
10964}
10965
10966#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10967#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10968#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10969
10970/* init callback for auto-configuration model -- overriding the default init */
10971static void alc268_auto_init(struct hda_codec *codec)
10972{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010973 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020010974 alc268_auto_init_multi_out(codec);
10975 alc268_auto_init_hp_out(codec);
10976 alc268_auto_init_mono_speaker_out(codec);
10977 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010978 if (spec->unsol_event)
10979 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020010980}
10981
10982/*
10983 * configuration and preset
10984 */
10985static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010986 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020010987 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010988 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020010989 [ALC268_ACER] = "acer",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010990 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010010991 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010992#ifdef CONFIG_SND_DEBUG
10993 [ALC268_TEST] = "test",
10994#endif
Kailang Yanga361d842007-06-05 12:30:55 +020010995 [ALC268_AUTO] = "auto",
10996};
10997
10998static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020010999 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011000 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011001 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011002 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011003 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011004 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011005 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011006 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011007 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011008 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011009 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011010 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011011 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011012 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011013 {}
11014};
11015
11016static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011017 [ALC267_QUANTA_IL1] = {
11018 .mixers = { alc267_quanta_il1_mixer },
11019 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11020 alc267_quanta_il1_verbs },
11021 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11022 .dac_nids = alc268_dac_nids,
11023 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11024 .adc_nids = alc268_adc_nids_alt,
11025 .hp_nid = 0x03,
11026 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11027 .channel_mode = alc268_modes,
11028 .input_mux = &alc268_capture_source,
11029 .unsol_event = alc267_quanta_il1_unsol_event,
11030 .init_hook = alc267_quanta_il1_automute,
11031 },
Kailang Yanga361d842007-06-05 12:30:55 +020011032 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011033 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11034 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011035 .init_verbs = { alc268_base_init_verbs },
11036 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11037 .dac_nids = alc268_dac_nids,
11038 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11039 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011040 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011041 .hp_nid = 0x03,
11042 .dig_out_nid = ALC268_DIGOUT_NID,
11043 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11044 .channel_mode = alc268_modes,
11045 .input_mux = &alc268_capture_source,
11046 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011047 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011048 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11049 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011050 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11051 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011052 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11053 .dac_nids = alc268_dac_nids,
11054 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11055 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011056 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011057 .hp_nid = 0x03,
11058 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11059 .channel_mode = alc268_modes,
11060 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011061 .unsol_event = alc268_toshiba_unsol_event,
11062 .init_hook = alc268_toshiba_automute,
11063 },
11064 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011065 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11066 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011067 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11068 alc268_acer_verbs },
11069 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11070 .dac_nids = alc268_dac_nids,
11071 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11072 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011073 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011074 .hp_nid = 0x02,
11075 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11076 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011077 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011078 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011079 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011080 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011081 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011082 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011083 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11084 alc268_dell_verbs },
11085 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11086 .dac_nids = alc268_dac_nids,
11087 .hp_nid = 0x02,
11088 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11089 .channel_mode = alc268_modes,
11090 .unsol_event = alc268_dell_unsol_event,
11091 .init_hook = alc268_dell_init_hook,
11092 .input_mux = &alc268_capture_source,
11093 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011094 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011095 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11096 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011097 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11098 alc268_toshiba_verbs },
11099 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11100 .dac_nids = alc268_dac_nids,
11101 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11102 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011103 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011104 .hp_nid = 0x03,
11105 .dig_out_nid = ALC268_DIGOUT_NID,
11106 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11107 .channel_mode = alc268_modes,
11108 .input_mux = &alc268_capture_source,
11109 .unsol_event = alc268_toshiba_unsol_event,
11110 .init_hook = alc268_toshiba_automute
11111 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011112#ifdef CONFIG_SND_DEBUG
11113 [ALC268_TEST] = {
11114 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11115 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11116 alc268_volume_init_verbs },
11117 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11118 .dac_nids = alc268_dac_nids,
11119 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11120 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011121 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011122 .hp_nid = 0x03,
11123 .dig_out_nid = ALC268_DIGOUT_NID,
11124 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11125 .channel_mode = alc268_modes,
11126 .input_mux = &alc268_capture_source,
11127 },
11128#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011129};
11130
11131static int patch_alc268(struct hda_codec *codec)
11132{
11133 struct alc_spec *spec;
11134 int board_config;
11135 int err;
11136
11137 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11138 if (spec == NULL)
11139 return -ENOMEM;
11140
11141 codec->spec = spec;
11142
11143 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11144 alc268_models,
11145 alc268_cfg_tbl);
11146
11147 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11148 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11149 "trying auto-probe from BIOS...\n");
11150 board_config = ALC268_AUTO;
11151 }
11152
11153 if (board_config == ALC268_AUTO) {
11154 /* automatic parse from the BIOS config */
11155 err = alc268_parse_auto_config(codec);
11156 if (err < 0) {
11157 alc_free(codec);
11158 return err;
11159 } else if (!err) {
11160 printk(KERN_INFO
11161 "hda_codec: Cannot set up configuration "
11162 "from BIOS. Using base mode...\n");
11163 board_config = ALC268_3ST;
11164 }
11165 }
11166
11167 if (board_config != ALC268_AUTO)
11168 setup_preset(spec, &alc268_presets[board_config]);
11169
Kailang Yang2f893282008-05-27 12:14:47 +020011170 if (codec->vendor_id == 0x10ec0267) {
11171 spec->stream_name_analog = "ALC267 Analog";
11172 spec->stream_name_digital = "ALC267 Digital";
11173 } else {
11174 spec->stream_name_analog = "ALC268 Analog";
11175 spec->stream_name_digital = "ALC268 Digital";
11176 }
11177
Kailang Yanga361d842007-06-05 12:30:55 +020011178 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11179 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011180 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011181
Kailang Yanga361d842007-06-05 12:30:55 +020011182 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11183
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011184 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11185 /* override the amp caps for beep generator */
11186 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11187 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11188 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11189 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11190 (0 << AC_AMPCAP_MUTE_SHIFT));
11191
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011192 if (!spec->adc_nids && spec->input_mux) {
11193 /* check whether NID 0x07 is valid */
11194 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011195 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011196
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011197 /* get type */
11198 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011199 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011200 spec->adc_nids = alc268_adc_nids_alt;
11201 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11202 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011203 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011204 spec->num_mixers++;
11205 } else {
11206 spec->adc_nids = alc268_adc_nids;
11207 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11208 spec->mixers[spec->num_mixers] =
11209 alc268_capture_mixer;
11210 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011211 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011212 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011213 /* set default input source */
11214 for (i = 0; i < spec->num_adc_nids; i++)
11215 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11216 0, AC_VERB_SET_CONNECT_SEL,
11217 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011218 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011219
11220 spec->vmaster_nid = 0x02;
11221
Kailang Yanga361d842007-06-05 12:30:55 +020011222 codec->patch_ops = alc_patch_ops;
11223 if (board_config == ALC268_AUTO)
11224 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011225
Kailang Yanga361d842007-06-05 12:30:55 +020011226 return 0;
11227}
11228
11229/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011230 * ALC269 channel source setting (2 channel)
11231 */
11232#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11233
11234#define alc269_dac_nids alc260_dac_nids
11235
11236static hda_nid_t alc269_adc_nids[1] = {
11237 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011238 0x08,
11239};
11240
Takashi Iwaie01bf502008-08-21 16:25:07 +020011241static hda_nid_t alc269_capsrc_nids[1] = {
11242 0x23,
11243};
11244
11245/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11246 * not a mux!
11247 */
11248
Kailang Yangf53281e2008-07-18 12:36:43 +020011249static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11250 .num_items = 2,
11251 .items = {
11252 { "i-Mic", 0x5 },
11253 { "e-Mic", 0x0 },
11254 },
11255};
11256
11257static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11258 .num_items = 2,
11259 .items = {
11260 { "i-Mic", 0x1 },
11261 { "e-Mic", 0x0 },
11262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011263};
11264
11265#define alc269_modes alc260_modes
11266#define alc269_capture_source alc880_lg_lw_capture_source
11267
11268static struct snd_kcontrol_new alc269_base_mixer[] = {
11269 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11270 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011275 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11276 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11278 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11280 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11282 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11283 { } /* end */
11284};
11285
Kailang Yangf53281e2008-07-18 12:36:43 +020011286/* bind volumes of both NID 0x0c and 0x0d */
11287static struct hda_bind_ctls alc269_epc_bind_vol = {
11288 .ops = &snd_hda_bind_vol,
11289 .values = {
11290 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11291 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11292 0
11293 },
11294};
11295
11296static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11297 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11298 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11299 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11300 { } /* end */
11301};
11302
Kailang Yangf6a92242007-12-13 16:52:54 +010011303/* capture mixer elements */
11304static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011305 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11306 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011307 {
11308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11309 /* The multiple "Capture Source" controls confuse alsamixer
11310 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011311 */
11312 /* .name = "Capture Source", */
11313 .name = "Input Source",
11314 .count = 1,
11315 .info = alc_mux_enum_info,
11316 .get = alc_mux_enum_get,
11317 .put = alc_mux_enum_put,
11318 },
11319 { } /* end */
11320};
11321
Kailang Yangf53281e2008-07-18 12:36:43 +020011322/* capture mixer elements */
11323static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11324 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11325 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11326 { } /* end */
11327};
11328
Takashi Iwai2005af22008-08-20 18:38:26 +020011329/* beep control */
11330static struct snd_kcontrol_new alc269_beep_mixer[] = {
11331 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11332 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11333 { } /* end */
11334};
11335
Kailang Yangf6a92242007-12-13 16:52:54 +010011336/*
11337 * generic initialization of ADC, input mixers and output mixers
11338 */
11339static struct hda_verb alc269_init_verbs[] = {
11340 /*
11341 * Unmute ADC0 and set the default input to mic-in
11342 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011344
11345 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11346 * analog-loopback mixer widget
11347 * Note: PASD motherboards uses the Line In 2 as the input for
11348 * front panel mic (mic 2)
11349 */
11350 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11356
11357 /*
11358 * Set up output mixers (0x0c - 0x0e)
11359 */
11360 /* set vol=0 to output mixers */
11361 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11362 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11363
11364 /* set up input amps for analog loopback */
11365 /* Amp Indices: DAC = 0, mixer = 1 */
11366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11372
11373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11375 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11377 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11378 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11380
11381 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11383 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11384 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11387 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11388
11389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11390 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11391
11392 /* FIXME: use matrix-type input source selection */
11393 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11394 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11399
11400 /* set EAPD */
11401 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11402 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11403 { }
11404};
11405
Kailang Yangf53281e2008-07-18 12:36:43 +020011406static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11407 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11408 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11409 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11411 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11413 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11414 {}
11415};
11416
11417static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11419 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11420 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11422 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11423 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11424 {}
11425};
11426
11427/* toggle speaker-output according to the hp-jack state */
11428static void alc269_speaker_automute(struct hda_codec *codec)
11429{
11430 unsigned int present;
11431 unsigned int bits;
11432
11433 present = snd_hda_codec_read(codec, 0x15, 0,
11434 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11435 bits = present ? AMP_IN_MUTE(0) : 0;
11436 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11437 AMP_IN_MUTE(0), bits);
11438 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11439 AMP_IN_MUTE(0), bits);
11440}
11441
11442static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11443{
11444 unsigned int present;
11445
11446 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11447 & AC_PINSENSE_PRESENCE;
11448 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11449 present ? 0 : 5);
11450}
11451
11452static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11453{
11454 unsigned int present;
11455
11456 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11457 & AC_PINSENSE_PRESENCE;
11458 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11459 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11460 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11461 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11462}
11463
11464/* unsolicited event for HP jack sensing */
11465static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11466 unsigned int res)
11467{
11468 if ((res >> 26) == ALC880_HP_EVENT)
11469 alc269_speaker_automute(codec);
11470
11471 if ((res >> 26) == ALC880_MIC_EVENT)
11472 alc269_eeepc_dmic_automute(codec);
11473}
11474
11475static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11476{
11477 alc269_speaker_automute(codec);
11478 alc269_eeepc_dmic_automute(codec);
11479}
11480
11481/* unsolicited event for HP jack sensing */
11482static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
Kailang Yangea1fb292008-08-26 12:58:38 +020011483 unsigned int res)
Kailang Yangf53281e2008-07-18 12:36:43 +020011484{
11485 if ((res >> 26) == ALC880_HP_EVENT)
11486 alc269_speaker_automute(codec);
11487
11488 if ((res >> 26) == ALC880_MIC_EVENT)
11489 alc269_eeepc_amic_automute(codec);
11490}
11491
11492static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11493{
11494 alc269_speaker_automute(codec);
11495 alc269_eeepc_amic_automute(codec);
11496}
11497
Kailang Yangf6a92242007-12-13 16:52:54 +010011498/* add playback controls from the parsed DAC table */
11499static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11500 const struct auto_pin_cfg *cfg)
11501{
11502 hda_nid_t nid;
11503 int err;
11504
11505 spec->multiout.num_dacs = 1; /* only use one dac */
11506 spec->multiout.dac_nids = spec->private_dac_nids;
11507 spec->multiout.dac_nids[0] = 2;
11508
11509 nid = cfg->line_out_pins[0];
11510 if (nid) {
11511 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11512 "Front Playback Volume",
11513 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11514 if (err < 0)
11515 return err;
11516 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11517 "Front Playback Switch",
11518 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11519 if (err < 0)
11520 return err;
11521 }
11522
11523 nid = cfg->speaker_pins[0];
11524 if (nid) {
11525 if (!cfg->line_out_pins[0]) {
11526 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11527 "Speaker Playback Volume",
11528 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11529 HDA_OUTPUT));
11530 if (err < 0)
11531 return err;
11532 }
11533 if (nid == 0x16) {
11534 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11535 "Speaker Playback Switch",
11536 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11537 HDA_OUTPUT));
11538 if (err < 0)
11539 return err;
11540 } else {
11541 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11542 "Speaker Playback Switch",
11543 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11544 HDA_OUTPUT));
11545 if (err < 0)
11546 return err;
11547 }
11548 }
11549 nid = cfg->hp_pins[0];
11550 if (nid) {
11551 /* spec->multiout.hp_nid = 2; */
11552 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11553 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11554 "Headphone Playback Volume",
11555 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11556 HDA_OUTPUT));
11557 if (err < 0)
11558 return err;
11559 }
11560 if (nid == 0x16) {
11561 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11562 "Headphone Playback Switch",
11563 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11564 HDA_OUTPUT));
11565 if (err < 0)
11566 return err;
11567 } else {
11568 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11569 "Headphone Playback Switch",
11570 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11571 HDA_OUTPUT));
11572 if (err < 0)
11573 return err;
11574 }
11575 }
11576 return 0;
11577}
11578
11579#define alc269_auto_create_analog_input_ctls \
11580 alc880_auto_create_analog_input_ctls
11581
11582#ifdef CONFIG_SND_HDA_POWER_SAVE
11583#define alc269_loopbacks alc880_loopbacks
11584#endif
11585
11586/* pcm configuration: identiacal with ALC880 */
11587#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11588#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11589#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11590#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11591
11592/*
11593 * BIOS auto configuration
11594 */
11595static int alc269_parse_auto_config(struct hda_codec *codec)
11596{
11597 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020011598 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010011599 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11600
11601 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11602 alc269_ignore);
11603 if (err < 0)
11604 return err;
11605
11606 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11607 if (err < 0)
11608 return err;
11609 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11610 if (err < 0)
11611 return err;
11612
11613 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11614
11615 if (spec->autocfg.dig_out_pin)
11616 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11617
11618 if (spec->kctl_alloc)
11619 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11620
Takashi Iwai2005af22008-08-20 18:38:26 +020011621 /* create a beep mixer control if the pin 0x1d isn't assigned */
11622 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
11623 if (spec->autocfg.input_pins[i] == 0x1d)
11624 break;
11625 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
11626 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
11627
Kailang Yangf6a92242007-12-13 16:52:54 +010011628 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11629 spec->num_mux_defs = 1;
11630 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020011631 /* set default input source */
11632 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
11633 0, AC_VERB_SET_CONNECT_SEL,
11634 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010011635
11636 err = alc_auto_add_mic_boost(codec);
11637 if (err < 0)
11638 return err;
11639
Kailang Yangf53281e2008-07-18 12:36:43 +020011640 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11641 spec->num_mixers++;
11642
Kailang Yangf6a92242007-12-13 16:52:54 +010011643 return 1;
11644}
11645
11646#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11647#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11648#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11649
11650
11651/* init callback for auto-configuration model -- overriding the default init */
11652static void alc269_auto_init(struct hda_codec *codec)
11653{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011654 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011655 alc269_auto_init_multi_out(codec);
11656 alc269_auto_init_hp_out(codec);
11657 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011658 if (spec->unsol_event)
11659 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011660}
11661
11662/*
11663 * configuration and preset
11664 */
11665static const char *alc269_models[ALC269_MODEL_LAST] = {
11666 [ALC269_BASIC] = "basic",
11667};
11668
11669static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011670 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11671 ALC269_ASUS_EEEPC_P703),
11672 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11673 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010011674 {}
11675};
11676
11677static struct alc_config_preset alc269_presets[] = {
11678 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011679 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010011680 .init_verbs = { alc269_init_verbs },
11681 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11682 .dac_nids = alc269_dac_nids,
11683 .hp_nid = 0x03,
11684 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11685 .channel_mode = alc269_modes,
11686 .input_mux = &alc269_capture_source,
11687 },
Kailang Yangf53281e2008-07-18 12:36:43 +020011688 [ALC269_ASUS_EEEPC_P703] = {
11689 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11690 .init_verbs = { alc269_init_verbs,
11691 alc269_eeepc_amic_init_verbs },
11692 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11693 .dac_nids = alc269_dac_nids,
11694 .hp_nid = 0x03,
11695 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11696 .channel_mode = alc269_modes,
11697 .input_mux = &alc269_eeepc_amic_capture_source,
11698 .unsol_event = alc269_eeepc_amic_unsol_event,
11699 .init_hook = alc269_eeepc_amic_inithook,
11700 },
11701 [ALC269_ASUS_EEEPC_P901] = {
11702 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11703 .init_verbs = { alc269_init_verbs,
11704 alc269_eeepc_dmic_init_verbs },
11705 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11706 .dac_nids = alc269_dac_nids,
11707 .hp_nid = 0x03,
11708 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11709 .channel_mode = alc269_modes,
11710 .input_mux = &alc269_eeepc_dmic_capture_source,
11711 .unsol_event = alc269_eeepc_dmic_unsol_event,
11712 .init_hook = alc269_eeepc_dmic_inithook,
11713 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011714};
11715
11716static int patch_alc269(struct hda_codec *codec)
11717{
11718 struct alc_spec *spec;
11719 int board_config;
11720 int err;
11721
11722 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11723 if (spec == NULL)
11724 return -ENOMEM;
11725
11726 codec->spec = spec;
11727
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011728 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11729
Kailang Yangf6a92242007-12-13 16:52:54 +010011730 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11731 alc269_models,
11732 alc269_cfg_tbl);
11733
11734 if (board_config < 0) {
11735 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11736 "trying auto-probe from BIOS...\n");
11737 board_config = ALC269_AUTO;
11738 }
11739
11740 if (board_config == ALC269_AUTO) {
11741 /* automatic parse from the BIOS config */
11742 err = alc269_parse_auto_config(codec);
11743 if (err < 0) {
11744 alc_free(codec);
11745 return err;
11746 } else if (!err) {
11747 printk(KERN_INFO
11748 "hda_codec: Cannot set up configuration "
11749 "from BIOS. Using base mode...\n");
11750 board_config = ALC269_BASIC;
11751 }
11752 }
11753
11754 if (board_config != ALC269_AUTO)
11755 setup_preset(spec, &alc269_presets[board_config]);
11756
11757 spec->stream_name_analog = "ALC269 Analog";
11758 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11759 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11760
11761 spec->stream_name_digital = "ALC269 Digital";
11762 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11763 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11764
11765 spec->adc_nids = alc269_adc_nids;
11766 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020011767 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010011768
11769 codec->patch_ops = alc_patch_ops;
11770 if (board_config == ALC269_AUTO)
11771 spec->init_hook = alc269_auto_init;
11772#ifdef CONFIG_SND_HDA_POWER_SAVE
11773 if (!spec->loopback.amplist)
11774 spec->loopback.amplist = alc269_loopbacks;
11775#endif
11776
11777 return 0;
11778}
11779
11780/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011781 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11782 */
11783
11784/*
11785 * set the path ways for 2 channel output
11786 * need to set the codec line out and mic 1 pin widgets to inputs
11787 */
11788static struct hda_verb alc861_threestack_ch2_init[] = {
11789 /* set pin widget 1Ah (line in) for input */
11790 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011791 /* set pin widget 18h (mic1/2) for input, for mic also enable
11792 * the vref
11793 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011794 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11795
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011796 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11797#if 0
11798 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11799 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11800#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011801 { } /* end */
11802};
11803/*
11804 * 6ch mode
11805 * need to set the codec line out and mic 1 pin widgets to outputs
11806 */
11807static struct hda_verb alc861_threestack_ch6_init[] = {
11808 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11809 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11810 /* set pin widget 18h (mic1) for output (CLFE)*/
11811 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11812
11813 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011814 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011815
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011816 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11817#if 0
11818 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11819 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11820#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011821 { } /* end */
11822};
11823
11824static struct hda_channel_mode alc861_threestack_modes[2] = {
11825 { 2, alc861_threestack_ch2_init },
11826 { 6, alc861_threestack_ch6_init },
11827};
Takashi Iwai22309c32006-08-09 16:57:28 +020011828/* Set mic1 as input and unmute the mixer */
11829static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11830 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11831 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11832 { } /* end */
11833};
11834/* Set mic1 as output and mute mixer */
11835static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11836 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11837 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11838 { } /* end */
11839};
11840
11841static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11842 { 2, alc861_uniwill_m31_ch2_init },
11843 { 4, alc861_uniwill_m31_ch4_init },
11844};
Kailang Yangdf694da2005-12-05 19:42:22 +010011845
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011846/* Set mic1 and line-in as input and unmute the mixer */
11847static struct hda_verb alc861_asus_ch2_init[] = {
11848 /* set pin widget 1Ah (line in) for input */
11849 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011850 /* set pin widget 18h (mic1/2) for input, for mic also enable
11851 * the vref
11852 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011853 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11854
11855 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11856#if 0
11857 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11859#endif
11860 { } /* end */
11861};
11862/* Set mic1 nad line-in as output and mute mixer */
11863static struct hda_verb alc861_asus_ch6_init[] = {
11864 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11865 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11866 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11867 /* set pin widget 18h (mic1) for output (CLFE)*/
11868 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11869 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11870 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11871 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11872
11873 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11874#if 0
11875 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11876 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11877#endif
11878 { } /* end */
11879};
11880
11881static struct hda_channel_mode alc861_asus_modes[2] = {
11882 { 2, alc861_asus_ch2_init },
11883 { 6, alc861_asus_ch6_init },
11884};
11885
Kailang Yangdf694da2005-12-05 19:42:22 +010011886/* patch-ALC861 */
11887
11888static struct snd_kcontrol_new alc861_base_mixer[] = {
11889 /* output mixer control */
11890 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11891 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11892 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11893 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11894 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11895
11896 /*Input mixer control */
11897 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11898 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11899 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11900 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11901 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11902 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11904 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011907
Kailang Yangdf694da2005-12-05 19:42:22 +010011908 /* Capture mixer control */
11909 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11910 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11911 {
11912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11913 .name = "Capture Source",
11914 .count = 1,
11915 .info = alc_mux_enum_info,
11916 .get = alc_mux_enum_get,
11917 .put = alc_mux_enum_put,
11918 },
11919 { } /* end */
11920};
11921
11922static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11923 /* output mixer control */
11924 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11925 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11926 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11927 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11928 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11929
11930 /* Input mixer control */
11931 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11932 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11933 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11934 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11935 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11936 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11938 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011941
Kailang Yangdf694da2005-12-05 19:42:22 +010011942 /* Capture mixer control */
11943 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11944 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11945 {
11946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11947 .name = "Capture Source",
11948 .count = 1,
11949 .info = alc_mux_enum_info,
11950 .get = alc_mux_enum_get,
11951 .put = alc_mux_enum_put,
11952 },
11953 {
11954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11955 .name = "Channel Mode",
11956 .info = alc_ch_mode_info,
11957 .get = alc_ch_mode_get,
11958 .put = alc_ch_mode_put,
11959 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11960 },
11961 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011962};
11963
Takashi Iwaid1d985f2006-11-23 19:27:12 +010011964static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011965 /* output mixer control */
11966 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11968 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020011969
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011970 /*Capture mixer control */
11971 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11972 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11973 {
11974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11975 .name = "Capture Source",
11976 .count = 1,
11977 .info = alc_mux_enum_info,
11978 .get = alc_mux_enum_get,
11979 .put = alc_mux_enum_put,
11980 },
11981
11982 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011983};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020011984
Takashi Iwai22309c32006-08-09 16:57:28 +020011985static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11986 /* output mixer control */
11987 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11988 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11989 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11990 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11991 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11992
11993 /* Input mixer control */
11994 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11995 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11996 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11997 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11998 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11999 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12001 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012004
Takashi Iwai22309c32006-08-09 16:57:28 +020012005 /* Capture mixer control */
12006 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12007 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12008 {
12009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12010 .name = "Capture Source",
12011 .count = 1,
12012 .info = alc_mux_enum_info,
12013 .get = alc_mux_enum_get,
12014 .put = alc_mux_enum_put,
12015 },
12016 {
12017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12018 .name = "Channel Mode",
12019 .info = alc_ch_mode_info,
12020 .get = alc_ch_mode_get,
12021 .put = alc_ch_mode_put,
12022 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12023 },
12024 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012025};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012026
12027static struct snd_kcontrol_new alc861_asus_mixer[] = {
12028 /* output mixer control */
12029 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12030 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12031 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12032 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12033 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12034
12035 /* Input mixer control */
12036 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12037 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12038 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12039 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12040 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12041 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12043 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12044 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12046
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012047 /* Capture mixer control */
12048 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12049 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12050 {
12051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12052 .name = "Capture Source",
12053 .count = 1,
12054 .info = alc_mux_enum_info,
12055 .get = alc_mux_enum_get,
12056 .put = alc_mux_enum_put,
12057 },
12058 {
12059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12060 .name = "Channel Mode",
12061 .info = alc_ch_mode_info,
12062 .get = alc_ch_mode_get,
12063 .put = alc_ch_mode_put,
12064 .private_value = ARRAY_SIZE(alc861_asus_modes),
12065 },
12066 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012067};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012068
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012069/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012070static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012071 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12072 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12073 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12074 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12075 { }
12076};
12077
Kailang Yangdf694da2005-12-05 19:42:22 +010012078/*
12079 * generic initialization of ADC, input mixers and output mixers
12080 */
12081static struct hda_verb alc861_base_init_verbs[] = {
12082 /*
12083 * Unmute ADC0 and set the default input to mic-in
12084 */
12085 /* port-A for surround (rear panel) */
12086 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12087 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12088 /* port-B for mic-in (rear panel) with vref */
12089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12090 /* port-C for line-in (rear panel) */
12091 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12092 /* port-D for Front */
12093 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12094 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12095 /* port-E for HP out (front panel) */
12096 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12097 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012098 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012099 /* port-F for mic-in (front panel) with vref */
12100 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12101 /* port-G for CLFE (rear panel) */
12102 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12103 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12104 /* port-H for side (rear panel) */
12105 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12106 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12107 /* CD-in */
12108 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12109 /* route front mic to ADC1*/
12110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012112
Kailang Yangdf694da2005-12-05 19:42:22 +010012113 /* Unmute DAC0~3 & spdif out*/
12114 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12115 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12116 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12117 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012119
Kailang Yangdf694da2005-12-05 19:42:22 +010012120 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12122 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12124 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012125
Kailang Yangdf694da2005-12-05 19:42:22 +010012126 /* Unmute Stereo Mixer 15 */
12127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012131
12132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012140 /* hp used DAC 3 (Front) */
12141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12143
12144 { }
12145};
12146
12147static struct hda_verb alc861_threestack_init_verbs[] = {
12148 /*
12149 * Unmute ADC0 and set the default input to mic-in
12150 */
12151 /* port-A for surround (rear panel) */
12152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12153 /* port-B for mic-in (rear panel) with vref */
12154 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12155 /* port-C for line-in (rear panel) */
12156 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12157 /* port-D for Front */
12158 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12159 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12160 /* port-E for HP out (front panel) */
12161 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12162 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012163 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012164 /* port-F for mic-in (front panel) with vref */
12165 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12166 /* port-G for CLFE (rear panel) */
12167 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12168 /* port-H for side (rear panel) */
12169 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12170 /* CD-in */
12171 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12172 /* route front mic to ADC1*/
12173 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12175 /* Unmute DAC0~3 & spdif out*/
12176 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12177 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12178 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12179 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012181
Kailang Yangdf694da2005-12-05 19:42:22 +010012182 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12183 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12184 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12185 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12186 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012187
Kailang Yangdf694da2005-12-05 19:42:22 +010012188 /* Unmute Stereo Mixer 15 */
12189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012193
12194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12195 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12196 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12197 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012202 /* hp used DAC 3 (Front) */
12203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12205 { }
12206};
Takashi Iwai22309c32006-08-09 16:57:28 +020012207
12208static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12209 /*
12210 * Unmute ADC0 and set the default input to mic-in
12211 */
12212 /* port-A for surround (rear panel) */
12213 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12214 /* port-B for mic-in (rear panel) with vref */
12215 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12216 /* port-C for line-in (rear panel) */
12217 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12218 /* port-D for Front */
12219 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12220 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12221 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012222 /* this has to be set to VREF80 */
12223 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012224 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012225 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012226 /* port-F for mic-in (front panel) with vref */
12227 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12228 /* port-G for CLFE (rear panel) */
12229 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12230 /* port-H for side (rear panel) */
12231 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12232 /* CD-in */
12233 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12234 /* route front mic to ADC1*/
12235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12237 /* Unmute DAC0~3 & spdif out*/
12238 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12239 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12240 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12241 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012243
Takashi Iwai22309c32006-08-09 16:57:28 +020012244 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12245 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12246 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12247 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12248 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012249
Takashi Iwai22309c32006-08-09 16:57:28 +020012250 /* Unmute Stereo Mixer 15 */
12251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012255
12256 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12258 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12259 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12262 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012264 /* hp used DAC 3 (Front) */
12265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12267 { }
12268};
12269
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012270static struct hda_verb alc861_asus_init_verbs[] = {
12271 /*
12272 * Unmute ADC0 and set the default input to mic-in
12273 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012274 /* port-A for surround (rear panel)
12275 * according to codec#0 this is the HP jack
12276 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012277 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12278 /* route front PCM to HP */
12279 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12280 /* port-B for mic-in (rear panel) with vref */
12281 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12282 /* port-C for line-in (rear panel) */
12283 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12284 /* port-D for Front */
12285 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12286 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12287 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012288 /* this has to be set to VREF80 */
12289 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012290 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012291 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012292 /* port-F for mic-in (front panel) with vref */
12293 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12294 /* port-G for CLFE (rear panel) */
12295 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12296 /* port-H for side (rear panel) */
12297 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12298 /* CD-in */
12299 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12300 /* route front mic to ADC1*/
12301 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12303 /* Unmute DAC0~3 & spdif out*/
12304 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12305 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12306 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12307 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12309 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12310 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12311 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12312 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12313 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012314
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012315 /* Unmute Stereo Mixer 15 */
12316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012320
12321 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12322 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12323 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12324 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12328 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012329 /* hp used DAC 3 (Front) */
12330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012331 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12332 { }
12333};
12334
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012335/* additional init verbs for ASUS laptops */
12336static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12337 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12338 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12339 { }
12340};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012341
Kailang Yangdf694da2005-12-05 19:42:22 +010012342/*
12343 * generic initialization of ADC, input mixers and output mixers
12344 */
12345static struct hda_verb alc861_auto_init_verbs[] = {
12346 /*
12347 * Unmute ADC0 and set the default input to mic-in
12348 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012349 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012351
Kailang Yangdf694da2005-12-05 19:42:22 +010012352 /* Unmute DAC0~3 & spdif out*/
12353 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12354 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12355 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12356 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012358
Kailang Yangdf694da2005-12-05 19:42:22 +010012359 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12360 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12361 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12362 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12363 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012364
Kailang Yangdf694da2005-12-05 19:42:22 +010012365 /* Unmute Stereo Mixer 15 */
12366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12370
12371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12372 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12373 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12374 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12379
12380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012382 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12383 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012386 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12387 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012388
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012389 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012390
12391 { }
12392};
12393
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012394static struct hda_verb alc861_toshiba_init_verbs[] = {
12395 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012396
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012397 { }
12398};
12399
12400/* toggle speaker-output according to the hp-jack state */
12401static void alc861_toshiba_automute(struct hda_codec *codec)
12402{
12403 unsigned int present;
12404
12405 present = snd_hda_codec_read(codec, 0x0f, 0,
12406 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012407 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12408 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12409 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12410 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012411}
12412
12413static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12414 unsigned int res)
12415{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012416 if ((res >> 26) == ALC880_HP_EVENT)
12417 alc861_toshiba_automute(codec);
12418}
12419
Kailang Yangdf694da2005-12-05 19:42:22 +010012420/* pcm configuration: identiacal with ALC880 */
12421#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12422#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12423#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12424#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12425
12426
12427#define ALC861_DIGOUT_NID 0x07
12428
12429static struct hda_channel_mode alc861_8ch_modes[1] = {
12430 { 8, NULL }
12431};
12432
12433static hda_nid_t alc861_dac_nids[4] = {
12434 /* front, surround, clfe, side */
12435 0x03, 0x06, 0x05, 0x04
12436};
12437
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012438static hda_nid_t alc660_dac_nids[3] = {
12439 /* front, clfe, surround */
12440 0x03, 0x05, 0x06
12441};
12442
Kailang Yangdf694da2005-12-05 19:42:22 +010012443static hda_nid_t alc861_adc_nids[1] = {
12444 /* ADC0-2 */
12445 0x08,
12446};
12447
12448static struct hda_input_mux alc861_capture_source = {
12449 .num_items = 5,
12450 .items = {
12451 { "Mic", 0x0 },
12452 { "Front Mic", 0x3 },
12453 { "Line", 0x1 },
12454 { "CD", 0x4 },
12455 { "Mixer", 0x5 },
12456 },
12457};
12458
12459/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012460static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12461 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012462{
12463 int i;
12464 hda_nid_t nid;
12465
12466 spec->multiout.dac_nids = spec->private_dac_nids;
12467 for (i = 0; i < cfg->line_outs; i++) {
12468 nid = cfg->line_out_pins[i];
12469 if (nid) {
12470 if (i >= ARRAY_SIZE(alc861_dac_nids))
12471 continue;
12472 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12473 }
12474 }
12475 spec->multiout.num_dacs = cfg->line_outs;
12476 return 0;
12477}
12478
12479/* add playback controls from the parsed DAC table */
12480static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12481 const struct auto_pin_cfg *cfg)
12482{
12483 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012484 static const char *chname[4] = {
12485 "Front", "Surround", NULL /*CLFE*/, "Side"
12486 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012487 hda_nid_t nid;
12488 int i, idx, err;
12489
12490 for (i = 0; i < cfg->line_outs; i++) {
12491 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012492 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012493 continue;
12494 if (nid == 0x05) {
12495 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012496 err = add_control(spec, ALC_CTL_BIND_MUTE,
12497 "Center Playback Switch",
12498 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12499 HDA_OUTPUT));
12500 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012501 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012502 err = add_control(spec, ALC_CTL_BIND_MUTE,
12503 "LFE Playback Switch",
12504 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12505 HDA_OUTPUT));
12506 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012507 return err;
12508 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012509 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12510 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012511 if (nid == alc861_dac_nids[idx])
12512 break;
12513 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012514 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12515 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12516 HDA_OUTPUT));
12517 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012518 return err;
12519 }
12520 }
12521 return 0;
12522}
12523
12524static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12525{
12526 int err;
12527 hda_nid_t nid;
12528
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012529 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012530 return 0;
12531
12532 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12533 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012534 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12535 "Headphone Playback Switch",
12536 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12537 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012538 return err;
12539 spec->multiout.hp_nid = nid;
12540 }
12541 return 0;
12542}
12543
12544/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012545static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12546 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012547{
Kailang Yangdf694da2005-12-05 19:42:22 +010012548 struct hda_input_mux *imux = &spec->private_imux;
12549 int i, err, idx, idx1;
12550
12551 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012552 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012553 case 0x0c:
12554 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012555 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012556 break;
12557 case 0x0f:
12558 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012559 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012560 break;
12561 case 0x0d:
12562 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012563 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012564 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012565 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012566 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012567 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012568 break;
12569 case 0x11:
12570 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012571 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012572 break;
12573 default:
12574 continue;
12575 }
12576
Takashi Iwai4a471b72005-12-07 13:56:29 +010012577 err = new_analog_input(spec, cfg->input_pins[i],
12578 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012579 if (err < 0)
12580 return err;
12581
Takashi Iwai4a471b72005-12-07 13:56:29 +010012582 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012583 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012584 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012585 }
12586 return 0;
12587}
12588
12589static struct snd_kcontrol_new alc861_capture_mixer[] = {
12590 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12591 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12592
12593 {
12594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12595 /* The multiple "Capture Source" controls confuse alsamixer
12596 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012597 */
12598 /* .name = "Capture Source", */
12599 .name = "Input Source",
12600 .count = 1,
12601 .info = alc_mux_enum_info,
12602 .get = alc_mux_enum_get,
12603 .put = alc_mux_enum_put,
12604 },
12605 { } /* end */
12606};
12607
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012608static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12609 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012610 int pin_type, int dac_idx)
12611{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012612 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12613 pin_type);
12614 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12615 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012616}
12617
12618static void alc861_auto_init_multi_out(struct hda_codec *codec)
12619{
12620 struct alc_spec *spec = codec->spec;
12621 int i;
12622
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012623 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012624 for (i = 0; i < spec->autocfg.line_outs; i++) {
12625 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012626 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012627 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012628 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012629 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012630 }
12631}
12632
12633static void alc861_auto_init_hp_out(struct hda_codec *codec)
12634{
12635 struct alc_spec *spec = codec->spec;
12636 hda_nid_t pin;
12637
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012638 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012639 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012640 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12641 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012642 pin = spec->autocfg.speaker_pins[0];
12643 if (pin)
12644 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012645}
12646
12647static void alc861_auto_init_analog_input(struct hda_codec *codec)
12648{
12649 struct alc_spec *spec = codec->spec;
12650 int i;
12651
12652 for (i = 0; i < AUTO_PIN_LAST; i++) {
12653 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012654 if (nid >= 0x0c && nid <= 0x11) {
12655 snd_hda_codec_write(codec, nid, 0,
12656 AC_VERB_SET_PIN_WIDGET_CONTROL,
12657 i <= AUTO_PIN_FRONT_MIC ?
12658 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012659 }
12660 }
12661}
12662
12663/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012664/* return 1 if successful, 0 if the proper config is not found,
12665 * or a negative error code
12666 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012667static int alc861_parse_auto_config(struct hda_codec *codec)
12668{
12669 struct alc_spec *spec = codec->spec;
12670 int err;
12671 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12672
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012673 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12674 alc861_ignore);
12675 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012676 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012677 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012678 return 0; /* can't find valid BIOS pin config */
12679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012680 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12681 if (err < 0)
12682 return err;
12683 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12684 if (err < 0)
12685 return err;
12686 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12687 if (err < 0)
12688 return err;
12689 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12690 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012691 return err;
12692
12693 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12694
12695 if (spec->autocfg.dig_out_pin)
12696 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12697
12698 if (spec->kctl_alloc)
12699 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12700
12701 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12702
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012703 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012704 spec->input_mux = &spec->private_imux;
12705
12706 spec->adc_nids = alc861_adc_nids;
12707 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12708 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12709 spec->num_mixers++;
12710
12711 return 1;
12712}
12713
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012714/* additional initialization for auto-configuration model */
12715static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012716{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012717 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012718 alc861_auto_init_multi_out(codec);
12719 alc861_auto_init_hp_out(codec);
12720 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012721 if (spec->unsol_event)
12722 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012723}
12724
Takashi Iwaicb53c622007-08-10 17:21:45 +020012725#ifdef CONFIG_SND_HDA_POWER_SAVE
12726static struct hda_amp_list alc861_loopbacks[] = {
12727 { 0x15, HDA_INPUT, 0 },
12728 { 0x15, HDA_INPUT, 1 },
12729 { 0x15, HDA_INPUT, 2 },
12730 { 0x15, HDA_INPUT, 3 },
12731 { } /* end */
12732};
12733#endif
12734
Kailang Yangdf694da2005-12-05 19:42:22 +010012735
12736/*
12737 * configuration and preset
12738 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012739static const char *alc861_models[ALC861_MODEL_LAST] = {
12740 [ALC861_3ST] = "3stack",
12741 [ALC660_3ST] = "3stack-660",
12742 [ALC861_3ST_DIG] = "3stack-dig",
12743 [ALC861_6ST_DIG] = "6stack-dig",
12744 [ALC861_UNIWILL_M31] = "uniwill-m31",
12745 [ALC861_TOSHIBA] = "toshiba",
12746 [ALC861_ASUS] = "asus",
12747 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12748 [ALC861_AUTO] = "auto",
12749};
12750
12751static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012752 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012753 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12754 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12755 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012756 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012757 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012758 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012759 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12760 * Any other models that need this preset?
12761 */
12762 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012763 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12764 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012765 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12766 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12767 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12768 /* FIXME: the below seems conflict */
12769 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12770 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12771 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012772 {}
12773};
12774
12775static struct alc_config_preset alc861_presets[] = {
12776 [ALC861_3ST] = {
12777 .mixers = { alc861_3ST_mixer },
12778 .init_verbs = { alc861_threestack_init_verbs },
12779 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12780 .dac_nids = alc861_dac_nids,
12781 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12782 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012783 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012784 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12785 .adc_nids = alc861_adc_nids,
12786 .input_mux = &alc861_capture_source,
12787 },
12788 [ALC861_3ST_DIG] = {
12789 .mixers = { alc861_base_mixer },
12790 .init_verbs = { alc861_threestack_init_verbs },
12791 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12792 .dac_nids = alc861_dac_nids,
12793 .dig_out_nid = ALC861_DIGOUT_NID,
12794 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12795 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012796 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012797 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12798 .adc_nids = alc861_adc_nids,
12799 .input_mux = &alc861_capture_source,
12800 },
12801 [ALC861_6ST_DIG] = {
12802 .mixers = { alc861_base_mixer },
12803 .init_verbs = { alc861_base_init_verbs },
12804 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12805 .dac_nids = alc861_dac_nids,
12806 .dig_out_nid = ALC861_DIGOUT_NID,
12807 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12808 .channel_mode = alc861_8ch_modes,
12809 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12810 .adc_nids = alc861_adc_nids,
12811 .input_mux = &alc861_capture_source,
12812 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012813 [ALC660_3ST] = {
12814 .mixers = { alc861_3ST_mixer },
12815 .init_verbs = { alc861_threestack_init_verbs },
12816 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12817 .dac_nids = alc660_dac_nids,
12818 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12819 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012820 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012821 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12822 .adc_nids = alc861_adc_nids,
12823 .input_mux = &alc861_capture_source,
12824 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012825 [ALC861_UNIWILL_M31] = {
12826 .mixers = { alc861_uniwill_m31_mixer },
12827 .init_verbs = { alc861_uniwill_m31_init_verbs },
12828 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12829 .dac_nids = alc861_dac_nids,
12830 .dig_out_nid = ALC861_DIGOUT_NID,
12831 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12832 .channel_mode = alc861_uniwill_m31_modes,
12833 .need_dac_fix = 1,
12834 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12835 .adc_nids = alc861_adc_nids,
12836 .input_mux = &alc861_capture_source,
12837 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012838 [ALC861_TOSHIBA] = {
12839 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012840 .init_verbs = { alc861_base_init_verbs,
12841 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012842 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12843 .dac_nids = alc861_dac_nids,
12844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12845 .channel_mode = alc883_3ST_2ch_modes,
12846 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12847 .adc_nids = alc861_adc_nids,
12848 .input_mux = &alc861_capture_source,
12849 .unsol_event = alc861_toshiba_unsol_event,
12850 .init_hook = alc861_toshiba_automute,
12851 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012852 [ALC861_ASUS] = {
12853 .mixers = { alc861_asus_mixer },
12854 .init_verbs = { alc861_asus_init_verbs },
12855 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12856 .dac_nids = alc861_dac_nids,
12857 .dig_out_nid = ALC861_DIGOUT_NID,
12858 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12859 .channel_mode = alc861_asus_modes,
12860 .need_dac_fix = 1,
12861 .hp_nid = 0x06,
12862 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12863 .adc_nids = alc861_adc_nids,
12864 .input_mux = &alc861_capture_source,
12865 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012866 [ALC861_ASUS_LAPTOP] = {
12867 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12868 .init_verbs = { alc861_asus_init_verbs,
12869 alc861_asus_laptop_init_verbs },
12870 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12871 .dac_nids = alc861_dac_nids,
12872 .dig_out_nid = ALC861_DIGOUT_NID,
12873 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12874 .channel_mode = alc883_3ST_2ch_modes,
12875 .need_dac_fix = 1,
12876 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12877 .adc_nids = alc861_adc_nids,
12878 .input_mux = &alc861_capture_source,
12879 },
12880};
Kailang Yangdf694da2005-12-05 19:42:22 +010012881
12882
12883static int patch_alc861(struct hda_codec *codec)
12884{
12885 struct alc_spec *spec;
12886 int board_config;
12887 int err;
12888
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012890 if (spec == NULL)
12891 return -ENOMEM;
12892
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012893 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012894
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012895 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12896 alc861_models,
12897 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012898
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012899 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012900 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12901 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012902 board_config = ALC861_AUTO;
12903 }
12904
12905 if (board_config == ALC861_AUTO) {
12906 /* automatic parse from the BIOS config */
12907 err = alc861_parse_auto_config(codec);
12908 if (err < 0) {
12909 alc_free(codec);
12910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012911 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012912 printk(KERN_INFO
12913 "hda_codec: Cannot set up configuration "
12914 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012915 board_config = ALC861_3ST_DIG;
12916 }
12917 }
12918
12919 if (board_config != ALC861_AUTO)
12920 setup_preset(spec, &alc861_presets[board_config]);
12921
12922 spec->stream_name_analog = "ALC861 Analog";
12923 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12924 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12925
12926 spec->stream_name_digital = "ALC861 Digital";
12927 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12928 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12929
Takashi Iwai2134ea42008-01-10 16:53:55 +010012930 spec->vmaster_nid = 0x03;
12931
Kailang Yangdf694da2005-12-05 19:42:22 +010012932 codec->patch_ops = alc_patch_ops;
12933 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012934 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012935#ifdef CONFIG_SND_HDA_POWER_SAVE
12936 if (!spec->loopback.amplist)
12937 spec->loopback.amplist = alc861_loopbacks;
12938#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012939
Kailang Yangdf694da2005-12-05 19:42:22 +010012940 return 0;
12941}
12942
12943/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012944 * ALC861-VD support
12945 *
12946 * Based on ALC882
12947 *
12948 * In addition, an independent DAC
12949 */
12950#define ALC861VD_DIGOUT_NID 0x06
12951
12952static hda_nid_t alc861vd_dac_nids[4] = {
12953 /* front, surr, clfe, side surr */
12954 0x02, 0x03, 0x04, 0x05
12955};
12956
12957/* dac_nids for ALC660vd are in a different order - according to
12958 * Realtek's driver.
12959 * This should probably tesult in a different mixer for 6stack models
12960 * of ALC660vd codecs, but for now there is only 3stack mixer
12961 * - and it is the same as in 861vd.
12962 * adc_nids in ALC660vd are (is) the same as in 861vd
12963 */
12964static hda_nid_t alc660vd_dac_nids[3] = {
12965 /* front, rear, clfe, rear_surr */
12966 0x02, 0x04, 0x03
12967};
12968
12969static hda_nid_t alc861vd_adc_nids[1] = {
12970 /* ADC0 */
12971 0x09,
12972};
12973
Takashi Iwaie1406342008-02-11 18:32:32 +010012974static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12975
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012976/* input MUX */
12977/* FIXME: should be a matrix-type input source selection */
12978static struct hda_input_mux alc861vd_capture_source = {
12979 .num_items = 4,
12980 .items = {
12981 { "Mic", 0x0 },
12982 { "Front Mic", 0x1 },
12983 { "Line", 0x2 },
12984 { "CD", 0x4 },
12985 },
12986};
12987
Kailang Yang272a5272007-05-14 11:00:38 +020012988static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010012989 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020012990 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010012991 { "Ext Mic", 0x0 },
12992 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020012993 },
12994};
12995
Kailang Yangd1a991a2007-08-15 16:21:59 +020012996static struct hda_input_mux alc861vd_hp_capture_source = {
12997 .num_items = 2,
12998 .items = {
12999 { "Front Mic", 0x0 },
13000 { "ATAPI Mic", 0x1 },
13001 },
13002};
13003
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013004#define alc861vd_mux_enum_info alc_mux_enum_info
13005#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013006/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13007#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013008
13009/*
13010 * 2ch mode
13011 */
13012static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13013 { 2, NULL }
13014};
13015
13016/*
13017 * 6ch mode
13018 */
13019static struct hda_verb alc861vd_6stack_ch6_init[] = {
13020 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13021 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13022 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13023 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13024 { } /* end */
13025};
13026
13027/*
13028 * 8ch mode
13029 */
13030static struct hda_verb alc861vd_6stack_ch8_init[] = {
13031 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13032 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13033 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13034 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13035 { } /* end */
13036};
13037
13038static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13039 { 6, alc861vd_6stack_ch6_init },
13040 { 8, alc861vd_6stack_ch8_init },
13041};
13042
13043static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13044 {
13045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13046 .name = "Channel Mode",
13047 .info = alc_ch_mode_info,
13048 .get = alc_ch_mode_get,
13049 .put = alc_ch_mode_put,
13050 },
13051 { } /* end */
13052};
13053
13054static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13055 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13056 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13057
13058 {
13059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13060 /* The multiple "Capture Source" controls confuse alsamixer
13061 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013062 */
13063 /* .name = "Capture Source", */
13064 .name = "Input Source",
13065 .count = 1,
13066 .info = alc861vd_mux_enum_info,
13067 .get = alc861vd_mux_enum_get,
13068 .put = alc861vd_mux_enum_put,
13069 },
13070 { } /* end */
13071};
13072
13073/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13074 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13075 */
13076static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13077 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13079
13080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13081 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13082
13083 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13084 HDA_OUTPUT),
13085 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13086 HDA_OUTPUT),
13087 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13088 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13089
13090 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13091 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13092
13093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13094
13095 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13098
13099 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13101 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13102
13103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13105
13106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13108
13109 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13110 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13111
13112 { } /* end */
13113};
13114
13115static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13116 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13118
13119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13120
13121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13124
13125 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13126 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13127 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13128
13129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13131
13132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13134
13135 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13136 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13137
13138 { } /* end */
13139};
13140
Kailang Yangbdd148a2007-05-08 15:19:08 +020013141static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13142 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13143 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13144 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13145
13146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13147
13148 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13151
13152 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13153 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13154 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13155
13156 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13157 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13158
13159 { } /* end */
13160};
13161
Tobin Davisb419f342008-03-07 11:57:51 +010013162/* Pin assignment: Speaker=0x14, HP = 0x15,
13163 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013164 */
13165static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013166 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13167 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013168 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13169 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013170 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13171 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13172 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13174 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13175 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13176 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13177 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013178 { } /* end */
13179};
13180
Kailang Yangd1a991a2007-08-15 16:21:59 +020013181/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13182 * Front Mic=0x18, ATAPI Mic = 0x19,
13183 */
13184static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13185 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13188 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13190 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13191 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13192 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013193
Kailang Yangd1a991a2007-08-15 16:21:59 +020013194 { } /* end */
13195};
13196
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013197/*
13198 * generic initialization of ADC, input mixers and output mixers
13199 */
13200static struct hda_verb alc861vd_volume_init_verbs[] = {
13201 /*
13202 * Unmute ADC0 and set the default input to mic-in
13203 */
13204 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13206
13207 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13208 * the analog-loopback mixer widget
13209 */
13210 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013216
13217 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013222
13223 /*
13224 * Set up output mixers (0x02 - 0x05)
13225 */
13226 /* set vol=0 to output mixers */
13227 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13231
13232 /* set up input amps for analog loopback */
13233 /* Amp Indices: DAC = 0, mixer = 1 */
13234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13236 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13237 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13242
13243 { }
13244};
13245
13246/*
13247 * 3-stack pin configuration:
13248 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13249 */
13250static struct hda_verb alc861vd_3stack_init_verbs[] = {
13251 /*
13252 * Set pin mode and muting
13253 */
13254 /* set front pin widgets 0x14 for output */
13255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13256 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13257 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13258
13259 /* Mic (rear) pin: input vref at 80% */
13260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13262 /* Front Mic pin: input vref at 80% */
13263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13265 /* Line In pin: input */
13266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13268 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13271 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13272 /* CD pin widget for input */
13273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13274
13275 { }
13276};
13277
13278/*
13279 * 6-stack pin configuration:
13280 */
13281static struct hda_verb alc861vd_6stack_init_verbs[] = {
13282 /*
13283 * Set pin mode and muting
13284 */
13285 /* set front pin widgets 0x14 for output */
13286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13288 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13289
13290 /* Rear Pin: output 1 (0x0d) */
13291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13293 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13294 /* CLFE Pin: output 2 (0x0e) */
13295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13297 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13298 /* Side Pin: output 3 (0x0f) */
13299 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13300 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13301 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13302
13303 /* Mic (rear) pin: input vref at 80% */
13304 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13306 /* Front Mic pin: input vref at 80% */
13307 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13309 /* Line In pin: input */
13310 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13312 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13313 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13314 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13315 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13316 /* CD pin widget for input */
13317 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13318
13319 { }
13320};
13321
Kailang Yangbdd148a2007-05-08 15:19:08 +020013322static struct hda_verb alc861vd_eapd_verbs[] = {
13323 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13324 { }
13325};
13326
Kailang Yangf9423e72008-05-27 12:32:25 +020013327static struct hda_verb alc660vd_eapd_verbs[] = {
13328 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13329 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13330 { }
13331};
13332
Kailang Yangbdd148a2007-05-08 15:19:08 +020013333static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13337 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013338 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013339 {}
13340};
13341
13342/* toggle speaker-output according to the hp-jack state */
13343static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13344{
13345 unsigned int present;
13346 unsigned char bits;
13347
13348 present = snd_hda_codec_read(codec, 0x1b, 0,
13349 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013350 bits = present ? HDA_AMP_MUTE : 0;
13351 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13352 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013353}
13354
13355static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13356{
13357 unsigned int present;
13358 unsigned char bits;
13359
13360 present = snd_hda_codec_read(codec, 0x18, 0,
13361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013362 bits = present ? HDA_AMP_MUTE : 0;
13363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13364 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013365}
13366
13367static void alc861vd_lenovo_automute(struct hda_codec *codec)
13368{
13369 alc861vd_lenovo_hp_automute(codec);
13370 alc861vd_lenovo_mic_automute(codec);
13371}
13372
13373static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13374 unsigned int res)
13375{
13376 switch (res >> 26) {
13377 case ALC880_HP_EVENT:
13378 alc861vd_lenovo_hp_automute(codec);
13379 break;
13380 case ALC880_MIC_EVENT:
13381 alc861vd_lenovo_mic_automute(codec);
13382 break;
13383 }
13384}
13385
Kailang Yang272a5272007-05-14 11:00:38 +020013386static struct hda_verb alc861vd_dallas_verbs[] = {
13387 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13388 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13390 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13391
13392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13398 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013400
Kailang Yang272a5272007-05-14 11:00:38 +020013401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13405 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13406 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13407 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13408 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13409
13410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13412 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13414 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13415 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13416 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13417 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13418
13419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13423
13424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013425 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013426 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13427
13428 { } /* end */
13429};
13430
13431/* toggle speaker-output according to the hp-jack state */
13432static void alc861vd_dallas_automute(struct hda_codec *codec)
13433{
13434 unsigned int present;
13435
13436 present = snd_hda_codec_read(codec, 0x15, 0,
13437 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013438 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13439 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013440}
13441
13442static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13443{
13444 if ((res >> 26) == ALC880_HP_EVENT)
13445 alc861vd_dallas_automute(codec);
13446}
13447
Takashi Iwaicb53c622007-08-10 17:21:45 +020013448#ifdef CONFIG_SND_HDA_POWER_SAVE
13449#define alc861vd_loopbacks alc880_loopbacks
13450#endif
13451
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013452/* pcm configuration: identiacal with ALC880 */
13453#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13454#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13455#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13456#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13457
13458/*
13459 * configuration and preset
13460 */
13461static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13462 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013463 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013464 [ALC861VD_3ST] = "3stack",
13465 [ALC861VD_3ST_DIG] = "3stack-digout",
13466 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013467 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013468 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013469 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013470 [ALC861VD_AUTO] = "auto",
13471};
13472
13473static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013474 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13475 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013476 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013477 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013478 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013479 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013480 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013481 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013482 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013483 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013484 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013485 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013486 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013487 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13488 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013489 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013490 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013491 {}
13492};
13493
13494static struct alc_config_preset alc861vd_presets[] = {
13495 [ALC660VD_3ST] = {
13496 .mixers = { alc861vd_3st_mixer },
13497 .init_verbs = { alc861vd_volume_init_verbs,
13498 alc861vd_3stack_init_verbs },
13499 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13500 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013501 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13502 .channel_mode = alc861vd_3stack_2ch_modes,
13503 .input_mux = &alc861vd_capture_source,
13504 },
Mike Crash6963f842007-06-25 12:12:51 +020013505 [ALC660VD_3ST_DIG] = {
13506 .mixers = { alc861vd_3st_mixer },
13507 .init_verbs = { alc861vd_volume_init_verbs,
13508 alc861vd_3stack_init_verbs },
13509 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13510 .dac_nids = alc660vd_dac_nids,
13511 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013512 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13513 .channel_mode = alc861vd_3stack_2ch_modes,
13514 .input_mux = &alc861vd_capture_source,
13515 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013516 [ALC861VD_3ST] = {
13517 .mixers = { alc861vd_3st_mixer },
13518 .init_verbs = { alc861vd_volume_init_verbs,
13519 alc861vd_3stack_init_verbs },
13520 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13521 .dac_nids = alc861vd_dac_nids,
13522 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13523 .channel_mode = alc861vd_3stack_2ch_modes,
13524 .input_mux = &alc861vd_capture_source,
13525 },
13526 [ALC861VD_3ST_DIG] = {
13527 .mixers = { alc861vd_3st_mixer },
13528 .init_verbs = { alc861vd_volume_init_verbs,
13529 alc861vd_3stack_init_verbs },
13530 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13531 .dac_nids = alc861vd_dac_nids,
13532 .dig_out_nid = ALC861VD_DIGOUT_NID,
13533 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13534 .channel_mode = alc861vd_3stack_2ch_modes,
13535 .input_mux = &alc861vd_capture_source,
13536 },
13537 [ALC861VD_6ST_DIG] = {
13538 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13539 .init_verbs = { alc861vd_volume_init_verbs,
13540 alc861vd_6stack_init_verbs },
13541 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13542 .dac_nids = alc861vd_dac_nids,
13543 .dig_out_nid = ALC861VD_DIGOUT_NID,
13544 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13545 .channel_mode = alc861vd_6stack_modes,
13546 .input_mux = &alc861vd_capture_source,
13547 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013548 [ALC861VD_LENOVO] = {
13549 .mixers = { alc861vd_lenovo_mixer },
13550 .init_verbs = { alc861vd_volume_init_verbs,
13551 alc861vd_3stack_init_verbs,
13552 alc861vd_eapd_verbs,
13553 alc861vd_lenovo_unsol_verbs },
13554 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13555 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013556 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13557 .channel_mode = alc861vd_3stack_2ch_modes,
13558 .input_mux = &alc861vd_capture_source,
13559 .unsol_event = alc861vd_lenovo_unsol_event,
13560 .init_hook = alc861vd_lenovo_automute,
13561 },
Kailang Yang272a5272007-05-14 11:00:38 +020013562 [ALC861VD_DALLAS] = {
13563 .mixers = { alc861vd_dallas_mixer },
13564 .init_verbs = { alc861vd_dallas_verbs },
13565 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13566 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013567 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13568 .channel_mode = alc861vd_3stack_2ch_modes,
13569 .input_mux = &alc861vd_dallas_capture_source,
13570 .unsol_event = alc861vd_dallas_unsol_event,
13571 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013572 },
13573 [ALC861VD_HP] = {
13574 .mixers = { alc861vd_hp_mixer },
13575 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13576 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13577 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013578 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013579 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13580 .channel_mode = alc861vd_3stack_2ch_modes,
13581 .input_mux = &alc861vd_hp_capture_source,
13582 .unsol_event = alc861vd_dallas_unsol_event,
13583 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013584 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013585};
13586
13587/*
13588 * BIOS auto configuration
13589 */
13590static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13591 hda_nid_t nid, int pin_type, int dac_idx)
13592{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013593 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013594}
13595
13596static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13597{
13598 struct alc_spec *spec = codec->spec;
13599 int i;
13600
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013601 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013602 for (i = 0; i <= HDA_SIDE; i++) {
13603 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013604 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013605 if (nid)
13606 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013607 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013608 }
13609}
13610
13611
13612static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13613{
13614 struct alc_spec *spec = codec->spec;
13615 hda_nid_t pin;
13616
13617 pin = spec->autocfg.hp_pins[0];
13618 if (pin) /* connect to front and use dac 0 */
13619 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013620 pin = spec->autocfg.speaker_pins[0];
13621 if (pin)
13622 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013623}
13624
13625#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13626#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13627
13628static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13629{
13630 struct alc_spec *spec = codec->spec;
13631 int i;
13632
13633 for (i = 0; i < AUTO_PIN_LAST; i++) {
13634 hda_nid_t nid = spec->autocfg.input_pins[i];
13635 if (alc861vd_is_input_pin(nid)) {
13636 snd_hda_codec_write(codec, nid, 0,
13637 AC_VERB_SET_PIN_WIDGET_CONTROL,
13638 i <= AUTO_PIN_FRONT_MIC ?
13639 PIN_VREF80 : PIN_IN);
13640 if (nid != ALC861VD_PIN_CD_NID)
13641 snd_hda_codec_write(codec, nid, 0,
13642 AC_VERB_SET_AMP_GAIN_MUTE,
13643 AMP_OUT_MUTE);
13644 }
13645 }
13646}
13647
Takashi Iwaif511b012008-08-15 16:46:42 +020013648#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13649
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013650#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13651#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13652
13653/* add playback controls from the parsed DAC table */
13654/* Based on ALC880 version. But ALC861VD has separate,
13655 * different NIDs for mute/unmute switch and volume control */
13656static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13657 const struct auto_pin_cfg *cfg)
13658{
13659 char name[32];
13660 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13661 hda_nid_t nid_v, nid_s;
13662 int i, err;
13663
13664 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013665 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013666 continue;
13667 nid_v = alc861vd_idx_to_mixer_vol(
13668 alc880_dac_to_idx(
13669 spec->multiout.dac_nids[i]));
13670 nid_s = alc861vd_idx_to_mixer_switch(
13671 alc880_dac_to_idx(
13672 spec->multiout.dac_nids[i]));
13673
13674 if (i == 2) {
13675 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013676 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13677 "Center Playback Volume",
13678 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13679 HDA_OUTPUT));
13680 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013681 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013682 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13683 "LFE Playback Volume",
13684 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13685 HDA_OUTPUT));
13686 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013687 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688 err = add_control(spec, ALC_CTL_BIND_MUTE,
13689 "Center Playback Switch",
13690 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13691 HDA_INPUT));
13692 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013693 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013694 err = add_control(spec, ALC_CTL_BIND_MUTE,
13695 "LFE Playback Switch",
13696 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13697 HDA_INPUT));
13698 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013699 return err;
13700 } else {
13701 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013702 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13703 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13704 HDA_OUTPUT));
13705 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013706 return err;
13707 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013708 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013709 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710 HDA_INPUT));
13711 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013712 return err;
13713 }
13714 }
13715 return 0;
13716}
13717
13718/* add playback controls for speaker and HP outputs */
13719/* Based on ALC880 version. But ALC861VD has separate,
13720 * different NIDs for mute/unmute switch and volume control */
13721static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13722 hda_nid_t pin, const char *pfx)
13723{
13724 hda_nid_t nid_v, nid_s;
13725 int err;
13726 char name[32];
13727
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013728 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013729 return 0;
13730
13731 if (alc880_is_fixed_pin(pin)) {
13732 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13733 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013734 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013735 spec->multiout.hp_nid = nid_v;
13736 else
13737 spec->multiout.extra_out_nid[0] = nid_v;
13738 /* control HP volume/switch on the output mixer amp */
13739 nid_v = alc861vd_idx_to_mixer_vol(
13740 alc880_fixed_pin_idx(pin));
13741 nid_s = alc861vd_idx_to_mixer_switch(
13742 alc880_fixed_pin_idx(pin));
13743
13744 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013745 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13746 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13747 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013748 return err;
13749 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013750 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13751 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13752 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013753 return err;
13754 } else if (alc880_is_multi_pin(pin)) {
13755 /* set manual connection */
13756 /* we have only a switch on HP-out PIN */
13757 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013758 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13759 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13760 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013761 return err;
13762 }
13763 return 0;
13764}
13765
13766/* parse the BIOS configuration and set up the alc_spec
13767 * return 1 if successful, 0 if the proper config is not found,
13768 * or a negative error code
13769 * Based on ALC880 version - had to change it to override
13770 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13771static int alc861vd_parse_auto_config(struct hda_codec *codec)
13772{
13773 struct alc_spec *spec = codec->spec;
13774 int err;
13775 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13776
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13778 alc861vd_ignore);
13779 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013780 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013781 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013782 return 0; /* can't find valid BIOS pin config */
13783
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013784 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13785 if (err < 0)
13786 return err;
13787 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13788 if (err < 0)
13789 return err;
13790 err = alc861vd_auto_create_extra_out(spec,
13791 spec->autocfg.speaker_pins[0],
13792 "Speaker");
13793 if (err < 0)
13794 return err;
13795 err = alc861vd_auto_create_extra_out(spec,
13796 spec->autocfg.hp_pins[0],
13797 "Headphone");
13798 if (err < 0)
13799 return err;
13800 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13801 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013802 return err;
13803
13804 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13805
13806 if (spec->autocfg.dig_out_pin)
13807 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13808
13809 if (spec->kctl_alloc)
13810 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13811
13812 spec->init_verbs[spec->num_init_verbs++]
13813 = alc861vd_volume_init_verbs;
13814
13815 spec->num_mux_defs = 1;
13816 spec->input_mux = &spec->private_imux;
13817
Takashi Iwai776e1842007-08-29 15:07:11 +020013818 err = alc_auto_add_mic_boost(codec);
13819 if (err < 0)
13820 return err;
13821
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013822 return 1;
13823}
13824
13825/* additional initialization for auto-configuration model */
13826static void alc861vd_auto_init(struct hda_codec *codec)
13827{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013828 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013829 alc861vd_auto_init_multi_out(codec);
13830 alc861vd_auto_init_hp_out(codec);
13831 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020013832 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013833 if (spec->unsol_event)
13834 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013835}
13836
13837static int patch_alc861vd(struct hda_codec *codec)
13838{
13839 struct alc_spec *spec;
13840 int err, board_config;
13841
13842 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13843 if (spec == NULL)
13844 return -ENOMEM;
13845
13846 codec->spec = spec;
13847
13848 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13849 alc861vd_models,
13850 alc861vd_cfg_tbl);
13851
13852 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13853 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13854 "ALC861VD, trying auto-probe from BIOS...\n");
13855 board_config = ALC861VD_AUTO;
13856 }
13857
13858 if (board_config == ALC861VD_AUTO) {
13859 /* automatic parse from the BIOS config */
13860 err = alc861vd_parse_auto_config(codec);
13861 if (err < 0) {
13862 alc_free(codec);
13863 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013864 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013865 printk(KERN_INFO
13866 "hda_codec: Cannot set up configuration "
13867 "from BIOS. Using base mode...\n");
13868 board_config = ALC861VD_3ST;
13869 }
13870 }
13871
13872 if (board_config != ALC861VD_AUTO)
13873 setup_preset(spec, &alc861vd_presets[board_config]);
13874
Kailang Yang2f893282008-05-27 12:14:47 +020013875 if (codec->vendor_id == 0x10ec0660) {
13876 spec->stream_name_analog = "ALC660-VD Analog";
13877 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013878 /* always turn on EAPD */
13879 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013880 } else {
13881 spec->stream_name_analog = "ALC861VD Analog";
13882 spec->stream_name_digital = "ALC861VD Digital";
13883 }
13884
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013885 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13886 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13887
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013888 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13889 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13890
13891 spec->adc_nids = alc861vd_adc_nids;
13892 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013893 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013894
13895 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13896 spec->num_mixers++;
13897
Takashi Iwai2134ea42008-01-10 16:53:55 +010013898 spec->vmaster_nid = 0x02;
13899
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013900 codec->patch_ops = alc_patch_ops;
13901
13902 if (board_config == ALC861VD_AUTO)
13903 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013904#ifdef CONFIG_SND_HDA_POWER_SAVE
13905 if (!spec->loopback.amplist)
13906 spec->loopback.amplist = alc861vd_loopbacks;
13907#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013908
13909 return 0;
13910}
13911
13912/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013913 * ALC662 support
13914 *
13915 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13916 * configuration. Each pin widget can choose any input DACs and a mixer.
13917 * Each ADC is connected from a mixer of all inputs. This makes possible
13918 * 6-channel independent captures.
13919 *
13920 * In addition, an independent DAC for the multi-playback (not used in this
13921 * driver yet).
13922 */
13923#define ALC662_DIGOUT_NID 0x06
13924#define ALC662_DIGIN_NID 0x0a
13925
13926static hda_nid_t alc662_dac_nids[4] = {
13927 /* front, rear, clfe, rear_surr */
13928 0x02, 0x03, 0x04
13929};
13930
13931static hda_nid_t alc662_adc_nids[1] = {
13932 /* ADC1-2 */
13933 0x09,
13934};
Takashi Iwaie1406342008-02-11 18:32:32 +010013935
Kailang Yang77a261b2008-02-19 11:38:05 +010013936static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013937
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013938/* input MUX */
13939/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013940static struct hda_input_mux alc662_capture_source = {
13941 .num_items = 4,
13942 .items = {
13943 { "Mic", 0x0 },
13944 { "Front Mic", 0x1 },
13945 { "Line", 0x2 },
13946 { "CD", 0x4 },
13947 },
13948};
13949
13950static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13951 .num_items = 2,
13952 .items = {
13953 { "Mic", 0x1 },
13954 { "Line", 0x2 },
13955 },
13956};
Kailang Yang291702f2007-10-16 14:28:03 +020013957
13958static struct hda_input_mux alc662_eeepc_capture_source = {
13959 .num_items = 2,
13960 .items = {
13961 { "i-Mic", 0x1 },
13962 { "e-Mic", 0x0 },
13963 },
13964};
13965
Kailang Yang6dda9f42008-05-27 12:05:31 +020013966static struct hda_input_mux alc663_capture_source = {
13967 .num_items = 3,
13968 .items = {
13969 { "Mic", 0x0 },
13970 { "Front Mic", 0x1 },
13971 { "Line", 0x2 },
13972 },
13973};
13974
13975static struct hda_input_mux alc663_m51va_capture_source = {
13976 .num_items = 2,
13977 .items = {
13978 { "Ext-Mic", 0x0 },
13979 { "D-Mic", 0x9 },
13980 },
13981};
13982
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013983#define alc662_mux_enum_info alc_mux_enum_info
13984#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013985#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013986
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013987/*
13988 * 2ch mode
13989 */
13990static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13991 { 2, NULL }
13992};
13993
13994/*
13995 * 2ch mode
13996 */
13997static struct hda_verb alc662_3ST_ch2_init[] = {
13998 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13999 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14000 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14001 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14002 { } /* end */
14003};
14004
14005/*
14006 * 6ch mode
14007 */
14008static struct hda_verb alc662_3ST_ch6_init[] = {
14009 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14010 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14011 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14012 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14013 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14014 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14015 { } /* end */
14016};
14017
14018static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14019 { 2, alc662_3ST_ch2_init },
14020 { 6, alc662_3ST_ch6_init },
14021};
14022
14023/*
14024 * 2ch mode
14025 */
14026static struct hda_verb alc662_sixstack_ch6_init[] = {
14027 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14028 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14029 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14030 { } /* end */
14031};
14032
14033/*
14034 * 6ch mode
14035 */
14036static struct hda_verb alc662_sixstack_ch8_init[] = {
14037 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14038 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14039 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14040 { } /* end */
14041};
14042
14043static struct hda_channel_mode alc662_5stack_modes[2] = {
14044 { 2, alc662_sixstack_ch6_init },
14045 { 6, alc662_sixstack_ch8_init },
14046};
14047
14048/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14049 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14050 */
14051
14052static struct snd_kcontrol_new alc662_base_mixer[] = {
14053 /* output mixer control */
14054 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014055 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014056 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014057 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014058 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14059 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014060 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14061 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14063
14064 /*Input mixer control */
14065 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14066 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14067 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14068 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14069 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14070 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14071 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14072 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014073 { } /* end */
14074};
14075
14076static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14077 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014078 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14080 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14081 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14086 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14087 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14088 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14089 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014090 { } /* end */
14091};
14092
14093static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14094 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014095 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014096 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014097 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014098 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14099 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014100 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14101 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14105 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14106 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14109 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14110 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14111 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14112 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014113 { } /* end */
14114};
14115
14116static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14117 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14118 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14120 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014126 { } /* end */
14127};
14128
Kailang Yang291702f2007-10-16 14:28:03 +020014129static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014130 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014131
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014132 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14133 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014134
14135 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14136 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14137 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14138
14139 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14140 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14141 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14142 { } /* end */
14143};
14144
Kailang Yang8c427222008-01-10 13:03:59 +010014145static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014146 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14147 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14149 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014154 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014155 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14159 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14160 { } /* end */
14161};
14162
Kailang Yang6dda9f42008-05-27 12:05:31 +020014163static struct snd_kcontrol_new alc663_m51va_mixer[] = {
14164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14165 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14169 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
14170 { } /* end */
14171};
14172
14173static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14175 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14176 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14177 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14179
14180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14182 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14183 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14184 { } /* end */
14185};
14186
14187static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14189 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14191
14192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14194 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14195 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14198 { } /* end */
14199};
14200
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014201static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14202 {
14203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14204 .name = "Channel Mode",
14205 .info = alc_ch_mode_info,
14206 .get = alc_ch_mode_get,
14207 .put = alc_ch_mode_put,
14208 },
14209 { } /* end */
14210};
14211
14212static struct hda_verb alc662_init_verbs[] = {
14213 /* ADC: mute amp left and right */
14214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14215 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14216 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14217
Takashi Iwaicb53c622007-08-10 17:21:45 +020014218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014223
Kailang Yangb60dd392007-09-20 12:50:29 +020014224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014230
14231 /* Front Pin: output 0 (0x0c) */
14232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14234
14235 /* Rear Pin: output 1 (0x0d) */
14236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14238
14239 /* CLFE Pin: output 2 (0x0e) */
14240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14242
14243 /* Mic (rear) pin: input vref at 80% */
14244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14246 /* Front Mic pin: input vref at 80% */
14247 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14249 /* Line In pin: input */
14250 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14252 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14255 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14256 /* CD pin widget for input */
14257 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14258
14259 /* FIXME: use matrix-type input source selection */
14260 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14261 /* Input mixer */
14262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014266
14267 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014271
14272 /* always trun on EAPD */
14273 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14274 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14275
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014276 { }
14277};
14278
14279static struct hda_verb alc662_sue_init_verbs[] = {
14280 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014282 {}
14283};
14284
14285static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14286 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14288 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014289};
14290
Kailang Yang8c427222008-01-10 13:03:59 +010014291/* Set Unsolicited Event*/
14292static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14294 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14295 {}
14296};
14297
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014298/*
14299 * generic initialization of ADC, input mixers and output mixers
14300 */
14301static struct hda_verb alc662_auto_init_verbs[] = {
14302 /*
14303 * Unmute ADC and set the default input to mic-in
14304 */
14305 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14307
14308 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14309 * mixer widget
14310 * Note: PASD motherboards uses the Line In 2 as the input for front
14311 * panel mic (mic 2)
14312 */
14313 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014319
14320 /*
14321 * Set up output mixers (0x0c - 0x0f)
14322 */
14323 /* set vol=0 to output mixers */
14324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14327
14328 /* set up input amps for analog loopback */
14329 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014336
14337
14338 /* FIXME: use matrix-type input source selection */
14339 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14340 /* Input mixer */
14341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014343 { }
14344};
14345
Takashi Iwai24fb9172008-09-02 14:48:20 +020014346/* additional verbs for ALC663 */
14347static struct hda_verb alc663_auto_init_verbs[] = {
14348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14350 { }
14351};
14352
Kailang Yang6dda9f42008-05-27 12:05:31 +020014353static struct hda_verb alc663_m51va_init_verbs[] = {
14354 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14355 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14356 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14357
14358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14359
14360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14362 {}
14363};
14364
14365static struct hda_verb alc663_g71v_init_verbs[] = {
14366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14367 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14368 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14369
14370 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14371 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14372 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14373
14374 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14375 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14376 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14377 {}
14378};
14379
14380static struct hda_verb alc663_g50v_init_verbs[] = {
14381 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14382 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14383 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14384
14385 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14386 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14387 {}
14388};
14389
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014390/* capture mixer elements */
14391static struct snd_kcontrol_new alc662_capture_mixer[] = {
14392 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14393 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14394 {
14395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14396 /* The multiple "Capture Source" controls confuse alsamixer
14397 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014398 */
14399 /* .name = "Capture Source", */
14400 .name = "Input Source",
14401 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010014402 .info = alc662_mux_enum_info,
14403 .get = alc662_mux_enum_get,
14404 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014405 },
14406 { } /* end */
14407};
14408
14409static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14410{
14411 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014412 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014413
14414 present = snd_hda_codec_read(codec, 0x14, 0,
14415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014416 bits = present ? HDA_AMP_MUTE : 0;
14417 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14418 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014419}
14420
14421static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14422{
14423 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014424 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014425
14426 present = snd_hda_codec_read(codec, 0x1b, 0,
14427 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014428 bits = present ? HDA_AMP_MUTE : 0;
14429 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14430 HDA_AMP_MUTE, bits);
14431 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14432 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014433}
14434
14435static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14436 unsigned int res)
14437{
14438 if ((res >> 26) == ALC880_HP_EVENT)
14439 alc662_lenovo_101e_all_automute(codec);
14440 if ((res >> 26) == ALC880_FRONT_EVENT)
14441 alc662_lenovo_101e_ispeaker_automute(codec);
14442}
14443
Kailang Yang291702f2007-10-16 14:28:03 +020014444static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14445{
14446 unsigned int present;
14447
14448 present = snd_hda_codec_read(codec, 0x18, 0,
14449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14450 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14451 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14452 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14453 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14454 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14455 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14456 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14457 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14458}
14459
14460/* unsolicited event for HP jack sensing */
14461static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14462 unsigned int res)
14463{
14464 if ((res >> 26) == ALC880_HP_EVENT)
14465 alc262_hippo1_automute( codec );
14466
14467 if ((res >> 26) == ALC880_MIC_EVENT)
14468 alc662_eeepc_mic_automute(codec);
14469}
14470
14471static void alc662_eeepc_inithook(struct hda_codec *codec)
14472{
14473 alc262_hippo1_automute( codec );
14474 alc662_eeepc_mic_automute(codec);
14475}
14476
Kailang Yang8c427222008-01-10 13:03:59 +010014477static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14478{
14479 unsigned int mute;
14480 unsigned int present;
14481
14482 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14483 present = snd_hda_codec_read(codec, 0x14, 0,
14484 AC_VERB_GET_PIN_SENSE, 0);
14485 present = (present & 0x80000000) != 0;
14486 if (present) {
14487 /* mute internal speaker */
14488 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014489 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010014490 } else {
14491 /* unmute internal speaker if necessary */
14492 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14493 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014494 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010014495 }
14496}
14497
14498/* unsolicited event for HP jack sensing */
14499static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14500 unsigned int res)
14501{
14502 if ((res >> 26) == ALC880_HP_EVENT)
14503 alc662_eeepc_ep20_automute(codec);
14504}
14505
14506static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14507{
14508 alc662_eeepc_ep20_automute(codec);
14509}
14510
Kailang Yang6dda9f42008-05-27 12:05:31 +020014511static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14512{
14513 unsigned int present;
14514 unsigned char bits;
14515
14516 present = snd_hda_codec_read(codec, 0x21, 0,
14517 AC_VERB_GET_PIN_SENSE, 0)
14518 & AC_PINSENSE_PRESENCE;
14519 bits = present ? HDA_AMP_MUTE : 0;
14520 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14521 HDA_AMP_MUTE, bits);
14522}
14523
14524static void alc663_m51va_mic_automute(struct hda_codec *codec)
14525{
14526 unsigned int present;
14527
14528 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014529 AC_VERB_GET_PIN_SENSE, 0)
14530 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020014531 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014532 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014533 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014534 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014535 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014536 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014537 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014538 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014539}
14540
14541static void alc663_m51va_unsol_event(struct hda_codec *codec,
14542 unsigned int res)
14543{
14544 switch (res >> 26) {
14545 case ALC880_HP_EVENT:
14546 alc663_m51va_speaker_automute(codec);
14547 break;
14548 case ALC880_MIC_EVENT:
14549 alc663_m51va_mic_automute(codec);
14550 break;
14551 }
14552}
14553
14554static void alc663_m51va_inithook(struct hda_codec *codec)
14555{
14556 alc663_m51va_speaker_automute(codec);
14557 alc663_m51va_mic_automute(codec);
14558}
14559
14560static void alc663_g71v_hp_automute(struct hda_codec *codec)
14561{
14562 unsigned int present;
14563 unsigned char bits;
14564
14565 present = snd_hda_codec_read(codec, 0x21, 0,
14566 AC_VERB_GET_PIN_SENSE, 0)
14567 & AC_PINSENSE_PRESENCE;
14568 bits = present ? HDA_AMP_MUTE : 0;
14569 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14570 HDA_AMP_MUTE, bits);
14571 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14572 HDA_AMP_MUTE, bits);
14573}
14574
14575static void alc663_g71v_front_automute(struct hda_codec *codec)
14576{
14577 unsigned int present;
14578 unsigned char bits;
14579
14580 present = snd_hda_codec_read(codec, 0x15, 0,
14581 AC_VERB_GET_PIN_SENSE, 0)
14582 & AC_PINSENSE_PRESENCE;
14583 bits = present ? HDA_AMP_MUTE : 0;
14584 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14585 HDA_AMP_MUTE, bits);
14586}
14587
14588static void alc663_g71v_unsol_event(struct hda_codec *codec,
14589 unsigned int res)
14590{
14591 switch (res >> 26) {
14592 case ALC880_HP_EVENT:
14593 alc663_g71v_hp_automute(codec);
14594 break;
14595 case ALC880_FRONT_EVENT:
14596 alc663_g71v_front_automute(codec);
14597 break;
14598 case ALC880_MIC_EVENT:
14599 alc662_eeepc_mic_automute(codec);
14600 break;
14601 }
14602}
14603
14604static void alc663_g71v_inithook(struct hda_codec *codec)
14605{
14606 alc663_g71v_front_automute(codec);
14607 alc663_g71v_hp_automute(codec);
14608 alc662_eeepc_mic_automute(codec);
14609}
14610
14611static void alc663_g50v_unsol_event(struct hda_codec *codec,
14612 unsigned int res)
14613{
14614 switch (res >> 26) {
14615 case ALC880_HP_EVENT:
14616 alc663_m51va_speaker_automute(codec);
14617 break;
14618 case ALC880_MIC_EVENT:
14619 alc662_eeepc_mic_automute(codec);
14620 break;
14621 }
14622}
14623
14624static void alc663_g50v_inithook(struct hda_codec *codec)
14625{
14626 alc663_m51va_speaker_automute(codec);
14627 alc662_eeepc_mic_automute(codec);
14628}
14629
Takashi Iwaicb53c622007-08-10 17:21:45 +020014630#ifdef CONFIG_SND_HDA_POWER_SAVE
14631#define alc662_loopbacks alc880_loopbacks
14632#endif
14633
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014634
14635/* pcm configuration: identiacal with ALC880 */
14636#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14637#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14638#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14639#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14640
14641/*
14642 * configuration and preset
14643 */
14644static const char *alc662_models[ALC662_MODEL_LAST] = {
14645 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14646 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14647 [ALC662_3ST_6ch] = "3stack-6ch",
14648 [ALC662_5ST_DIG] = "6stack-dig",
14649 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014650 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014651 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014652 [ALC663_ASUS_M51VA] = "m51va",
14653 [ALC663_ASUS_G71V] = "g71v",
14654 [ALC663_ASUS_H13] = "h13",
14655 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014656 [ALC662_AUTO] = "auto",
14657};
14658
14659static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014660 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14661 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14662 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014663 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014664 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014665 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014666 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014667 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14668 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14669 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014670 {}
14671};
14672
14673static struct alc_config_preset alc662_presets[] = {
14674 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014675 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014676 .init_verbs = { alc662_init_verbs },
14677 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14678 .dac_nids = alc662_dac_nids,
14679 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014680 .dig_in_nid = ALC662_DIGIN_NID,
14681 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14682 .channel_mode = alc662_3ST_2ch_modes,
14683 .input_mux = &alc662_capture_source,
14684 },
14685 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014686 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14687 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014688 .init_verbs = { alc662_init_verbs },
14689 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14690 .dac_nids = alc662_dac_nids,
14691 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014692 .dig_in_nid = ALC662_DIGIN_NID,
14693 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14694 .channel_mode = alc662_3ST_6ch_modes,
14695 .need_dac_fix = 1,
14696 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014697 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014698 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014699 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14700 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014701 .init_verbs = { alc662_init_verbs },
14702 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14703 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014704 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14705 .channel_mode = alc662_3ST_6ch_modes,
14706 .need_dac_fix = 1,
14707 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014708 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014709 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014710 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14711 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014712 .init_verbs = { alc662_init_verbs },
14713 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14714 .dac_nids = alc662_dac_nids,
14715 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014716 .dig_in_nid = ALC662_DIGIN_NID,
14717 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14718 .channel_mode = alc662_5stack_modes,
14719 .input_mux = &alc662_capture_source,
14720 },
14721 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014722 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014723 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14725 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014726 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14727 .channel_mode = alc662_3ST_2ch_modes,
14728 .input_mux = &alc662_lenovo_101e_capture_source,
14729 .unsol_event = alc662_lenovo_101e_unsol_event,
14730 .init_hook = alc662_lenovo_101e_all_automute,
14731 },
Kailang Yang291702f2007-10-16 14:28:03 +020014732 [ALC662_ASUS_EEEPC_P701] = {
14733 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14734 .init_verbs = { alc662_init_verbs,
14735 alc662_eeepc_sue_init_verbs },
14736 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14737 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014738 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14739 .channel_mode = alc662_3ST_2ch_modes,
14740 .input_mux = &alc662_eeepc_capture_source,
14741 .unsol_event = alc662_eeepc_unsol_event,
14742 .init_hook = alc662_eeepc_inithook,
14743 },
Kailang Yang8c427222008-01-10 13:03:59 +010014744 [ALC662_ASUS_EEEPC_EP20] = {
14745 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14746 alc662_chmode_mixer },
14747 .init_verbs = { alc662_init_verbs,
14748 alc662_eeepc_ep20_sue_init_verbs },
14749 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14750 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014751 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14752 .channel_mode = alc662_3ST_6ch_modes,
14753 .input_mux = &alc662_lenovo_101e_capture_source,
14754 .unsol_event = alc662_eeepc_ep20_unsol_event,
14755 .init_hook = alc662_eeepc_ep20_inithook,
14756 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014757 [ALC663_ASUS_M51VA] = {
14758 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14759 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14760 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14761 .dac_nids = alc662_dac_nids,
14762 .dig_out_nid = ALC662_DIGOUT_NID,
14763 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14764 .channel_mode = alc662_3ST_2ch_modes,
14765 .input_mux = &alc663_m51va_capture_source,
14766 .unsol_event = alc663_m51va_unsol_event,
14767 .init_hook = alc663_m51va_inithook,
14768 },
14769 [ALC663_ASUS_G71V] = {
14770 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14771 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14773 .dac_nids = alc662_dac_nids,
14774 .dig_out_nid = ALC662_DIGOUT_NID,
14775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14776 .channel_mode = alc662_3ST_2ch_modes,
14777 .input_mux = &alc662_eeepc_capture_source,
14778 .unsol_event = alc663_g71v_unsol_event,
14779 .init_hook = alc663_g71v_inithook,
14780 },
14781 [ALC663_ASUS_H13] = {
14782 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14783 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14784 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14785 .dac_nids = alc662_dac_nids,
14786 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14787 .channel_mode = alc662_3ST_2ch_modes,
14788 .input_mux = &alc663_m51va_capture_source,
14789 .unsol_event = alc663_m51va_unsol_event,
14790 .init_hook = alc663_m51va_inithook,
14791 },
14792 [ALC663_ASUS_G50V] = {
14793 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14794 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14796 .dac_nids = alc662_dac_nids,
14797 .dig_out_nid = ALC662_DIGOUT_NID,
14798 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14799 .channel_mode = alc662_3ST_6ch_modes,
14800 .input_mux = &alc663_capture_source,
14801 .unsol_event = alc663_g50v_unsol_event,
14802 .init_hook = alc663_g50v_inithook,
14803 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014804};
14805
14806
14807/*
14808 * BIOS auto configuration
14809 */
14810
14811/* add playback controls from the parsed DAC table */
14812static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14813 const struct auto_pin_cfg *cfg)
14814{
14815 char name[32];
14816 static const char *chname[4] = {
14817 "Front", "Surround", NULL /*CLFE*/, "Side"
14818 };
14819 hda_nid_t nid;
14820 int i, err;
14821
14822 for (i = 0; i < cfg->line_outs; i++) {
14823 if (!spec->multiout.dac_nids[i])
14824 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014825 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014826 if (i == 2) {
14827 /* Center/LFE */
14828 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14829 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014830 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14831 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014832 if (err < 0)
14833 return err;
14834 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14835 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014836 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14837 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014838 if (err < 0)
14839 return err;
14840 err = add_control(spec, ALC_CTL_BIND_MUTE,
14841 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014842 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14843 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014844 if (err < 0)
14845 return err;
14846 err = add_control(spec, ALC_CTL_BIND_MUTE,
14847 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014848 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14849 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014850 if (err < 0)
14851 return err;
14852 } else {
14853 sprintf(name, "%s Playback Volume", chname[i]);
14854 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014855 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14856 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014857 if (err < 0)
14858 return err;
14859 sprintf(name, "%s Playback Switch", chname[i]);
14860 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014861 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14862 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014863 if (err < 0)
14864 return err;
14865 }
14866 }
14867 return 0;
14868}
14869
14870/* add playback controls for speaker and HP outputs */
14871static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14872 const char *pfx)
14873{
14874 hda_nid_t nid;
14875 int err;
14876 char name[32];
14877
14878 if (!pin)
14879 return 0;
14880
Takashi Iwai24fb9172008-09-02 14:48:20 +020014881 if (pin == 0x17) {
14882 /* ALC663 has a mono output pin on 0x17 */
14883 sprintf(name, "%s Playback Switch", pfx);
14884 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14885 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
14886 return err;
14887 }
14888
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014889 if (alc880_is_fixed_pin(pin)) {
14890 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14891 /* printk("DAC nid=%x\n",nid); */
14892 /* specify the DAC as the extra output */
14893 if (!spec->multiout.hp_nid)
14894 spec->multiout.hp_nid = nid;
14895 else
14896 spec->multiout.extra_out_nid[0] = nid;
14897 /* control HP volume/switch on the output mixer amp */
14898 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14899 sprintf(name, "%s Playback Volume", pfx);
14900 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14901 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14902 if (err < 0)
14903 return err;
14904 sprintf(name, "%s Playback Switch", pfx);
14905 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14906 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14907 if (err < 0)
14908 return err;
14909 } else if (alc880_is_multi_pin(pin)) {
14910 /* set manual connection */
14911 /* we have only a switch on HP-out PIN */
14912 sprintf(name, "%s Playback Switch", pfx);
14913 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14914 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14915 if (err < 0)
14916 return err;
14917 }
14918 return 0;
14919}
14920
14921/* create playback/capture controls for input pins */
14922static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14923 const struct auto_pin_cfg *cfg)
14924{
14925 struct hda_input_mux *imux = &spec->private_imux;
14926 int i, err, idx;
14927
14928 for (i = 0; i < AUTO_PIN_LAST; i++) {
14929 if (alc880_is_input_pin(cfg->input_pins[i])) {
14930 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14931 err = new_analog_input(spec, cfg->input_pins[i],
14932 auto_pin_cfg_labels[i],
14933 idx, 0x0b);
14934 if (err < 0)
14935 return err;
14936 imux->items[imux->num_items].label =
14937 auto_pin_cfg_labels[i];
14938 imux->items[imux->num_items].index =
14939 alc880_input_pin_idx(cfg->input_pins[i]);
14940 imux->num_items++;
14941 }
14942 }
14943 return 0;
14944}
14945
14946static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14947 hda_nid_t nid, int pin_type,
14948 int dac_idx)
14949{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014950 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014951 /* need the manual connection? */
14952 if (alc880_is_multi_pin(nid)) {
14953 struct alc_spec *spec = codec->spec;
14954 int idx = alc880_multi_pin_idx(nid);
14955 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14956 AC_VERB_SET_CONNECT_SEL,
14957 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14958 }
14959}
14960
14961static void alc662_auto_init_multi_out(struct hda_codec *codec)
14962{
14963 struct alc_spec *spec = codec->spec;
14964 int i;
14965
Kailang Yang8c427222008-01-10 13:03:59 +010014966 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014967 for (i = 0; i <= HDA_SIDE; i++) {
14968 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014969 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014970 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014971 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014972 i);
14973 }
14974}
14975
14976static void alc662_auto_init_hp_out(struct hda_codec *codec)
14977{
14978 struct alc_spec *spec = codec->spec;
14979 hda_nid_t pin;
14980
14981 pin = spec->autocfg.hp_pins[0];
14982 if (pin) /* connect to front */
14983 /* use dac 0 */
14984 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014985 pin = spec->autocfg.speaker_pins[0];
14986 if (pin)
14987 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014988}
14989
14990#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14991#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14992
14993static void alc662_auto_init_analog_input(struct hda_codec *codec)
14994{
14995 struct alc_spec *spec = codec->spec;
14996 int i;
14997
14998 for (i = 0; i < AUTO_PIN_LAST; i++) {
14999 hda_nid_t nid = spec->autocfg.input_pins[i];
15000 if (alc662_is_input_pin(nid)) {
15001 snd_hda_codec_write(codec, nid, 0,
15002 AC_VERB_SET_PIN_WIDGET_CONTROL,
15003 (i <= AUTO_PIN_FRONT_MIC ?
15004 PIN_VREF80 : PIN_IN));
15005 if (nid != ALC662_PIN_CD_NID)
15006 snd_hda_codec_write(codec, nid, 0,
15007 AC_VERB_SET_AMP_GAIN_MUTE,
15008 AMP_OUT_MUTE);
15009 }
15010 }
15011}
15012
Takashi Iwaif511b012008-08-15 16:46:42 +020015013#define alc662_auto_init_input_src alc882_auto_init_input_src
15014
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015015static int alc662_parse_auto_config(struct hda_codec *codec)
15016{
15017 struct alc_spec *spec = codec->spec;
15018 int err;
15019 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
15020
15021 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15022 alc662_ignore);
15023 if (err < 0)
15024 return err;
15025 if (!spec->autocfg.line_outs)
15026 return 0; /* can't find valid BIOS pin config */
15027
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015028 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15029 if (err < 0)
15030 return err;
15031 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
15032 if (err < 0)
15033 return err;
15034 err = alc662_auto_create_extra_out(spec,
15035 spec->autocfg.speaker_pins[0],
15036 "Speaker");
15037 if (err < 0)
15038 return err;
15039 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
15040 "Headphone");
15041 if (err < 0)
15042 return err;
15043 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
15044 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015045 return err;
15046
15047 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15048
15049 if (spec->autocfg.dig_out_pin)
15050 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
15051
15052 if (spec->kctl_alloc)
15053 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
15054
15055 spec->num_mux_defs = 1;
15056 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020015057
Takashi Iwai8c872862007-06-19 12:11:16 +020015058 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020015059 if (codec->vendor_id == 0x10ec0663)
15060 spec->init_verbs[spec->num_init_verbs++] =
15061 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020015062
15063 err = alc_auto_add_mic_boost(codec);
15064 if (err < 0)
15065 return err;
15066
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015067 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
15068 spec->num_mixers++;
Takashi Iwai8c872862007-06-19 12:11:16 +020015069 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015070}
15071
15072/* additional initialization for auto-configuration model */
15073static void alc662_auto_init(struct hda_codec *codec)
15074{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015075 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015076 alc662_auto_init_multi_out(codec);
15077 alc662_auto_init_hp_out(codec);
15078 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015079 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015080 if (spec->unsol_event)
15081 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015082}
15083
15084static int patch_alc662(struct hda_codec *codec)
15085{
15086 struct alc_spec *spec;
15087 int err, board_config;
15088
15089 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15090 if (!spec)
15091 return -ENOMEM;
15092
15093 codec->spec = spec;
15094
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020015095 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15096
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015097 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
15098 alc662_models,
15099 alc662_cfg_tbl);
15100 if (board_config < 0) {
15101 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
15102 "trying auto-probe from BIOS...\n");
15103 board_config = ALC662_AUTO;
15104 }
15105
15106 if (board_config == ALC662_AUTO) {
15107 /* automatic parse from the BIOS config */
15108 err = alc662_parse_auto_config(codec);
15109 if (err < 0) {
15110 alc_free(codec);
15111 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020015112 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015113 printk(KERN_INFO
15114 "hda_codec: Cannot set up configuration "
15115 "from BIOS. Using base mode...\n");
15116 board_config = ALC662_3ST_2ch_DIG;
15117 }
15118 }
15119
15120 if (board_config != ALC662_AUTO)
15121 setup_preset(spec, &alc662_presets[board_config]);
15122
Kailang Yang6dda9f42008-05-27 12:05:31 +020015123 if (codec->vendor_id == 0x10ec0663) {
15124 spec->stream_name_analog = "ALC663 Analog";
15125 spec->stream_name_digital = "ALC663 Digital";
15126 } else {
15127 spec->stream_name_analog = "ALC662 Analog";
15128 spec->stream_name_digital = "ALC662 Digital";
15129 }
15130
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015131 spec->stream_analog_playback = &alc662_pcm_analog_playback;
15132 spec->stream_analog_capture = &alc662_pcm_analog_capture;
15133
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015134 spec->stream_digital_playback = &alc662_pcm_digital_playback;
15135 spec->stream_digital_capture = &alc662_pcm_digital_capture;
15136
Takashi Iwaie1406342008-02-11 18:32:32 +010015137 spec->adc_nids = alc662_adc_nids;
15138 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
15139 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015140
Takashi Iwai2134ea42008-01-10 16:53:55 +010015141 spec->vmaster_nid = 0x02;
15142
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015143 codec->patch_ops = alc_patch_ops;
15144 if (board_config == ALC662_AUTO)
15145 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015146#ifdef CONFIG_SND_HDA_POWER_SAVE
15147 if (!spec->loopback.amplist)
15148 spec->loopback.amplist = alc662_loopbacks;
15149#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015150
15151 return 0;
15152}
15153
15154/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070015155 * patch entries
15156 */
15157struct hda_codec_preset snd_hda_preset_realtek[] = {
15158 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015159 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015160 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020015161 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015162 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015163 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015164 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015165 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
15166 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
15167 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015168 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
15169 .patch = patch_alc883 },
15170 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
15171 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015172 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015173 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015174 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015175 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020015176 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020015177 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010015178 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015179 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015180 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015181 {} /* terminator */
15182};