blob: 99c1de639e972c3e030a88f9e0ce790899048e3f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang 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 Woithe7cf51e482006-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,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200116 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100117 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100118 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100119#ifdef CONFIG_SND_DEBUG
120 ALC268_TEST,
121#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200122 ALC268_AUTO,
123 ALC268_MODEL_LAST /* last tag */
124};
125
Kailang Yangf6a92242007-12-13 16:52:54 +0100126/* ALC269 models */
127enum {
128 ALC269_BASIC,
Kailang Yangf53281e2008-07-18 12:36:43 +0200129 ALC269_ASUS_EEEPC_P703,
130 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100131 ALC269_AUTO,
132 ALC269_MODEL_LAST /* last tag */
133};
134
Kailang Yangdf694da2005-12-05 19:42:22 +0100135/* ALC861 models */
136enum {
137 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200138 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100139 ALC861_3ST_DIG,
140 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200141 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200142 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200143 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100144 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100145 ALC861_AUTO,
146 ALC861_MODEL_LAST,
147};
148
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100149/* ALC861-VD models */
150enum {
151 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200152 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153 ALC861VD_3ST,
154 ALC861VD_3ST_DIG,
155 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200156 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200157 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200158 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100159 ALC861VD_AUTO,
160 ALC861VD_MODEL_LAST,
161};
162
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200163/* ALC662 models */
164enum {
165 ALC662_3ST_2ch_DIG,
166 ALC662_3ST_6ch_DIG,
167 ALC662_3ST_6ch,
168 ALC662_5ST_DIG,
169 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200170 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100171 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200172 ALC663_ASUS_M51VA,
173 ALC663_ASUS_G71V,
174 ALC663_ASUS_H13,
175 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200176 ALC662_AUTO,
177 ALC662_MODEL_LAST,
178};
179
Kailang Yangdf694da2005-12-05 19:42:22 +0100180/* ALC882 models */
181enum {
182 ALC882_3ST_DIG,
183 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200184 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200185 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200186 ALC882_TARGA,
187 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200188 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100189 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200190 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200191 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200192 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100193 ALC882_MODEL_LAST,
194};
195
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200196/* ALC883 models */
197enum {
198 ALC883_3ST_2ch_DIG,
199 ALC883_3ST_6ch_DIG,
200 ALC883_3ST_6ch,
201 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200202 ALC883_TARGA_DIG,
203 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200204 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200205 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200206 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200207 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100208 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200209 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200211 ALC888_LENOVO_MS7195_DIG,
Kailang Yangea1fb292008-08-26 12:58:38 +0200212 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200213 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100214 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100215 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100216 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100217 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200218 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200219 ALC883_AUTO,
220 ALC883_MODEL_LAST,
221};
222
Kailang Yangdf694da2005-12-05 19:42:22 +0100223/* for GPIO Poll */
224#define GPIO_MASK 0x03
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226struct alc_spec {
227 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100228 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 unsigned int num_mixers;
230
Kailang Yangdf694da2005-12-05 19:42:22 +0100231 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200232 * don't forget NULL
233 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200234 */
235 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Takashi Iwai16ded522005-06-10 19:58:24 +0200237 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 struct hda_pcm_stream *stream_analog_playback;
239 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100240 struct hda_pcm_stream *stream_analog_alt_playback;
241 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200243 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 struct hda_pcm_stream *stream_digital_playback;
245 struct hda_pcm_stream *stream_digital_capture;
246
247 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200248 struct hda_multi_out multiout; /* playback set-up
249 * max_channels, dacs must be set
250 * dig_out_nid and hp_nid are optional
251 */
Takashi Iwai63300792008-01-24 15:31:36 +0100252 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 /* capture */
255 unsigned int num_adc_nids;
256 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100257 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200258 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200261 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 const struct hda_input_mux *input_mux;
263 unsigned int cur_mux[3];
264
265 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100266 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200268 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100271 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200272
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200273 /* dynamic controls, init_verbs and input_mux */
274 struct auto_pin_cfg autocfg;
275 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100276 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200277 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200278 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100279
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100280 /* hooks */
281 void (*init_hook)(struct hda_codec *codec);
282 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
283
Takashi Iwai834be882006-03-01 14:16:17 +0100284 /* for pin sensing */
285 unsigned int sense_updated: 1;
286 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100287 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200288
Takashi Iwai2134ea42008-01-10 16:53:55 +0100289 /* for virtual master */
290 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200291#ifdef CONFIG_SND_HDA_POWER_SAVE
292 struct hda_loopback_check loopback;
293#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200294
295 /* for PLL fix */
296 hda_nid_t pll_nid;
297 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100298};
299
300/*
301 * configuration template - to be copied to the spec instance
302 */
303struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200304 struct snd_kcontrol_new *mixers[5]; /* should be identical size
305 * with spec
306 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100307 const struct hda_verb *init_verbs[5];
308 unsigned int num_dacs;
309 hda_nid_t *dac_nids;
310 hda_nid_t dig_out_nid; /* optional */
311 hda_nid_t hp_nid; /* optional */
312 unsigned int num_adc_nids;
313 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100314 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100315 hda_nid_t dig_in_nid;
316 unsigned int num_channel_mode;
317 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200318 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200319 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100320 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100321 void (*unsol_event)(struct hda_codec *, unsigned int);
322 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200323#ifdef CONFIG_SND_HDA_POWER_SAVE
324 struct hda_amp_list *loopbacks;
325#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326};
327
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329/*
330 * input MUX handling
331 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200332static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200337 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
338 if (mux_idx >= spec->num_mux_defs)
339 mux_idx = 0;
340 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
348 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
349
350 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
351 return 0;
352}
353
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
355 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356{
357 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
358 struct alc_spec *spec = codec->spec;
359 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200360 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100361 hda_nid_t nid = spec->capsrc_nids ?
362 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100364 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365}
366
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368/*
369 * channel mode setting
370 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200371static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373{
374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
375 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100376 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
377 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100385 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386 spec->num_channel_mode,
387 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388}
389
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
394 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200395 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
396 spec->num_channel_mode,
397 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200398 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200399 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
400 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401}
402
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100404 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200405 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100406 * being part of a format specifier. Maximum allowed length of a value is
407 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100408 *
409 * Note: some retasking pin complexes seem to ignore requests for input
410 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
411 * are requested. Therefore order this list so that this behaviour will not
412 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200413 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
414 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200415 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100417 "Mic 50pc bias", "Mic 80pc bias",
418 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100419};
420static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100421 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422};
423/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200424 * in the pin being assumed to be exclusively an input or an output pin. In
425 * addition, "input" pins may or may not process the mic bias option
426 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
427 * accept requests for bias as of chip versions up to March 2006) and/or
428 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100429 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430#define ALC_PIN_DIR_IN 0x00
431#define ALC_PIN_DIR_OUT 0x01
432#define ALC_PIN_DIR_INOUT 0x02
433#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
434#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435
Kailang Yangea1fb292008-08-26 12:58:38 +0200436/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 * For each direction the minimum and maximum values are given.
438 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200439static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 { 0, 2 }, /* ALC_PIN_DIR_IN */
441 { 3, 4 }, /* ALC_PIN_DIR_OUT */
442 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200443 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
444 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100445};
446#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
447#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
448#define alc_pin_mode_n_items(_dir) \
449 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
450
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200451static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
452 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200453{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100454 unsigned int item_num = uinfo->value.enumerated.item;
455 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
456
457 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200458 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
460
461 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
462 item_num = alc_pin_mode_min(dir);
463 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200464 return 0;
465}
466
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200469{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100470 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200474 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200475 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
476 AC_VERB_GET_PIN_WIDGET_CONTROL,
477 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200478
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479 /* Find enumerated value for current pinctl setting */
480 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484 return 0;
485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489{
490 signed int change;
491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
492 hda_nid_t nid = kcontrol->private_value & 0xffff;
493 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
494 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
496 AC_VERB_GET_PIN_WIDGET_CONTROL,
497 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200499 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 val = alc_pin_mode_min(dir);
501
502 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100503 if (change) {
504 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200505 snd_hda_codec_write_cache(codec, nid, 0,
506 AC_VERB_SET_PIN_WIDGET_CONTROL,
507 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100508
Kailang Yangea1fb292008-08-26 12:58:38 +0200509 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100510 * for the requested pin mode. Enum values of 2 or less are
511 * input modes.
512 *
513 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200514 * reduces noise slightly (particularly on input) so we'll
515 * do it. However, having both input and output buffers
516 * enabled simultaneously doesn't seem to be problematic if
517 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100518 */
519 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200520 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
521 HDA_AMP_MUTE, HDA_AMP_MUTE);
522 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
523 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100524 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200525 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
526 HDA_AMP_MUTE, HDA_AMP_MUTE);
527 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
528 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100529 }
530 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200531 return change;
532}
533
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200535 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 .info = alc_pin_mode_info, \
537 .get = alc_pin_mode_get, \
538 .put = alc_pin_mode_put, \
539 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100540
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100541/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
542 * together using a mask with more than one bit set. This control is
543 * currently used only by the ALC260 test model. At this stage they are not
544 * needed for any "production" models.
545 */
546#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200547#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200548
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200549static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100551{
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 hda_nid_t nid = kcontrol->private_value & 0xffff;
554 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
555 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 unsigned int val = snd_hda_codec_read(codec, nid, 0,
557 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100558
559 *valp = (val & mask) != 0;
560 return 0;
561}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100564{
565 signed int change;
566 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
567 hda_nid_t nid = kcontrol->private_value & 0xffff;
568 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
569 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200570 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
571 AC_VERB_GET_GPIO_DATA,
572 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100573
574 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
576 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100577 gpio_data &= ~mask;
578 else
579 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200580 snd_hda_codec_write_cache(codec, nid, 0,
581 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100582
583 return change;
584}
585#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
587 .info = alc_gpio_data_info, \
588 .get = alc_gpio_data_get, \
589 .put = alc_gpio_data_put, \
590 .private_value = nid | (mask<<16) }
591#endif /* CONFIG_SND_DEBUG */
592
Jonathan Woithe92621f12006-02-28 11:47:47 +0100593/* A switch control to allow the enabling of the digital IO pins on the
594 * ALC260. This is incredibly simplistic; the intention of this control is
595 * to provide something in the test model allowing digital outputs to be
596 * identified if present. If models are found which can utilise these
597 * outputs a more complete mixer control can be devised for those models if
598 * necessary.
599 */
600#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200601#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200602
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
604 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 hda_nid_t nid = kcontrol->private_value & 0xffff;
608 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
609 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200610 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100611 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100612
613 *valp = (val & mask) != 0;
614 return 0;
615}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200616static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
617 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100618{
619 signed int change;
620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
621 hda_nid_t nid = kcontrol->private_value & 0xffff;
622 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
623 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100625 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100627
628 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200629 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100630 if (val==0)
631 ctrl_data &= ~mask;
632 else
633 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200634 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
635 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100636
637 return change;
638}
639#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
640 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
641 .info = alc_spdif_ctrl_info, \
642 .get = alc_spdif_ctrl_get, \
643 .put = alc_spdif_ctrl_put, \
644 .private_value = nid | (mask<<16) }
645#endif /* CONFIG_SND_DEBUG */
646
Jonathan Woithef8225f62008-01-08 12:16:54 +0100647/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
648 * Again, this is only used in the ALC26x test models to help identify when
649 * the EAPD line must be asserted for features to work.
650 */
651#ifdef CONFIG_SND_DEBUG
652#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
653
654static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
656{
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 hda_nid_t nid = kcontrol->private_value & 0xffff;
659 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
660 long *valp = ucontrol->value.integer.value;
661 unsigned int val = snd_hda_codec_read(codec, nid, 0,
662 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
663
664 *valp = (val & mask) != 0;
665 return 0;
666}
667
668static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
670{
671 int change;
672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
673 hda_nid_t nid = kcontrol->private_value & 0xffff;
674 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
675 long val = *ucontrol->value.integer.value;
676 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
677 AC_VERB_GET_EAPD_BTLENABLE,
678 0x00);
679
680 /* Set/unset the masked control bit(s) as needed */
681 change = (!val ? 0 : mask) != (ctrl_data & mask);
682 if (!val)
683 ctrl_data &= ~mask;
684 else
685 ctrl_data |= mask;
686 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
687 ctrl_data);
688
689 return change;
690}
691
692#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
693 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
694 .info = alc_eapd_ctrl_info, \
695 .get = alc_eapd_ctrl_get, \
696 .put = alc_eapd_ctrl_put, \
697 .private_value = nid | (mask<<16) }
698#endif /* CONFIG_SND_DEBUG */
699
Kailang Yangdf694da2005-12-05 19:42:22 +0100700/*
701 * set up from the preset table
702 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703static void setup_preset(struct alc_spec *spec,
704 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100705{
706 int i;
707
708 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
709 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
711 i++)
712 spec->init_verbs[spec->num_init_verbs++] =
713 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200714
Kailang Yangdf694da2005-12-05 19:42:22 +0100715 spec->channel_mode = preset->channel_mode;
716 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200717 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100718
719 spec->multiout.max_channels = spec->channel_mode[0].channels;
720
721 spec->multiout.num_dacs = preset->num_dacs;
722 spec->multiout.dac_nids = preset->dac_nids;
723 spec->multiout.dig_out_nid = preset->dig_out_nid;
724 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200725
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200726 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200727 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200728 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100729 spec->input_mux = preset->input_mux;
730
731 spec->num_adc_nids = preset->num_adc_nids;
732 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100733 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100734 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100735
736 spec->unsol_event = preset->unsol_event;
737 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200738#ifdef CONFIG_SND_HDA_POWER_SAVE
739 spec->loopback.amplist = preset->loopbacks;
740#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100741}
742
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200743/* Enable GPIO mask and set output */
744static struct hda_verb alc_gpio1_init_verbs[] = {
745 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
746 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
747 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
748 { }
749};
750
751static struct hda_verb alc_gpio2_init_verbs[] = {
752 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
753 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
754 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
755 { }
756};
757
Kailang Yangbdd148a2007-05-08 15:19:08 +0200758static struct hda_verb alc_gpio3_init_verbs[] = {
759 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
760 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
761 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
762 { }
763};
764
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200765/*
766 * Fix hardware PLL issue
767 * On some codecs, the analog PLL gating control must be off while
768 * the default value is 1.
769 */
770static void alc_fix_pll(struct hda_codec *codec)
771{
772 struct alc_spec *spec = codec->spec;
773 unsigned int val;
774
775 if (!spec->pll_nid)
776 return;
777 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
778 spec->pll_coef_idx);
779 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
780 AC_VERB_GET_PROC_COEF, 0);
781 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
782 spec->pll_coef_idx);
783 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
784 val & ~(1 << spec->pll_coef_bit));
785}
786
787static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
788 unsigned int coef_idx, unsigned int coef_bit)
789{
790 struct alc_spec *spec = codec->spec;
791 spec->pll_nid = nid;
792 spec->pll_coef_idx = coef_idx;
793 spec->pll_coef_bit = coef_bit;
794 alc_fix_pll(codec);
795}
796
Kailang Yangc9b58002007-10-16 14:30:01 +0200797static void alc_sku_automute(struct hda_codec *codec)
798{
799 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200800 unsigned int present;
801 unsigned int hp_nid = spec->autocfg.hp_pins[0];
802 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
803
804 /* need to execute and sync at first */
805 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
806 present = snd_hda_codec_read(codec, hp_nid, 0,
807 AC_VERB_GET_PIN_SENSE, 0);
808 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100809 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
810 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200811}
812
813/* unsolicited event for HP jack sensing */
814static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
815{
816 if (codec->vendor_id == 0x10ec0880)
817 res >>= 28;
818 else
819 res >>= 26;
820 if (res != ALC880_HP_EVENT)
821 return;
822
823 alc_sku_automute(codec);
824}
825
Kailang Yangf9423e72008-05-27 12:32:25 +0200826/* additional initialization for ALC888 variants */
827static void alc888_coef_init(struct hda_codec *codec)
828{
829 unsigned int tmp;
830
831 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
832 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
833 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
834 if ((tmp & 0xf0) == 2)
835 /* alc888S-VC */
836 snd_hda_codec_read(codec, 0x20, 0,
837 AC_VERB_SET_PROC_COEF, 0x830);
838 else
839 /* alc888-VB */
840 snd_hda_codec_read(codec, 0x20, 0,
841 AC_VERB_SET_PROC_COEF, 0x3030);
842}
843
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200844/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
845 * 31 ~ 16 : Manufacture ID
846 * 15 ~ 8 : SKU ID
847 * 7 ~ 0 : Assembly ID
848 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
849 */
850static void alc_subsystem_id(struct hda_codec *codec,
851 unsigned int porta, unsigned int porte,
852 unsigned int portd)
853{
Kailang Yangc9b58002007-10-16 14:30:01 +0200854 unsigned int ass, tmp, i;
855 unsigned nid;
856 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200857
Kailang Yangc9b58002007-10-16 14:30:01 +0200858 ass = codec->subsystem_id & 0xffff;
859 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
860 goto do_sku;
861
Kailang Yangea1fb292008-08-26 12:58:38 +0200862 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200863 * 31~30 : port conetcivity
864 * 29~21 : reserve
865 * 20 : PCBEEP input
866 * 19~16 : Check sum (15:1)
867 * 15~1 : Custom
868 * 0 : override
869 */
870 nid = 0x1d;
871 if (codec->vendor_id == 0x10ec0260)
872 nid = 0x17;
873 ass = snd_hda_codec_read(codec, nid, 0,
874 AC_VERB_GET_CONFIG_DEFAULT, 0);
875 if (!(ass & 1) && !(ass & 0x100000))
876 return;
877 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200878 return;
879
Kailang Yangc9b58002007-10-16 14:30:01 +0200880 /* check sum */
881 tmp = 0;
882 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100883 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200884 tmp++;
885 }
886 if (((ass >> 16) & 0xf) != tmp)
887 return;
888do_sku:
889 /*
890 * 0 : override
891 * 1 : Swap Jack
892 * 2 : 0 --> Desktop, 1 --> Laptop
893 * 3~5 : External Amplifier control
894 * 7~6 : Reserved
895 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200896 tmp = (ass & 0x38) >> 3; /* external Amp control */
897 switch (tmp) {
898 case 1:
899 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
900 break;
901 case 3:
902 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
903 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200904 case 7:
905 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
906 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200908 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200909 case 0x10ec0260:
910 snd_hda_codec_write(codec, 0x0f, 0,
911 AC_VERB_SET_EAPD_BTLENABLE, 2);
912 snd_hda_codec_write(codec, 0x10, 0,
913 AC_VERB_SET_EAPD_BTLENABLE, 2);
914 break;
915 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200916 case 0x10ec0267:
917 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200918 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200919 case 0x10ec0660:
920 case 0x10ec0662:
921 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200923 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200924 snd_hda_codec_write(codec, 0x14, 0,
925 AC_VERB_SET_EAPD_BTLENABLE, 2);
926 snd_hda_codec_write(codec, 0x15, 0,
927 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200928 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200929 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200930 switch (codec->vendor_id) {
931 case 0x10ec0260:
932 snd_hda_codec_write(codec, 0x1a, 0,
933 AC_VERB_SET_COEF_INDEX, 7);
934 tmp = snd_hda_codec_read(codec, 0x1a, 0,
935 AC_VERB_GET_PROC_COEF, 0);
936 snd_hda_codec_write(codec, 0x1a, 0,
937 AC_VERB_SET_COEF_INDEX, 7);
938 snd_hda_codec_write(codec, 0x1a, 0,
939 AC_VERB_SET_PROC_COEF,
940 tmp | 0x2010);
941 break;
942 case 0x10ec0262:
943 case 0x10ec0880:
944 case 0x10ec0882:
945 case 0x10ec0883:
946 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200947 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200948 snd_hda_codec_write(codec, 0x20, 0,
949 AC_VERB_SET_COEF_INDEX, 7);
950 tmp = snd_hda_codec_read(codec, 0x20, 0,
951 AC_VERB_GET_PROC_COEF, 0);
952 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200953 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200954 snd_hda_codec_write(codec, 0x20, 0,
955 AC_VERB_SET_PROC_COEF,
956 tmp | 0x2010);
957 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200958 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200959 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200960 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200961 case 0x10ec0267:
962 case 0x10ec0268:
963 snd_hda_codec_write(codec, 0x20, 0,
964 AC_VERB_SET_COEF_INDEX, 7);
965 tmp = snd_hda_codec_read(codec, 0x20, 0,
966 AC_VERB_GET_PROC_COEF, 0);
967 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200968 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200969 snd_hda_codec_write(codec, 0x20, 0,
970 AC_VERB_SET_PROC_COEF,
971 tmp | 0x3000);
972 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200974 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200975 break;
976 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200977
Kailang Yang8c427222008-01-10 13:03:59 +0100978 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200979 * when the external headphone out jack is plugged"
980 */
Kailang Yang8c427222008-01-10 13:03:59 +0100981 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200982 return;
983 /*
984 * 10~8 : Jack location
985 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
986 * 14~13: Resvered
987 * 15 : 1 --> enable the function "Mute internal speaker
988 * when the external headphone out jack is plugged"
989 */
990 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100991 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200992 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100993 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200994 else
995 return;
996 }
997
998 if (!spec->autocfg.hp_pins[0]) {
999 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1000 if (tmp == 0)
1001 spec->autocfg.hp_pins[0] = porta;
1002 else if (tmp == 1)
1003 spec->autocfg.hp_pins[0] = porte;
1004 else if (tmp == 2)
1005 spec->autocfg.hp_pins[0] = portd;
1006 else
1007 return;
1008 }
1009
1010 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1011 AC_VERB_SET_UNSOLICITED_ENABLE,
1012 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001013
Kailang Yangc9b58002007-10-16 14:30:01 +02001014 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001015}
1016
Takashi Iwai41e41f12005-06-08 14:48:49 +02001017/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001018 * Fix-up pin default configurations
1019 */
1020
1021struct alc_pincfg {
1022 hda_nid_t nid;
1023 u32 val;
1024};
1025
1026static void alc_fix_pincfg(struct hda_codec *codec,
1027 const struct snd_pci_quirk *quirk,
1028 const struct alc_pincfg **pinfix)
1029{
1030 const struct alc_pincfg *cfg;
1031
1032 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1033 if (!quirk)
1034 return;
1035
1036 cfg = pinfix[quirk->value];
1037 for (; cfg->nid; cfg++) {
1038 int i;
1039 u32 val = cfg->val;
1040 for (i = 0; i < 4; i++) {
1041 snd_hda_codec_write(codec, cfg->nid, 0,
1042 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1043 val & 0xff);
1044 val >>= 8;
1045 }
1046 }
1047}
1048
1049/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001050 * ALC880 3-stack model
1051 *
1052 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001053 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1054 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 */
1056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001057static hda_nid_t alc880_dac_nids[4] = {
1058 /* front, rear, clfe, rear_surr */
1059 0x02, 0x05, 0x04, 0x03
1060};
1061
1062static hda_nid_t alc880_adc_nids[3] = {
1063 /* ADC0-2 */
1064 0x07, 0x08, 0x09,
1065};
1066
1067/* The datasheet says the node 0x07 is connected from inputs,
1068 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001069 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001071static hda_nid_t alc880_adc_nids_alt[2] = {
1072 /* ADC1-2 */
1073 0x08, 0x09,
1074};
1075
1076#define ALC880_DIGOUT_NID 0x06
1077#define ALC880_DIGIN_NID 0x0a
1078
1079static struct hda_input_mux alc880_capture_source = {
1080 .num_items = 4,
1081 .items = {
1082 { "Mic", 0x0 },
1083 { "Front Mic", 0x3 },
1084 { "Line", 0x2 },
1085 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001087};
1088
1089/* channel source setting (2/6 channel selection for 3-stack) */
1090/* 2ch mode */
1091static struct hda_verb alc880_threestack_ch2_init[] = {
1092 /* set line-in to input, mute it */
1093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1095 /* set mic-in to input vref 80%, mute it */
1096 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1097 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 { } /* end */
1099};
1100
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001101/* 6ch mode */
1102static struct hda_verb alc880_threestack_ch6_init[] = {
1103 /* set line-in to output, unmute it */
1104 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1105 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1106 /* set mic-in to output, unmute it */
1107 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1108 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1109 { } /* end */
1110};
1111
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001112static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001113 { 2, alc880_threestack_ch2_init },
1114 { 6, alc880_threestack_ch6_init },
1115};
1116
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001117static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001119 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001120 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001121 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001122 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001124 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1125 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1134 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1135 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137 {
1138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1139 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001140 .info = alc_ch_mode_info,
1141 .get = alc_ch_mode_get,
1142 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001143 },
1144 { } /* end */
1145};
1146
1147/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001148static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1153 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1154 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1155 {
1156 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1157 /* The multiple "Capture Source" controls confuse alsamixer
1158 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001159 */
1160 /* .name = "Capture Source", */
1161 .name = "Input Source",
1162 .count = 3,
1163 .info = alc_mux_enum_info,
1164 .get = alc_mux_enum_get,
1165 .put = alc_mux_enum_put,
1166 },
1167 { } /* end */
1168};
1169
1170/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001171static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001172 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1174 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1175 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 {
1177 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1178 /* The multiple "Capture Source" controls confuse alsamixer
1179 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 */
1181 /* .name = "Capture Source", */
1182 .name = "Input Source",
1183 .count = 2,
1184 .info = alc_mux_enum_info,
1185 .get = alc_mux_enum_get,
1186 .put = alc_mux_enum_put,
1187 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 { } /* end */
1189};
1190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001191
1192
1193/*
1194 * ALC880 5-stack model
1195 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001196 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1197 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001198 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1199 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1200 */
1201
1202/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001203static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001204 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001205 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 { } /* end */
1207};
1208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001209/* channel source setting (6/8 channel selection for 5-stack) */
1210/* 6ch mode */
1211static struct hda_verb alc880_fivestack_ch6_init[] = {
1212 /* set line-in to input, mute it */
1213 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1214 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001215 { } /* end */
1216};
1217
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001218/* 8ch mode */
1219static struct hda_verb alc880_fivestack_ch8_init[] = {
1220 /* set line-in to output, unmute it */
1221 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1222 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1223 { } /* end */
1224};
1225
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001226static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001227 { 6, alc880_fivestack_ch6_init },
1228 { 8, alc880_fivestack_ch8_init },
1229};
1230
1231
1232/*
1233 * ALC880 6-stack model
1234 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001235 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1236 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001237 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1238 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1239 */
1240
1241static hda_nid_t alc880_6st_dac_nids[4] = {
1242 /* front, rear, clfe, rear_surr */
1243 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001244};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245
1246static struct hda_input_mux alc880_6stack_capture_source = {
1247 .num_items = 4,
1248 .items = {
1249 { "Mic", 0x0 },
1250 { "Front Mic", 0x1 },
1251 { "Line", 0x2 },
1252 { "CD", 0x4 },
1253 },
1254};
1255
1256/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001257static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 { 8, NULL },
1259};
1260
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001261static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001263 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001264 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001265 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001266 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1267 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001268 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1269 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001270 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001271 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1274 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1275 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1278 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1280 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1281 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001282 {
1283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1284 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001285 .info = alc_ch_mode_info,
1286 .get = alc_ch_mode_get,
1287 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001288 },
1289 { } /* end */
1290};
1291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001292
1293/*
1294 * ALC880 W810 model
1295 *
1296 * W810 has rear IO for:
1297 * Front (DAC 02)
1298 * Surround (DAC 03)
1299 * Center/LFE (DAC 04)
1300 * Digital out (06)
1301 *
1302 * The system also has a pair of internal speakers, and a headphone jack.
1303 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001304 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001305 * There is a variable resistor to control the speaker or headphone
1306 * volume. This is a hardware-only device without a software API.
1307 *
1308 * Plugging headphones in will disable the internal speakers. This is
1309 * implemented in hardware, not via the driver using jack sense. In
1310 * a similar fashion, plugging into the rear socket marked "front" will
1311 * disable both the speakers and headphones.
1312 *
1313 * For input, there's a microphone jack, and an "audio in" jack.
1314 * These may not do anything useful with this driver yet, because I
1315 * haven't setup any initialization verbs for these yet...
1316 */
1317
1318static hda_nid_t alc880_w810_dac_nids[3] = {
1319 /* front, rear/surround, clfe */
1320 0x02, 0x03, 0x04
1321};
1322
1323/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001324static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001325 { 6, NULL }
1326};
1327
1328/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001329static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001331 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001332 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001333 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001334 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1335 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001336 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1337 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1339 { } /* end */
1340};
1341
1342
1343/*
1344 * Z710V model
1345 *
1346 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001347 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1348 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001349 */
1350
1351static hda_nid_t alc880_z71v_dac_nids[1] = {
1352 0x02
1353};
1354#define ALC880_Z71V_HP_DAC 0x03
1355
1356/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001357static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001358 { 2, NULL }
1359};
1360
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001361static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001362 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001363 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001365 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001366 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1367 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1370 { } /* end */
1371};
1372
1373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374/*
1375 * ALC880 F1734 model
1376 *
1377 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1378 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1379 */
1380
1381static hda_nid_t alc880_f1734_dac_nids[1] = {
1382 0x03
1383};
1384#define ALC880_F1734_HP_DAC 0x02
1385
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001386static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001387 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001388 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001389 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1390 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001395 { } /* end */
1396};
1397
Takashi Iwai937b4162008-02-11 14:52:36 +01001398static struct hda_input_mux alc880_f1734_capture_source = {
1399 .num_items = 2,
1400 .items = {
1401 { "Mic", 0x1 },
1402 { "CD", 0x4 },
1403 },
1404};
1405
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001406
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407/*
1408 * ALC880 ASUS model
1409 *
1410 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1411 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1412 * Mic = 0x18, Line = 0x1a
1413 */
1414
1415#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1416#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1417
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001418static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001419 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001421 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001422 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001423 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1424 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001425 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1426 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 {
1434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1435 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001436 .info = alc_ch_mode_info,
1437 .get = alc_ch_mode_get,
1438 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001439 },
1440 { } /* end */
1441};
1442
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001443/*
1444 * ALC880 ASUS W1V model
1445 *
1446 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1447 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1448 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1449 */
1450
1451/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001452static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001453 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1454 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001455 { } /* end */
1456};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001457
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001458/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001459static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001460 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1461 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1462 { } /* end */
1463};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001464
Kailang Yangdf694da2005-12-05 19:42:22 +01001465/* TCL S700 */
1466static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1467 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1468 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1471 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1474 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1475 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1476 {
1477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1478 /* The multiple "Capture Source" controls confuse alsamixer
1479 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001480 */
1481 /* .name = "Capture Source", */
1482 .name = "Input Source",
1483 .count = 1,
1484 .info = alc_mux_enum_info,
1485 .get = alc_mux_enum_get,
1486 .put = alc_mux_enum_put,
1487 },
1488 { } /* end */
1489};
1490
Kailang Yangccc656c2006-10-17 12:32:26 +02001491/* Uniwill */
1492static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001493 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1494 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1495 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1496 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001497 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1498 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1499 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1500 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1501 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1502 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1504 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1507 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1508 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1511 {
1512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1513 .name = "Channel Mode",
1514 .info = alc_ch_mode_info,
1515 .get = alc_ch_mode_get,
1516 .put = alc_ch_mode_put,
1517 },
1518 { } /* end */
1519};
1520
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001521static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1522 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1523 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1524 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1525 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1526 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1527 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1528 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1529 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1530 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1531 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1532 { } /* end */
1533};
1534
Kailang Yangccc656c2006-10-17 12:32:26 +02001535static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001536 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1537 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1538 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1539 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1542 { } /* end */
1543};
1544
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001546 * virtual master controls
1547 */
1548
1549/*
1550 * slave controls for virtual master
1551 */
1552static const char *alc_slave_vols[] = {
1553 "Front Playback Volume",
1554 "Surround Playback Volume",
1555 "Center Playback Volume",
1556 "LFE Playback Volume",
1557 "Side Playback Volume",
1558 "Headphone Playback Volume",
1559 "Speaker Playback Volume",
1560 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001561 "Line-Out Playback Volume",
1562 NULL,
1563};
1564
1565static const char *alc_slave_sws[] = {
1566 "Front Playback Switch",
1567 "Surround Playback Switch",
1568 "Center Playback Switch",
1569 "LFE Playback Switch",
1570 "Side Playback Switch",
1571 "Headphone Playback Switch",
1572 "Speaker Playback Switch",
1573 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001574 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001575 NULL,
1576};
1577
1578/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001579 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 */
1581static int alc_build_controls(struct hda_codec *codec)
1582{
1583 struct alc_spec *spec = codec->spec;
1584 int err;
1585 int i;
1586
1587 for (i = 0; i < spec->num_mixers; i++) {
1588 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1589 if (err < 0)
1590 return err;
1591 }
1592
1593 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001594 err = snd_hda_create_spdif_out_ctls(codec,
1595 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 if (err < 0)
1597 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001598 err = snd_hda_create_spdif_share_sw(codec,
1599 &spec->multiout);
1600 if (err < 0)
1601 return err;
1602 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001603 }
1604 if (spec->dig_in_nid) {
1605 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1606 if (err < 0)
1607 return err;
1608 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001609
1610 /* if we have no master control, let's create it */
1611 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001612 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001613 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001614 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001615 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001616 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001617 if (err < 0)
1618 return err;
1619 }
1620 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1621 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1622 NULL, alc_slave_sws);
1623 if (err < 0)
1624 return err;
1625 }
1626
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 return 0;
1628}
1629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001630
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631/*
1632 * initialize the codec volumes, etc
1633 */
1634
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001635/*
1636 * generic initialization of ADC, input mixers and output mixers
1637 */
1638static struct hda_verb alc880_volume_init_verbs[] = {
1639 /*
1640 * Unmute ADC0-2 and set the default input to mic-in
1641 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001642 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001644 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001646 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001649 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1650 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001651 * Note: PASD motherboards uses the Line In 2 as the input for front
1652 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001663 /*
1664 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 /* set vol=0 to output mixers */
1667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1668 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1669 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1671 /* set up input amps for analog loopback */
1672 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001675 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001677 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1680 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681
1682 { }
1683};
1684
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685/*
1686 * 3-stack pin configuration:
1687 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1688 */
1689static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1690 /*
1691 * preset connection lists of input pins
1692 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1693 */
1694 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1695 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1696 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1697
1698 /*
1699 * Set pin mode and muting
1700 */
1701 /* set front pin widgets 0x14 for output */
1702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1707 /* Mic2 (as headphone out) for HP output */
1708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710 /* Line In pin widget for input */
1711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1713 /* Line2 (as front mic) pin widget for input and vref at 80% */
1714 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1715 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1716 /* CD pin widget for input */
1717 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1718
1719 { }
1720};
1721
1722/*
1723 * 5-stack pin configuration:
1724 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1725 * line-in/side = 0x1a, f-mic = 0x1b
1726 */
1727static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1728 /*
1729 * preset connection lists of input pins
1730 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1731 */
1732 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1733 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1734
1735 /*
1736 * Set pin mode and muting
1737 */
1738 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1742 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743 /* unmute pins for output (no gain on this amp) */
1744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1747 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1748
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1752 /* Mic2 (as headphone out) for HP output */
1753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001755 /* Line In pin widget for input */
1756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1758 /* Line2 (as front mic) pin widget for input and vref at 80% */
1759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1760 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1761 /* CD pin widget for input */
1762 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763
1764 { }
1765};
1766
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767/*
1768 * W810 pin configuration:
1769 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1770 */
1771static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772 /* hphone/speaker input selector: front DAC */
1773 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1774
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1781
1782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001783 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785 { }
1786};
1787
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001788/*
1789 * Z71V pin configuration:
1790 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1791 */
1792static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001797
Takashi Iwai16ded522005-06-10 19:58:24 +02001798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001802
1803 { }
1804};
1805
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806/*
1807 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001808 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1809 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810 */
1811static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1812 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1813
Takashi Iwai16ded522005-06-10 19:58:24 +02001814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001820 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1822
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833 { }
1834};
Takashi Iwai16ded522005-06-10 19:58:24 +02001835
Kailang Yangccc656c2006-10-17 12:32:26 +02001836/*
1837 * Uniwill pin configuration:
1838 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1839 * line = 0x1a
1840 */
1841static struct hda_verb alc880_uniwill_init_verbs[] = {
1842 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1843
1844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1850 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1858
1859 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1860 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1862 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1865 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1866 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1867 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1868
1869 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1870 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1871
1872 { }
1873};
1874
1875/*
1876* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001877* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001878 */
1879static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1880 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1881
1882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1886 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1894
1895 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1897 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1898 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1899 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1901
1902 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1903 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1904
1905 { }
1906};
1907
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001908static struct hda_verb alc880_beep_init_verbs[] = {
1909 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1910 { }
1911};
1912
Kailang Yangccc656c2006-10-17 12:32:26 +02001913/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001914static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001915{
1916 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001917 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001918
1919 present = snd_hda_codec_read(codec, 0x14, 0,
1920 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001921 bits = present ? HDA_AMP_MUTE : 0;
1922 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1923 HDA_AMP_MUTE, bits);
1924 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1925 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001926}
1927
1928/* auto-toggle front mic */
1929static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1930{
1931 unsigned int present;
1932 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001933
1934 present = snd_hda_codec_read(codec, 0x18, 0,
1935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001936 bits = present ? HDA_AMP_MUTE : 0;
1937 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001938}
1939
1940static void alc880_uniwill_automute(struct hda_codec *codec)
1941{
1942 alc880_uniwill_hp_automute(codec);
1943 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001944}
1945
1946static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1947 unsigned int res)
1948{
1949 /* Looks like the unsol event is incompatible with the standard
1950 * definition. 4bit tag is placed at 28 bit!
1951 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001952 switch (res >> 28) {
1953 case ALC880_HP_EVENT:
1954 alc880_uniwill_hp_automute(codec);
1955 break;
1956 case ALC880_MIC_EVENT:
1957 alc880_uniwill_mic_automute(codec);
1958 break;
1959 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001960}
1961
1962static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1963{
1964 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001965 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001966
1967 present = snd_hda_codec_read(codec, 0x14, 0,
1968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001969 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001970 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001971}
1972
1973static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1974{
1975 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001976
Kailang Yangccc656c2006-10-17 12:32:26 +02001977 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001978 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1979 present &= HDA_AMP_VOLMASK;
1980 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1981 HDA_AMP_VOLMASK, present);
1982 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1983 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001984}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001985
Kailang Yangccc656c2006-10-17 12:32:26 +02001986static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1987 unsigned int res)
1988{
1989 /* Looks like the unsol event is incompatible with the standard
1990 * definition. 4bit tag is placed at 28 bit!
1991 */
1992 if ((res >> 28) == ALC880_HP_EVENT)
1993 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001994 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001995 alc880_uniwill_p53_dcvol_automute(codec);
1996}
1997
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001998/*
1999 * F1734 pin configuration:
2000 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2001 */
2002static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002003 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002004 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2005 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2007 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2008
2009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013
2014 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002016 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2022 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002023
Takashi Iwai937b4162008-02-11 14:52:36 +01002024 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2025 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2026
Takashi Iwai16ded522005-06-10 19:58:24 +02002027 { }
2028};
2029
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030/*
2031 * ASUS pin configuration:
2032 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2033 */
2034static struct hda_verb alc880_pin_asus_init_verbs[] = {
2035 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2036 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2037 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2038 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2039
2040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2046 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2048
2049 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2053 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059 { }
2060};
2061
2062/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002063#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2064#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002065
Kailang Yangdf694da2005-12-05 19:42:22 +01002066/* Clevo m520g init */
2067static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2068 /* headphone output */
2069 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2070 /* line-out */
2071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2073 /* Line-in */
2074 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2075 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2076 /* CD */
2077 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2078 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2079 /* Mic1 (rear panel) */
2080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2081 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2082 /* Mic2 (front panel) */
2083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2085 /* headphone */
2086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2088 /* change to EAPD mode */
2089 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2090 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2091
2092 { }
2093};
2094
2095static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002096 /* change to EAPD mode */
2097 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2098 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2099
Kailang Yangdf694da2005-12-05 19:42:22 +01002100 /* Headphone output */
2101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2102 /* Front output*/
2103 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2105
2106 /* Line In pin widget for input */
2107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2108 /* CD pin widget for input */
2109 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2110 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2111 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2112
2113 /* change to EAPD mode */
2114 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2115 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2116
2117 { }
2118};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002119
2120/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002121 * LG m1 express dual
2122 *
2123 * Pin assignment:
2124 * Rear Line-In/Out (blue): 0x14
2125 * Build-in Mic-In: 0x15
2126 * Speaker-out: 0x17
2127 * HP-Out (green): 0x1b
2128 * Mic-In/Out (red): 0x19
2129 * SPDIF-Out: 0x1e
2130 */
2131
2132/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2133static hda_nid_t alc880_lg_dac_nids[3] = {
2134 0x05, 0x02, 0x03
2135};
2136
2137/* seems analog CD is not working */
2138static struct hda_input_mux alc880_lg_capture_source = {
2139 .num_items = 3,
2140 .items = {
2141 { "Mic", 0x1 },
2142 { "Line", 0x5 },
2143 { "Internal Mic", 0x6 },
2144 },
2145};
2146
2147/* 2,4,6 channel modes */
2148static struct hda_verb alc880_lg_ch2_init[] = {
2149 /* set line-in and mic-in to input */
2150 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2151 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2152 { }
2153};
2154
2155static struct hda_verb alc880_lg_ch4_init[] = {
2156 /* set line-in to out and mic-in to input */
2157 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2158 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2159 { }
2160};
2161
2162static struct hda_verb alc880_lg_ch6_init[] = {
2163 /* set line-in and mic-in to output */
2164 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2165 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2166 { }
2167};
2168
2169static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2170 { 2, alc880_lg_ch2_init },
2171 { 4, alc880_lg_ch4_init },
2172 { 6, alc880_lg_ch6_init },
2173};
2174
2175static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2177 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002178 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2179 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2180 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2181 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2182 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2183 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2188 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2189 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2190 {
2191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2192 .name = "Channel Mode",
2193 .info = alc_ch_mode_info,
2194 .get = alc_ch_mode_get,
2195 .put = alc_ch_mode_put,
2196 },
2197 { } /* end */
2198};
2199
2200static struct hda_verb alc880_lg_init_verbs[] = {
2201 /* set capture source to mic-in */
2202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2205 /* mute all amp mixer inputs */
2206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002209 /* line-in to input */
2210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2212 /* built-in mic */
2213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2215 /* speaker-out */
2216 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2217 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2218 /* mic-in to input */
2219 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2220 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 /* HP-out */
2223 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 /* jack sense */
2227 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2228 { }
2229};
2230
2231/* toggle speaker-output according to the hp-jack state */
2232static void alc880_lg_automute(struct hda_codec *codec)
2233{
2234 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002235 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002236
2237 present = snd_hda_codec_read(codec, 0x1b, 0,
2238 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002239 bits = present ? HDA_AMP_MUTE : 0;
2240 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2241 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002242}
2243
2244static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2245{
2246 /* Looks like the unsol event is incompatible with the standard
2247 * definition. 4bit tag is placed at 28 bit!
2248 */
2249 if ((res >> 28) == 0x01)
2250 alc880_lg_automute(codec);
2251}
2252
2253/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002254 * LG LW20
2255 *
2256 * Pin assignment:
2257 * Speaker-out: 0x14
2258 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002259 * Built-in Mic-In: 0x19
2260 * Line-In: 0x1b
2261 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002262 * SPDIF-Out: 0x1e
2263 */
2264
Takashi Iwaid6815182006-03-23 16:06:23 +01002265static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002266 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002267 .items = {
2268 { "Mic", 0x0 },
2269 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002270 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002271 },
2272};
2273
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002274#define alc880_lg_lw_modes alc880_threestack_modes
2275
Takashi Iwaid6815182006-03-23 16:06:23 +01002276static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002277 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2278 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2279 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2280 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2281 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2282 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2283 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2284 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2289 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2290 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002291 {
2292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2293 .name = "Channel Mode",
2294 .info = alc_ch_mode_info,
2295 .get = alc_ch_mode_get,
2296 .put = alc_ch_mode_put,
2297 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002298 { } /* end */
2299};
2300
2301static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002302 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2303 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2304 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2305
Takashi Iwaid6815182006-03-23 16:06:23 +01002306 /* set capture source to mic-in */
2307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002311 /* speaker-out */
2312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2314 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2317 /* mic-in to input */
2318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2320 /* built-in mic */
2321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2323 /* jack sense */
2324 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2325 { }
2326};
2327
2328/* toggle speaker-output according to the hp-jack state */
2329static void alc880_lg_lw_automute(struct hda_codec *codec)
2330{
2331 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002332 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002333
2334 present = snd_hda_codec_read(codec, 0x1b, 0,
2335 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002336 bits = present ? HDA_AMP_MUTE : 0;
2337 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2338 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002339}
2340
2341static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2342{
2343 /* Looks like the unsol event is incompatible with the standard
2344 * definition. 4bit tag is placed at 28 bit!
2345 */
2346 if ((res >> 28) == 0x01)
2347 alc880_lg_lw_automute(codec);
2348}
2349
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002350static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2351 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2356 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2357 { } /* end */
2358};
2359
2360static struct hda_input_mux alc880_medion_rim_capture_source = {
2361 .num_items = 2,
2362 .items = {
2363 { "Mic", 0x0 },
2364 { "Internal Mic", 0x1 },
2365 },
2366};
2367
2368static struct hda_verb alc880_medion_rim_init_verbs[] = {
2369 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2370
2371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2373
2374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2377 /* Mic2 (as headphone out) for HP output */
2378 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2379 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2380 /* Internal Speaker */
2381 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2382 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2383
2384 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2385 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2386
2387 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2388 { }
2389};
2390
2391/* toggle speaker-output according to the hp-jack state */
2392static void alc880_medion_rim_automute(struct hda_codec *codec)
2393{
2394 unsigned int present;
2395 unsigned char bits;
2396
2397 present = snd_hda_codec_read(codec, 0x14, 0,
2398 AC_VERB_GET_PIN_SENSE, 0)
2399 & AC_PINSENSE_PRESENCE;
2400 bits = present ? HDA_AMP_MUTE : 0;
2401 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2402 HDA_AMP_MUTE, bits);
2403 if (present)
2404 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2405 else
2406 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2407}
2408
2409static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2410 unsigned int res)
2411{
2412 /* Looks like the unsol event is incompatible with the standard
2413 * definition. 4bit tag is placed at 28 bit!
2414 */
2415 if ((res >> 28) == ALC880_HP_EVENT)
2416 alc880_medion_rim_automute(codec);
2417}
2418
Takashi Iwaicb53c622007-08-10 17:21:45 +02002419#ifdef CONFIG_SND_HDA_POWER_SAVE
2420static struct hda_amp_list alc880_loopbacks[] = {
2421 { 0x0b, HDA_INPUT, 0 },
2422 { 0x0b, HDA_INPUT, 1 },
2423 { 0x0b, HDA_INPUT, 2 },
2424 { 0x0b, HDA_INPUT, 3 },
2425 { 0x0b, HDA_INPUT, 4 },
2426 { } /* end */
2427};
2428
2429static struct hda_amp_list alc880_lg_loopbacks[] = {
2430 { 0x0b, HDA_INPUT, 1 },
2431 { 0x0b, HDA_INPUT, 6 },
2432 { 0x0b, HDA_INPUT, 7 },
2433 { } /* end */
2434};
2435#endif
2436
Takashi Iwaid6815182006-03-23 16:06:23 +01002437/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002438 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002439 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002440
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441static int alc_init(struct hda_codec *codec)
2442{
2443 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 unsigned int i;
2445
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002446 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002447 if (codec->vendor_id == 0x10ec0888)
2448 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002449
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002450 for (i = 0; i < spec->num_init_verbs; i++)
2451 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002452
2453 if (spec->init_hook)
2454 spec->init_hook(codec);
2455
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 return 0;
2457}
2458
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002459static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2460{
2461 struct alc_spec *spec = codec->spec;
2462
2463 if (spec->unsol_event)
2464 spec->unsol_event(codec, res);
2465}
2466
Takashi Iwaicb53c622007-08-10 17:21:45 +02002467#ifdef CONFIG_SND_HDA_POWER_SAVE
2468static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2469{
2470 struct alc_spec *spec = codec->spec;
2471 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2472}
2473#endif
2474
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475/*
2476 * Analog playback callbacks
2477 */
2478static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2479 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002480 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481{
2482 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002483 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2484 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485}
2486
2487static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2488 struct hda_codec *codec,
2489 unsigned int stream_tag,
2490 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002491 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492{
2493 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002494 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2495 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496}
2497
2498static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2499 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002500 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501{
2502 struct alc_spec *spec = codec->spec;
2503 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2504}
2505
2506/*
2507 * Digital out
2508 */
2509static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2510 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002511 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512{
2513 struct alc_spec *spec = codec->spec;
2514 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2515}
2516
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002517static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2518 struct hda_codec *codec,
2519 unsigned int stream_tag,
2520 unsigned int format,
2521 struct snd_pcm_substream *substream)
2522{
2523 struct alc_spec *spec = codec->spec;
2524 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2525 stream_tag, format, substream);
2526}
2527
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2529 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002530 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531{
2532 struct alc_spec *spec = codec->spec;
2533 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2534}
2535
2536/*
2537 * Analog capture
2538 */
Takashi Iwai63300792008-01-24 15:31:36 +01002539static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540 struct hda_codec *codec,
2541 unsigned int stream_tag,
2542 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002543 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544{
2545 struct alc_spec *spec = codec->spec;
2546
Takashi Iwai63300792008-01-24 15:31:36 +01002547 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 stream_tag, 0, format);
2549 return 0;
2550}
2551
Takashi Iwai63300792008-01-24 15:31:36 +01002552static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002554 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555{
2556 struct alc_spec *spec = codec->spec;
2557
Takashi Iwai888afa12008-03-18 09:57:50 +01002558 snd_hda_codec_cleanup_stream(codec,
2559 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 return 0;
2561}
2562
2563
2564/*
2565 */
2566static struct hda_pcm_stream alc880_pcm_analog_playback = {
2567 .substreams = 1,
2568 .channels_min = 2,
2569 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002570 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 .ops = {
2572 .open = alc880_playback_pcm_open,
2573 .prepare = alc880_playback_pcm_prepare,
2574 .cleanup = alc880_playback_pcm_cleanup
2575 },
2576};
2577
2578static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002579 .substreams = 1,
2580 .channels_min = 2,
2581 .channels_max = 2,
2582 /* NID is set in alc_build_pcms */
2583};
2584
2585static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2586 .substreams = 1,
2587 .channels_min = 2,
2588 .channels_max = 2,
2589 /* NID is set in alc_build_pcms */
2590};
2591
2592static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2593 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 .channels_min = 2,
2595 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002596 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002598 .prepare = alc880_alt_capture_pcm_prepare,
2599 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 },
2601};
2602
2603static struct hda_pcm_stream alc880_pcm_digital_playback = {
2604 .substreams = 1,
2605 .channels_min = 2,
2606 .channels_max = 2,
2607 /* NID is set in alc_build_pcms */
2608 .ops = {
2609 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002610 .close = alc880_dig_playback_pcm_close,
2611 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 },
2613};
2614
2615static struct hda_pcm_stream alc880_pcm_digital_capture = {
2616 .substreams = 1,
2617 .channels_min = 2,
2618 .channels_max = 2,
2619 /* NID is set in alc_build_pcms */
2620};
2621
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002622/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002623static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002624 .substreams = 0,
2625 .channels_min = 0,
2626 .channels_max = 0,
2627};
2628
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629static int alc_build_pcms(struct hda_codec *codec)
2630{
2631 struct alc_spec *spec = codec->spec;
2632 struct hda_pcm *info = spec->pcm_rec;
2633 int i;
2634
2635 codec->num_pcms = 1;
2636 codec->pcm_info = info;
2637
2638 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002639 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002640 if (snd_BUG_ON(!spec->multiout.dac_nids))
2641 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002642 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2643 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2644 }
2645 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002646 if (snd_BUG_ON(!spec->adc_nids))
2647 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002648 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2649 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2650 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651
Takashi Iwai4a471b72005-12-07 13:56:29 +01002652 if (spec->channel_mode) {
2653 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2654 for (i = 0; i < spec->num_channel_mode; i++) {
2655 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2656 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2657 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 }
2659 }
2660
Takashi Iwaie08a0072006-09-07 17:52:14 +02002661 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002663 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002664 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002666 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002667 if (spec->multiout.dig_out_nid &&
2668 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2670 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2671 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002672 if (spec->dig_in_nid &&
2673 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2675 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2676 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002677 /* FIXME: do we need this for all Realtek codec models? */
2678 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 }
2680
Takashi Iwaie08a0072006-09-07 17:52:14 +02002681 /* If the use of more than one ADC is requested for the current
2682 * model, configure a second analog capture-only PCM.
2683 */
2684 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002685 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2686 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002687 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002688 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002689 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002690 if (spec->alt_dac_nid) {
2691 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2692 *spec->stream_analog_alt_playback;
2693 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2694 spec->alt_dac_nid;
2695 } else {
2696 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2697 alc_pcm_null_stream;
2698 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2699 }
2700 if (spec->num_adc_nids > 1) {
2701 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2702 *spec->stream_analog_alt_capture;
2703 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2704 spec->adc_nids[1];
2705 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2706 spec->num_adc_nids - 1;
2707 } else {
2708 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2709 alc_pcm_null_stream;
2710 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002711 }
2712 }
2713
Linus Torvalds1da177e2005-04-16 15:20:36 -07002714 return 0;
2715}
2716
2717static void alc_free(struct hda_codec *codec)
2718{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002719 struct alc_spec *spec = codec->spec;
2720 unsigned int i;
2721
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002722 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 return;
2724
2725 if (spec->kctl_alloc) {
2726 for (i = 0; i < spec->num_kctl_used; i++)
2727 kfree(spec->kctl_alloc[i].name);
2728 kfree(spec->kctl_alloc);
2729 }
2730 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002731 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732}
2733
2734/*
2735 */
2736static struct hda_codec_ops alc_patch_ops = {
2737 .build_controls = alc_build_controls,
2738 .build_pcms = alc_build_pcms,
2739 .init = alc_init,
2740 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002741 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002742#ifdef CONFIG_SND_HDA_POWER_SAVE
2743 .check_power_status = alc_check_power_status,
2744#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745};
2746
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002747
2748/*
2749 * Test configuration for debugging
2750 *
2751 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2752 * enum controls.
2753 */
2754#ifdef CONFIG_SND_DEBUG
2755static hda_nid_t alc880_test_dac_nids[4] = {
2756 0x02, 0x03, 0x04, 0x05
2757};
2758
2759static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002760 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002761 .items = {
2762 { "In-1", 0x0 },
2763 { "In-2", 0x1 },
2764 { "In-3", 0x2 },
2765 { "In-4", 0x3 },
2766 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002767 { "Front", 0x5 },
2768 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002769 },
2770};
2771
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002772static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002773 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002774 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002775 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002776 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002777};
2778
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002779static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2780 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002781{
2782 static char *texts[] = {
2783 "N/A", "Line Out", "HP Out",
2784 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2785 };
2786 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2787 uinfo->count = 1;
2788 uinfo->value.enumerated.items = 8;
2789 if (uinfo->value.enumerated.item >= 8)
2790 uinfo->value.enumerated.item = 7;
2791 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2792 return 0;
2793}
2794
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002795static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2796 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002797{
2798 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2799 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2800 unsigned int pin_ctl, item = 0;
2801
2802 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2803 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2804 if (pin_ctl & AC_PINCTL_OUT_EN) {
2805 if (pin_ctl & AC_PINCTL_HP_EN)
2806 item = 2;
2807 else
2808 item = 1;
2809 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2810 switch (pin_ctl & AC_PINCTL_VREFEN) {
2811 case AC_PINCTL_VREF_HIZ: item = 3; break;
2812 case AC_PINCTL_VREF_50: item = 4; break;
2813 case AC_PINCTL_VREF_GRD: item = 5; break;
2814 case AC_PINCTL_VREF_80: item = 6; break;
2815 case AC_PINCTL_VREF_100: item = 7; break;
2816 }
2817 }
2818 ucontrol->value.enumerated.item[0] = item;
2819 return 0;
2820}
2821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002822static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2823 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002824{
2825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2826 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2827 static unsigned int ctls[] = {
2828 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2829 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2830 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2831 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2832 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2833 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2834 };
2835 unsigned int old_ctl, new_ctl;
2836
2837 old_ctl = snd_hda_codec_read(codec, nid, 0,
2838 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2839 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2840 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002841 int val;
2842 snd_hda_codec_write_cache(codec, nid, 0,
2843 AC_VERB_SET_PIN_WIDGET_CONTROL,
2844 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002845 val = ucontrol->value.enumerated.item[0] >= 3 ?
2846 HDA_AMP_MUTE : 0;
2847 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2848 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002849 return 1;
2850 }
2851 return 0;
2852}
2853
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002854static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2855 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002856{
2857 static char *texts[] = {
2858 "Front", "Surround", "CLFE", "Side"
2859 };
2860 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2861 uinfo->count = 1;
2862 uinfo->value.enumerated.items = 4;
2863 if (uinfo->value.enumerated.item >= 4)
2864 uinfo->value.enumerated.item = 3;
2865 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2866 return 0;
2867}
2868
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002869static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2870 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002871{
2872 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2873 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2874 unsigned int sel;
2875
2876 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2877 ucontrol->value.enumerated.item[0] = sel & 3;
2878 return 0;
2879}
2880
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002881static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2882 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002883{
2884 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2885 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2886 unsigned int sel;
2887
2888 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2889 if (ucontrol->value.enumerated.item[0] != sel) {
2890 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002891 snd_hda_codec_write_cache(codec, nid, 0,
2892 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002893 return 1;
2894 }
2895 return 0;
2896}
2897
2898#define PIN_CTL_TEST(xname,nid) { \
2899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2900 .name = xname, \
2901 .info = alc_test_pin_ctl_info, \
2902 .get = alc_test_pin_ctl_get, \
2903 .put = alc_test_pin_ctl_put, \
2904 .private_value = nid \
2905 }
2906
2907#define PIN_SRC_TEST(xname,nid) { \
2908 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2909 .name = xname, \
2910 .info = alc_test_pin_src_info, \
2911 .get = alc_test_pin_src_get, \
2912 .put = alc_test_pin_src_put, \
2913 .private_value = nid \
2914 }
2915
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002916static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2918 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2919 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2920 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2922 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2923 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2924 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002925 PIN_CTL_TEST("Front Pin Mode", 0x14),
2926 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2927 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2928 PIN_CTL_TEST("Side Pin Mode", 0x17),
2929 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2930 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2931 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2932 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2933 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2934 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2935 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2936 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2937 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2938 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2939 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2940 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2941 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2942 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2943 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2944 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002947 {
2948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2949 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002950 .info = alc_ch_mode_info,
2951 .get = alc_ch_mode_get,
2952 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002953 },
2954 { } /* end */
2955};
2956
2957static struct hda_verb alc880_test_init_verbs[] = {
2958 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2966 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002967 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002972 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2975 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2976 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002977 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002982 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2987 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002988 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002993 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002995 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002996 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002997 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002999 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003000 /* Analog input/passthru */
3001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003006 { }
3007};
3008#endif
3009
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010/*
3011 */
3012
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003013static const char *alc880_models[ALC880_MODEL_LAST] = {
3014 [ALC880_3ST] = "3stack",
3015 [ALC880_TCL_S700] = "tcl",
3016 [ALC880_3ST_DIG] = "3stack-digout",
3017 [ALC880_CLEVO] = "clevo",
3018 [ALC880_5ST] = "5stack",
3019 [ALC880_5ST_DIG] = "5stack-digout",
3020 [ALC880_W810] = "w810",
3021 [ALC880_Z71V] = "z71v",
3022 [ALC880_6ST] = "6stack",
3023 [ALC880_6ST_DIG] = "6stack-digout",
3024 [ALC880_ASUS] = "asus",
3025 [ALC880_ASUS_W1V] = "asus-w1v",
3026 [ALC880_ASUS_DIG] = "asus-dig",
3027 [ALC880_ASUS_DIG2] = "asus-dig2",
3028 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003029 [ALC880_UNIWILL_P53] = "uniwill-p53",
3030 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003031 [ALC880_F1734] = "F1734",
3032 [ALC880_LG] = "lg",
3033 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003034 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003035#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003036 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003037#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003038 [ALC880_AUTO] = "auto",
3039};
3040
3041static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003042 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003043 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3044 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3045 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3046 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3047 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3048 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3049 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3050 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003051 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3052 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003053 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3054 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3055 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3057 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3058 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3059 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3060 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3061 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3062 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003063 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003064 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3065 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3066 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003067 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003068 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003069 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3070 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003071 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3072 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003073 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3074 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3075 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3076 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003077 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3078 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003079 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003080 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003081 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003082 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003083 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3084 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003085 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003086 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003087 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003088 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003089 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003090 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003092 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003093 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003094 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3095 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003096 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003097 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3098 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3099 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3100 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003101 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3102 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003103 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003104 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003105 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3106 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003107 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3108 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3109 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003110 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3111 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3112 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003113 {}
3114};
3115
Takashi Iwai16ded522005-06-10 19:58:24 +02003116/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003118 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003119static struct alc_config_preset alc880_presets[] = {
3120 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003122 .init_verbs = { alc880_volume_init_verbs,
3123 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003126 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3127 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003128 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 .input_mux = &alc880_capture_source,
3130 },
3131 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003133 .init_verbs = { alc880_volume_init_verbs,
3134 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .dac_nids = alc880_dac_nids,
3137 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3139 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003140 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 .input_mux = &alc880_capture_source,
3142 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003143 [ALC880_TCL_S700] = {
3144 .mixers = { alc880_tcl_s700_mixer },
3145 .init_verbs = { alc880_volume_init_verbs,
3146 alc880_pin_tcl_S700_init_verbs,
3147 alc880_gpio2_init_verbs },
3148 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3149 .dac_nids = alc880_dac_nids,
3150 .hp_nid = 0x03,
3151 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3152 .channel_mode = alc880_2_jack_modes,
3153 .input_mux = &alc880_capture_source,
3154 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003155 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003156 .mixers = { alc880_three_stack_mixer,
3157 alc880_five_stack_mixer},
3158 .init_verbs = { alc880_volume_init_verbs,
3159 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003160 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3161 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003162 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3163 .channel_mode = alc880_fivestack_modes,
3164 .input_mux = &alc880_capture_source,
3165 },
3166 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003167 .mixers = { alc880_three_stack_mixer,
3168 alc880_five_stack_mixer },
3169 .init_verbs = { alc880_volume_init_verbs,
3170 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3172 .dac_nids = alc880_dac_nids,
3173 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003174 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3175 .channel_mode = alc880_fivestack_modes,
3176 .input_mux = &alc880_capture_source,
3177 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003178 [ALC880_6ST] = {
3179 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003182 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3183 .dac_nids = alc880_6st_dac_nids,
3184 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3185 .channel_mode = alc880_sixstack_modes,
3186 .input_mux = &alc880_6stack_capture_source,
3187 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003188 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003189 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003190 .init_verbs = { alc880_volume_init_verbs,
3191 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003192 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3193 .dac_nids = alc880_6st_dac_nids,
3194 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003195 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3196 .channel_mode = alc880_sixstack_modes,
3197 .input_mux = &alc880_6stack_capture_source,
3198 },
3199 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003201 .init_verbs = { alc880_volume_init_verbs,
3202 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003203 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003204 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3205 .dac_nids = alc880_w810_dac_nids,
3206 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003207 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3208 .channel_mode = alc880_w810_modes,
3209 .input_mux = &alc880_capture_source,
3210 },
3211 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003213 .init_verbs = { alc880_volume_init_verbs,
3214 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3216 .dac_nids = alc880_z71v_dac_nids,
3217 .dig_out_nid = ALC880_DIGOUT_NID,
3218 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3220 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003221 .input_mux = &alc880_capture_source,
3222 },
3223 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003225 .init_verbs = { alc880_volume_init_verbs,
3226 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3228 .dac_nids = alc880_f1734_dac_nids,
3229 .hp_nid = 0x02,
3230 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3231 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003232 .input_mux = &alc880_f1734_capture_source,
3233 .unsol_event = alc880_uniwill_p53_unsol_event,
3234 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003235 },
3236 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003238 .init_verbs = { alc880_volume_init_verbs,
3239 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003240 alc880_gpio1_init_verbs },
3241 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3242 .dac_nids = alc880_asus_dac_nids,
3243 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3244 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003245 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003246 .input_mux = &alc880_capture_source,
3247 },
3248 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003249 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 .init_verbs = { alc880_volume_init_verbs,
3251 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 alc880_gpio1_init_verbs },
3253 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3254 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003255 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3257 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003258 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003259 .input_mux = &alc880_capture_source,
3260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003261 [ALC880_ASUS_DIG2] = {
3262 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003263 .init_verbs = { alc880_volume_init_verbs,
3264 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003265 alc880_gpio2_init_verbs }, /* use GPIO2 */
3266 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3267 .dac_nids = alc880_asus_dac_nids,
3268 .dig_out_nid = ALC880_DIGOUT_NID,
3269 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3270 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003271 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003272 .input_mux = &alc880_capture_source,
3273 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003274 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003276 .init_verbs = { alc880_volume_init_verbs,
3277 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 alc880_gpio1_init_verbs },
3279 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3280 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003281 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003282 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3283 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003284 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003285 .input_mux = &alc880_capture_source,
3286 },
3287 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003288 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003289 .init_verbs = { alc880_volume_init_verbs,
3290 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3292 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003293 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3295 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003296 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003297 .input_mux = &alc880_capture_source,
3298 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003299 [ALC880_UNIWILL] = {
3300 .mixers = { alc880_uniwill_mixer },
3301 .init_verbs = { alc880_volume_init_verbs,
3302 alc880_uniwill_init_verbs },
3303 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3304 .dac_nids = alc880_asus_dac_nids,
3305 .dig_out_nid = ALC880_DIGOUT_NID,
3306 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3307 .channel_mode = alc880_threestack_modes,
3308 .need_dac_fix = 1,
3309 .input_mux = &alc880_capture_source,
3310 .unsol_event = alc880_uniwill_unsol_event,
3311 .init_hook = alc880_uniwill_automute,
3312 },
3313 [ALC880_UNIWILL_P53] = {
3314 .mixers = { alc880_uniwill_p53_mixer },
3315 .init_verbs = { alc880_volume_init_verbs,
3316 alc880_uniwill_p53_init_verbs },
3317 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3318 .dac_nids = alc880_asus_dac_nids,
3319 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003320 .channel_mode = alc880_threestack_modes,
3321 .input_mux = &alc880_capture_source,
3322 .unsol_event = alc880_uniwill_p53_unsol_event,
3323 .init_hook = alc880_uniwill_p53_hp_automute,
3324 },
3325 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003326 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003327 alc880_pcbeep_mixer, },
3328 .init_verbs = { alc880_volume_init_verbs,
3329 alc880_uniwill_p53_init_verbs,
3330 alc880_beep_init_verbs },
3331 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3332 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003333 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003334 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3335 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003336 .input_mux = &alc880_capture_source,
3337 .unsol_event = alc880_uniwill_p53_unsol_event,
3338 .init_hook = alc880_uniwill_p53_hp_automute,
3339 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003340 [ALC880_CLEVO] = {
3341 .mixers = { alc880_three_stack_mixer },
3342 .init_verbs = { alc880_volume_init_verbs,
3343 alc880_pin_clevo_init_verbs },
3344 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3345 .dac_nids = alc880_dac_nids,
3346 .hp_nid = 0x03,
3347 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3348 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003349 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003350 .input_mux = &alc880_capture_source,
3351 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003352 [ALC880_LG] = {
3353 .mixers = { alc880_lg_mixer },
3354 .init_verbs = { alc880_volume_init_verbs,
3355 alc880_lg_init_verbs },
3356 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3357 .dac_nids = alc880_lg_dac_nids,
3358 .dig_out_nid = ALC880_DIGOUT_NID,
3359 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3360 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003361 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003362 .input_mux = &alc880_lg_capture_source,
3363 .unsol_event = alc880_lg_unsol_event,
3364 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003365#ifdef CONFIG_SND_HDA_POWER_SAVE
3366 .loopbacks = alc880_lg_loopbacks,
3367#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003368 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003369 [ALC880_LG_LW] = {
3370 .mixers = { alc880_lg_lw_mixer },
3371 .init_verbs = { alc880_volume_init_verbs,
3372 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003374 .dac_nids = alc880_dac_nids,
3375 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003376 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3377 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003378 .input_mux = &alc880_lg_lw_capture_source,
3379 .unsol_event = alc880_lg_lw_unsol_event,
3380 .init_hook = alc880_lg_lw_automute,
3381 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003382 [ALC880_MEDION_RIM] = {
3383 .mixers = { alc880_medion_rim_mixer },
3384 .init_verbs = { alc880_volume_init_verbs,
3385 alc880_medion_rim_init_verbs,
3386 alc_gpio2_init_verbs },
3387 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3388 .dac_nids = alc880_dac_nids,
3389 .dig_out_nid = ALC880_DIGOUT_NID,
3390 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3391 .channel_mode = alc880_2_jack_modes,
3392 .input_mux = &alc880_medion_rim_capture_source,
3393 .unsol_event = alc880_medion_rim_unsol_event,
3394 .init_hook = alc880_medion_rim_automute,
3395 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003396#ifdef CONFIG_SND_DEBUG
3397 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003398 .mixers = { alc880_test_mixer },
3399 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003400 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3401 .dac_nids = alc880_test_dac_nids,
3402 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003403 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3404 .channel_mode = alc880_test_modes,
3405 .input_mux = &alc880_test_capture_source,
3406 },
3407#endif
3408};
3409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410/*
3411 * Automatic parse of I/O pins from the BIOS configuration
3412 */
3413
3414#define NUM_CONTROL_ALLOC 32
3415#define NUM_VERB_ALLOC 32
3416
3417enum {
3418 ALC_CTL_WIDGET_VOL,
3419 ALC_CTL_WIDGET_MUTE,
3420 ALC_CTL_BIND_MUTE,
3421};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003422static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003423 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3424 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003425 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426};
3427
3428/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003429static int add_control(struct alc_spec *spec, int type, const char *name,
3430 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003432 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433
3434 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3435 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003437 /* array + terminator */
3438 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3439 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003440 return -ENOMEM;
3441 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003442 memcpy(knew, spec->kctl_alloc,
3443 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003444 kfree(spec->kctl_alloc);
3445 }
3446 spec->kctl_alloc = knew;
3447 spec->num_kctl_alloc = num;
3448 }
3449
3450 knew = &spec->kctl_alloc[spec->num_kctl_used];
3451 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003452 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003453 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003454 return -ENOMEM;
3455 knew->private_value = val;
3456 spec->num_kctl_used++;
3457 return 0;
3458}
3459
3460#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3461#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3462#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3463#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3464#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3465#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3466#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3467#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3468#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3469#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3470#define ALC880_PIN_CD_NID 0x1c
3471
3472/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003473static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3474 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475{
3476 hda_nid_t nid;
3477 int assigned[4];
3478 int i, j;
3479
3480 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003481 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003482
3483 /* check the pins hardwired to audio widget */
3484 for (i = 0; i < cfg->line_outs; i++) {
3485 nid = cfg->line_out_pins[i];
3486 if (alc880_is_fixed_pin(nid)) {
3487 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003488 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 assigned[idx] = 1;
3490 }
3491 }
3492 /* left pins can be connect to any audio widget */
3493 for (i = 0; i < cfg->line_outs; i++) {
3494 nid = cfg->line_out_pins[i];
3495 if (alc880_is_fixed_pin(nid))
3496 continue;
3497 /* search for an empty channel */
3498 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003499 if (!assigned[j]) {
3500 spec->multiout.dac_nids[i] =
3501 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003502 assigned[j] = 1;
3503 break;
3504 }
3505 }
3506 }
3507 spec->multiout.num_dacs = cfg->line_outs;
3508 return 0;
3509}
3510
3511/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003512static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3513 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003514{
3515 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003516 static const char *chname[4] = {
3517 "Front", "Surround", NULL /*CLFE*/, "Side"
3518 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 hda_nid_t nid;
3520 int i, err;
3521
3522 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003523 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003524 continue;
3525 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3526 if (i == 2) {
3527 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3529 "Center Playback Volume",
3530 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3531 HDA_OUTPUT));
3532 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003533 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003534 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3535 "LFE Playback Volume",
3536 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3537 HDA_OUTPUT));
3538 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003539 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003540 err = add_control(spec, ALC_CTL_BIND_MUTE,
3541 "Center Playback Switch",
3542 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3543 HDA_INPUT));
3544 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003546 err = add_control(spec, ALC_CTL_BIND_MUTE,
3547 "LFE Playback Switch",
3548 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3549 HDA_INPUT));
3550 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551 return err;
3552 } else {
3553 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003554 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3555 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3556 HDA_OUTPUT));
3557 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003558 return err;
3559 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003560 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3561 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3562 HDA_INPUT));
3563 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003564 return err;
3565 }
3566 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567 return 0;
3568}
3569
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003570/* add playback controls for speaker and HP outputs */
3571static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3572 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003573{
3574 hda_nid_t nid;
3575 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003576 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003578 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579 return 0;
3580
3581 if (alc880_is_fixed_pin(pin)) {
3582 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003583 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003584 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003586 else
3587 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 /* control HP volume/switch on the output mixer amp */
3589 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003590 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003591 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3592 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3593 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003595 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003596 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3597 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3598 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 return err;
3600 } else if (alc880_is_multi_pin(pin)) {
3601 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003603 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003604 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3605 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3606 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003607 return err;
3608 }
3609 return 0;
3610}
3611
3612/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003613static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3614 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003615 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003616{
3617 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003618 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003619
3620 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003621 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3622 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3623 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003624 return err;
3625 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003626 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3627 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3628 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629 return err;
3630 return 0;
3631}
3632
3633/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003634static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3635 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003636{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003637 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003638 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003639
3640 for (i = 0; i < AUTO_PIN_LAST; i++) {
3641 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003642 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003643 err = new_analog_input(spec, cfg->input_pins[i],
3644 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003645 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003646 if (err < 0)
3647 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003648 imux->items[imux->num_items].label =
3649 auto_pin_cfg_labels[i];
3650 imux->items[imux->num_items].index =
3651 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003652 imux->num_items++;
3653 }
3654 }
3655 return 0;
3656}
3657
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003658static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3659 unsigned int pin_type)
3660{
3661 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3662 pin_type);
3663 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003664 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3665 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003666}
3667
Kailang Yangdf694da2005-12-05 19:42:22 +01003668static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3669 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003670 int dac_idx)
3671{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003672 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003673 /* need the manual connection? */
3674 if (alc880_is_multi_pin(nid)) {
3675 struct alc_spec *spec = codec->spec;
3676 int idx = alc880_multi_pin_idx(nid);
3677 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3678 AC_VERB_SET_CONNECT_SEL,
3679 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3680 }
3681}
3682
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003683static int get_pin_type(int line_out_type)
3684{
3685 if (line_out_type == AUTO_PIN_HP_OUT)
3686 return PIN_HP;
3687 else
3688 return PIN_OUT;
3689}
3690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691static void alc880_auto_init_multi_out(struct hda_codec *codec)
3692{
3693 struct alc_spec *spec = codec->spec;
3694 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003695
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003696 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003697 for (i = 0; i < spec->autocfg.line_outs; i++) {
3698 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003699 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3700 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003701 }
3702}
3703
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003704static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003705{
3706 struct alc_spec *spec = codec->spec;
3707 hda_nid_t pin;
3708
Takashi Iwai82bc9552006-03-21 11:24:42 +01003709 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003710 if (pin) /* connect to front */
3711 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003712 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003713 if (pin) /* connect to front */
3714 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3715}
3716
3717static void alc880_auto_init_analog_input(struct hda_codec *codec)
3718{
3719 struct alc_spec *spec = codec->spec;
3720 int i;
3721
3722 for (i = 0; i < AUTO_PIN_LAST; i++) {
3723 hda_nid_t nid = spec->autocfg.input_pins[i];
3724 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003725 snd_hda_codec_write(codec, nid, 0,
3726 AC_VERB_SET_PIN_WIDGET_CONTROL,
3727 i <= AUTO_PIN_FRONT_MIC ?
3728 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003729 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003730 snd_hda_codec_write(codec, nid, 0,
3731 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732 AMP_OUT_MUTE);
3733 }
3734 }
3735}
3736
3737/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738/* return 1 if successful, 0 if the proper config is not found,
3739 * or a negative error code
3740 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003741static int alc880_parse_auto_config(struct hda_codec *codec)
3742{
3743 struct alc_spec *spec = codec->spec;
3744 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003745 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003746
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003747 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3748 alc880_ignore);
3749 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003750 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003751 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003753
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003754 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3755 if (err < 0)
3756 return err;
3757 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3758 if (err < 0)
3759 return err;
3760 err = alc880_auto_create_extra_out(spec,
3761 spec->autocfg.speaker_pins[0],
3762 "Speaker");
3763 if (err < 0)
3764 return err;
3765 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3766 "Headphone");
3767 if (err < 0)
3768 return err;
3769 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3770 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 return err;
3772
3773 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3774
3775 if (spec->autocfg.dig_out_pin)
3776 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3777 if (spec->autocfg.dig_in_pin)
3778 spec->dig_in_nid = ALC880_DIGIN_NID;
3779
3780 if (spec->kctl_alloc)
3781 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3782
3783 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3784
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003785 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003786 spec->input_mux = &spec->private_imux;
3787
3788 return 1;
3789}
3790
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003791/* additional initialization for auto-configuration model */
3792static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003794 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003795 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003796 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003797 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003798 if (spec->unsol_event)
3799 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003800}
3801
3802/*
3803 * OK, here we have finally the patch for ALC880
3804 */
3805
Linus Torvalds1da177e2005-04-16 15:20:36 -07003806static int patch_alc880(struct hda_codec *codec)
3807{
3808 struct alc_spec *spec;
3809 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003810 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003812 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003813 if (spec == NULL)
3814 return -ENOMEM;
3815
3816 codec->spec = spec;
3817
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003818 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3819 alc880_models,
3820 alc880_cfg_tbl);
3821 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003822 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3823 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003824 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003825 }
3826
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003827 if (board_config == ALC880_AUTO) {
3828 /* automatic parse from the BIOS config */
3829 err = alc880_parse_auto_config(codec);
3830 if (err < 0) {
3831 alc_free(codec);
3832 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003833 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003834 printk(KERN_INFO
3835 "hda_codec: Cannot set up configuration "
3836 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003837 board_config = ALC880_3ST;
3838 }
3839 }
3840
Kailang Yangdf694da2005-12-05 19:42:22 +01003841 if (board_config != ALC880_AUTO)
3842 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003843
3844 spec->stream_name_analog = "ALC880 Analog";
3845 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3846 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003847 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003848
3849 spec->stream_name_digital = "ALC880 Digital";
3850 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3851 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3852
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003853 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003854 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003855 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003856 /* get type */
3857 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 if (wcap != AC_WID_AUD_IN) {
3859 spec->adc_nids = alc880_adc_nids_alt;
3860 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003861 spec->mixers[spec->num_mixers] =
3862 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003863 spec->num_mixers++;
3864 } else {
3865 spec->adc_nids = alc880_adc_nids;
3866 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3867 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3868 spec->num_mixers++;
3869 }
3870 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003871
Takashi Iwai2134ea42008-01-10 16:53:55 +01003872 spec->vmaster_nid = 0x0c;
3873
Linus Torvalds1da177e2005-04-16 15:20:36 -07003874 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003875 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003876 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003877#ifdef CONFIG_SND_HDA_POWER_SAVE
3878 if (!spec->loopback.amplist)
3879 spec->loopback.amplist = alc880_loopbacks;
3880#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003881
3882 return 0;
3883}
3884
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886/*
3887 * ALC260 support
3888 */
3889
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003890static hda_nid_t alc260_dac_nids[1] = {
3891 /* front */
3892 0x02,
3893};
3894
3895static hda_nid_t alc260_adc_nids[1] = {
3896 /* ADC0 */
3897 0x04,
3898};
3899
Kailang Yangdf694da2005-12-05 19:42:22 +01003900static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003901 /* ADC1 */
3902 0x05,
3903};
3904
Kailang Yangdf694da2005-12-05 19:42:22 +01003905static hda_nid_t alc260_hp_adc_nids[2] = {
3906 /* ADC1, 0 */
3907 0x05, 0x04
3908};
3909
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003910/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3911 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3912 */
3913static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003914 /* ADC0, ADC1 */
3915 0x04, 0x05
3916};
3917
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918#define ALC260_DIGOUT_NID 0x03
3919#define ALC260_DIGIN_NID 0x06
3920
3921static struct hda_input_mux alc260_capture_source = {
3922 .num_items = 4,
3923 .items = {
3924 { "Mic", 0x0 },
3925 { "Front Mic", 0x1 },
3926 { "Line", 0x2 },
3927 { "CD", 0x4 },
3928 },
3929};
3930
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003931/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003932 * headphone jack and the internal CD lines since these are the only pins at
3933 * which audio can appear. For flexibility, also allow the option of
3934 * recording the mixer output on the second ADC (ADC0 doesn't have a
3935 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003936 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003937static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3938 {
3939 .num_items = 3,
3940 .items = {
3941 { "Mic/Line", 0x0 },
3942 { "CD", 0x4 },
3943 { "Headphone", 0x2 },
3944 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003945 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003946 {
3947 .num_items = 4,
3948 .items = {
3949 { "Mic/Line", 0x0 },
3950 { "CD", 0x4 },
3951 { "Headphone", 0x2 },
3952 { "Mixer", 0x5 },
3953 },
3954 },
3955
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003956};
3957
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003958/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3959 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003960 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003961static struct hda_input_mux alc260_acer_capture_sources[2] = {
3962 {
3963 .num_items = 4,
3964 .items = {
3965 { "Mic", 0x0 },
3966 { "Line", 0x2 },
3967 { "CD", 0x4 },
3968 { "Headphone", 0x5 },
3969 },
3970 },
3971 {
3972 .num_items = 5,
3973 .items = {
3974 { "Mic", 0x0 },
3975 { "Line", 0x2 },
3976 { "CD", 0x4 },
3977 { "Headphone", 0x6 },
3978 { "Mixer", 0x5 },
3979 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003980 },
3981};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003982/*
3983 * This is just place-holder, so there's something for alc_build_pcms to look
3984 * at when it calculates the maximum number of channels. ALC260 has no mixer
3985 * element which allows changing the channel mode, so the verb list is
3986 * never used.
3987 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003988static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003989 { 2, NULL },
3990};
3991
Kailang Yangdf694da2005-12-05 19:42:22 +01003992
3993/* Mixer combinations
3994 *
3995 * basic: base_output + input + pc_beep + capture
3996 * HP: base_output + input + capture_alt
3997 * HP_3013: hp_3013 + input + capture
3998 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003999 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004000 */
4001
4002static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004003 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004004 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004005 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4007 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4008 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4009 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004010};
Kailang Yangdf694da2005-12-05 19:42:22 +01004011
4012static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004013 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4014 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4015 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4016 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4018 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4019 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4020 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004021 { } /* end */
4022};
4023
Kailang Yangdf694da2005-12-05 19:42:22 +01004024static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4025 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4026 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4027 { } /* end */
4028};
4029
Takashi Iwaibec15c32008-01-28 18:16:30 +01004030/* update HP, line and mono out pins according to the master switch */
4031static void alc260_hp_master_update(struct hda_codec *codec,
4032 hda_nid_t hp, hda_nid_t line,
4033 hda_nid_t mono)
4034{
4035 struct alc_spec *spec = codec->spec;
4036 unsigned int val = spec->master_sw ? PIN_HP : 0;
4037 /* change HP and line-out pins */
4038 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4039 val);
4040 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4041 val);
4042 /* mono (speaker) depending on the HP jack sense */
4043 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4044 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4045 val);
4046}
4047
4048static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4049 struct snd_ctl_elem_value *ucontrol)
4050{
4051 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4052 struct alc_spec *spec = codec->spec;
4053 *ucontrol->value.integer.value = spec->master_sw;
4054 return 0;
4055}
4056
4057static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4058 struct snd_ctl_elem_value *ucontrol)
4059{
4060 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4061 struct alc_spec *spec = codec->spec;
4062 int val = !!*ucontrol->value.integer.value;
4063 hda_nid_t hp, line, mono;
4064
4065 if (val == spec->master_sw)
4066 return 0;
4067 spec->master_sw = val;
4068 hp = (kcontrol->private_value >> 16) & 0xff;
4069 line = (kcontrol->private_value >> 8) & 0xff;
4070 mono = kcontrol->private_value & 0xff;
4071 alc260_hp_master_update(codec, hp, line, mono);
4072 return 1;
4073}
4074
4075static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4076 {
4077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4078 .name = "Master Playback Switch",
4079 .info = snd_ctl_boolean_mono_info,
4080 .get = alc260_hp_master_sw_get,
4081 .put = alc260_hp_master_sw_put,
4082 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4083 },
4084 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4085 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4086 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4087 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4088 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4089 HDA_OUTPUT),
4090 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4091 { } /* end */
4092};
4093
4094static struct hda_verb alc260_hp_unsol_verbs[] = {
4095 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4096 {},
4097};
4098
4099static void alc260_hp_automute(struct hda_codec *codec)
4100{
4101 struct alc_spec *spec = codec->spec;
4102 unsigned int present;
4103
4104 present = snd_hda_codec_read(codec, 0x10, 0,
4105 AC_VERB_GET_PIN_SENSE, 0);
4106 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4107 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4108}
4109
4110static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4111{
4112 if ((res >> 26) == ALC880_HP_EVENT)
4113 alc260_hp_automute(codec);
4114}
4115
Kailang Yangdf694da2005-12-05 19:42:22 +01004116static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004117 {
4118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4119 .name = "Master Playback Switch",
4120 .info = snd_ctl_boolean_mono_info,
4121 .get = alc260_hp_master_sw_get,
4122 .put = alc260_hp_master_sw_put,
4123 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4124 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004125 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4126 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4127 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4128 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004131 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4132 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004133 { } /* end */
4134};
4135
Kailang Yang3f878302008-08-26 13:02:23 +02004136static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4137 .ops = &snd_hda_bind_vol,
4138 .values = {
4139 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4140 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4141 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4142 0
4143 },
4144};
4145
4146static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4147 .ops = &snd_hda_bind_sw,
4148 .values = {
4149 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4150 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4151 0
4152 },
4153};
4154
4155static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4156 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4157 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4158 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4160 { } /* end */
4161};
4162
Takashi Iwaibec15c32008-01-28 18:16:30 +01004163static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4165 {},
4166};
4167
4168static void alc260_hp_3013_automute(struct hda_codec *codec)
4169{
4170 struct alc_spec *spec = codec->spec;
4171 unsigned int present;
4172
4173 present = snd_hda_codec_read(codec, 0x15, 0,
4174 AC_VERB_GET_PIN_SENSE, 0);
4175 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4176 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4177}
4178
4179static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4180 unsigned int res)
4181{
4182 if ((res >> 26) == ALC880_HP_EVENT)
4183 alc260_hp_3013_automute(codec);
4184}
4185
Kailang Yang3f878302008-08-26 13:02:23 +02004186static void alc260_hp_3012_automute(struct hda_codec *codec)
4187{
4188 unsigned int present, bits;
4189
4190 present = snd_hda_codec_read(codec, 0x10, 0,
4191 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4192
4193 bits = present ? 0 : PIN_OUT;
4194 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4195 bits);
4196 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4197 bits);
4198 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4199 bits);
4200}
4201
4202static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4203 unsigned int res)
4204{
4205 if ((res >> 26) == ALC880_HP_EVENT)
4206 alc260_hp_3012_automute(codec);
4207}
4208
4209/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004210 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4211 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004212static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004214 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004215 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004216 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4217 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4218 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4219 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004220 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004221 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4222 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004223 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4224 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004225 { } /* end */
4226};
4227
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004228/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4229 * versions of the ALC260 don't act on requests to enable mic bias from NID
4230 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4231 * datasheet doesn't mention this restriction. At this stage it's not clear
4232 * whether this behaviour is intentional or is a hardware bug in chip
4233 * revisions available in early 2006. Therefore for now allow the
4234 * "Headphone Jack Mode" control to span all choices, but if it turns out
4235 * that the lack of mic bias for this NID is intentional we could change the
4236 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4237 *
4238 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4239 * don't appear to make the mic bias available from the "line" jack, even
4240 * though the NID used for this jack (0x14) can supply it. The theory is
4241 * that perhaps Acer have included blocking capacitors between the ALC260
4242 * and the output jack. If this turns out to be the case for all such
4243 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4244 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004245 *
4246 * The C20x Tablet series have a mono internal speaker which is controlled
4247 * via the chip's Mono sum widget and pin complex, so include the necessary
4248 * controls for such models. On models without a "mono speaker" the control
4249 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004250 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004251static struct snd_kcontrol_new alc260_acer_mixer[] = {
4252 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4253 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004254 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004255 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004256 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004257 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004258 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004259 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4260 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4262 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4263 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4264 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4265 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4266 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4267 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4268 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4269 { } /* end */
4270};
4271
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004272/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4273 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4274 */
4275static struct snd_kcontrol_new alc260_will_mixer[] = {
4276 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4277 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4279 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4280 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4281 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4282 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4283 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4284 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4285 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4286 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4287 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4288 { } /* end */
4289};
4290
4291/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4292 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4293 */
4294static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4295 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4296 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4298 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4299 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4300 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4301 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4302 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4303 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4304 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4305 { } /* end */
4306};
4307
Kailang Yangdf694da2005-12-05 19:42:22 +01004308/* capture mixer elements */
4309static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004310 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4311 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004312 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4313 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004314 {
4315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 /* The multiple "Capture Source" controls confuse alsamixer
4317 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004318 */
4319 /* .name = "Capture Source", */
4320 .name = "Input Source",
4321 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004322 .info = alc_mux_enum_info,
4323 .get = alc_mux_enum_get,
4324 .put = alc_mux_enum_put,
4325 },
4326 { } /* end */
4327};
4328
Kailang Yangdf694da2005-12-05 19:42:22 +01004329static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4330 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4331 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4332 {
4333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4334 /* The multiple "Capture Source" controls confuse alsamixer
4335 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004336 */
4337 /* .name = "Capture Source", */
4338 .name = "Input Source",
4339 .count = 1,
4340 .info = alc_mux_enum_info,
4341 .get = alc_mux_enum_get,
4342 .put = alc_mux_enum_put,
4343 },
4344 { } /* end */
4345};
4346
4347/*
4348 * initialization verbs
4349 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004350static struct hda_verb alc260_init_verbs[] = {
4351 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004353 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004354 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004357 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004358 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004362 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004363 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004364 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004366 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004367 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004368 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4369 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004370 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371 /* set connection select to line in (default select for this ADC) */
4372 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004373 /* mute capture amp left and right */
4374 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4375 /* set connection select to line in (default select for this ADC) */
4376 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004377 /* set vol=0 Line-Out mixer amp left and right */
4378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4379 /* unmute pin widget amp left and right (no gain on this amp) */
4380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4381 /* set vol=0 HP mixer amp left and right */
4382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4383 /* unmute pin widget amp left and right (no gain on this amp) */
4384 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4385 /* set vol=0 Mono mixer amp left and right */
4386 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4387 /* unmute pin widget amp left and right (no gain on this amp) */
4388 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4389 /* unmute LINE-2 out pin */
4390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004391 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4392 * Line In 2 = 0x03
4393 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004394 /* mute analog inputs */
4395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004400 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004401 /* mute Front out path */
4402 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4404 /* mute Headphone out path */
4405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4407 /* mute Mono out path */
4408 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4409 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004410 { }
4411};
4412
Takashi Iwai474167d2006-05-17 17:17:43 +02004413#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004414static struct hda_verb alc260_hp_init_verbs[] = {
4415 /* Headphone and output */
4416 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4417 /* mono output */
4418 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4419 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4420 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4421 /* Mic2 (front panel) pin widget for input and vref at 80% */
4422 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4423 /* Line In pin widget for input */
4424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4425 /* Line-2 pin widget for output */
4426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4427 /* CD pin widget for input */
4428 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4429 /* unmute amp left and right */
4430 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4431 /* set connection select to line in (default select for this ADC) */
4432 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4433 /* unmute Line-Out mixer amp left and right (volume = 0) */
4434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4435 /* mute pin widget amp left and right (no gain on this amp) */
4436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4437 /* unmute HP mixer amp left and right (volume = 0) */
4438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4439 /* mute pin widget amp left and right (no gain on this amp) */
4440 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004441 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4442 * Line In 2 = 0x03
4443 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004444 /* mute analog inputs */
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004450 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4451 /* Unmute Front out path */
4452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4454 /* Unmute Headphone out path */
4455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4457 /* Unmute Mono out path */
4458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4459 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4460 { }
4461};
Takashi Iwai474167d2006-05-17 17:17:43 +02004462#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004463
4464static struct hda_verb alc260_hp_3013_init_verbs[] = {
4465 /* Line out and output */
4466 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4467 /* mono output */
4468 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4469 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4470 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4471 /* Mic2 (front panel) pin widget for input and vref at 80% */
4472 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4473 /* Line In pin widget for input */
4474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4475 /* Headphone pin widget for output */
4476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4477 /* CD pin widget for input */
4478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4479 /* unmute amp left and right */
4480 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4481 /* set connection select to line in (default select for this ADC) */
4482 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4483 /* unmute Line-Out mixer amp left and right (volume = 0) */
4484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4485 /* mute pin widget amp left and right (no gain on this amp) */
4486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4487 /* unmute HP mixer amp left and right (volume = 0) */
4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4489 /* mute pin widget amp left and right (no gain on this amp) */
4490 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004491 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4492 * Line In 2 = 0x03
4493 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004494 /* mute analog inputs */
4495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4501 /* Unmute Front out path */
4502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4504 /* Unmute Headphone out path */
4505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4507 /* Unmute Mono out path */
4508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4510 { }
4511};
4512
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004513/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004514 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4515 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004516 */
4517static struct hda_verb alc260_fujitsu_init_verbs[] = {
4518 /* Disable all GPIOs */
4519 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4520 /* Internal speaker is connected to headphone pin */
4521 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4522 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004524 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4525 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4526 /* Ensure all other unused pins are disabled and muted. */
4527 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004529 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004530 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004531 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004532 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004535
Jonathan Woithef7ace402006-02-28 11:46:14 +01004536 /* Disable digital (SPDIF) pins */
4537 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4538 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004539
Kailang Yangea1fb292008-08-26 12:58:38 +02004540 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004541 * when acting as an output.
4542 */
4543 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4544
4545 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4552 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4553 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4554 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004555
Jonathan Woithef7ace402006-02-28 11:46:14 +01004556 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4557 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4558 /* Unmute Line1 pin widget output buffer since it starts as an output.
4559 * If the pin mode is changed by the user the pin mode control will
4560 * take care of enabling the pin's input/output buffers as needed.
4561 * Therefore there's no need to enable the input buffer at this
4562 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004563 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004565 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004566 * mixer ctrl)
4567 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004568 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004569
Jonathan Woithef7ace402006-02-28 11:46:14 +01004570 /* Mute capture amp left and right */
4571 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004572 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004573 * in (on mic1 pin)
4574 */
4575 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004576
Jonathan Woithef7ace402006-02-28 11:46:14 +01004577 /* Do the same for the second ADC: mute capture input amp and
4578 * set ADC connection to line in (on mic1 pin)
4579 */
4580 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4581 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004582
Jonathan Woithef7ace402006-02-28 11:46:14 +01004583 /* Mute all inputs to mixer widget (even unconnected ones) */
4584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004592
4593 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004594};
4595
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004596/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4597 * similar laptops (adapted from Fujitsu init verbs).
4598 */
4599static struct hda_verb alc260_acer_init_verbs[] = {
4600 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4601 * the headphone jack. Turn this on and rely on the standard mute
4602 * methods whenever the user wants to turn these outputs off.
4603 */
4604 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4605 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4606 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4607 /* Internal speaker/Headphone jack is connected to Line-out pin */
4608 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4609 /* Internal microphone/Mic jack is connected to Mic1 pin */
4610 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4611 /* Line In jack is connected to Line1 pin */
4612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004613 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4614 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004615 /* Ensure all other unused pins are disabled and muted. */
4616 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4617 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004618 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4619 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4620 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4622 /* Disable digital (SPDIF) pins */
4623 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4624 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4625
Kailang Yangea1fb292008-08-26 12:58:38 +02004626 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004627 * bus when acting as outputs.
4628 */
4629 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4630 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4631
4632 /* Start with output sum widgets muted and their output gains at min */
4633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4641 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4642
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004643 /* Unmute Line-out pin widget amp left and right
4644 * (no equiv mixer ctrl)
4645 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004647 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4648 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004649 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4650 * inputs. If the pin mode is changed by the user the pin mode control
4651 * will take care of enabling the pin's input/output buffers as needed.
4652 * Therefore there's no need to enable the input buffer at this
4653 * stage.
4654 */
4655 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4656 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4657
4658 /* Mute capture amp left and right */
4659 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4660 /* Set ADC connection select to match default mixer setting - mic
4661 * (on mic1 pin)
4662 */
4663 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4664
4665 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004666 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004667 */
4668 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004669 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004670
4671 /* Mute all inputs to mixer widget (even unconnected ones) */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4680
4681 { }
4682};
4683
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004684static struct hda_verb alc260_will_verbs[] = {
4685 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4686 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4687 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4688 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4689 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4690 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4691 {}
4692};
4693
4694static struct hda_verb alc260_replacer_672v_verbs[] = {
4695 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4696 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4697 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4698
4699 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4700 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4701 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4702
4703 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4704 {}
4705};
4706
4707/* toggle speaker-output according to the hp-jack state */
4708static void alc260_replacer_672v_automute(struct hda_codec *codec)
4709{
4710 unsigned int present;
4711
4712 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4713 present = snd_hda_codec_read(codec, 0x0f, 0,
4714 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4715 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004716 snd_hda_codec_write_cache(codec, 0x01, 0,
4717 AC_VERB_SET_GPIO_DATA, 1);
4718 snd_hda_codec_write_cache(codec, 0x0f, 0,
4719 AC_VERB_SET_PIN_WIDGET_CONTROL,
4720 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004721 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004722 snd_hda_codec_write_cache(codec, 0x01, 0,
4723 AC_VERB_SET_GPIO_DATA, 0);
4724 snd_hda_codec_write_cache(codec, 0x0f, 0,
4725 AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004727 }
4728}
4729
4730static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4731 unsigned int res)
4732{
4733 if ((res >> 26) == ALC880_HP_EVENT)
4734 alc260_replacer_672v_automute(codec);
4735}
4736
Kailang Yang3f878302008-08-26 13:02:23 +02004737static struct hda_verb alc260_hp_dc7600_verbs[] = {
4738 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4740 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4741 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4742 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4744 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4745 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4746 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4747 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4748 {}
4749};
4750
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004751/* Test configuration for debugging, modelled after the ALC880 test
4752 * configuration.
4753 */
4754#ifdef CONFIG_SND_DEBUG
4755static hda_nid_t alc260_test_dac_nids[1] = {
4756 0x02,
4757};
4758static hda_nid_t alc260_test_adc_nids[2] = {
4759 0x04, 0x05,
4760};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004761/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004762 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004763 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004764 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004765static struct hda_input_mux alc260_test_capture_sources[2] = {
4766 {
4767 .num_items = 7,
4768 .items = {
4769 { "MIC1 pin", 0x0 },
4770 { "MIC2 pin", 0x1 },
4771 { "LINE1 pin", 0x2 },
4772 { "LINE2 pin", 0x3 },
4773 { "CD pin", 0x4 },
4774 { "LINE-OUT pin", 0x5 },
4775 { "HP-OUT pin", 0x6 },
4776 },
4777 },
4778 {
4779 .num_items = 8,
4780 .items = {
4781 { "MIC1 pin", 0x0 },
4782 { "MIC2 pin", 0x1 },
4783 { "LINE1 pin", 0x2 },
4784 { "LINE2 pin", 0x3 },
4785 { "CD pin", 0x4 },
4786 { "Mixer", 0x5 },
4787 { "LINE-OUT pin", 0x6 },
4788 { "HP-OUT pin", 0x7 },
4789 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004790 },
4791};
4792static struct snd_kcontrol_new alc260_test_mixer[] = {
4793 /* Output driver widgets */
4794 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4795 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4796 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4797 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4798 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4799 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4800
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004801 /* Modes for retasking pin widgets
4802 * Note: the ALC260 doesn't seem to act on requests to enable mic
4803 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4804 * mention this restriction. At this stage it's not clear whether
4805 * this behaviour is intentional or is a hardware bug in chip
4806 * revisions available at least up until early 2006. Therefore for
4807 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4808 * choices, but if it turns out that the lack of mic bias for these
4809 * NIDs is intentional we could change their modes from
4810 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4811 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004812 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4813 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4814 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4815 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4816 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4817 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4818
4819 /* Loopback mixer controls */
4820 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4821 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4822 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4823 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4824 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4825 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4826 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4827 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4828 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4829 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4830 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4831 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4832 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4833 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4834 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4835 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004836
4837 /* Controls for GPIO pins, assuming they are configured as outputs */
4838 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4839 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4840 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4841 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4842
Jonathan Woithe92621f12006-02-28 11:47:47 +01004843 /* Switches to allow the digital IO pins to be enabled. The datasheet
4844 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004845 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004846 */
4847 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4848 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4849
Jonathan Woithef8225f62008-01-08 12:16:54 +01004850 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4851 * this output to turn on an external amplifier.
4852 */
4853 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4854 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4855
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004856 { } /* end */
4857};
4858static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004859 /* Enable all GPIOs as outputs with an initial value of 0 */
4860 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4861 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4862 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4863
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004864 /* Enable retasking pins as output, initially without power amp */
4865 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4866 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4870 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4871
Jonathan Woithe92621f12006-02-28 11:47:47 +01004872 /* Disable digital (SPDIF) pins initially, but users can enable
4873 * them via a mixer switch. In the case of SPDIF-out, this initverb
4874 * payload also sets the generation to 0, output to be in "consumer"
4875 * PCM format, copyright asserted, no pre-emphasis and no validity
4876 * control.
4877 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004878 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4879 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4880
Kailang Yangea1fb292008-08-26 12:58:38 +02004881 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004882 * OUT1 sum bus when acting as an output.
4883 */
4884 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4885 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4886 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4887 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4888
4889 /* Start with output sum widgets muted and their output gains at min */
4890 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4891 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4892 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4893 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4894 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4895 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4896 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4899
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004900 /* Unmute retasking pin widget output buffers since the default
4901 * state appears to be output. As the pin mode is changed by the
4902 * user the pin mode control will take care of enabling the pin's
4903 * input/output buffers as needed.
4904 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004905 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4909 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4910 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4911 /* Also unmute the mono-out pin widget */
4912 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4913
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004914 /* Mute capture amp left and right */
4915 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004916 /* Set ADC connection select to match default mixer setting (mic1
4917 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004918 */
4919 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4920
4921 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004922 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004923 */
4924 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4925 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4926
4927 /* Mute all inputs to mixer widget (even unconnected ones) */
4928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4936
4937 { }
4938};
4939#endif
4940
Takashi Iwai63300792008-01-24 15:31:36 +01004941#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4942#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004943
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004944#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4945#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4946
Kailang Yangdf694da2005-12-05 19:42:22 +01004947/*
4948 * for BIOS auto-configuration
4949 */
4950
4951static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4952 const char *pfx)
4953{
4954 hda_nid_t nid_vol;
4955 unsigned long vol_val, sw_val;
4956 char name[32];
4957 int err;
4958
4959 if (nid >= 0x0f && nid < 0x11) {
4960 nid_vol = nid - 0x7;
4961 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4962 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4963 } else if (nid == 0x11) {
4964 nid_vol = nid - 0x7;
4965 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4966 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4967 } else if (nid >= 0x12 && nid <= 0x15) {
4968 nid_vol = 0x08;
4969 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4970 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4971 } else
4972 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004973
Kailang Yangdf694da2005-12-05 19:42:22 +01004974 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004975 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4976 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004977 return err;
4978 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004979 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4980 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004981 return err;
4982 return 1;
4983}
4984
4985/* add playback controls from the parsed DAC table */
4986static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4987 const struct auto_pin_cfg *cfg)
4988{
4989 hda_nid_t nid;
4990 int err;
4991
4992 spec->multiout.num_dacs = 1;
4993 spec->multiout.dac_nids = spec->private_dac_nids;
4994 spec->multiout.dac_nids[0] = 0x02;
4995
4996 nid = cfg->line_out_pins[0];
4997 if (nid) {
4998 err = alc260_add_playback_controls(spec, nid, "Front");
4999 if (err < 0)
5000 return err;
5001 }
5002
Takashi Iwai82bc9552006-03-21 11:24:42 +01005003 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005004 if (nid) {
5005 err = alc260_add_playback_controls(spec, nid, "Speaker");
5006 if (err < 0)
5007 return err;
5008 }
5009
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005010 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005011 if (nid) {
5012 err = alc260_add_playback_controls(spec, nid, "Headphone");
5013 if (err < 0)
5014 return err;
5015 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005016 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005017}
5018
5019/* create playback/capture controls for input pins */
5020static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5021 const struct auto_pin_cfg *cfg)
5022{
Kailang Yangdf694da2005-12-05 19:42:22 +01005023 struct hda_input_mux *imux = &spec->private_imux;
5024 int i, err, idx;
5025
5026 for (i = 0; i < AUTO_PIN_LAST; i++) {
5027 if (cfg->input_pins[i] >= 0x12) {
5028 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005029 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005030 auto_pin_cfg_labels[i], idx,
5031 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005032 if (err < 0)
5033 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005034 imux->items[imux->num_items].label =
5035 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005036 imux->items[imux->num_items].index = idx;
5037 imux->num_items++;
5038 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005039 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005040 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005041 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005042 auto_pin_cfg_labels[i], idx,
5043 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005044 if (err < 0)
5045 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005046 imux->items[imux->num_items].label =
5047 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 imux->items[imux->num_items].index = idx;
5049 imux->num_items++;
5050 }
5051 }
5052 return 0;
5053}
5054
5055static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5056 hda_nid_t nid, int pin_type,
5057 int sel_idx)
5058{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005059 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005060 /* need the manual connection? */
5061 if (nid >= 0x12) {
5062 int idx = nid - 0x12;
5063 snd_hda_codec_write(codec, idx + 0x0b, 0,
5064 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005065 }
5066}
5067
5068static void alc260_auto_init_multi_out(struct hda_codec *codec)
5069{
5070 struct alc_spec *spec = codec->spec;
5071 hda_nid_t nid;
5072
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005073 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005074 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005075 if (nid) {
5076 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5077 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5078 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005079
Takashi Iwai82bc9552006-03-21 11:24:42 +01005080 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005081 if (nid)
5082 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5083
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005084 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005085 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005086 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005087}
Kailang Yangdf694da2005-12-05 19:42:22 +01005088
5089#define ALC260_PIN_CD_NID 0x16
5090static void alc260_auto_init_analog_input(struct hda_codec *codec)
5091{
5092 struct alc_spec *spec = codec->spec;
5093 int i;
5094
5095 for (i = 0; i < AUTO_PIN_LAST; i++) {
5096 hda_nid_t nid = spec->autocfg.input_pins[i];
5097 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005098 snd_hda_codec_write(codec, nid, 0,
5099 AC_VERB_SET_PIN_WIDGET_CONTROL,
5100 i <= AUTO_PIN_FRONT_MIC ?
5101 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005102 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005103 snd_hda_codec_write(codec, nid, 0,
5104 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005105 AMP_OUT_MUTE);
5106 }
5107 }
5108}
5109
5110/*
5111 * generic initialization of ADC, input mixers and output mixers
5112 */
5113static struct hda_verb alc260_volume_init_verbs[] = {
5114 /*
5115 * Unmute ADC0-1 and set the default input to mic-in
5116 */
5117 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5118 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005121
Kailang Yangdf694da2005-12-05 19:42:22 +01005122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5123 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005124 * Note: PASD motherboards uses the Line In 2 as the input for
5125 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005126 */
5127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005128 /* mute analog inputs */
5129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005134
5135 /*
5136 * Set up output mixers (0x08 - 0x0a)
5137 */
5138 /* set vol=0 to output mixers */
5139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5141 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5142 /* set up input amps for analog loopback */
5143 /* Amp Indices: DAC = 0, mixer = 1 */
5144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5149 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005150
Kailang Yangdf694da2005-12-05 19:42:22 +01005151 { }
5152};
5153
5154static int alc260_parse_auto_config(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
5157 unsigned int wcap;
5158 int err;
5159 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5160
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005161 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5162 alc260_ignore);
5163 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005164 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005165 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5166 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005167 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005170 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5171 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005172 return err;
5173
5174 spec->multiout.max_channels = 2;
5175
5176 if (spec->autocfg.dig_out_pin)
5177 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5178 if (spec->kctl_alloc)
5179 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5180
5181 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5182
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005183 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005184 spec->input_mux = &spec->private_imux;
5185
5186 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005187 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005188 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005189 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005190 spec->adc_nids = alc260_adc_nids_alt;
5191 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5192 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 } else {
5194 spec->adc_nids = alc260_adc_nids;
5195 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5196 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005197 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005198 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005199
5200 return 1;
5201}
5202
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005203/* additional initialization for auto-configuration model */
5204static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005205{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005206 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 alc260_auto_init_multi_out(codec);
5208 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005209 if (spec->unsol_event)
5210 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005211}
5212
Takashi Iwaicb53c622007-08-10 17:21:45 +02005213#ifdef CONFIG_SND_HDA_POWER_SAVE
5214static struct hda_amp_list alc260_loopbacks[] = {
5215 { 0x07, HDA_INPUT, 0 },
5216 { 0x07, HDA_INPUT, 1 },
5217 { 0x07, HDA_INPUT, 2 },
5218 { 0x07, HDA_INPUT, 3 },
5219 { 0x07, HDA_INPUT, 4 },
5220 { } /* end */
5221};
5222#endif
5223
Kailang Yangdf694da2005-12-05 19:42:22 +01005224/*
5225 * ALC260 configurations
5226 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005227static const char *alc260_models[ALC260_MODEL_LAST] = {
5228 [ALC260_BASIC] = "basic",
5229 [ALC260_HP] = "hp",
5230 [ALC260_HP_3013] = "hp-3013",
5231 [ALC260_FUJITSU_S702X] = "fujitsu",
5232 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005233 [ALC260_WILL] = "will",
5234 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005235#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005236 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005237#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005238 [ALC260_AUTO] = "auto",
5239};
5240
5241static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005242 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005243 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005244 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005245 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005246 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005247 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005248 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005249 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5250 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5251 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5252 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5253 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5254 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5255 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5256 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5257 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005258 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005259 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005260 {}
5261};
5262
Kailang Yangdf694da2005-12-05 19:42:22 +01005263static struct alc_config_preset alc260_presets[] = {
5264 [ALC260_BASIC] = {
5265 .mixers = { alc260_base_output_mixer,
5266 alc260_input_mixer,
5267 alc260_pc_beep_mixer,
5268 alc260_capture_mixer },
5269 .init_verbs = { alc260_init_verbs },
5270 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5271 .dac_nids = alc260_dac_nids,
5272 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5273 .adc_nids = alc260_adc_nids,
5274 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5275 .channel_mode = alc260_modes,
5276 .input_mux = &alc260_capture_source,
5277 },
5278 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005279 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005280 alc260_input_mixer,
5281 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005282 .init_verbs = { alc260_init_verbs,
5283 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005284 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5285 .dac_nids = alc260_dac_nids,
5286 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5287 .adc_nids = alc260_hp_adc_nids,
5288 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5289 .channel_mode = alc260_modes,
5290 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005291 .unsol_event = alc260_hp_unsol_event,
5292 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005293 },
Kailang Yang3f878302008-08-26 13:02:23 +02005294 [ALC260_HP_DC7600] = {
5295 .mixers = { alc260_hp_dc7600_mixer,
5296 alc260_input_mixer,
5297 alc260_capture_alt_mixer },
5298 .init_verbs = { alc260_init_verbs,
5299 alc260_hp_dc7600_verbs },
5300 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5301 .dac_nids = alc260_dac_nids,
5302 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5303 .adc_nids = alc260_hp_adc_nids,
5304 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5305 .channel_mode = alc260_modes,
5306 .input_mux = &alc260_capture_source,
5307 .unsol_event = alc260_hp_3012_unsol_event,
5308 .init_hook = alc260_hp_3012_automute,
5309 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005310 [ALC260_HP_3013] = {
5311 .mixers = { alc260_hp_3013_mixer,
5312 alc260_input_mixer,
5313 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005314 .init_verbs = { alc260_hp_3013_init_verbs,
5315 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005316 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5317 .dac_nids = alc260_dac_nids,
5318 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5319 .adc_nids = alc260_hp_adc_nids,
5320 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5321 .channel_mode = alc260_modes,
5322 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005323 .unsol_event = alc260_hp_3013_unsol_event,
5324 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005325 },
5326 [ALC260_FUJITSU_S702X] = {
5327 .mixers = { alc260_fujitsu_mixer,
5328 alc260_capture_mixer },
5329 .init_verbs = { alc260_fujitsu_init_verbs },
5330 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5331 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005332 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5333 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005334 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5335 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005336 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5337 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005338 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005339 [ALC260_ACER] = {
5340 .mixers = { alc260_acer_mixer,
5341 alc260_capture_mixer },
5342 .init_verbs = { alc260_acer_init_verbs },
5343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5344 .dac_nids = alc260_dac_nids,
5345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5346 .adc_nids = alc260_dual_adc_nids,
5347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5348 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005349 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5350 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005351 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005352 [ALC260_WILL] = {
5353 .mixers = { alc260_will_mixer,
5354 alc260_capture_mixer },
5355 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5356 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5357 .dac_nids = alc260_dac_nids,
5358 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5359 .adc_nids = alc260_adc_nids,
5360 .dig_out_nid = ALC260_DIGOUT_NID,
5361 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5362 .channel_mode = alc260_modes,
5363 .input_mux = &alc260_capture_source,
5364 },
5365 [ALC260_REPLACER_672V] = {
5366 .mixers = { alc260_replacer_672v_mixer,
5367 alc260_capture_mixer },
5368 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5369 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5370 .dac_nids = alc260_dac_nids,
5371 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5372 .adc_nids = alc260_adc_nids,
5373 .dig_out_nid = ALC260_DIGOUT_NID,
5374 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5375 .channel_mode = alc260_modes,
5376 .input_mux = &alc260_capture_source,
5377 .unsol_event = alc260_replacer_672v_unsol_event,
5378 .init_hook = alc260_replacer_672v_automute,
5379 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005380#ifdef CONFIG_SND_DEBUG
5381 [ALC260_TEST] = {
5382 .mixers = { alc260_test_mixer,
5383 alc260_capture_mixer },
5384 .init_verbs = { alc260_test_init_verbs },
5385 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5386 .dac_nids = alc260_test_dac_nids,
5387 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5388 .adc_nids = alc260_test_adc_nids,
5389 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5390 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005391 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5392 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005393 },
5394#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005395};
5396
Linus Torvalds1da177e2005-04-16 15:20:36 -07005397static int patch_alc260(struct hda_codec *codec)
5398{
5399 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005400 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005401
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005402 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005403 if (spec == NULL)
5404 return -ENOMEM;
5405
5406 codec->spec = spec;
5407
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005408 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5409 alc260_models,
5410 alc260_cfg_tbl);
5411 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005412 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5413 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005414 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005415 }
5416
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 if (board_config == ALC260_AUTO) {
5418 /* automatic parse from the BIOS config */
5419 err = alc260_parse_auto_config(codec);
5420 if (err < 0) {
5421 alc_free(codec);
5422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005423 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005424 printk(KERN_INFO
5425 "hda_codec: Cannot set up configuration "
5426 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005427 board_config = ALC260_BASIC;
5428 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005429 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005430
Kailang Yangdf694da2005-12-05 19:42:22 +01005431 if (board_config != ALC260_AUTO)
5432 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005433
5434 spec->stream_name_analog = "ALC260 Analog";
5435 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5436 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5437
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005438 spec->stream_name_digital = "ALC260 Digital";
5439 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5440 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5441
Takashi Iwai2134ea42008-01-10 16:53:55 +01005442 spec->vmaster_nid = 0x08;
5443
Linus Torvalds1da177e2005-04-16 15:20:36 -07005444 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005445 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005446 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005447#ifdef CONFIG_SND_HDA_POWER_SAVE
5448 if (!spec->loopback.amplist)
5449 spec->loopback.amplist = alc260_loopbacks;
5450#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005451
5452 return 0;
5453}
5454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005455
Linus Torvalds1da177e2005-04-16 15:20:36 -07005456/*
5457 * ALC882 support
5458 *
5459 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5460 * configuration. Each pin widget can choose any input DACs and a mixer.
5461 * Each ADC is connected from a mixer of all inputs. This makes possible
5462 * 6-channel independent captures.
5463 *
5464 * In addition, an independent DAC for the multi-playback (not used in this
5465 * driver yet).
5466 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005467#define ALC882_DIGOUT_NID 0x06
5468#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005469
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005470static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005471 { 8, NULL }
5472};
5473
5474static hda_nid_t alc882_dac_nids[4] = {
5475 /* front, rear, clfe, rear_surr */
5476 0x02, 0x03, 0x04, 0x05
5477};
5478
Kailang Yangdf694da2005-12-05 19:42:22 +01005479/* identical with ALC880 */
5480#define alc882_adc_nids alc880_adc_nids
5481#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005482
Takashi Iwaie1406342008-02-11 18:32:32 +01005483static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5484static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5485
Linus Torvalds1da177e2005-04-16 15:20:36 -07005486/* input MUX */
5487/* FIXME: should be a matrix-type input source selection */
5488
5489static struct hda_input_mux alc882_capture_source = {
5490 .num_items = 4,
5491 .items = {
5492 { "Mic", 0x0 },
5493 { "Front Mic", 0x1 },
5494 { "Line", 0x2 },
5495 { "CD", 0x4 },
5496 },
5497};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498#define alc882_mux_enum_info alc_mux_enum_info
5499#define alc882_mux_enum_get alc_mux_enum_get
5500
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005501static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5502 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503{
5504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5505 struct alc_spec *spec = codec->spec;
5506 const struct hda_input_mux *imux = spec->input_mux;
5507 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005508 hda_nid_t nid = spec->capsrc_nids ?
5509 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5511 unsigned int i, idx;
5512
5513 idx = ucontrol->value.enumerated.item[0];
5514 if (idx >= imux->num_items)
5515 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005516 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 return 0;
5518 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005519 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5520 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005521 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005522 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 }
5524 *cur_val = idx;
5525 return 1;
5526}
5527
Kailang Yangdf694da2005-12-05 19:42:22 +01005528/*
Kailang Yang272a5272007-05-14 11:00:38 +02005529 * 2ch mode
5530 */
5531static struct hda_verb alc882_3ST_ch2_init[] = {
5532 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5533 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5534 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5535 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5536 { } /* end */
5537};
5538
5539/*
5540 * 6ch mode
5541 */
5542static struct hda_verb alc882_3ST_ch6_init[] = {
5543 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5544 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5545 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5546 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5547 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5548 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5549 { } /* end */
5550};
5551
5552static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5553 { 2, alc882_3ST_ch2_init },
5554 { 6, alc882_3ST_ch6_init },
5555};
5556
5557/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 * 6ch mode
5559 */
5560static struct hda_verb alc882_sixstack_ch6_init[] = {
5561 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5562 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5563 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5564 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5565 { } /* end */
5566};
5567
5568/*
5569 * 8ch mode
5570 */
5571static struct hda_verb alc882_sixstack_ch8_init[] = {
5572 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5573 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5574 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5575 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5576 { } /* end */
5577};
5578
5579static struct hda_channel_mode alc882_sixstack_modes[2] = {
5580 { 6, alc882_sixstack_ch6_init },
5581 { 8, alc882_sixstack_ch8_init },
5582};
5583
Takashi Iwai87350ad2007-08-16 18:19:38 +02005584/*
5585 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5586 */
5587
5588/*
5589 * 2ch mode
5590 */
5591static struct hda_verb alc885_mbp_ch2_init[] = {
5592 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5593 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5594 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5595 { } /* end */
5596};
5597
5598/*
5599 * 6ch mode
5600 */
5601static struct hda_verb alc885_mbp_ch6_init[] = {
5602 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5603 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5604 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5605 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5606 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5607 { } /* end */
5608};
5609
5610static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5611 { 2, alc885_mbp_ch2_init },
5612 { 6, alc885_mbp_ch6_init },
5613};
5614
5615
Linus Torvalds1da177e2005-04-16 15:20:36 -07005616/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5617 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5618 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005619static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005620 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005621 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005622 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005623 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005624 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5625 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005626 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5627 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005628 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005629 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5631 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5632 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5633 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5634 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005639 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5641 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5642 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005643 { } /* end */
5644};
5645
Takashi Iwai87350ad2007-08-16 18:19:38 +02005646static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005647 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5648 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5649 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5650 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5651 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5652 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5654 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005655 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005656 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5657 { } /* end */
5658};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005659static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5661 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5667 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5669 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5670 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5671 { } /* end */
5672};
5673
Kailang Yang272a5272007-05-14 11:00:38 +02005674static struct snd_kcontrol_new alc882_targa_mixer[] = {
5675 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5676 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5680 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5681 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005685 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5686 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005687 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005688 { } /* end */
5689};
5690
5691/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5692 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5693 */
5694static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5696 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5698 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5699 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5700 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5701 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5702 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5703 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5704 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005708 { } /* end */
5709};
5710
Takashi Iwai914759b2007-09-06 14:52:04 +02005711static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5712 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5713 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5722 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5723 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5724 { } /* end */
5725};
5726
Kailang Yangdf694da2005-12-05 19:42:22 +01005727static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5728 {
5729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5730 .name = "Channel Mode",
5731 .info = alc_ch_mode_info,
5732 .get = alc_ch_mode_get,
5733 .put = alc_ch_mode_put,
5734 },
5735 { } /* end */
5736};
5737
Linus Torvalds1da177e2005-04-16 15:20:36 -07005738static struct hda_verb alc882_init_verbs[] = {
5739 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005743 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005747 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005751 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005755
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005756 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005759 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005760 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005763 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005764 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005765 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005767 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005768 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005769 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005770 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005771 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005772 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5775 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5778 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5781 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5783 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5784 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005785 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005786 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005787
5788 /* FIXME: use matrix-type input source selection */
5789 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5790 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005795 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005800 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5805 /* ADC1: mute amp left and right */
5806 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005807 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005808 /* ADC2: mute amp left and right */
5809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005810 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005811 /* ADC3: mute amp left and right */
5812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005813 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005814
5815 { }
5816};
5817
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005818static struct hda_verb alc882_eapd_verbs[] = {
5819 /* change to EAPD mode */
5820 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005821 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005822 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005823};
5824
Tobin Davis9102cd12006-12-15 10:02:12 +01005825/* Mac Pro test */
5826static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5832 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5833 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5834 { } /* end */
5835};
5836
5837static struct hda_verb alc882_macpro_init_verbs[] = {
5838 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5842 /* Front Pin: output 0 (0x0c) */
5843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5845 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5846 /* Front Mic pin: input vref at 80% */
5847 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5849 /* Speaker: output */
5850 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5852 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5853 /* Headphone output (output 0 - 0x0c) */
5854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5856 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5857
5858 /* FIXME: use matrix-type input source selection */
5859 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5860 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5865 /* Input mixer2 */
5866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5870 /* Input mixer3 */
5871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5875 /* ADC1: mute amp left and right */
5876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5877 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5878 /* ADC2: mute amp left and right */
5879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5880 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5881 /* ADC3: mute amp left and right */
5882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5883 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5884
5885 { }
5886};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005887
Takashi Iwai87350ad2007-08-16 18:19:38 +02005888/* Macbook Pro rev3 */
5889static struct hda_verb alc885_mbp3_init_verbs[] = {
5890 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5894 /* Rear mixer */
5895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5898 /* Front Pin: output 0 (0x0c) */
5899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5901 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5902 /* HP Pin: output 0 (0x0d) */
5903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5906 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5907 /* Mic (rear) pin: input vref at 80% */
5908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5910 /* Front Mic pin: input vref at 80% */
5911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5913 /* Line In pin: use output 1 when in LineOut mode */
5914 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5916 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5917
5918 /* FIXME: use matrix-type input source selection */
5919 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5920 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5925 /* Input mixer2 */
5926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5930 /* Input mixer3 */
5931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5935 /* ADC1: mute amp left and right */
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5937 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5938 /* ADC2: mute amp left and right */
5939 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5940 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5941 /* ADC3: mute amp left and right */
5942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5943 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5944
5945 { }
5946};
5947
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005948/* iMac 24 mixer. */
5949static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5950 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5951 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5952 { } /* end */
5953};
5954
5955/* iMac 24 init verbs. */
5956static struct hda_verb alc885_imac24_init_verbs[] = {
5957 /* Internal speakers: output 0 (0x0c) */
5958 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5959 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5960 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5961 /* Internal speakers: output 0 (0x0c) */
5962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5964 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5965 /* Headphone: output 0 (0x0c) */
5966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5968 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5969 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5970 /* Front Mic: input vref at 80% */
5971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5973 { }
5974};
5975
5976/* Toggle speaker-output according to the hp-jack state */
5977static void alc885_imac24_automute(struct hda_codec *codec)
5978{
5979 unsigned int present;
5980
5981 present = snd_hda_codec_read(codec, 0x14, 0,
5982 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005983 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5984 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5985 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005987}
5988
5989/* Processes unsolicited events. */
5990static void alc885_imac24_unsol_event(struct hda_codec *codec,
5991 unsigned int res)
5992{
5993 /* Headphone insertion or removal. */
5994 if ((res >> 26) == ALC880_HP_EVENT)
5995 alc885_imac24_automute(codec);
5996}
5997
Takashi Iwai87350ad2007-08-16 18:19:38 +02005998static void alc885_mbp3_automute(struct hda_codec *codec)
5999{
6000 unsigned int present;
6001
6002 present = snd_hda_codec_read(codec, 0x15, 0,
6003 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6004 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6005 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6006 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6007 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6008
6009}
6010static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6011 unsigned int res)
6012{
6013 /* Headphone insertion or removal. */
6014 if ((res >> 26) == ALC880_HP_EVENT)
6015 alc885_mbp3_automute(codec);
6016}
6017
6018
Kailang Yang272a5272007-05-14 11:00:38 +02006019static struct hda_verb alc882_targa_verbs[] = {
6020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6022
6023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006025
Kailang Yang272a5272007-05-14 11:00:38 +02006026 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6027 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6028 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6029
6030 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6031 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6032 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6033 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6034 { } /* end */
6035};
6036
6037/* toggle speaker-output according to the hp-jack state */
6038static void alc882_targa_automute(struct hda_codec *codec)
6039{
6040 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006041
Kailang Yang272a5272007-05-14 11:00:38 +02006042 present = snd_hda_codec_read(codec, 0x14, 0,
6043 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006044 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6045 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006046 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6047 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006048}
6049
6050static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6051{
6052 /* Looks like the unsol event is incompatible with the standard
6053 * definition. 4bit tag is placed at 26 bit!
6054 */
6055 if (((res >> 26) == ALC880_HP_EVENT)) {
6056 alc882_targa_automute(codec);
6057 }
6058}
6059
6060static struct hda_verb alc882_asus_a7j_verbs[] = {
6061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6063
6064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006067
Kailang Yang272a5272007-05-14 11:00:38 +02006068 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6070 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6071
6072 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6073 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6075 { } /* end */
6076};
6077
Takashi Iwai914759b2007-09-06 14:52:04 +02006078static struct hda_verb alc882_asus_a7m_verbs[] = {
6079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6081
6082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006085
Takashi Iwai914759b2007-09-06 14:52:04 +02006086 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6087 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6088 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6089
6090 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6091 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6092 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6093 { } /* end */
6094};
6095
Tobin Davis9102cd12006-12-15 10:02:12 +01006096static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6097{
6098 unsigned int gpiostate, gpiomask, gpiodir;
6099
6100 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6101 AC_VERB_GET_GPIO_DATA, 0);
6102
6103 if (!muted)
6104 gpiostate |= (1 << pin);
6105 else
6106 gpiostate &= ~(1 << pin);
6107
6108 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6109 AC_VERB_GET_GPIO_MASK, 0);
6110 gpiomask |= (1 << pin);
6111
6112 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6113 AC_VERB_GET_GPIO_DIRECTION, 0);
6114 gpiodir |= (1 << pin);
6115
6116
6117 snd_hda_codec_write(codec, codec->afg, 0,
6118 AC_VERB_SET_GPIO_MASK, gpiomask);
6119 snd_hda_codec_write(codec, codec->afg, 0,
6120 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6121
6122 msleep(1);
6123
6124 snd_hda_codec_write(codec, codec->afg, 0,
6125 AC_VERB_SET_GPIO_DATA, gpiostate);
6126}
6127
Takashi Iwai7debbe52007-08-16 15:01:03 +02006128/* set up GPIO at initialization */
6129static void alc885_macpro_init_hook(struct hda_codec *codec)
6130{
6131 alc882_gpio_mute(codec, 0, 0);
6132 alc882_gpio_mute(codec, 1, 0);
6133}
6134
6135/* set up GPIO and update auto-muting at initialization */
6136static void alc885_imac24_init_hook(struct hda_codec *codec)
6137{
6138 alc885_macpro_init_hook(codec);
6139 alc885_imac24_automute(codec);
6140}
6141
Kailang Yangdf694da2005-12-05 19:42:22 +01006142/*
6143 * generic initialization of ADC, input mixers and output mixers
6144 */
6145static struct hda_verb alc882_auto_init_verbs[] = {
6146 /*
6147 * Unmute ADC0-2 and set the default input to mic-in
6148 */
6149 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6151 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6152 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6153 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6155
Takashi Iwaicb53c622007-08-10 17:21:45 +02006156 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006157 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006158 * Note: PASD motherboards uses the Line In 2 as the input for
6159 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006160 */
6161 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006167
6168 /*
6169 * Set up output mixers (0x0c - 0x0f)
6170 */
6171 /* set vol=0 to output mixers */
6172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6173 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6174 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6176 /* set up input amps for analog loopback */
6177 /* Amp Indices: DAC = 0, mixer = 1 */
6178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6186 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6187 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6188
6189 /* FIXME: use matrix-type input source selection */
6190 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6191 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6196 /* Input mixer2 */
6197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6199 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6200 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6201 /* Input mixer3 */
6202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6206
6207 { }
6208};
6209
6210/* capture mixer elements */
6211static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6212 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6213 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6214 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6215 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6216 {
6217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6218 /* The multiple "Capture Source" controls confuse alsamixer
6219 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006220 */
6221 /* .name = "Capture Source", */
6222 .name = "Input Source",
6223 .count = 2,
6224 .info = alc882_mux_enum_info,
6225 .get = alc882_mux_enum_get,
6226 .put = alc882_mux_enum_put,
6227 },
6228 { } /* end */
6229};
6230
6231static struct snd_kcontrol_new alc882_capture_mixer[] = {
6232 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6233 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6236 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6237 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6238 {
6239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6240 /* The multiple "Capture Source" controls confuse alsamixer
6241 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006242 */
6243 /* .name = "Capture Source", */
6244 .name = "Input Source",
6245 .count = 3,
6246 .info = alc882_mux_enum_info,
6247 .get = alc882_mux_enum_get,
6248 .put = alc882_mux_enum_put,
6249 },
6250 { } /* end */
6251};
6252
Takashi Iwaicb53c622007-08-10 17:21:45 +02006253#ifdef CONFIG_SND_HDA_POWER_SAVE
6254#define alc882_loopbacks alc880_loopbacks
6255#endif
6256
Kailang Yangdf694da2005-12-05 19:42:22 +01006257/* pcm configuration: identiacal with ALC880 */
6258#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6259#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6260#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6261#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6262
6263/*
6264 * configuration and preset
6265 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006266static const char *alc882_models[ALC882_MODEL_LAST] = {
6267 [ALC882_3ST_DIG] = "3stack-dig",
6268 [ALC882_6ST_DIG] = "6stack-dig",
6269 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006270 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006271 [ALC882_TARGA] = "targa",
6272 [ALC882_ASUS_A7J] = "asus-a7j",
6273 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006274 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006275 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006276 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006277 [ALC882_AUTO] = "auto",
6278};
6279
6280static struct snd_pci_quirk alc882_cfg_tbl[] = {
6281 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006282 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006283 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006284 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006285 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006286 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006287 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006288 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006289 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006290 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6291 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6292 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006293 {}
6294};
6295
6296static struct alc_config_preset alc882_presets[] = {
6297 [ALC882_3ST_DIG] = {
6298 .mixers = { alc882_base_mixer },
6299 .init_verbs = { alc882_init_verbs },
6300 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6301 .dac_nids = alc882_dac_nids,
6302 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006303 .dig_in_nid = ALC882_DIGIN_NID,
6304 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6305 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006306 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006307 .input_mux = &alc882_capture_source,
6308 },
6309 [ALC882_6ST_DIG] = {
6310 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6311 .init_verbs = { alc882_init_verbs },
6312 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6313 .dac_nids = alc882_dac_nids,
6314 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006315 .dig_in_nid = ALC882_DIGIN_NID,
6316 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6317 .channel_mode = alc882_sixstack_modes,
6318 .input_mux = &alc882_capture_source,
6319 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006320 [ALC882_ARIMA] = {
6321 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6322 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6323 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6324 .dac_nids = alc882_dac_nids,
6325 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6326 .channel_mode = alc882_sixstack_modes,
6327 .input_mux = &alc882_capture_source,
6328 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006329 [ALC882_W2JC] = {
6330 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6331 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6332 alc880_gpio1_init_verbs },
6333 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6334 .dac_nids = alc882_dac_nids,
6335 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6336 .channel_mode = alc880_threestack_modes,
6337 .need_dac_fix = 1,
6338 .input_mux = &alc882_capture_source,
6339 .dig_out_nid = ALC882_DIGOUT_NID,
6340 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006341 [ALC885_MBP3] = {
6342 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6343 .init_verbs = { alc885_mbp3_init_verbs,
6344 alc880_gpio1_init_verbs },
6345 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6346 .dac_nids = alc882_dac_nids,
6347 .channel_mode = alc885_mbp_6ch_modes,
6348 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6349 .input_mux = &alc882_capture_source,
6350 .dig_out_nid = ALC882_DIGOUT_NID,
6351 .dig_in_nid = ALC882_DIGIN_NID,
6352 .unsol_event = alc885_mbp3_unsol_event,
6353 .init_hook = alc885_mbp3_automute,
6354 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006355 [ALC885_MACPRO] = {
6356 .mixers = { alc882_macpro_mixer },
6357 .init_verbs = { alc882_macpro_init_verbs },
6358 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6359 .dac_nids = alc882_dac_nids,
6360 .dig_out_nid = ALC882_DIGOUT_NID,
6361 .dig_in_nid = ALC882_DIGIN_NID,
6362 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6363 .channel_mode = alc882_ch_modes,
6364 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006365 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006366 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006367 [ALC885_IMAC24] = {
6368 .mixers = { alc885_imac24_mixer },
6369 .init_verbs = { alc885_imac24_init_verbs },
6370 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6371 .dac_nids = alc882_dac_nids,
6372 .dig_out_nid = ALC882_DIGOUT_NID,
6373 .dig_in_nid = ALC882_DIGIN_NID,
6374 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6375 .channel_mode = alc882_ch_modes,
6376 .input_mux = &alc882_capture_source,
6377 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006378 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006379 },
Kailang Yang272a5272007-05-14 11:00:38 +02006380 [ALC882_TARGA] = {
6381 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6382 alc882_capture_mixer },
6383 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6384 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6385 .dac_nids = alc882_dac_nids,
6386 .dig_out_nid = ALC882_DIGOUT_NID,
6387 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6388 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006389 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006390 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6391 .channel_mode = alc882_3ST_6ch_modes,
6392 .need_dac_fix = 1,
6393 .input_mux = &alc882_capture_source,
6394 .unsol_event = alc882_targa_unsol_event,
6395 .init_hook = alc882_targa_automute,
6396 },
6397 [ALC882_ASUS_A7J] = {
6398 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6399 alc882_capture_mixer },
6400 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6401 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6402 .dac_nids = alc882_dac_nids,
6403 .dig_out_nid = ALC882_DIGOUT_NID,
6404 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6405 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006406 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006407 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6408 .channel_mode = alc882_3ST_6ch_modes,
6409 .need_dac_fix = 1,
6410 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006411 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006412 [ALC882_ASUS_A7M] = {
6413 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6414 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6415 alc880_gpio1_init_verbs,
6416 alc882_asus_a7m_verbs },
6417 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6418 .dac_nids = alc882_dac_nids,
6419 .dig_out_nid = ALC882_DIGOUT_NID,
6420 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6421 .channel_mode = alc880_threestack_modes,
6422 .need_dac_fix = 1,
6423 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006424 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006425};
6426
6427
6428/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006429 * Pin config fixes
6430 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006431enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006432 PINFIX_ABIT_AW9D_MAX
6433};
6434
6435static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6436 { 0x15, 0x01080104 }, /* side */
6437 { 0x16, 0x01011012 }, /* rear */
6438 { 0x17, 0x01016011 }, /* clfe */
6439 { }
6440};
6441
6442static const struct alc_pincfg *alc882_pin_fixes[] = {
6443 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6444};
6445
6446static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6447 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6448 {}
6449};
6450
6451/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006452 * BIOS auto configuration
6453 */
6454static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6455 hda_nid_t nid, int pin_type,
6456 int dac_idx)
6457{
6458 /* set as output */
6459 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006460 int idx;
6461
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006462 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006463 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6464 idx = 4;
6465 else
6466 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006467 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6468
6469}
6470
6471static void alc882_auto_init_multi_out(struct hda_codec *codec)
6472{
6473 struct alc_spec *spec = codec->spec;
6474 int i;
6475
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006476 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006477 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006478 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006479 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006480 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006481 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006482 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006483 }
6484}
6485
6486static void alc882_auto_init_hp_out(struct hda_codec *codec)
6487{
6488 struct alc_spec *spec = codec->spec;
6489 hda_nid_t pin;
6490
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006491 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006492 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006493 /* use dac 0 */
6494 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006495 pin = spec->autocfg.speaker_pins[0];
6496 if (pin)
6497 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006498}
6499
6500#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6501#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6502
6503static void alc882_auto_init_analog_input(struct hda_codec *codec)
6504{
6505 struct alc_spec *spec = codec->spec;
6506 int i;
6507
6508 for (i = 0; i < AUTO_PIN_LAST; i++) {
6509 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006510 unsigned int vref;
6511 if (!nid)
6512 continue;
6513 vref = PIN_IN;
6514 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006515 unsigned int pincap;
6516 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6517 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006518 AC_PINCAP_VREF_80)
6519 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006520 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006521 snd_hda_codec_write(codec, nid, 0,
6522 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6523 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6524 snd_hda_codec_write(codec, nid, 0,
6525 AC_VERB_SET_AMP_GAIN_MUTE,
6526 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006527 }
6528}
6529
Takashi Iwaif511b012008-08-15 16:46:42 +02006530static void alc882_auto_init_input_src(struct hda_codec *codec)
6531{
6532 struct alc_spec *spec = codec->spec;
6533 const struct hda_input_mux *imux = spec->input_mux;
6534 int c;
6535
6536 for (c = 0; c < spec->num_adc_nids; c++) {
6537 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6538 hda_nid_t nid = spec->capsrc_nids[c];
6539 int conns, mute, idx, item;
6540
6541 conns = snd_hda_get_connections(codec, nid, conn_list,
6542 ARRAY_SIZE(conn_list));
6543 if (conns < 0)
6544 continue;
6545 for (idx = 0; idx < conns; idx++) {
6546 /* if the current connection is the selected one,
6547 * unmute it as default - otherwise mute it
6548 */
6549 mute = AMP_IN_MUTE(idx);
6550 for (item = 0; item < imux->num_items; item++) {
6551 if (imux->items[item].index == idx) {
6552 if (spec->cur_mux[c] == item)
6553 mute = AMP_IN_UNMUTE(idx);
6554 break;
6555 }
6556 }
6557 snd_hda_codec_write(codec, nid, 0,
6558 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6559 }
6560 }
6561}
6562
Takashi Iwai776e1842007-08-29 15:07:11 +02006563/* add mic boosts if needed */
6564static int alc_auto_add_mic_boost(struct hda_codec *codec)
6565{
6566 struct alc_spec *spec = codec->spec;
6567 int err;
6568 hda_nid_t nid;
6569
6570 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006571 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006572 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6573 "Mic Boost",
6574 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6575 if (err < 0)
6576 return err;
6577 }
6578 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006579 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006580 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6581 "Front Mic Boost",
6582 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6583 if (err < 0)
6584 return err;
6585 }
6586 return 0;
6587}
6588
Kailang Yangdf694da2005-12-05 19:42:22 +01006589/* almost identical with ALC880 parser... */
6590static int alc882_parse_auto_config(struct hda_codec *codec)
6591{
6592 struct alc_spec *spec = codec->spec;
6593 int err = alc880_parse_auto_config(codec);
6594
6595 if (err < 0)
6596 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006597 else if (!err)
6598 return 0; /* no config found */
6599
6600 err = alc_auto_add_mic_boost(codec);
6601 if (err < 0)
6602 return err;
6603
6604 /* hack - override the init verbs */
6605 spec->init_verbs[0] = alc882_auto_init_verbs;
6606
6607 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006608}
6609
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006610/* additional initialization for auto-configuration model */
6611static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006612{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006613 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006614 alc882_auto_init_multi_out(codec);
6615 alc882_auto_init_hp_out(codec);
6616 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006617 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006618 if (spec->unsol_event)
6619 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006620}
6621
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006622static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6623
Linus Torvalds1da177e2005-04-16 15:20:36 -07006624static int patch_alc882(struct hda_codec *codec)
6625{
6626 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006627 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006628
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006629 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006630 if (spec == NULL)
6631 return -ENOMEM;
6632
Linus Torvalds1da177e2005-04-16 15:20:36 -07006633 codec->spec = spec;
6634
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006635 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6636 alc882_models,
6637 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006638
Kailang Yangdf694da2005-12-05 19:42:22 +01006639 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006640 /* Pick up systems that don't supply PCI SSID */
6641 switch (codec->subsystem_id) {
6642 case 0x106b0c00: /* Mac Pro */
6643 board_config = ALC885_MACPRO;
6644 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006645 case 0x106b1000: /* iMac 24 */
6646 board_config = ALC885_IMAC24;
6647 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006648 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006649 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006650 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006651 board_config = ALC885_MBP3;
6652 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006653 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006654 /* ALC889A is handled better as ALC888-compatible */
6655 if (codec->revision_id == 0x100103) {
6656 alc_free(codec);
6657 return patch_alc883(codec);
6658 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006659 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6660 "trying auto-probe from BIOS...\n");
6661 board_config = ALC882_AUTO;
6662 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006663 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006664
Takashi Iwaif95474e2007-07-10 00:47:43 +02006665 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6666
Kailang Yangdf694da2005-12-05 19:42:22 +01006667 if (board_config == ALC882_AUTO) {
6668 /* automatic parse from the BIOS config */
6669 err = alc882_parse_auto_config(codec);
6670 if (err < 0) {
6671 alc_free(codec);
6672 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006673 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006674 printk(KERN_INFO
6675 "hda_codec: Cannot set up configuration "
6676 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 board_config = ALC882_3ST_DIG;
6678 }
6679 }
6680
6681 if (board_config != ALC882_AUTO)
6682 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006683
Kailang Yang2f893282008-05-27 12:14:47 +02006684 if (codec->vendor_id == 0x10ec0885) {
6685 spec->stream_name_analog = "ALC885 Analog";
6686 spec->stream_name_digital = "ALC885 Digital";
6687 } else {
6688 spec->stream_name_analog = "ALC882 Analog";
6689 spec->stream_name_digital = "ALC882 Digital";
6690 }
6691
Kailang Yangdf694da2005-12-05 19:42:22 +01006692 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6693 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006694 /* FIXME: setup DAC5 */
6695 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6696 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006697
Kailang Yangdf694da2005-12-05 19:42:22 +01006698 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6699 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006701 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006702 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006703 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006704 /* get type */
6705 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006706 if (wcap != AC_WID_AUD_IN) {
6707 spec->adc_nids = alc882_adc_nids_alt;
6708 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006709 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006710 spec->mixers[spec->num_mixers] =
6711 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006712 spec->num_mixers++;
6713 } else {
6714 spec->adc_nids = alc882_adc_nids;
6715 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006716 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006717 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6718 spec->num_mixers++;
6719 }
6720 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006721
Takashi Iwai2134ea42008-01-10 16:53:55 +01006722 spec->vmaster_nid = 0x0c;
6723
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006725 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006726 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006727#ifdef CONFIG_SND_HDA_POWER_SAVE
6728 if (!spec->loopback.amplist)
6729 spec->loopback.amplist = alc882_loopbacks;
6730#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006731
6732 return 0;
6733}
6734
6735/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006736 * ALC883 support
6737 *
6738 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6739 * configuration. Each pin widget can choose any input DACs and a mixer.
6740 * Each ADC is connected from a mixer of all inputs. This makes possible
6741 * 6-channel independent captures.
6742 *
6743 * In addition, an independent DAC for the multi-playback (not used in this
6744 * driver yet).
6745 */
6746#define ALC883_DIGOUT_NID 0x06
6747#define ALC883_DIGIN_NID 0x0a
6748
6749static hda_nid_t alc883_dac_nids[4] = {
6750 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006751 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006752};
6753
6754static hda_nid_t alc883_adc_nids[2] = {
6755 /* ADC1-2 */
6756 0x08, 0x09,
6757};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006758
Takashi Iwaie1406342008-02-11 18:32:32 +01006759static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6760
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006761/* input MUX */
6762/* FIXME: should be a matrix-type input source selection */
6763
6764static struct hda_input_mux alc883_capture_source = {
6765 .num_items = 4,
6766 .items = {
6767 { "Mic", 0x0 },
6768 { "Front Mic", 0x1 },
6769 { "Line", 0x2 },
6770 { "CD", 0x4 },
6771 },
6772};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006773
Jiang zhe17bba1b2008-06-04 12:11:07 +02006774static struct hda_input_mux alc883_3stack_6ch_intel = {
6775 .num_items = 4,
6776 .items = {
6777 { "Mic", 0x1 },
6778 { "Front Mic", 0x0 },
6779 { "Line", 0x2 },
6780 { "CD", 0x4 },
6781 },
6782};
6783
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006784static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6785 .num_items = 2,
6786 .items = {
6787 { "Mic", 0x1 },
6788 { "Line", 0x2 },
6789 },
6790};
6791
Kailang Yang272a5272007-05-14 11:00:38 +02006792static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6793 .num_items = 4,
6794 .items = {
6795 { "Mic", 0x0 },
6796 { "iMic", 0x1 },
6797 { "Line", 0x2 },
6798 { "CD", 0x4 },
6799 },
6800};
6801
Jiang zhefb97dc62008-03-06 11:07:11 +01006802static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6803 .num_items = 2,
6804 .items = {
6805 { "Mic", 0x0 },
6806 { "Int Mic", 0x1 },
6807 },
6808};
6809
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006810#define alc883_mux_enum_info alc_mux_enum_info
6811#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006812/* ALC883 has the ALC882-type input selection */
6813#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006814
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006815/*
6816 * 2ch mode
6817 */
6818static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6819 { 2, NULL }
6820};
6821
6822/*
6823 * 2ch mode
6824 */
6825static struct hda_verb alc883_3ST_ch2_init[] = {
6826 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6827 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6830 { } /* end */
6831};
6832
6833/*
Tobin Davisb2011312007-09-17 12:45:11 +02006834 * 4ch mode
6835 */
6836static struct hda_verb alc883_3ST_ch4_init[] = {
6837 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6838 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6841 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6842 { } /* end */
6843};
6844
6845/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006846 * 6ch mode
6847 */
6848static struct hda_verb alc883_3ST_ch6_init[] = {
6849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6851 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6855 { } /* end */
6856};
6857
Tobin Davisb2011312007-09-17 12:45:11 +02006858static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006859 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006860 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006861 { 6, alc883_3ST_ch6_init },
6862};
6863
6864/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006865 * 2ch mode
6866 */
6867static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6868 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6869 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6872 { } /* end */
6873};
6874
6875/*
6876 * 4ch mode
6877 */
6878static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6879 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6880 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6881 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6882 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6883 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6884 { } /* end */
6885};
6886
6887/*
6888 * 6ch mode
6889 */
6890static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6891 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6892 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6893 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6896 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6897 { } /* end */
6898};
6899
6900static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6901 { 2, alc883_3ST_ch2_intel_init },
6902 { 4, alc883_3ST_ch4_intel_init },
6903 { 6, alc883_3ST_ch6_intel_init },
6904};
6905
6906/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006907 * 6ch mode
6908 */
6909static struct hda_verb alc883_sixstack_ch6_init[] = {
6910 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6911 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6913 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6914 { } /* end */
6915};
6916
6917/*
6918 * 8ch mode
6919 */
6920static struct hda_verb alc883_sixstack_ch8_init[] = {
6921 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6922 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6923 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6924 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6925 { } /* end */
6926};
6927
6928static struct hda_channel_mode alc883_sixstack_modes[2] = {
6929 { 6, alc883_sixstack_ch6_init },
6930 { 8, alc883_sixstack_ch8_init },
6931};
6932
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006933static struct hda_verb alc883_medion_eapd_verbs[] = {
6934 /* eanable EAPD on medion laptop */
6935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6936 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6937 { }
6938};
6939
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006940/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6941 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6942 */
6943
6944static struct snd_kcontrol_new alc883_base_mixer[] = {
6945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6946 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6948 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6949 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6950 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6951 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6952 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6953 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6954 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006964 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006965 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6966 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6967 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6969 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6970 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6971 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6972 {
6973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6974 /* .name = "Capture Source", */
6975 .name = "Input Source",
6976 .count = 2,
6977 .info = alc883_mux_enum_info,
6978 .get = alc883_mux_enum_get,
6979 .put = alc883_mux_enum_put,
6980 },
6981 { } /* end */
6982};
6983
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006984static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6986 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7000 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7001 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7002 {
7003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7004 /* .name = "Capture Source", */
7005 .name = "Input Source",
7006 .count = 2,
7007 .info = alc883_mux_enum_info,
7008 .get = alc883_mux_enum_get,
7009 .put = alc883_mux_enum_put,
7010 },
7011 { } /* end */
7012};
7013
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007014static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007015 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7018 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7024 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7026 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7027 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7028 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7029 {
7030 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7031 /* .name = "Capture Source", */
7032 .name = "Input Source",
7033 .count = 2,
7034 .info = alc883_mux_enum_info,
7035 .get = alc883_mux_enum_get,
7036 .put = alc883_mux_enum_put,
7037 },
7038 { } /* end */
7039};
7040
Jiang zhefb97dc62008-03-06 11:07:11 +01007041static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7042 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7043 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7045 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7051 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7053 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7054 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7055 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7056 {
7057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7058 /* .name = "Capture Source", */
7059 .name = "Input Source",
7060 .count = 2,
7061 .info = alc883_mux_enum_info,
7062 .get = alc883_mux_enum_get,
7063 .put = alc883_mux_enum_put,
7064 },
7065 { } /* end */
7066};
7067
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007068static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7069 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7070 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7072 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007080 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007081 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7084 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7085 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7086 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7087 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7088 {
7089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7090 /* .name = "Capture Source", */
7091 .name = "Input Source",
7092 .count = 2,
7093 .info = alc883_mux_enum_info,
7094 .get = alc883_mux_enum_get,
7095 .put = alc883_mux_enum_put,
7096 },
7097 { } /* end */
7098};
7099
7100static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7102 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7104 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7107 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7108 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7110 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7111 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007118 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007119 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7120 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7121 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7122 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7123 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7124 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7125 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7126 {
7127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7128 /* .name = "Capture Source", */
7129 .name = "Input Source",
7130 .count = 2,
7131 .info = alc883_mux_enum_info,
7132 .get = alc883_mux_enum_get,
7133 .put = alc883_mux_enum_put,
7134 },
7135 { } /* end */
7136};
7137
Jiang zhe17bba1b2008-06-04 12:11:07 +02007138static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7142 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7143 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7144 HDA_OUTPUT),
7145 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7146 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7147 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7151 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7152 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7154 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7156 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7157 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7159 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7160 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7162 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7163 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7164 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7165 {
7166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7167 /* .name = "Capture Source", */
7168 .name = "Input Source",
7169 .count = 2,
7170 .info = alc883_mux_enum_info,
7171 .get = alc883_mux_enum_get,
7172 .put = alc883_mux_enum_put,
7173 },
7174 { } /* end */
7175};
7176
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007177static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007178 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007179 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007180 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007181 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007182 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7190 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007192 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007195 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007196 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7197 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7198 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7199 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7200 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7201
7202 {
7203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7204 /* .name = "Capture Source", */
7205 .name = "Input Source",
7206 .count = 1,
7207 .info = alc883_mux_enum_info,
7208 .get = alc883_mux_enum_get,
7209 .put = alc883_mux_enum_put,
7210 },
7211 { } /* end */
7212};
7213
Kailang Yangccc656c2006-10-17 12:32:26 +02007214static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7217 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7218 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7219 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7220 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7221 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7222 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7223 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7231 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7232 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7233 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7234 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7235 {
7236 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7237 /* .name = "Capture Source", */
7238 .name = "Input Source",
7239 .count = 2,
7240 .info = alc883_mux_enum_info,
7241 .get = alc883_mux_enum_get,
7242 .put = alc883_mux_enum_put,
7243 },
7244 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007245};
Kailang Yangccc656c2006-10-17 12:32:26 +02007246
7247static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7250 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007256 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7257 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7258 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007259 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7260 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7261 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7262 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7263 {
7264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7265 /* .name = "Capture Source", */
7266 .name = "Input Source",
7267 .count = 2,
7268 .info = alc883_mux_enum_info,
7269 .get = alc883_mux_enum_get,
7270 .put = alc883_mux_enum_put,
7271 },
7272 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007273};
Kailang Yangccc656c2006-10-17 12:32:26 +02007274
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007275static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7277 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007278 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7279 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7285 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7286 {
7287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7288 /* .name = "Capture Source", */
7289 .name = "Input Source",
7290 .count = 1,
7291 .info = alc883_mux_enum_info,
7292 .get = alc883_mux_enum_get,
7293 .put = alc883_mux_enum_put,
7294 },
7295 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007296};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007297
Kailang Yang272a5272007-05-14 11:00:38 +02007298static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7299 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7300 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7301 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7302 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7303 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7305 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7306 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7307 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7308 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7309 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7311 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7312 {
7313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7314 /* .name = "Capture Source", */
7315 .name = "Input Source",
7316 .count = 2,
7317 .info = alc883_mux_enum_info,
7318 .get = alc883_mux_enum_get,
7319 .put = alc883_mux_enum_put,
7320 },
7321 { } /* end */
7322};
7323
7324static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7328 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7329 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7334 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7335 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7336 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7337 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7338 {
7339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7340 /* .name = "Capture Source", */
7341 .name = "Input Source",
7342 .count = 2,
7343 .info = alc883_mux_enum_info,
7344 .get = alc883_mux_enum_get,
7345 .put = alc883_mux_enum_put,
7346 },
7347 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007348};
Kailang Yang272a5272007-05-14 11:00:38 +02007349
Tobin Davis2880a862007-08-07 11:50:26 +02007350static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007351 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7352 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7355 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007359 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7360 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7361 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7362 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7363 {
7364 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7365 /* .name = "Capture Source", */
7366 .name = "Input Source",
7367 .count = 2,
7368 .info = alc883_mux_enum_info,
7369 .get = alc883_mux_enum_get,
7370 .put = alc883_mux_enum_put,
7371 },
7372 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007373};
Tobin Davis2880a862007-08-07 11:50:26 +02007374
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007375static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7376 {
7377 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7378 .name = "Channel Mode",
7379 .info = alc_ch_mode_info,
7380 .get = alc_ch_mode_get,
7381 .put = alc_ch_mode_put,
7382 },
7383 { } /* end */
7384};
7385
7386static struct hda_verb alc883_init_verbs[] = {
7387 /* ADC1: mute amp left and right */
7388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7390 /* ADC2: mute amp left and right */
7391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7392 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7393 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7397 /* Rear mixer */
7398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7401 /* CLFE mixer */
7402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7405 /* Side mixer */
7406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7409
Takashi Iwaicb53c622007-08-10 17:21:45 +02007410 /* mute analog input loopbacks */
7411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007416
7417 /* Front Pin: output 0 (0x0c) */
7418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7420 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7421 /* Rear Pin: output 1 (0x0d) */
7422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7425 /* CLFE Pin: output 2 (0x0e) */
7426 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7428 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7429 /* Side Pin: output 3 (0x0f) */
7430 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7432 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7433 /* Mic (rear) pin: input vref at 80% */
7434 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7436 /* Front Mic pin: input vref at 80% */
7437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7439 /* Line In pin: input */
7440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7442 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7445 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7446 /* CD pin widget for input */
7447 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7448
7449 /* FIXME: use matrix-type input source selection */
7450 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7451 /* Input mixer2 */
7452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7456 /* Input mixer3 */
7457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7461 { }
7462};
7463
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007464/* toggle speaker-output according to the hp-jack state */
7465static void alc883_mitac_hp_automute(struct hda_codec *codec)
7466{
7467 unsigned int present;
7468
7469 present = snd_hda_codec_read(codec, 0x15, 0,
7470 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7471 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7472 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7473 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7474 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7475}
7476
7477/* auto-toggle front mic */
7478/*
7479static void alc883_mitac_mic_automute(struct hda_codec *codec)
7480{
7481 unsigned int present;
7482 unsigned char bits;
7483
7484 present = snd_hda_codec_read(codec, 0x18, 0,
7485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7486 bits = present ? HDA_AMP_MUTE : 0;
7487 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7488}
7489*/
7490
7491static void alc883_mitac_automute(struct hda_codec *codec)
7492{
7493 alc883_mitac_hp_automute(codec);
7494 /* alc883_mitac_mic_automute(codec); */
7495}
7496
7497static void alc883_mitac_unsol_event(struct hda_codec *codec,
7498 unsigned int res)
7499{
7500 switch (res >> 26) {
7501 case ALC880_HP_EVENT:
7502 alc883_mitac_hp_automute(codec);
7503 break;
7504 case ALC880_MIC_EVENT:
7505 /* alc883_mitac_mic_automute(codec); */
7506 break;
7507 }
7508}
7509
7510static struct hda_verb alc883_mitac_verbs[] = {
7511 /* HP */
7512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7514 /* Subwoofer */
7515 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7517
7518 /* enable unsolicited event */
7519 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7520 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7521
7522 { } /* end */
7523};
7524
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007525static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007526 /* HP */
7527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7529 /* Int speaker */
7530 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7532
7533 /* enable unsolicited event */
7534 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007535 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007536
7537 { } /* end */
7538};
7539
Jiang zhefb97dc62008-03-06 11:07:11 +01007540static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7541 /* HP */
7542 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7544 /* Subwoofer */
7545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7547
7548 /* enable unsolicited event */
7549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7550
7551 { } /* end */
7552};
7553
Kailang Yangccc656c2006-10-17 12:32:26 +02007554static struct hda_verb alc883_tagra_verbs[] = {
7555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7557
7558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007560
Kailang Yangccc656c2006-10-17 12:32:26 +02007561 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7563 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7564
7565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007566 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7567 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7568 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007569
7570 { } /* end */
7571};
7572
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007573static struct hda_verb alc883_lenovo_101e_verbs[] = {
7574 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7575 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7576 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7577 { } /* end */
7578};
7579
Kailang Yang272a5272007-05-14 11:00:38 +02007580static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7583 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7585 { } /* end */
7586};
7587
7588static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7592 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7593 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7594 { } /* end */
7595};
7596
Kailang Yang189609a2007-08-20 11:31:23 +02007597static struct hda_verb alc883_haier_w66_verbs[] = {
7598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7599 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7600
7601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7602
7603 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7605 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7606 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7607 { } /* end */
7608};
7609
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007610static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007612 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7613 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007614 { }
7615};
7616
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007617static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007618 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7619 { }
7620};
7621
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007622static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007623 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7624 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7625 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7626 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7627 { }
7628};
7629
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007630static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7633 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7635 { }
7636};
7637
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007638static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7639 { 2, alc888_3st_hp_2ch_init },
7640 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007641};
7642
Kailang Yang272a5272007-05-14 11:00:38 +02007643/* toggle front-jack and RCA according to the hp-jack state */
7644static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7645{
7646 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007647
Kailang Yang272a5272007-05-14 11:00:38 +02007648 present = snd_hda_codec_read(codec, 0x1b, 0,
7649 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007650 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7651 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7652 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7653 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007654}
7655
7656/* toggle RCA according to the front-jack state */
7657static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7658{
7659 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007660
Kailang Yang272a5272007-05-14 11:00:38 +02007661 present = snd_hda_codec_read(codec, 0x14, 0,
7662 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007663 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7664 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007665}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007666
Kailang Yang272a5272007-05-14 11:00:38 +02007667static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7668 unsigned int res)
7669{
7670 if ((res >> 26) == ALC880_HP_EVENT)
7671 alc888_lenovo_ms7195_front_automute(codec);
7672 if ((res >> 26) == ALC880_FRONT_EVENT)
7673 alc888_lenovo_ms7195_rca_automute(codec);
7674}
7675
7676static struct hda_verb alc883_medion_md2_verbs[] = {
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7679
7680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7681
7682 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7683 { } /* end */
7684};
7685
7686/* toggle speaker-output according to the hp-jack state */
7687static void alc883_medion_md2_automute(struct hda_codec *codec)
7688{
7689 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007690
Kailang Yang272a5272007-05-14 11:00:38 +02007691 present = snd_hda_codec_read(codec, 0x14, 0,
7692 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007693 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7694 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007695}
7696
7697static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7698 unsigned int res)
7699{
7700 if ((res >> 26) == ALC880_HP_EVENT)
7701 alc883_medion_md2_automute(codec);
7702}
7703
Kailang Yangccc656c2006-10-17 12:32:26 +02007704/* toggle speaker-output according to the hp-jack state */
7705static void alc883_tagra_automute(struct hda_codec *codec)
7706{
7707 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007708 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007709
7710 present = snd_hda_codec_read(codec, 0x14, 0,
7711 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007712 bits = present ? HDA_AMP_MUTE : 0;
7713 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7714 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007715 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7716 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007717}
7718
7719static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7720{
7721 if ((res >> 26) == ALC880_HP_EVENT)
7722 alc883_tagra_automute(codec);
7723}
7724
Jiang zhe368c7a92008-03-04 11:20:33 +01007725/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007726static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007727{
7728 unsigned int present;
7729 unsigned char bits;
7730
7731 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7732 & AC_PINSENSE_PRESENCE;
7733 bits = present ? HDA_AMP_MUTE : 0;
7734 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7735 HDA_AMP_MUTE, bits);
7736}
7737
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007738static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7739{
7740 unsigned int present;
7741
7742 present = snd_hda_codec_read(codec, 0x18, 0,
7743 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7744 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7745 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7746}
7747
7748static void alc883_clevo_m720_automute(struct hda_codec *codec)
7749{
7750 alc883_clevo_m720_hp_automute(codec);
7751 alc883_clevo_m720_mic_automute(codec);
7752}
7753
7754static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007755 unsigned int res)
7756{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007757 switch (res >> 26) {
7758 case ALC880_HP_EVENT:
7759 alc883_clevo_m720_hp_automute(codec);
7760 break;
7761 case ALC880_MIC_EVENT:
7762 alc883_clevo_m720_mic_automute(codec);
7763 break;
7764 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007765}
7766
Jiang zhefb97dc62008-03-06 11:07:11 +01007767/* toggle speaker-output according to the hp-jack state */
7768static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7769{
7770 unsigned int present;
7771 unsigned char bits;
7772
7773 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7774 & AC_PINSENSE_PRESENCE;
7775 bits = present ? HDA_AMP_MUTE : 0;
7776 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7777 HDA_AMP_MUTE, bits);
7778}
7779
7780static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7781 unsigned int res)
7782{
7783 if ((res >> 26) == ALC880_HP_EVENT)
7784 alc883_2ch_fujitsu_pi2515_automute(codec);
7785}
7786
Kailang Yang189609a2007-08-20 11:31:23 +02007787static void alc883_haier_w66_automute(struct hda_codec *codec)
7788{
7789 unsigned int present;
7790 unsigned char bits;
7791
7792 present = snd_hda_codec_read(codec, 0x1b, 0,
7793 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7794 bits = present ? 0x80 : 0;
7795 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7796 0x80, bits);
7797}
7798
7799static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7800 unsigned int res)
7801{
7802 if ((res >> 26) == ALC880_HP_EVENT)
7803 alc883_haier_w66_automute(codec);
7804}
7805
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007806static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7807{
7808 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007809 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007810
7811 present = snd_hda_codec_read(codec, 0x14, 0,
7812 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007813 bits = present ? HDA_AMP_MUTE : 0;
7814 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7815 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007816}
7817
7818static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7819{
7820 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007821 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007822
7823 present = snd_hda_codec_read(codec, 0x1b, 0,
7824 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007825 bits = present ? HDA_AMP_MUTE : 0;
7826 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7827 HDA_AMP_MUTE, bits);
7828 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7829 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007830}
7831
7832static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7833 unsigned int res)
7834{
7835 if ((res >> 26) == ALC880_HP_EVENT)
7836 alc883_lenovo_101e_all_automute(codec);
7837 if ((res >> 26) == ALC880_FRONT_EVENT)
7838 alc883_lenovo_101e_ispeaker_automute(codec);
7839}
7840
Takashi Iwai676a9b52007-08-16 15:23:35 +02007841/* toggle speaker-output according to the hp-jack state */
7842static void alc883_acer_aspire_automute(struct hda_codec *codec)
7843{
7844 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007845
Takashi Iwai676a9b52007-08-16 15:23:35 +02007846 present = snd_hda_codec_read(codec, 0x14, 0,
7847 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7848 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7849 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7850 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7851 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7852}
7853
7854static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7855 unsigned int res)
7856{
7857 if ((res >> 26) == ALC880_HP_EVENT)
7858 alc883_acer_aspire_automute(codec);
7859}
7860
Kailang Yangd1a991a2007-08-15 16:21:59 +02007861static struct hda_verb alc883_acer_eapd_verbs[] = {
7862 /* HP Pin: output 0 (0x0c) */
7863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7865 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7866 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7868 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007869 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007870 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7871 /* eanable EAPD on medion laptop */
7872 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7873 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007874 /* enable unsolicited event */
7875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007876 { }
7877};
7878
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007879static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7880{
7881 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007882
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007883 present = snd_hda_codec_read(codec, 0x1b, 0,
7884 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7885 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7886 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7888 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7889 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7891 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7892 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7893}
7894
7895static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7896 unsigned int res)
7897{
7898 switch (res >> 26) {
7899 case ALC880_HP_EVENT:
7900 printk("hp_event\n");
7901 alc888_6st_dell_front_automute(codec);
7902 break;
7903 }
7904}
7905
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007906/*
7907 * generic initialization of ADC, input mixers and output mixers
7908 */
7909static struct hda_verb alc883_auto_init_verbs[] = {
7910 /*
7911 * Unmute ADC0-2 and set the default input to mic-in
7912 */
7913 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7917
Takashi Iwaicb53c622007-08-10 17:21:45 +02007918 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007919 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007920 * Note: PASD motherboards uses the Line In 2 as the input for
7921 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007922 */
7923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007929
7930 /*
7931 * Set up output mixers (0x0c - 0x0f)
7932 */
7933 /* set vol=0 to output mixers */
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7938 /* set up input amps for analog loopback */
7939 /* Amp Indices: DAC = 0, mixer = 1 */
7940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7948 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7949 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7950
7951 /* FIXME: use matrix-type input source selection */
7952 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7953 /* Input mixer1 */
7954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007957 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7959 /* Input mixer2 */
7960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007963 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007965
7966 { }
7967};
7968
7969/* capture mixer elements */
7970static struct snd_kcontrol_new alc883_capture_mixer[] = {
7971 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7972 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7973 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7974 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7975 {
7976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7977 /* The multiple "Capture Source" controls confuse alsamixer
7978 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007979 */
7980 /* .name = "Capture Source", */
7981 .name = "Input Source",
7982 .count = 2,
7983 .info = alc882_mux_enum_info,
7984 .get = alc882_mux_enum_get,
7985 .put = alc882_mux_enum_put,
7986 },
7987 { } /* end */
7988};
7989
Takashi Iwaicb53c622007-08-10 17:21:45 +02007990#ifdef CONFIG_SND_HDA_POWER_SAVE
7991#define alc883_loopbacks alc880_loopbacks
7992#endif
7993
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007994/* pcm configuration: identiacal with ALC880 */
7995#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7996#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007997#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007998#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7999#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8000
8001/*
8002 * configuration and preset
8003 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008004static const char *alc883_models[ALC883_MODEL_LAST] = {
8005 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8006 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8007 [ALC883_3ST_6ch] = "3stack-6ch",
8008 [ALC883_6ST_DIG] = "6stack-dig",
8009 [ALC883_TARGA_DIG] = "targa-dig",
8010 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008011 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008012 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008013 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008014 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008015 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008016 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008017 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8018 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02008019 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008020 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008021 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008022 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008023 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008024 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008025 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008026 [ALC883_AUTO] = "auto",
8027};
8028
8029static struct snd_pci_quirk alc883_cfg_tbl[] = {
8030 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008031 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8032 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8033 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008034 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008035 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008036 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008037 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008038 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8039 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008040 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008041 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02008042 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008043 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008044 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8045 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8046 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008047 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008048 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8049 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8050 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008051 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008052 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008053 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008054 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8055 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8056 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8057 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8058 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8059 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8060 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8061 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8062 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008063 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8064 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008065 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008066 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008067 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008068 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008069 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008070 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008071 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8072 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008073 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008074 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008075 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008076 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008077 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008078 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008079 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8080 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02008081 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008082 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008083 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008084 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8085 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008086 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008087 {}
8088};
8089
8090static struct alc_config_preset alc883_presets[] = {
8091 [ALC883_3ST_2ch_DIG] = {
8092 .mixers = { alc883_3ST_2ch_mixer },
8093 .init_verbs = { alc883_init_verbs },
8094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8095 .dac_nids = alc883_dac_nids,
8096 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008097 .dig_in_nid = ALC883_DIGIN_NID,
8098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8099 .channel_mode = alc883_3ST_2ch_modes,
8100 .input_mux = &alc883_capture_source,
8101 },
8102 [ALC883_3ST_6ch_DIG] = {
8103 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8104 .init_verbs = { alc883_init_verbs },
8105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8106 .dac_nids = alc883_dac_nids,
8107 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008108 .dig_in_nid = ALC883_DIGIN_NID,
8109 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8110 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008111 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008112 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008113 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008114 [ALC883_3ST_6ch] = {
8115 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8116 .init_verbs = { alc883_init_verbs },
8117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8118 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008119 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8120 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008121 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008122 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008123 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008124 [ALC883_3ST_6ch_INTEL] = {
8125 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8126 .init_verbs = { alc883_init_verbs },
8127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8128 .dac_nids = alc883_dac_nids,
8129 .dig_out_nid = ALC883_DIGOUT_NID,
8130 .dig_in_nid = ALC883_DIGIN_NID,
8131 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8132 .channel_mode = alc883_3ST_6ch_intel_modes,
8133 .need_dac_fix = 1,
8134 .input_mux = &alc883_3stack_6ch_intel,
8135 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008136 [ALC883_6ST_DIG] = {
8137 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8138 .init_verbs = { alc883_init_verbs },
8139 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8140 .dac_nids = alc883_dac_nids,
8141 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008142 .dig_in_nid = ALC883_DIGIN_NID,
8143 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8144 .channel_mode = alc883_sixstack_modes,
8145 .input_mux = &alc883_capture_source,
8146 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008147 [ALC883_TARGA_DIG] = {
8148 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8149 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8150 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8151 .dac_nids = alc883_dac_nids,
8152 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008153 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8154 .channel_mode = alc883_3ST_6ch_modes,
8155 .need_dac_fix = 1,
8156 .input_mux = &alc883_capture_source,
8157 .unsol_event = alc883_tagra_unsol_event,
8158 .init_hook = alc883_tagra_automute,
8159 },
8160 [ALC883_TARGA_2ch_DIG] = {
8161 .mixers = { alc883_tagra_2ch_mixer},
8162 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8163 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8164 .dac_nids = alc883_dac_nids,
8165 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008166 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8167 .channel_mode = alc883_3ST_2ch_modes,
8168 .input_mux = &alc883_capture_source,
8169 .unsol_event = alc883_tagra_unsol_event,
8170 .init_hook = alc883_tagra_automute,
8171 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008172 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008173 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008174 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8175 * and the headphone jack. Turn this on and rely on the
8176 * standard mute methods whenever the user wants to turn
8177 * these outputs off.
8178 */
8179 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8181 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008182 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8183 .channel_mode = alc883_3ST_2ch_modes,
8184 .input_mux = &alc883_capture_source,
8185 },
Tobin Davis2880a862007-08-07 11:50:26 +02008186 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008187 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008188 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8190 .dac_nids = alc883_dac_nids,
8191 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8193 .channel_mode = alc883_3ST_2ch_modes,
8194 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008195 .unsol_event = alc883_acer_aspire_unsol_event,
8196 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008197 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008198 [ALC883_MEDION] = {
8199 .mixers = { alc883_fivestack_mixer,
8200 alc883_chmode_mixer },
8201 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008202 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008203 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8204 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008205 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8206 .channel_mode = alc883_sixstack_modes,
8207 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008208 },
Kailang Yang272a5272007-05-14 11:00:38 +02008209 [ALC883_MEDION_MD2] = {
8210 .mixers = { alc883_medion_md2_mixer},
8211 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8213 .dac_nids = alc883_dac_nids,
8214 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008215 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8216 .channel_mode = alc883_3ST_2ch_modes,
8217 .input_mux = &alc883_capture_source,
8218 .unsol_event = alc883_medion_md2_unsol_event,
8219 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008220 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008221 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008222 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008223 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8225 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8227 .channel_mode = alc883_3ST_2ch_modes,
8228 .input_mux = &alc883_capture_source,
8229 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008230 [ALC883_CLEVO_M720] = {
8231 .mixers = { alc883_clevo_m720_mixer },
8232 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8234 .dac_nids = alc883_dac_nids,
8235 .dig_out_nid = ALC883_DIGOUT_NID,
8236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8237 .channel_mode = alc883_3ST_2ch_modes,
8238 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008239 .unsol_event = alc883_clevo_m720_unsol_event,
8240 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008241 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008242 [ALC883_LENOVO_101E_2ch] = {
8243 .mixers = { alc883_lenovo_101e_2ch_mixer},
8244 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8245 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8246 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008247 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8248 .channel_mode = alc883_3ST_2ch_modes,
8249 .input_mux = &alc883_lenovo_101e_capture_source,
8250 .unsol_event = alc883_lenovo_101e_unsol_event,
8251 .init_hook = alc883_lenovo_101e_all_automute,
8252 },
Kailang Yang272a5272007-05-14 11:00:38 +02008253 [ALC883_LENOVO_NB0763] = {
8254 .mixers = { alc883_lenovo_nb0763_mixer },
8255 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8256 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8257 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008258 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8259 .channel_mode = alc883_3ST_2ch_modes,
8260 .need_dac_fix = 1,
8261 .input_mux = &alc883_lenovo_nb0763_capture_source,
8262 .unsol_event = alc883_medion_md2_unsol_event,
8263 .init_hook = alc883_medion_md2_automute,
8264 },
8265 [ALC888_LENOVO_MS7195_DIG] = {
8266 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8267 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8268 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8269 .dac_nids = alc883_dac_nids,
8270 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008271 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8272 .channel_mode = alc883_3ST_6ch_modes,
8273 .need_dac_fix = 1,
8274 .input_mux = &alc883_capture_source,
8275 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8276 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008277 },
8278 [ALC883_HAIER_W66] = {
8279 .mixers = { alc883_tagra_2ch_mixer},
8280 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8281 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8282 .dac_nids = alc883_dac_nids,
8283 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008284 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8285 .channel_mode = alc883_3ST_2ch_modes,
8286 .input_mux = &alc883_capture_source,
8287 .unsol_event = alc883_haier_w66_unsol_event,
8288 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008289 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008290 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008291 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008292 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008293 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8294 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008295 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8296 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008297 .need_dac_fix = 1,
8298 .input_mux = &alc883_capture_source,
8299 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008300 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008301 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008302 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8303 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8304 .dac_nids = alc883_dac_nids,
8305 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008306 .dig_in_nid = ALC883_DIGIN_NID,
8307 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8308 .channel_mode = alc883_sixstack_modes,
8309 .input_mux = &alc883_capture_source,
8310 .unsol_event = alc888_6st_dell_unsol_event,
8311 .init_hook = alc888_6st_dell_front_automute,
8312 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008313 [ALC883_MITAC] = {
8314 .mixers = { alc883_mitac_mixer },
8315 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8316 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8317 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008318 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8319 .channel_mode = alc883_3ST_2ch_modes,
8320 .input_mux = &alc883_capture_source,
8321 .unsol_event = alc883_mitac_unsol_event,
8322 .init_hook = alc883_mitac_automute,
8323 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008324 [ALC883_FUJITSU_PI2515] = {
8325 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8326 .init_verbs = { alc883_init_verbs,
8327 alc883_2ch_fujitsu_pi2515_verbs},
8328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8329 .dac_nids = alc883_dac_nids,
8330 .dig_out_nid = ALC883_DIGOUT_NID,
8331 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8332 .channel_mode = alc883_3ST_2ch_modes,
8333 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8334 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8335 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8336 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008337};
8338
8339
8340/*
8341 * BIOS auto configuration
8342 */
8343static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8344 hda_nid_t nid, int pin_type,
8345 int dac_idx)
8346{
8347 /* set as output */
8348 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008349 int idx;
8350
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008351 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008352 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8353 idx = 4;
8354 else
8355 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008356 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8357
8358}
8359
8360static void alc883_auto_init_multi_out(struct hda_codec *codec)
8361{
8362 struct alc_spec *spec = codec->spec;
8363 int i;
8364
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008365 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008366 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008367 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008368 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008369 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008370 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008371 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008372 }
8373}
8374
8375static void alc883_auto_init_hp_out(struct hda_codec *codec)
8376{
8377 struct alc_spec *spec = codec->spec;
8378 hda_nid_t pin;
8379
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008380 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008381 if (pin) /* connect to front */
8382 /* use dac 0 */
8383 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008384 pin = spec->autocfg.speaker_pins[0];
8385 if (pin)
8386 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008387}
8388
8389#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8390#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8391
8392static void alc883_auto_init_analog_input(struct hda_codec *codec)
8393{
8394 struct alc_spec *spec = codec->spec;
8395 int i;
8396
8397 for (i = 0; i < AUTO_PIN_LAST; i++) {
8398 hda_nid_t nid = spec->autocfg.input_pins[i];
8399 if (alc883_is_input_pin(nid)) {
8400 snd_hda_codec_write(codec, nid, 0,
8401 AC_VERB_SET_PIN_WIDGET_CONTROL,
8402 (i <= AUTO_PIN_FRONT_MIC ?
8403 PIN_VREF80 : PIN_IN));
8404 if (nid != ALC883_PIN_CD_NID)
8405 snd_hda_codec_write(codec, nid, 0,
8406 AC_VERB_SET_AMP_GAIN_MUTE,
8407 AMP_OUT_MUTE);
8408 }
8409 }
8410}
8411
Takashi Iwaif511b012008-08-15 16:46:42 +02008412#define alc883_auto_init_input_src alc882_auto_init_input_src
8413
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008414/* almost identical with ALC880 parser... */
8415static int alc883_parse_auto_config(struct hda_codec *codec)
8416{
8417 struct alc_spec *spec = codec->spec;
8418 int err = alc880_parse_auto_config(codec);
8419
8420 if (err < 0)
8421 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008422 else if (!err)
8423 return 0; /* no config found */
8424
8425 err = alc_auto_add_mic_boost(codec);
8426 if (err < 0)
8427 return err;
8428
8429 /* hack - override the init verbs */
8430 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008431 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8432 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008433
8434 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008435}
8436
8437/* additional initialization for auto-configuration model */
8438static void alc883_auto_init(struct hda_codec *codec)
8439{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008440 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008441 alc883_auto_init_multi_out(codec);
8442 alc883_auto_init_hp_out(codec);
8443 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008444 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008445 if (spec->unsol_event)
8446 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008447}
8448
8449static int patch_alc883(struct hda_codec *codec)
8450{
8451 struct alc_spec *spec;
8452 int err, board_config;
8453
8454 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8455 if (spec == NULL)
8456 return -ENOMEM;
8457
8458 codec->spec = spec;
8459
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008460 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8461
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008462 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8463 alc883_models,
8464 alc883_cfg_tbl);
8465 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008466 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8467 "trying auto-probe from BIOS...\n");
8468 board_config = ALC883_AUTO;
8469 }
8470
8471 if (board_config == ALC883_AUTO) {
8472 /* automatic parse from the BIOS config */
8473 err = alc883_parse_auto_config(codec);
8474 if (err < 0) {
8475 alc_free(codec);
8476 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008477 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008478 printk(KERN_INFO
8479 "hda_codec: Cannot set up configuration "
8480 "from BIOS. Using base mode...\n");
8481 board_config = ALC883_3ST_2ch_DIG;
8482 }
8483 }
8484
8485 if (board_config != ALC883_AUTO)
8486 setup_preset(spec, &alc883_presets[board_config]);
8487
Kailang Yang2f893282008-05-27 12:14:47 +02008488 switch (codec->vendor_id) {
8489 case 0x10ec0888:
8490 spec->stream_name_analog = "ALC888 Analog";
8491 spec->stream_name_digital = "ALC888 Digital";
8492 break;
8493 case 0x10ec0889:
8494 spec->stream_name_analog = "ALC889 Analog";
8495 spec->stream_name_digital = "ALC889 Digital";
8496 break;
8497 default:
8498 spec->stream_name_analog = "ALC883 Analog";
8499 spec->stream_name_digital = "ALC883 Digital";
8500 break;
8501 }
8502
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008503 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8504 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008505 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008506
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008507 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8508 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8509
Takashi Iwaie1406342008-02-11 18:32:32 +01008510 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8511 spec->adc_nids = alc883_adc_nids;
8512 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008513
Takashi Iwai2134ea42008-01-10 16:53:55 +01008514 spec->vmaster_nid = 0x0c;
8515
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008516 codec->patch_ops = alc_patch_ops;
8517 if (board_config == ALC883_AUTO)
8518 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008519
Takashi Iwaicb53c622007-08-10 17:21:45 +02008520#ifdef CONFIG_SND_HDA_POWER_SAVE
8521 if (!spec->loopback.amplist)
8522 spec->loopback.amplist = alc883_loopbacks;
8523#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008524
8525 return 0;
8526}
8527
8528/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008529 * ALC262 support
8530 */
8531
8532#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8533#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8534
8535#define alc262_dac_nids alc260_dac_nids
8536#define alc262_adc_nids alc882_adc_nids
8537#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008538#define alc262_capsrc_nids alc882_capsrc_nids
8539#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008540
8541#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008542#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008543
Kailang Yang4e555fe2008-08-26 13:05:55 +02008544static hda_nid_t alc262_dmic_adc_nids[1] = {
8545 /* ADC0 */
8546 0x09
8547};
8548
8549static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8550
Kailang Yangdf694da2005-12-05 19:42:22 +01008551static struct snd_kcontrol_new alc262_base_mixer[] = {
8552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8553 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008561 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8562 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008563 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008564 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008565 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8568 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8569 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008570 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008571};
8572
Kailang Yangccc656c2006-10-17 12:32:26 +02008573static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8574 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8575 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008583 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8584 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008585 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008586 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008587 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008588 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8590 { } /* end */
8591};
8592
Takashi Iwaice875f02008-01-28 18:17:43 +01008593/* update HP, line and mono-out pins according to the master switch */
8594static void alc262_hp_master_update(struct hda_codec *codec)
8595{
8596 struct alc_spec *spec = codec->spec;
8597 int val = spec->master_sw;
8598
8599 /* HP & line-out */
8600 snd_hda_codec_write_cache(codec, 0x1b, 0,
8601 AC_VERB_SET_PIN_WIDGET_CONTROL,
8602 val ? PIN_HP : 0);
8603 snd_hda_codec_write_cache(codec, 0x15, 0,
8604 AC_VERB_SET_PIN_WIDGET_CONTROL,
8605 val ? PIN_HP : 0);
8606 /* mono (speaker) depending on the HP jack sense */
8607 val = val && !spec->jack_present;
8608 snd_hda_codec_write_cache(codec, 0x16, 0,
8609 AC_VERB_SET_PIN_WIDGET_CONTROL,
8610 val ? PIN_OUT : 0);
8611}
8612
8613static void alc262_hp_bpc_automute(struct hda_codec *codec)
8614{
8615 struct alc_spec *spec = codec->spec;
8616 unsigned int presence;
8617 presence = snd_hda_codec_read(codec, 0x1b, 0,
8618 AC_VERB_GET_PIN_SENSE, 0);
8619 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8620 alc262_hp_master_update(codec);
8621}
8622
8623static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8624{
8625 if ((res >> 26) != ALC880_HP_EVENT)
8626 return;
8627 alc262_hp_bpc_automute(codec);
8628}
8629
8630static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8631{
8632 struct alc_spec *spec = codec->spec;
8633 unsigned int presence;
8634 presence = snd_hda_codec_read(codec, 0x15, 0,
8635 AC_VERB_GET_PIN_SENSE, 0);
8636 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8637 alc262_hp_master_update(codec);
8638}
8639
8640static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8641 unsigned int res)
8642{
8643 if ((res >> 26) != ALC880_HP_EVENT)
8644 return;
8645 alc262_hp_wildwest_automute(codec);
8646}
8647
8648static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8649 struct snd_ctl_elem_value *ucontrol)
8650{
8651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8652 struct alc_spec *spec = codec->spec;
8653 *ucontrol->value.integer.value = spec->master_sw;
8654 return 0;
8655}
8656
8657static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8658 struct snd_ctl_elem_value *ucontrol)
8659{
8660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8661 struct alc_spec *spec = codec->spec;
8662 int val = !!*ucontrol->value.integer.value;
8663
8664 if (val == spec->master_sw)
8665 return 0;
8666 spec->master_sw = val;
8667 alc262_hp_master_update(codec);
8668 return 1;
8669}
8670
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008671static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008672 {
8673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8674 .name = "Master Playback Switch",
8675 .info = snd_ctl_boolean_mono_info,
8676 .get = alc262_hp_master_sw_get,
8677 .put = alc262_hp_master_sw_put,
8678 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008679 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8680 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008682 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8683 HDA_OUTPUT),
8684 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8685 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008689 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8690 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8694 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8695 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8696 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8697 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8698 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8699 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8700 { } /* end */
8701};
8702
Kailang Yangcd7509a2007-01-26 18:33:17 +01008703static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008704 {
8705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8706 .name = "Master Playback Switch",
8707 .info = snd_ctl_boolean_mono_info,
8708 .get = alc262_hp_master_sw_get,
8709 .put = alc262_hp_master_sw_put,
8710 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8712 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008715 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8716 HDA_OUTPUT),
8717 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8718 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008719 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8720 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008721 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8724 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8725 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8726 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8727 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8728 { } /* end */
8729};
8730
8731static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8732 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8733 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008734 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008735 { } /* end */
8736};
8737
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008738/* mute/unmute internal speaker according to the hp jack and mute state */
8739static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8740{
8741 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008742
8743 if (force || !spec->sense_updated) {
8744 unsigned int present;
8745 present = snd_hda_codec_read(codec, 0x15, 0,
8746 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008747 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008748 spec->sense_updated = 1;
8749 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008750 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8751 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008752}
8753
8754static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8755 unsigned int res)
8756{
8757 if ((res >> 26) != ALC880_HP_EVENT)
8758 return;
8759 alc262_hp_t5735_automute(codec, 1);
8760}
8761
8762static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8763{
8764 alc262_hp_t5735_automute(codec, 1);
8765}
8766
8767static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008770 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8775 { } /* end */
8776};
8777
8778static struct hda_verb alc262_hp_t5735_verbs[] = {
8779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8781
8782 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8783 { }
8784};
8785
Kailang Yang8c427222008-01-10 13:03:59 +01008786static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008789 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8790 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8793 { } /* end */
8794};
8795
8796static struct hda_verb alc262_hp_rp5700_verbs[] = {
8797 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8802 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8807 {}
8808};
8809
8810static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8811 .num_items = 1,
8812 .items = {
8813 { "Line", 0x1 },
8814 },
8815};
8816
Takashi Iwai0724ea22007-08-23 00:31:43 +02008817/* bind hp and internal speaker mute (with plug check) */
8818static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8819 struct snd_ctl_elem_value *ucontrol)
8820{
8821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8822 long *valp = ucontrol->value.integer.value;
8823 int change;
8824
8825 /* change hp mute */
8826 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8827 HDA_AMP_MUTE,
8828 valp[0] ? 0 : HDA_AMP_MUTE);
8829 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8830 HDA_AMP_MUTE,
8831 valp[1] ? 0 : HDA_AMP_MUTE);
8832 if (change) {
8833 /* change speaker according to HP jack state */
8834 struct alc_spec *spec = codec->spec;
8835 unsigned int mute;
8836 if (spec->jack_present)
8837 mute = HDA_AMP_MUTE;
8838 else
8839 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8840 HDA_OUTPUT, 0);
8841 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8842 HDA_AMP_MUTE, mute);
8843 }
8844 return change;
8845}
Takashi Iwai5b319542007-07-26 11:49:22 +02008846
Kailang Yang272a5272007-05-14 11:00:38 +02008847static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008848 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8849 {
8850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8851 .name = "Master Playback Switch",
8852 .info = snd_hda_mixer_amp_switch_info,
8853 .get = snd_hda_mixer_amp_switch_get,
8854 .put = alc262_sony_master_sw_put,
8855 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8856 },
Kailang Yang272a5272007-05-14 11:00:38 +02008857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8859 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8860 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8861 { } /* end */
8862};
8863
Kailang Yang83c34212007-07-05 11:43:05 +02008864static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8865 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8866 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8868 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8870 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8871 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8872 { } /* end */
8873};
Kailang Yang272a5272007-05-14 11:00:38 +02008874
Kailang Yangdf694da2005-12-05 19:42:22 +01008875#define alc262_capture_mixer alc882_capture_mixer
8876#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8877
8878/*
8879 * generic initialization of ADC, input mixers and output mixers
8880 */
8881static struct hda_verb alc262_init_verbs[] = {
8882 /*
8883 * Unmute ADC0-2 and set the default input to mic-in
8884 */
8885 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8887 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8889 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8891
Takashi Iwaicb53c622007-08-10 17:21:45 +02008892 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008893 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008894 * Note: PASD motherboards uses the Line In 2 as the input for
8895 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008896 */
8897 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008903
8904 /*
8905 * Set up output mixers (0x0c - 0x0e)
8906 */
8907 /* set vol=0 to output mixers */
8908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8911 /* set up input amps for analog loopback */
8912 /* Amp Indices: DAC = 0, mixer = 1 */
8913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919
8920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8924 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8926
8927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02008932
Kailang Yangdf694da2005-12-05 19:42:22 +01008933 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8934 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02008935
Kailang Yangdf694da2005-12-05 19:42:22 +01008936 /* FIXME: use matrix-type input source selection */
8937 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8938 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8943 /* Input mixer2 */
8944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8948 /* Input mixer3 */
8949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008953
8954 { }
8955};
8956
Kailang Yang4e555fe2008-08-26 13:05:55 +02008957static struct hda_verb alc262_eapd_verbs[] = {
8958 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8959 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8960 { }
8961};
8962
Kailang Yangccc656c2006-10-17 12:32:26 +02008963static struct hda_verb alc262_hippo_unsol_verbs[] = {
8964 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8966 {}
8967};
8968
8969static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8970 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8971 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8972 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8973
8974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8975 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8976 {}
8977};
8978
Kailang Yang272a5272007-05-14 11:00:38 +02008979static struct hda_verb alc262_sony_unsol_verbs[] = {
8980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8982 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8983
8984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008986 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008987};
8988
Kailang Yang4e555fe2008-08-26 13:05:55 +02008989static struct hda_input_mux alc262_dmic_capture_source = {
8990 .num_items = 2,
8991 .items = {
8992 { "Int DMic", 0x9 },
8993 { "Mic", 0x0 },
8994 },
8995};
8996
8997static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
8998 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8999 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9003 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9004 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9005 {
9006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9007 /* The multiple "Capture Source" controls confuse alsamixer
9008 * So call somewhat different..
9009 */
9010 /* .name = "Capture Source", */
9011 .name = "Input Source",
9012 .count = 1,
9013 .info = alc_mux_enum_info,
9014 .get = alc_mux_enum_get,
9015 .put = alc_mux_enum_put,
9016 },
9017 { } /* end */
9018};
9019
9020static struct hda_verb alc262_toshiba_s06_verbs[] = {
9021 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9024 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9025 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9027 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9029 {}
9030};
9031
9032static void alc262_dmic_automute(struct hda_codec *codec)
9033{
9034 unsigned int present;
9035
9036 present = snd_hda_codec_read(codec, 0x18, 0,
9037 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9038 snd_hda_codec_write(codec, 0x22, 0,
9039 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9040}
9041
9042/* toggle speaker-output according to the hp-jack state */
9043static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9044{
9045 unsigned int present;
9046 unsigned char bits;
9047
9048 present = snd_hda_codec_read(codec, 0x15, 0,
9049 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9050 bits = present ? 0 : PIN_OUT;
9051 snd_hda_codec_write(codec, 0x14, 0,
9052 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9053}
9054
9055
9056
9057/* unsolicited event for HP jack sensing */
9058static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9059 unsigned int res)
9060{
9061 if ((res >> 26) == ALC880_HP_EVENT)
9062 alc262_toshiba_s06_speaker_automute(codec);
9063 if ((res >> 26) == ALC880_MIC_EVENT)
9064 alc262_dmic_automute(codec);
9065
9066}
9067
9068static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9069{
9070 alc262_toshiba_s06_speaker_automute(codec);
9071 alc262_dmic_automute(codec);
9072}
9073
Kailang Yangccc656c2006-10-17 12:32:26 +02009074/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009075static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009076{
9077 struct alc_spec *spec = codec->spec;
9078 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009079 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009080
Takashi Iwai5b319542007-07-26 11:49:22 +02009081 /* need to execute and sync at first */
9082 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9083 present = snd_hda_codec_read(codec, 0x15, 0,
9084 AC_VERB_GET_PIN_SENSE, 0);
9085 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009086 if (spec->jack_present) {
9087 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009088 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9089 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 } else {
9091 /* unmute internal speaker if necessary */
9092 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009093 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9094 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009095 }
9096}
9097
9098/* unsolicited event for HP jack sensing */
9099static void alc262_hippo_unsol_event(struct hda_codec *codec,
9100 unsigned int res)
9101{
9102 if ((res >> 26) != ALC880_HP_EVENT)
9103 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009104 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009105}
9106
Takashi Iwai5b319542007-07-26 11:49:22 +02009107static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009108{
Kailang Yangccc656c2006-10-17 12:32:26 +02009109 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009110 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009111
Takashi Iwai5b319542007-07-26 11:49:22 +02009112 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9113 present = snd_hda_codec_read(codec, 0x1b, 0,
9114 AC_VERB_GET_PIN_SENSE, 0);
9115 present = (present & 0x80000000) != 0;
9116 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009117 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009118 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9119 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009120 } else {
9121 /* unmute internal speaker if necessary */
9122 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009123 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9124 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009125 }
9126}
9127
9128/* unsolicited event for HP jack sensing */
9129static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9130 unsigned int res)
9131{
9132 if ((res >> 26) != ALC880_HP_EVENT)
9133 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009134 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009135}
9136
Takashi Iwai834be882006-03-01 14:16:17 +01009137/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009138 * nec model
9139 * 0x15 = headphone
9140 * 0x16 = internal speaker
9141 * 0x18 = external mic
9142 */
9143
9144static struct snd_kcontrol_new alc262_nec_mixer[] = {
9145 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9146 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9147
9148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9150 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9151
9152 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9154 { } /* end */
9155};
9156
9157static struct hda_verb alc262_nec_verbs[] = {
9158 /* Unmute Speaker */
9159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9160
9161 /* Headphone */
9162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9164
9165 /* External mic to headphone */
9166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9167 /* External mic to speaker */
9168 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9169 {}
9170};
9171
9172/*
Takashi Iwai834be882006-03-01 14:16:17 +01009173 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009174 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9175 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009176 */
9177
9178#define ALC_HP_EVENT 0x37
9179
9180static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9181 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009185 {}
9186};
9187
Jiang zhe0e31daf2008-03-20 12:12:39 +01009188static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9189 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9190 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9191 {}
9192};
9193
Takashi Iwai834be882006-03-01 14:16:17 +01009194static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009195 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009196 .items = {
9197 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009198 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009199 { "CD", 0x4 },
9200 },
9201};
9202
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009203static struct hda_input_mux alc262_HP_capture_source = {
9204 .num_items = 5,
9205 .items = {
9206 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009207 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009208 { "Line", 0x2 },
9209 { "CD", 0x4 },
9210 { "AUX IN", 0x6 },
9211 },
9212};
9213
zhejiangaccbe492007-08-31 12:36:05 +02009214static struct hda_input_mux alc262_HP_D7000_capture_source = {
9215 .num_items = 4,
9216 .items = {
9217 { "Mic", 0x0 },
9218 { "Front Mic", 0x2 },
9219 { "Line", 0x1 },
9220 { "CD", 0x4 },
9221 },
9222};
9223
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009224/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009225static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9226{
9227 struct alc_spec *spec = codec->spec;
9228 unsigned int mute;
9229
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009230 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009231 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009232 /* need to execute and sync at first */
9233 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009234 /* check laptop HP jack */
9235 present = snd_hda_codec_read(codec, 0x14, 0,
9236 AC_VERB_GET_PIN_SENSE, 0);
9237 /* need to execute and sync at first */
9238 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9239 /* check docking HP jack */
9240 present |= snd_hda_codec_read(codec, 0x1b, 0,
9241 AC_VERB_GET_PIN_SENSE, 0);
9242 if (present & AC_PINSENSE_PRESENCE)
9243 spec->jack_present = 1;
9244 else
9245 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009246 spec->sense_updated = 1;
9247 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009248 /* unmute internal speaker only if both HPs are unplugged and
9249 * master switch is on
9250 */
9251 if (spec->jack_present)
9252 mute = HDA_AMP_MUTE;
9253 else
Takashi Iwai834be882006-03-01 14:16:17 +01009254 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009255 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9256 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009257}
9258
9259/* unsolicited event for HP jack sensing */
9260static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9261 unsigned int res)
9262{
9263 if ((res >> 26) != ALC_HP_EVENT)
9264 return;
9265 alc262_fujitsu_automute(codec, 1);
9266}
9267
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009268static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9269{
9270 alc262_fujitsu_automute(codec, 1);
9271}
9272
Takashi Iwai834be882006-03-01 14:16:17 +01009273/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009274static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9275 .ops = &snd_hda_bind_vol,
9276 .values = {
9277 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9278 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9279 0
9280 },
9281};
Takashi Iwai834be882006-03-01 14:16:17 +01009282
Jiang zhe0e31daf2008-03-20 12:12:39 +01009283/* mute/unmute internal speaker according to the hp jack and mute state */
9284static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9285{
9286 struct alc_spec *spec = codec->spec;
9287 unsigned int mute;
9288
9289 if (force || !spec->sense_updated) {
9290 unsigned int present_int_hp;
9291 /* need to execute and sync at first */
9292 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9293 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9294 AC_VERB_GET_PIN_SENSE, 0);
9295 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9296 spec->sense_updated = 1;
9297 }
9298 if (spec->jack_present) {
9299 /* mute internal speaker */
9300 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9301 HDA_AMP_MUTE, HDA_AMP_MUTE);
9302 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9303 HDA_AMP_MUTE, HDA_AMP_MUTE);
9304 } else {
9305 /* unmute internal speaker if necessary */
9306 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9307 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9308 HDA_AMP_MUTE, mute);
9309 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9310 HDA_AMP_MUTE, mute);
9311 }
9312}
9313
9314/* unsolicited event for HP jack sensing */
9315static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9316 unsigned int res)
9317{
9318 if ((res >> 26) != ALC_HP_EVENT)
9319 return;
9320 alc262_lenovo_3000_automute(codec, 1);
9321}
9322
Takashi Iwai834be882006-03-01 14:16:17 +01009323/* bind hp and internal speaker mute (with plug check) */
9324static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9325 struct snd_ctl_elem_value *ucontrol)
9326{
9327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9328 long *valp = ucontrol->value.integer.value;
9329 int change;
9330
Tony Vroon5d9fab22008-03-14 17:09:18 +01009331 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9332 HDA_AMP_MUTE,
9333 valp ? 0 : HDA_AMP_MUTE);
9334 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9335 HDA_AMP_MUTE,
9336 valp ? 0 : HDA_AMP_MUTE);
9337
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009338 if (change)
9339 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009340 return change;
9341}
9342
9343static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009344 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009345 {
9346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9347 .name = "Master Playback Switch",
9348 .info = snd_hda_mixer_amp_switch_info,
9349 .get = snd_hda_mixer_amp_switch_get,
9350 .put = alc262_fujitsu_master_sw_put,
9351 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9352 },
9353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009355 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9356 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009357 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009360 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9361 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9362 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009363 { } /* end */
9364};
9365
Jiang zhe0e31daf2008-03-20 12:12:39 +01009366/* bind hp and internal speaker mute (with plug check) */
9367static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9368 struct snd_ctl_elem_value *ucontrol)
9369{
9370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9371 long *valp = ucontrol->value.integer.value;
9372 int change;
9373
9374 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9375 HDA_AMP_MUTE,
9376 valp ? 0 : HDA_AMP_MUTE);
9377
9378 if (change)
9379 alc262_lenovo_3000_automute(codec, 0);
9380 return change;
9381}
9382
9383static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9384 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9385 {
9386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9387 .name = "Master Playback Switch",
9388 .info = snd_hda_mixer_amp_switch_info,
9389 .get = snd_hda_mixer_amp_switch_get,
9390 .put = alc262_lenovo_3000_master_sw_put,
9391 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9392 },
9393 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9394 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9398 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9399 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9400 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9401 { } /* end */
9402};
9403
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009404/* additional init verbs for Benq laptops */
9405static struct hda_verb alc262_EAPD_verbs[] = {
9406 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9407 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9408 {}
9409};
9410
Kailang Yang83c34212007-07-05 11:43:05 +02009411static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9413 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9414
9415 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9416 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9417 {}
9418};
9419
Tobin Davisf651b502007-10-26 12:40:47 +02009420/* Samsung Q1 Ultra Vista model setup */
9421static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009422 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9423 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9426 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009427 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009428 { } /* end */
9429};
9430
9431static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009432 /* output mixer */
9433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9436 /* speaker */
9437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9441 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9447 /* internal mic */
9448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9450 /* ADC, choose mic */
9451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009461 {}
9462};
9463
Tobin Davisf651b502007-10-26 12:40:47 +02009464/* mute/unmute internal speaker according to the hp jack and mute state */
9465static void alc262_ultra_automute(struct hda_codec *codec)
9466{
9467 struct alc_spec *spec = codec->spec;
9468 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009469
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009470 mute = 0;
9471 /* auto-mute only when HP is used as HP */
9472 if (!spec->cur_mux[0]) {
9473 unsigned int present;
9474 /* need to execute and sync at first */
9475 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9476 present = snd_hda_codec_read(codec, 0x15, 0,
9477 AC_VERB_GET_PIN_SENSE, 0);
9478 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9479 if (spec->jack_present)
9480 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009481 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009482 /* mute/unmute internal speaker */
9483 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9484 HDA_AMP_MUTE, mute);
9485 /* mute/unmute HP */
9486 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9487 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009488}
9489
9490/* unsolicited event for HP jack sensing */
9491static void alc262_ultra_unsol_event(struct hda_codec *codec,
9492 unsigned int res)
9493{
9494 if ((res >> 26) != ALC880_HP_EVENT)
9495 return;
9496 alc262_ultra_automute(codec);
9497}
9498
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009499static struct hda_input_mux alc262_ultra_capture_source = {
9500 .num_items = 2,
9501 .items = {
9502 { "Mic", 0x1 },
9503 { "Headphone", 0x7 },
9504 },
9505};
9506
9507static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9508 struct snd_ctl_elem_value *ucontrol)
9509{
9510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9511 struct alc_spec *spec = codec->spec;
9512 int ret;
9513
9514 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9515 if (!ret)
9516 return 0;
9517 /* reprogram the HP pin as mic or HP according to the input source */
9518 snd_hda_codec_write_cache(codec, 0x15, 0,
9519 AC_VERB_SET_PIN_WIDGET_CONTROL,
9520 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9521 alc262_ultra_automute(codec); /* mute/unmute HP */
9522 return ret;
9523}
9524
9525static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9526 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9527 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9528 {
9529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9530 .name = "Capture Source",
9531 .info = alc882_mux_enum_info,
9532 .get = alc882_mux_enum_get,
9533 .put = alc262_ultra_mux_enum_put,
9534 },
9535 { } /* end */
9536};
9537
Kailang Yangdf694da2005-12-05 19:42:22 +01009538/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009539static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9540 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009541{
9542 hda_nid_t nid;
9543 int err;
9544
9545 spec->multiout.num_dacs = 1; /* only use one dac */
9546 spec->multiout.dac_nids = spec->private_dac_nids;
9547 spec->multiout.dac_nids[0] = 2;
9548
9549 nid = cfg->line_out_pins[0];
9550 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009551 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9552 "Front Playback Volume",
9553 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9554 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009555 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009556 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9557 "Front Playback Switch",
9558 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9559 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009560 return err;
9561 }
9562
Takashi Iwai82bc9552006-03-21 11:24:42 +01009563 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009564 if (nid) {
9565 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009566 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9567 "Speaker Playback Volume",
9568 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9569 HDA_OUTPUT));
9570 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009571 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009572 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9573 "Speaker Playback Switch",
9574 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9575 HDA_OUTPUT));
9576 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009577 return err;
9578 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009579 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9580 "Speaker Playback Switch",
9581 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9582 HDA_OUTPUT));
9583 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009584 return err;
9585 }
9586 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009587 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009588 if (nid) {
9589 /* spec->multiout.hp_nid = 2; */
9590 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009591 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9592 "Headphone Playback Volume",
9593 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9594 HDA_OUTPUT));
9595 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009597 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9598 "Headphone Playback Switch",
9599 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9600 HDA_OUTPUT));
9601 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009602 return err;
9603 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009604 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9605 "Headphone Playback Switch",
9606 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9607 HDA_OUTPUT));
9608 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 return err;
9610 }
9611 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009612 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009613}
9614
9615/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009616#define alc262_auto_create_analog_input_ctls \
9617 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009618
9619/*
9620 * generic initialization of ADC, input mixers and output mixers
9621 */
9622static struct hda_verb alc262_volume_init_verbs[] = {
9623 /*
9624 * Unmute ADC0-2 and set the default input to mic-in
9625 */
9626 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9632
Takashi Iwaicb53c622007-08-10 17:21:45 +02009633 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009634 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009635 * Note: PASD motherboards uses the Line In 2 as the input for
9636 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009637 */
9638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009644
9645 /*
9646 * Set up output mixers (0x0c - 0x0f)
9647 */
9648 /* set vol=0 to output mixers */
9649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009652
Kailang Yangdf694da2005-12-05 19:42:22 +01009653 /* set up input amps for analog loopback */
9654 /* Amp Indices: DAC = 0, mixer = 1 */
9655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9661
9662 /* FIXME: use matrix-type input source selection */
9663 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9664 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9669 /* Input mixer2 */
9670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9674 /* Input mixer3 */
9675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9679
9680 { }
9681};
9682
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009683static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9684 /*
9685 * Unmute ADC0-2 and set the default input to mic-in
9686 */
9687 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9689 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9691 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9692 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9693
Takashi Iwaicb53c622007-08-10 17:21:45 +02009694 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009695 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009696 * Note: PASD motherboards uses the Line In 2 as the input for
9697 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698 */
9699 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009707
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009708 /*
9709 * Set up output mixers (0x0c - 0x0e)
9710 */
9711 /* set vol=0 to output mixers */
9712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9715
9716 /* set up input amps for analog loopback */
9717 /* Amp Indices: DAC = 0, mixer = 1 */
9718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9724
Takashi Iwaice875f02008-01-28 18:17:43 +01009725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9728
9729 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9731
9732 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9733 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9734
9735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9738 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9740
9741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9743 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9745 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9746 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9747
9748
9749 /* FIXME: use matrix-type input source selection */
9750 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9751 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9756 /* Input mixer2 */
9757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9761 /* Input mixer3 */
9762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9766
Takashi Iwaice875f02008-01-28 18:17:43 +01009767 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9768
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009769 { }
9770};
9771
Kailang Yangcd7509a2007-01-26 18:33:17 +01009772static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9773 /*
9774 * Unmute ADC0-2 and set the default input to mic-in
9775 */
9776 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9777 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9778 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9779 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9780 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9781 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9782
Takashi Iwaicb53c622007-08-10 17:21:45 +02009783 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009784 * mixer widget
9785 * Note: PASD motherboards uses the Line In 2 as the input for front
9786 * panel mic (mic 2)
9787 */
9788 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009789 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9790 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009797 /*
9798 * Set up output mixers (0x0c - 0x0e)
9799 */
9800 /* set vol=0 to output mixers */
9801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9804
9805 /* set up input amps for analog loopback */
9806 /* Amp Indices: DAC = 0, mixer = 1 */
9807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9813
9814
9815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9816 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9817 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9820 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9821 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9822
9823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9825
9826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9828
9829 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9830 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9832 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9833 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9834 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9835
9836 /* FIXME: use matrix-type input source selection */
9837 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9838 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9844 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9846 /* Input mixer2 */
9847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9852 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9854 /* Input mixer3 */
9855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9860 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9862
Takashi Iwaice875f02008-01-28 18:17:43 +01009863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9864
Kailang Yangcd7509a2007-01-26 18:33:17 +01009865 { }
9866};
9867
Takashi Iwaicb53c622007-08-10 17:21:45 +02009868#ifdef CONFIG_SND_HDA_POWER_SAVE
9869#define alc262_loopbacks alc880_loopbacks
9870#endif
9871
Kailang Yangdf694da2005-12-05 19:42:22 +01009872/* pcm configuration: identiacal with ALC880 */
9873#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9874#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9875#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9876#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9877
9878/*
9879 * BIOS auto configuration
9880 */
9881static int alc262_parse_auto_config(struct hda_codec *codec)
9882{
9883 struct alc_spec *spec = codec->spec;
9884 int err;
9885 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9886
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009887 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9888 alc262_ignore);
9889 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009890 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009891 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009892 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009893 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9894 if (err < 0)
9895 return err;
9896 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9897 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009898 return err;
9899
9900 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9901
9902 if (spec->autocfg.dig_out_pin)
9903 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9904 if (spec->autocfg.dig_in_pin)
9905 spec->dig_in_nid = ALC262_DIGIN_NID;
9906
9907 if (spec->kctl_alloc)
9908 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9909
9910 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009911 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009912 spec->input_mux = &spec->private_imux;
9913
Takashi Iwai776e1842007-08-29 15:07:11 +02009914 err = alc_auto_add_mic_boost(codec);
9915 if (err < 0)
9916 return err;
9917
Kailang Yangdf694da2005-12-05 19:42:22 +01009918 return 1;
9919}
9920
9921#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9922#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9923#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +02009924#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +01009925
9926
9927/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009928static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009929{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009930 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009931 alc262_auto_init_multi_out(codec);
9932 alc262_auto_init_hp_out(codec);
9933 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009934 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009935 if (spec->unsol_event)
9936 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009937}
9938
9939/*
9940 * configuration and preset
9941 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009942static const char *alc262_models[ALC262_MODEL_LAST] = {
9943 [ALC262_BASIC] = "basic",
9944 [ALC262_HIPPO] = "hippo",
9945 [ALC262_HIPPO_1] = "hippo_1",
9946 [ALC262_FUJITSU] = "fujitsu",
9947 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009948 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009949 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009950 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009951 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009952 [ALC262_BENQ_T31] = "benq-t31",
9953 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009954 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009955 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009956 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009957 [ALC262_AUTO] = "auto",
9958};
9959
9960static struct snd_pci_quirk alc262_cfg_tbl[] = {
9961 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009962 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009963 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009964 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009965 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9966 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009967 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009968 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009969 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009970 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009971 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009972 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009973 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009974 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009975 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009976 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009977 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009978 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009979 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9980 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9981 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009982 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9983 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009984 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009985 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009986 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009987 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9988 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9989 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009990 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9991 ALC262_SONY_ASSAMD),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009992 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009993 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009994 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009995 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009996 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009997 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009998 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02009999 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010000 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010001 {}
10002};
10003
10004static struct alc_config_preset alc262_presets[] = {
10005 [ALC262_BASIC] = {
10006 .mixers = { alc262_base_mixer },
10007 .init_verbs = { alc262_init_verbs },
10008 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10009 .dac_nids = alc262_dac_nids,
10010 .hp_nid = 0x03,
10011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10012 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010013 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010014 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010015 [ALC262_HIPPO] = {
10016 .mixers = { alc262_base_mixer },
10017 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10018 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10019 .dac_nids = alc262_dac_nids,
10020 .hp_nid = 0x03,
10021 .dig_out_nid = ALC262_DIGOUT_NID,
10022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10023 .channel_mode = alc262_modes,
10024 .input_mux = &alc262_capture_source,
10025 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010026 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010027 },
10028 [ALC262_HIPPO_1] = {
10029 .mixers = { alc262_hippo1_mixer },
10030 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10031 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10032 .dac_nids = alc262_dac_nids,
10033 .hp_nid = 0x02,
10034 .dig_out_nid = ALC262_DIGOUT_NID,
10035 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10036 .channel_mode = alc262_modes,
10037 .input_mux = &alc262_capture_source,
10038 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010039 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010040 },
Takashi Iwai834be882006-03-01 14:16:17 +010010041 [ALC262_FUJITSU] = {
10042 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010043 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10044 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010045 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10046 .dac_nids = alc262_dac_nids,
10047 .hp_nid = 0x03,
10048 .dig_out_nid = ALC262_DIGOUT_NID,
10049 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10050 .channel_mode = alc262_modes,
10051 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010052 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010053 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010054 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010055 [ALC262_HP_BPC] = {
10056 .mixers = { alc262_HP_BPC_mixer },
10057 .init_verbs = { alc262_HP_BPC_init_verbs },
10058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10059 .dac_nids = alc262_dac_nids,
10060 .hp_nid = 0x03,
10061 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10062 .channel_mode = alc262_modes,
10063 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010064 .unsol_event = alc262_hp_bpc_unsol_event,
10065 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010066 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010067 [ALC262_HP_BPC_D7000_WF] = {
10068 .mixers = { alc262_HP_BPC_WildWest_mixer },
10069 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10070 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10071 .dac_nids = alc262_dac_nids,
10072 .hp_nid = 0x03,
10073 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10074 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010075 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010076 .unsol_event = alc262_hp_wildwest_unsol_event,
10077 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010078 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010079 [ALC262_HP_BPC_D7000_WL] = {
10080 .mixers = { alc262_HP_BPC_WildWest_mixer,
10081 alc262_HP_BPC_WildWest_option_mixer },
10082 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10084 .dac_nids = alc262_dac_nids,
10085 .hp_nid = 0x03,
10086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10087 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010088 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010089 .unsol_event = alc262_hp_wildwest_unsol_event,
10090 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010091 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010092 [ALC262_HP_TC_T5735] = {
10093 .mixers = { alc262_hp_t5735_mixer },
10094 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10096 .dac_nids = alc262_dac_nids,
10097 .hp_nid = 0x03,
10098 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10099 .channel_mode = alc262_modes,
10100 .input_mux = &alc262_capture_source,
10101 .unsol_event = alc262_hp_t5735_unsol_event,
10102 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010103 },
10104 [ALC262_HP_RP5700] = {
10105 .mixers = { alc262_hp_rp5700_mixer },
10106 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10107 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10108 .dac_nids = alc262_dac_nids,
10109 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10110 .channel_mode = alc262_modes,
10111 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010112 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010113 [ALC262_BENQ_ED8] = {
10114 .mixers = { alc262_base_mixer },
10115 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10116 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10117 .dac_nids = alc262_dac_nids,
10118 .hp_nid = 0x03,
10119 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10120 .channel_mode = alc262_modes,
10121 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010122 },
Kailang Yang272a5272007-05-14 11:00:38 +020010123 [ALC262_SONY_ASSAMD] = {
10124 .mixers = { alc262_sony_mixer },
10125 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10126 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10127 .dac_nids = alc262_dac_nids,
10128 .hp_nid = 0x02,
10129 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10130 .channel_mode = alc262_modes,
10131 .input_mux = &alc262_capture_source,
10132 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010133 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010134 },
10135 [ALC262_BENQ_T31] = {
10136 .mixers = { alc262_benq_t31_mixer },
10137 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10138 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10139 .dac_nids = alc262_dac_nids,
10140 .hp_nid = 0x03,
10141 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10142 .channel_mode = alc262_modes,
10143 .input_mux = &alc262_capture_source,
10144 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010145 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010146 },
Tobin Davisf651b502007-10-26 12:40:47 +020010147 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010148 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10149 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010150 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10151 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010152 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10153 .channel_mode = alc262_modes,
10154 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010155 .adc_nids = alc262_adc_nids, /* ADC0 */
10156 .capsrc_nids = alc262_capsrc_nids,
10157 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010158 .unsol_event = alc262_ultra_unsol_event,
10159 .init_hook = alc262_ultra_automute,
10160 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010161 [ALC262_LENOVO_3000] = {
10162 .mixers = { alc262_lenovo_3000_mixer },
10163 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10164 alc262_lenovo_3000_unsol_verbs },
10165 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10166 .dac_nids = alc262_dac_nids,
10167 .hp_nid = 0x03,
10168 .dig_out_nid = ALC262_DIGOUT_NID,
10169 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10170 .channel_mode = alc262_modes,
10171 .input_mux = &alc262_fujitsu_capture_source,
10172 .unsol_event = alc262_lenovo_3000_unsol_event,
10173 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010174 [ALC262_NEC] = {
10175 .mixers = { alc262_nec_mixer },
10176 .init_verbs = { alc262_nec_verbs },
10177 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10178 .dac_nids = alc262_dac_nids,
10179 .hp_nid = 0x03,
10180 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10181 .channel_mode = alc262_modes,
10182 .input_mux = &alc262_capture_source,
10183 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010184 [ALC262_TOSHIBA_S06] = {
10185 .mixers = { alc262_toshiba_s06_mixer },
10186 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10187 alc262_eapd_verbs },
10188 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10189 .capsrc_nids = alc262_dmic_capsrc_nids,
10190 .dac_nids = alc262_dac_nids,
10191 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10192 .dig_out_nid = ALC262_DIGOUT_NID,
10193 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10194 .channel_mode = alc262_modes,
10195 .input_mux = &alc262_dmic_capture_source,
10196 .unsol_event = alc262_toshiba_s06_unsol_event,
10197 .init_hook = alc262_toshiba_s06_init_hook,
10198 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010199};
10200
10201static int patch_alc262(struct hda_codec *codec)
10202{
10203 struct alc_spec *spec;
10204 int board_config;
10205 int err;
10206
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010207 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010208 if (spec == NULL)
10209 return -ENOMEM;
10210
10211 codec->spec = spec;
10212#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010213 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10214 * under-run
10215 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010216 {
10217 int tmp;
10218 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10219 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10220 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10221 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10222 }
10223#endif
10224
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010225 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10226
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010227 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10228 alc262_models,
10229 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010230
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010231 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010232 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10233 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010234 board_config = ALC262_AUTO;
10235 }
10236
10237 if (board_config == ALC262_AUTO) {
10238 /* automatic parse from the BIOS config */
10239 err = alc262_parse_auto_config(codec);
10240 if (err < 0) {
10241 alc_free(codec);
10242 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010243 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010244 printk(KERN_INFO
10245 "hda_codec: Cannot set up configuration "
10246 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010247 board_config = ALC262_BASIC;
10248 }
10249 }
10250
10251 if (board_config != ALC262_AUTO)
10252 setup_preset(spec, &alc262_presets[board_config]);
10253
10254 spec->stream_name_analog = "ALC262 Analog";
10255 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10256 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010257
Kailang Yangdf694da2005-12-05 19:42:22 +010010258 spec->stream_name_digital = "ALC262 Digital";
10259 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10260 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010262 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010263 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010264 unsigned int wcap = get_wcaps(codec, 0x07);
10265
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010266 /* get type */
10267 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010268 if (wcap != AC_WID_AUD_IN) {
10269 spec->adc_nids = alc262_adc_nids_alt;
10270 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010271 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010272 spec->mixers[spec->num_mixers] =
10273 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010274 spec->num_mixers++;
10275 } else {
10276 spec->adc_nids = alc262_adc_nids;
10277 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010278 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010279 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10280 spec->num_mixers++;
10281 }
10282 }
10283
Takashi Iwai2134ea42008-01-10 16:53:55 +010010284 spec->vmaster_nid = 0x0c;
10285
Kailang Yangdf694da2005-12-05 19:42:22 +010010286 codec->patch_ops = alc_patch_ops;
10287 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010288 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010289#ifdef CONFIG_SND_HDA_POWER_SAVE
10290 if (!spec->loopback.amplist)
10291 spec->loopback.amplist = alc262_loopbacks;
10292#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010293
Kailang Yangdf694da2005-12-05 19:42:22 +010010294 return 0;
10295}
10296
Kailang Yangdf694da2005-12-05 19:42:22 +010010297/*
Kailang Yanga361d842007-06-05 12:30:55 +020010298 * ALC268 channel source setting (2 channel)
10299 */
10300#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10301#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010302
Kailang Yanga361d842007-06-05 12:30:55 +020010303static hda_nid_t alc268_dac_nids[2] = {
10304 /* front, hp */
10305 0x02, 0x03
10306};
10307
10308static hda_nid_t alc268_adc_nids[2] = {
10309 /* ADC0-1 */
10310 0x08, 0x07
10311};
10312
10313static hda_nid_t alc268_adc_nids_alt[1] = {
10314 /* ADC0 */
10315 0x08
10316};
10317
Takashi Iwaie1406342008-02-11 18:32:32 +010010318static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10319
Kailang Yanga361d842007-06-05 12:30:55 +020010320static struct snd_kcontrol_new alc268_base_mixer[] = {
10321 /* output mixer control */
10322 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10323 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10324 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010326 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10327 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10328 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010329 { }
10330};
10331
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010332/* bind Beep switches of both NID 0x0f and 0x10 */
10333static struct hda_bind_ctls alc268_bind_beep_sw = {
10334 .ops = &snd_hda_bind_sw,
10335 .values = {
10336 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10337 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10338 0
10339 },
10340};
10341
10342static struct snd_kcontrol_new alc268_beep_mixer[] = {
10343 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10344 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10345 { }
10346};
10347
Kailang Yangd1a991a2007-08-15 16:21:59 +020010348static struct hda_verb alc268_eapd_verbs[] = {
10349 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10350 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10351 { }
10352};
10353
Takashi Iwaid2738092007-08-16 14:59:45 +020010354/* Toshiba specific */
10355#define alc268_toshiba_automute alc262_hippo_automute
10356
10357static struct hda_verb alc268_toshiba_verbs[] = {
10358 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10359 { } /* end */
10360};
10361
Kailang Yang8ef355d2008-08-26 13:10:22 +020010362static struct hda_input_mux alc268_acer_lc_capture_source = {
10363 .num_items = 2,
10364 .items = {
10365 { "i-Mic", 0x6 },
10366 { "E-Mic", 0x0 },
10367 },
10368};
10369
Takashi Iwaid2738092007-08-16 14:59:45 +020010370/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010371/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010372static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10373 .ops = &snd_hda_bind_vol,
10374 .values = {
10375 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10376 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10377 0
10378 },
10379};
10380
Takashi Iwai889c4392007-08-23 18:56:52 +020010381/* mute/unmute internal speaker according to the hp jack and mute state */
10382static void alc268_acer_automute(struct hda_codec *codec, int force)
10383{
10384 struct alc_spec *spec = codec->spec;
10385 unsigned int mute;
10386
10387 if (force || !spec->sense_updated) {
10388 unsigned int present;
10389 present = snd_hda_codec_read(codec, 0x14, 0,
10390 AC_VERB_GET_PIN_SENSE, 0);
10391 spec->jack_present = (present & 0x80000000) != 0;
10392 spec->sense_updated = 1;
10393 }
10394 if (spec->jack_present)
10395 mute = HDA_AMP_MUTE; /* mute internal speaker */
10396 else /* unmute internal speaker if necessary */
10397 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10398 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10399 HDA_AMP_MUTE, mute);
10400}
10401
10402
10403/* bind hp and internal speaker mute (with plug check) */
10404static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10405 struct snd_ctl_elem_value *ucontrol)
10406{
10407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10408 long *valp = ucontrol->value.integer.value;
10409 int change;
10410
10411 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10412 HDA_AMP_MUTE,
10413 valp[0] ? 0 : HDA_AMP_MUTE);
10414 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10415 HDA_AMP_MUTE,
10416 valp[1] ? 0 : HDA_AMP_MUTE);
10417 if (change)
10418 alc268_acer_automute(codec, 0);
10419 return change;
10420}
Takashi Iwaid2738092007-08-16 14:59:45 +020010421
Kailang Yang8ef355d2008-08-26 13:10:22 +020010422static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10423 /* output mixer control */
10424 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10425 {
10426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10427 .name = "Master Playback Switch",
10428 .info = snd_hda_mixer_amp_switch_info,
10429 .get = snd_hda_mixer_amp_switch_get,
10430 .put = alc268_acer_master_sw_put,
10431 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10432 },
10433 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10434 { }
10435};
10436
Takashi Iwaid2738092007-08-16 14:59:45 +020010437static struct snd_kcontrol_new alc268_acer_mixer[] = {
10438 /* output mixer control */
10439 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10440 {
10441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10442 .name = "Master Playback Switch",
10443 .info = snd_hda_mixer_amp_switch_info,
10444 .get = snd_hda_mixer_amp_switch_get,
10445 .put = alc268_acer_master_sw_put,
10446 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10447 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010448 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10449 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10450 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010451 { }
10452};
10453
Kailang Yang8ef355d2008-08-26 13:10:22 +020010454static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10455 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10457 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10458 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10459 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10461 { }
10462};
10463
Takashi Iwaid2738092007-08-16 14:59:45 +020010464static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10466 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010471 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10472 { }
10473};
10474
10475/* unsolicited event for HP jack sensing */
10476static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10477 unsigned int res)
10478{
Takashi Iwai889c4392007-08-23 18:56:52 +020010479 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010480 return;
10481 alc268_toshiba_automute(codec);
10482}
10483
10484static void alc268_acer_unsol_event(struct hda_codec *codec,
10485 unsigned int res)
10486{
Takashi Iwai889c4392007-08-23 18:56:52 +020010487 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010488 return;
10489 alc268_acer_automute(codec, 1);
10490}
10491
Takashi Iwai889c4392007-08-23 18:56:52 +020010492static void alc268_acer_init_hook(struct hda_codec *codec)
10493{
10494 alc268_acer_automute(codec, 1);
10495}
10496
Kailang Yang8ef355d2008-08-26 13:10:22 +020010497/* toggle speaker-output according to the hp-jack state */
10498static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10499{
10500 unsigned int present;
10501 unsigned char bits;
10502
10503 present = snd_hda_codec_read(codec, 0x15, 0,
10504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10505 bits = present ? AMP_IN_MUTE(0) : 0;
10506 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10507 AMP_IN_MUTE(0), bits);
10508 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10509 AMP_IN_MUTE(0), bits);
10510}
10511
10512
10513static void alc268_acer_mic_automute(struct hda_codec *codec)
10514{
10515 unsigned int present;
10516
10517 present = snd_hda_codec_read(codec, 0x18, 0,
10518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10519 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10520 present ? 0x0 : 0x6);
10521}
10522
10523static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10524 unsigned int res)
10525{
10526 if ((res >> 26) == ALC880_HP_EVENT)
10527 alc268_aspire_one_speaker_automute(codec);
10528 if ((res >> 26) == ALC880_MIC_EVENT)
10529 alc268_acer_mic_automute(codec);
10530}
10531
10532static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10533{
10534 alc268_aspire_one_speaker_automute(codec);
10535 alc268_acer_mic_automute(codec);
10536}
10537
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010538static struct snd_kcontrol_new alc268_dell_mixer[] = {
10539 /* output mixer control */
10540 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10541 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10542 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10544 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10545 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10546 { }
10547};
10548
10549static struct hda_verb alc268_dell_verbs[] = {
10550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10552 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10553 { }
10554};
10555
10556/* mute/unmute internal speaker according to the hp jack and mute state */
10557static void alc268_dell_automute(struct hda_codec *codec)
10558{
10559 unsigned int present;
10560 unsigned int mute;
10561
10562 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10563 if (present & 0x80000000)
10564 mute = HDA_AMP_MUTE;
10565 else
10566 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10567 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10568 HDA_AMP_MUTE, mute);
10569}
10570
10571static void alc268_dell_unsol_event(struct hda_codec *codec,
10572 unsigned int res)
10573{
10574 if ((res >> 26) != ALC880_HP_EVENT)
10575 return;
10576 alc268_dell_automute(codec);
10577}
10578
10579#define alc268_dell_init_hook alc268_dell_automute
10580
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010581static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10583 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10584 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10586 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10587 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10588 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10589 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10590 { }
10591};
10592
10593static struct hda_verb alc267_quanta_il1_verbs[] = {
10594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10596 { }
10597};
10598
10599static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10600{
10601 unsigned int present;
10602
10603 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10604 & AC_PINSENSE_PRESENCE;
10605 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10606 present ? 0 : PIN_OUT);
10607}
10608
10609static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10610{
10611 unsigned int present;
10612
10613 present = snd_hda_codec_read(codec, 0x18, 0,
10614 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10615 snd_hda_codec_write(codec, 0x23, 0,
10616 AC_VERB_SET_CONNECT_SEL,
10617 present ? 0x00 : 0x01);
10618}
10619
10620static void alc267_quanta_il1_automute(struct hda_codec *codec)
10621{
10622 alc267_quanta_il1_hp_automute(codec);
10623 alc267_quanta_il1_mic_automute(codec);
10624}
10625
10626static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10627 unsigned int res)
10628{
10629 switch (res >> 26) {
10630 case ALC880_HP_EVENT:
10631 alc267_quanta_il1_hp_automute(codec);
10632 break;
10633 case ALC880_MIC_EVENT:
10634 alc267_quanta_il1_mic_automute(codec);
10635 break;
10636 }
10637}
10638
Kailang Yanga361d842007-06-05 12:30:55 +020010639/*
10640 * generic initialization of ADC, input mixers and output mixers
10641 */
10642static struct hda_verb alc268_base_init_verbs[] = {
10643 /* Unmute DAC0-1 and set vol = 0 */
10644 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10645 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10646 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10647 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10650
10651 /*
10652 * Set up output mixers (0x0c - 0x0e)
10653 */
10654 /* set vol=0 to output mixers */
10655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10658 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10659
10660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10661 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10662
10663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10669 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10670 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10671
10672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10674 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10678 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010679
10680 /* set PCBEEP vol = 0, mute connections */
10681 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10683 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010684
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010685 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010686
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010687 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10689 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010691
Kailang Yanga361d842007-06-05 12:30:55 +020010692 { }
10693};
10694
10695/*
10696 * generic initialization of ADC, input mixers and output mixers
10697 */
10698static struct hda_verb alc268_volume_init_verbs[] = {
10699 /* set output DAC */
10700 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10701 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10702 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10703 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10704
10705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10708 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10709 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10710
10711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10715 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10716
10717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10718 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10720 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10721
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010722 /* set PCBEEP vol = 0, mute connections */
10723 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010726
10727 { }
10728};
10729
10730#define alc268_mux_enum_info alc_mux_enum_info
10731#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010732#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010733
10734static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10735 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10736 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10737 {
10738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10739 /* The multiple "Capture Source" controls confuse alsamixer
10740 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010741 */
10742 /* .name = "Capture Source", */
10743 .name = "Input Source",
10744 .count = 1,
10745 .info = alc268_mux_enum_info,
10746 .get = alc268_mux_enum_get,
10747 .put = alc268_mux_enum_put,
10748 },
10749 { } /* end */
10750};
10751
10752static struct snd_kcontrol_new alc268_capture_mixer[] = {
10753 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10754 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10755 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10756 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10757 {
10758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10759 /* The multiple "Capture Source" controls confuse alsamixer
10760 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010761 */
10762 /* .name = "Capture Source", */
10763 .name = "Input Source",
10764 .count = 2,
10765 .info = alc268_mux_enum_info,
10766 .get = alc268_mux_enum_get,
10767 .put = alc268_mux_enum_put,
10768 },
10769 { } /* end */
10770};
10771
10772static struct hda_input_mux alc268_capture_source = {
10773 .num_items = 4,
10774 .items = {
10775 { "Mic", 0x0 },
10776 { "Front Mic", 0x1 },
10777 { "Line", 0x2 },
10778 { "CD", 0x3 },
10779 },
10780};
10781
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010782static struct hda_input_mux alc268_acer_capture_source = {
10783 .num_items = 3,
10784 .items = {
10785 { "Mic", 0x0 },
10786 { "Internal Mic", 0x6 },
10787 { "Line", 0x2 },
10788 },
10789};
10790
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010791#ifdef CONFIG_SND_DEBUG
10792static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010793 /* Volume widgets */
10794 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10795 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10796 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10797 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10798 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10799 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10800 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10801 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10802 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10803 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10804 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10805 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10806 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010807 /* The below appears problematic on some hardwares */
10808 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010809 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10810 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10811 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10812 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10813
10814 /* Modes for retasking pin widgets */
10815 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10816 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10817 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10818 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10819
10820 /* Controls for GPIO pins, assuming they are configured as outputs */
10821 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10822 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10823 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10824 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10825
10826 /* Switches to allow the digital SPDIF output pin to be enabled.
10827 * The ALC268 does not have an SPDIF input.
10828 */
10829 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10830
10831 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10832 * this output to turn on an external amplifier.
10833 */
10834 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10835 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10836
10837 { } /* end */
10838};
10839#endif
10840
Kailang Yanga361d842007-06-05 12:30:55 +020010841/* create input playback/capture controls for the given pin */
10842static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10843 const char *ctlname, int idx)
10844{
10845 char name[32];
10846 int err;
10847
10848 sprintf(name, "%s Playback Volume", ctlname);
10849 if (nid == 0x14) {
10850 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10851 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10852 HDA_OUTPUT));
10853 if (err < 0)
10854 return err;
10855 } else if (nid == 0x15) {
10856 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10857 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10858 HDA_OUTPUT));
10859 if (err < 0)
10860 return err;
10861 } else
10862 return -1;
10863 sprintf(name, "%s Playback Switch", ctlname);
10864 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10865 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10866 if (err < 0)
10867 return err;
10868 return 0;
10869}
10870
10871/* add playback controls from the parsed DAC table */
10872static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10873 const struct auto_pin_cfg *cfg)
10874{
10875 hda_nid_t nid;
10876 int err;
10877
10878 spec->multiout.num_dacs = 2; /* only use one dac */
10879 spec->multiout.dac_nids = spec->private_dac_nids;
10880 spec->multiout.dac_nids[0] = 2;
10881 spec->multiout.dac_nids[1] = 3;
10882
10883 nid = cfg->line_out_pins[0];
10884 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020010885 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020010886
10887 nid = cfg->speaker_pins[0];
10888 if (nid == 0x1d) {
10889 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10890 "Speaker Playback Volume",
10891 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10892 if (err < 0)
10893 return err;
10894 }
10895 nid = cfg->hp_pins[0];
10896 if (nid)
10897 alc268_new_analog_output(spec, nid, "Headphone", 0);
10898
10899 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10900 if (nid == 0x16) {
10901 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10902 "Mono Playback Switch",
10903 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10904 if (err < 0)
10905 return err;
10906 }
Kailang Yangea1fb292008-08-26 12:58:38 +020010907 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020010908}
10909
10910/* create playback/capture controls for input pins */
10911static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10912 const struct auto_pin_cfg *cfg)
10913{
10914 struct hda_input_mux *imux = &spec->private_imux;
10915 int i, idx1;
10916
10917 for (i = 0; i < AUTO_PIN_LAST; i++) {
10918 switch(cfg->input_pins[i]) {
10919 case 0x18:
10920 idx1 = 0; /* Mic 1 */
10921 break;
10922 case 0x19:
10923 idx1 = 1; /* Mic 2 */
10924 break;
10925 case 0x1a:
10926 idx1 = 2; /* Line In */
10927 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020010928 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020010929 idx1 = 3; /* CD */
10930 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010931 case 0x12:
10932 case 0x13:
10933 idx1 = 6; /* digital mics */
10934 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010935 default:
10936 continue;
10937 }
10938 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10939 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020010940 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020010941 }
10942 return 0;
10943}
10944
10945static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10946{
10947 struct alc_spec *spec = codec->spec;
10948 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10949 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10950 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10951 unsigned int dac_vol1, dac_vol2;
10952
10953 if (speaker_nid) {
10954 snd_hda_codec_write(codec, speaker_nid, 0,
10955 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10956 snd_hda_codec_write(codec, 0x0f, 0,
10957 AC_VERB_SET_AMP_GAIN_MUTE,
10958 AMP_IN_UNMUTE(1));
10959 snd_hda_codec_write(codec, 0x10, 0,
10960 AC_VERB_SET_AMP_GAIN_MUTE,
10961 AMP_IN_UNMUTE(1));
10962 } else {
10963 snd_hda_codec_write(codec, 0x0f, 0,
10964 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10965 snd_hda_codec_write(codec, 0x10, 0,
10966 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10967 }
10968
10969 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020010970 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010971 dac_vol2 = AMP_OUT_ZERO;
10972 else if (line_nid == 0x15)
10973 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020010974 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010975 dac_vol2 = AMP_OUT_ZERO;
10976 else if (hp_nid == 0x15)
10977 dac_vol1 = AMP_OUT_ZERO;
10978 if (line_nid != 0x16 || hp_nid != 0x16 ||
10979 spec->autocfg.line_out_pins[1] != 0x16 ||
10980 spec->autocfg.line_out_pins[2] != 0x16)
10981 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10982
10983 snd_hda_codec_write(codec, 0x02, 0,
10984 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10985 snd_hda_codec_write(codec, 0x03, 0,
10986 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10987}
10988
10989/* pcm configuration: identiacal with ALC880 */
10990#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10991#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010992#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010993#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10994
10995/*
10996 * BIOS auto configuration
10997 */
10998static int alc268_parse_auto_config(struct hda_codec *codec)
10999{
11000 struct alc_spec *spec = codec->spec;
11001 int err;
11002 static hda_nid_t alc268_ignore[] = { 0 };
11003
11004 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11005 alc268_ignore);
11006 if (err < 0)
11007 return err;
11008 if (!spec->autocfg.line_outs)
11009 return 0; /* can't find valid BIOS pin config */
11010
11011 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11012 if (err < 0)
11013 return err;
11014 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11015 if (err < 0)
11016 return err;
11017
11018 spec->multiout.max_channels = 2;
11019
11020 /* digital only support output */
11021 if (spec->autocfg.dig_out_pin)
11022 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11023
11024 if (spec->kctl_alloc)
11025 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11026
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011027 if (spec->autocfg.speaker_pins[0] != 0x1d)
11028 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11029
Kailang Yanga361d842007-06-05 12:30:55 +020011030 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11031 spec->num_mux_defs = 1;
11032 spec->input_mux = &spec->private_imux;
11033
Takashi Iwai776e1842007-08-29 15:07:11 +020011034 err = alc_auto_add_mic_boost(codec);
11035 if (err < 0)
11036 return err;
11037
Kailang Yanga361d842007-06-05 12:30:55 +020011038 return 1;
11039}
11040
11041#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11042#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11043#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11044
11045/* init callback for auto-configuration model -- overriding the default init */
11046static void alc268_auto_init(struct hda_codec *codec)
11047{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011048 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011049 alc268_auto_init_multi_out(codec);
11050 alc268_auto_init_hp_out(codec);
11051 alc268_auto_init_mono_speaker_out(codec);
11052 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011053 if (spec->unsol_event)
11054 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011055}
11056
11057/*
11058 * configuration and preset
11059 */
11060static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011061 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011062 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011063 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011064 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011065 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011066 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011067 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011068#ifdef CONFIG_SND_DEBUG
11069 [ALC268_TEST] = "test",
11070#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011071 [ALC268_AUTO] = "auto",
11072};
11073
11074static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011075 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011076 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011077 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011078 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011079 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011080 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11081 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011082 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011083 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011084 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011085 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011086 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011087 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011088 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011089 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011090 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011091 {}
11092};
11093
11094static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011095 [ALC267_QUANTA_IL1] = {
11096 .mixers = { alc267_quanta_il1_mixer },
11097 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11098 alc267_quanta_il1_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,
11103 .hp_nid = 0x03,
11104 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11105 .channel_mode = alc268_modes,
11106 .input_mux = &alc268_capture_source,
11107 .unsol_event = alc267_quanta_il1_unsol_event,
11108 .init_hook = alc267_quanta_il1_automute,
11109 },
Kailang Yanga361d842007-06-05 12:30:55 +020011110 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011111 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11112 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011113 .init_verbs = { alc268_base_init_verbs },
11114 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11115 .dac_nids = alc268_dac_nids,
11116 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11117 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011118 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011119 .hp_nid = 0x03,
11120 .dig_out_nid = ALC268_DIGOUT_NID,
11121 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11122 .channel_mode = alc268_modes,
11123 .input_mux = &alc268_capture_source,
11124 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011125 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011126 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11127 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011128 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11129 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011130 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11131 .dac_nids = alc268_dac_nids,
11132 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11133 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011134 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011135 .hp_nid = 0x03,
11136 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11137 .channel_mode = alc268_modes,
11138 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011139 .unsol_event = alc268_toshiba_unsol_event,
11140 .init_hook = alc268_toshiba_automute,
11141 },
11142 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011143 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11144 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011145 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11146 alc268_acer_verbs },
11147 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11148 .dac_nids = alc268_dac_nids,
11149 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11150 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011151 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011152 .hp_nid = 0x02,
11153 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11154 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011155 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011156 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011157 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011158 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011159 [ALC268_ACER_ASPIRE_ONE] = {
11160 .mixers = { alc268_acer_aspire_one_mixer,
11161 alc268_capture_alt_mixer },
11162 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11163 alc268_acer_aspire_one_verbs },
11164 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11165 .dac_nids = alc268_dac_nids,
11166 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11167 .adc_nids = alc268_adc_nids_alt,
11168 .capsrc_nids = alc268_capsrc_nids,
11169 .hp_nid = 0x03,
11170 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11171 .channel_mode = alc268_modes,
11172 .input_mux = &alc268_acer_lc_capture_source,
11173 .unsol_event = alc268_acer_lc_unsol_event,
11174 .init_hook = alc268_acer_lc_init_hook,
11175 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011176 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011177 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011178 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11179 alc268_dell_verbs },
11180 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11181 .dac_nids = alc268_dac_nids,
11182 .hp_nid = 0x02,
11183 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11184 .channel_mode = alc268_modes,
11185 .unsol_event = alc268_dell_unsol_event,
11186 .init_hook = alc268_dell_init_hook,
11187 .input_mux = &alc268_capture_source,
11188 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011189 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011190 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11191 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011192 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11193 alc268_toshiba_verbs },
11194 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11195 .dac_nids = alc268_dac_nids,
11196 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11197 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011198 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011199 .hp_nid = 0x03,
11200 .dig_out_nid = ALC268_DIGOUT_NID,
11201 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11202 .channel_mode = alc268_modes,
11203 .input_mux = &alc268_capture_source,
11204 .unsol_event = alc268_toshiba_unsol_event,
11205 .init_hook = alc268_toshiba_automute
11206 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011207#ifdef CONFIG_SND_DEBUG
11208 [ALC268_TEST] = {
11209 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11210 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11211 alc268_volume_init_verbs },
11212 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11213 .dac_nids = alc268_dac_nids,
11214 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11215 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011216 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011217 .hp_nid = 0x03,
11218 .dig_out_nid = ALC268_DIGOUT_NID,
11219 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11220 .channel_mode = alc268_modes,
11221 .input_mux = &alc268_capture_source,
11222 },
11223#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011224};
11225
11226static int patch_alc268(struct hda_codec *codec)
11227{
11228 struct alc_spec *spec;
11229 int board_config;
11230 int err;
11231
11232 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11233 if (spec == NULL)
11234 return -ENOMEM;
11235
11236 codec->spec = spec;
11237
11238 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11239 alc268_models,
11240 alc268_cfg_tbl);
11241
11242 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11243 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11244 "trying auto-probe from BIOS...\n");
11245 board_config = ALC268_AUTO;
11246 }
11247
11248 if (board_config == ALC268_AUTO) {
11249 /* automatic parse from the BIOS config */
11250 err = alc268_parse_auto_config(codec);
11251 if (err < 0) {
11252 alc_free(codec);
11253 return err;
11254 } else if (!err) {
11255 printk(KERN_INFO
11256 "hda_codec: Cannot set up configuration "
11257 "from BIOS. Using base mode...\n");
11258 board_config = ALC268_3ST;
11259 }
11260 }
11261
11262 if (board_config != ALC268_AUTO)
11263 setup_preset(spec, &alc268_presets[board_config]);
11264
Kailang Yang2f893282008-05-27 12:14:47 +020011265 if (codec->vendor_id == 0x10ec0267) {
11266 spec->stream_name_analog = "ALC267 Analog";
11267 spec->stream_name_digital = "ALC267 Digital";
11268 } else {
11269 spec->stream_name_analog = "ALC268 Analog";
11270 spec->stream_name_digital = "ALC268 Digital";
11271 }
11272
Kailang Yanga361d842007-06-05 12:30:55 +020011273 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11274 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011275 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011276
Kailang Yanga361d842007-06-05 12:30:55 +020011277 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11278
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011279 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11280 /* override the amp caps for beep generator */
11281 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11282 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11283 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11284 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11285 (0 << AC_AMPCAP_MUTE_SHIFT));
11286
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011287 if (!spec->adc_nids && spec->input_mux) {
11288 /* check whether NID 0x07 is valid */
11289 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011290 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011291
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011292 /* get type */
11293 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011294 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011295 spec->adc_nids = alc268_adc_nids_alt;
11296 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11297 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011298 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011299 spec->num_mixers++;
11300 } else {
11301 spec->adc_nids = alc268_adc_nids;
11302 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11303 spec->mixers[spec->num_mixers] =
11304 alc268_capture_mixer;
11305 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011306 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011307 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011308 /* set default input source */
11309 for (i = 0; i < spec->num_adc_nids; i++)
11310 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11311 0, AC_VERB_SET_CONNECT_SEL,
11312 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011313 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011314
11315 spec->vmaster_nid = 0x02;
11316
Kailang Yanga361d842007-06-05 12:30:55 +020011317 codec->patch_ops = alc_patch_ops;
11318 if (board_config == ALC268_AUTO)
11319 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011320
Kailang Yanga361d842007-06-05 12:30:55 +020011321 return 0;
11322}
11323
11324/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011325 * ALC269 channel source setting (2 channel)
11326 */
11327#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11328
11329#define alc269_dac_nids alc260_dac_nids
11330
11331static hda_nid_t alc269_adc_nids[1] = {
11332 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011333 0x08,
11334};
11335
Takashi Iwaie01bf502008-08-21 16:25:07 +020011336static hda_nid_t alc269_capsrc_nids[1] = {
11337 0x23,
11338};
11339
11340/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11341 * not a mux!
11342 */
11343
Kailang Yangf53281e2008-07-18 12:36:43 +020011344static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11345 .num_items = 2,
11346 .items = {
11347 { "i-Mic", 0x5 },
11348 { "e-Mic", 0x0 },
11349 },
11350};
11351
11352static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11353 .num_items = 2,
11354 .items = {
11355 { "i-Mic", 0x1 },
11356 { "e-Mic", 0x0 },
11357 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011358};
11359
11360#define alc269_modes alc260_modes
11361#define alc269_capture_source alc880_lg_lw_capture_source
11362
11363static struct snd_kcontrol_new alc269_base_mixer[] = {
11364 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11365 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011370 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11371 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11375 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11377 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11378 { } /* end */
11379};
11380
Kailang Yangf53281e2008-07-18 12:36:43 +020011381/* bind volumes of both NID 0x0c and 0x0d */
11382static struct hda_bind_ctls alc269_epc_bind_vol = {
11383 .ops = &snd_hda_bind_vol,
11384 .values = {
11385 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11386 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11387 0
11388 },
11389};
11390
11391static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11392 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11393 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11394 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11395 { } /* end */
11396};
11397
Kailang Yangf6a92242007-12-13 16:52:54 +010011398/* capture mixer elements */
11399static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011400 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11401 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011402 {
11403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11404 /* The multiple "Capture Source" controls confuse alsamixer
11405 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011406 */
11407 /* .name = "Capture Source", */
11408 .name = "Input Source",
11409 .count = 1,
11410 .info = alc_mux_enum_info,
11411 .get = alc_mux_enum_get,
11412 .put = alc_mux_enum_put,
11413 },
11414 { } /* end */
11415};
11416
Kailang Yangf53281e2008-07-18 12:36:43 +020011417/* capture mixer elements */
11418static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11419 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11420 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11421 { } /* end */
11422};
11423
Takashi Iwai2005af22008-08-20 18:38:26 +020011424/* beep control */
11425static struct snd_kcontrol_new alc269_beep_mixer[] = {
11426 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11427 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11428 { } /* end */
11429};
11430
Kailang Yangf6a92242007-12-13 16:52:54 +010011431/*
11432 * generic initialization of ADC, input mixers and output mixers
11433 */
11434static struct hda_verb alc269_init_verbs[] = {
11435 /*
11436 * Unmute ADC0 and set the default input to mic-in
11437 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011439
11440 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11441 * analog-loopback mixer widget
11442 * Note: PASD motherboards uses the Line In 2 as the input for
11443 * front panel mic (mic 2)
11444 */
11445 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11451
11452 /*
11453 * Set up output mixers (0x0c - 0x0e)
11454 */
11455 /* set vol=0 to output mixers */
11456 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11457 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11458
11459 /* set up input amps for analog loopback */
11460 /* Amp Indices: DAC = 0, mixer = 1 */
11461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11467
11468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11475
11476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11479 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11480 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11482 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11483
11484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11486
11487 /* FIXME: use matrix-type input source selection */
11488 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11489 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11494
11495 /* set EAPD */
11496 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11497 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11498 { }
11499};
11500
Kailang Yangf53281e2008-07-18 12:36:43 +020011501static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11503 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11504 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11506 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11507 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11508 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11509 {}
11510};
11511
11512static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11513 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11514 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11515 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11519 {}
11520};
11521
11522/* toggle speaker-output according to the hp-jack state */
11523static void alc269_speaker_automute(struct hda_codec *codec)
11524{
11525 unsigned int present;
11526 unsigned int bits;
11527
11528 present = snd_hda_codec_read(codec, 0x15, 0,
11529 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11530 bits = present ? AMP_IN_MUTE(0) : 0;
11531 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11532 AMP_IN_MUTE(0), bits);
11533 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11534 AMP_IN_MUTE(0), bits);
11535}
11536
11537static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11538{
11539 unsigned int present;
11540
11541 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11542 & AC_PINSENSE_PRESENCE;
11543 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11544 present ? 0 : 5);
11545}
11546
11547static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11548{
11549 unsigned int present;
11550
11551 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11552 & AC_PINSENSE_PRESENCE;
11553 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11554 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11555 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11556 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11557}
11558
11559/* unsolicited event for HP jack sensing */
11560static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11561 unsigned int res)
11562{
11563 if ((res >> 26) == ALC880_HP_EVENT)
11564 alc269_speaker_automute(codec);
11565
11566 if ((res >> 26) == ALC880_MIC_EVENT)
11567 alc269_eeepc_dmic_automute(codec);
11568}
11569
11570static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11571{
11572 alc269_speaker_automute(codec);
11573 alc269_eeepc_dmic_automute(codec);
11574}
11575
11576/* unsolicited event for HP jack sensing */
11577static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
Kailang Yangea1fb292008-08-26 12:58:38 +020011578 unsigned int res)
Kailang Yangf53281e2008-07-18 12:36:43 +020011579{
11580 if ((res >> 26) == ALC880_HP_EVENT)
11581 alc269_speaker_automute(codec);
11582
11583 if ((res >> 26) == ALC880_MIC_EVENT)
11584 alc269_eeepc_amic_automute(codec);
11585}
11586
11587static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11588{
11589 alc269_speaker_automute(codec);
11590 alc269_eeepc_amic_automute(codec);
11591}
11592
Kailang Yangf6a92242007-12-13 16:52:54 +010011593/* add playback controls from the parsed DAC table */
11594static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11595 const struct auto_pin_cfg *cfg)
11596{
11597 hda_nid_t nid;
11598 int err;
11599
11600 spec->multiout.num_dacs = 1; /* only use one dac */
11601 spec->multiout.dac_nids = spec->private_dac_nids;
11602 spec->multiout.dac_nids[0] = 2;
11603
11604 nid = cfg->line_out_pins[0];
11605 if (nid) {
11606 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11607 "Front Playback Volume",
11608 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11609 if (err < 0)
11610 return err;
11611 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11612 "Front Playback Switch",
11613 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11614 if (err < 0)
11615 return err;
11616 }
11617
11618 nid = cfg->speaker_pins[0];
11619 if (nid) {
11620 if (!cfg->line_out_pins[0]) {
11621 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11622 "Speaker Playback Volume",
11623 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11624 HDA_OUTPUT));
11625 if (err < 0)
11626 return err;
11627 }
11628 if (nid == 0x16) {
11629 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11630 "Speaker Playback Switch",
11631 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11632 HDA_OUTPUT));
11633 if (err < 0)
11634 return err;
11635 } else {
11636 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11637 "Speaker Playback Switch",
11638 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11639 HDA_OUTPUT));
11640 if (err < 0)
11641 return err;
11642 }
11643 }
11644 nid = cfg->hp_pins[0];
11645 if (nid) {
11646 /* spec->multiout.hp_nid = 2; */
11647 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11648 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11649 "Headphone Playback Volume",
11650 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11651 HDA_OUTPUT));
11652 if (err < 0)
11653 return err;
11654 }
11655 if (nid == 0x16) {
11656 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11657 "Headphone Playback Switch",
11658 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11659 HDA_OUTPUT));
11660 if (err < 0)
11661 return err;
11662 } else {
11663 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11664 "Headphone Playback Switch",
11665 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11666 HDA_OUTPUT));
11667 if (err < 0)
11668 return err;
11669 }
11670 }
11671 return 0;
11672}
11673
11674#define alc269_auto_create_analog_input_ctls \
11675 alc880_auto_create_analog_input_ctls
11676
11677#ifdef CONFIG_SND_HDA_POWER_SAVE
11678#define alc269_loopbacks alc880_loopbacks
11679#endif
11680
11681/* pcm configuration: identiacal with ALC880 */
11682#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11683#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11684#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11685#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11686
11687/*
11688 * BIOS auto configuration
11689 */
11690static int alc269_parse_auto_config(struct hda_codec *codec)
11691{
11692 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020011693 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010011694 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11695
11696 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11697 alc269_ignore);
11698 if (err < 0)
11699 return err;
11700
11701 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11702 if (err < 0)
11703 return err;
11704 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11705 if (err < 0)
11706 return err;
11707
11708 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11709
11710 if (spec->autocfg.dig_out_pin)
11711 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11712
11713 if (spec->kctl_alloc)
11714 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11715
Takashi Iwai2005af22008-08-20 18:38:26 +020011716 /* create a beep mixer control if the pin 0x1d isn't assigned */
11717 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
11718 if (spec->autocfg.input_pins[i] == 0x1d)
11719 break;
11720 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
11721 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
11722
Kailang Yangf6a92242007-12-13 16:52:54 +010011723 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11724 spec->num_mux_defs = 1;
11725 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020011726 /* set default input source */
11727 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
11728 0, AC_VERB_SET_CONNECT_SEL,
11729 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010011730
11731 err = alc_auto_add_mic_boost(codec);
11732 if (err < 0)
11733 return err;
11734
Kailang Yangf53281e2008-07-18 12:36:43 +020011735 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11736 spec->num_mixers++;
11737
Kailang Yangf6a92242007-12-13 16:52:54 +010011738 return 1;
11739}
11740
11741#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11742#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11743#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11744
11745
11746/* init callback for auto-configuration model -- overriding the default init */
11747static void alc269_auto_init(struct hda_codec *codec)
11748{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011749 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011750 alc269_auto_init_multi_out(codec);
11751 alc269_auto_init_hp_out(codec);
11752 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011753 if (spec->unsol_event)
11754 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011755}
11756
11757/*
11758 * configuration and preset
11759 */
11760static const char *alc269_models[ALC269_MODEL_LAST] = {
11761 [ALC269_BASIC] = "basic",
11762};
11763
11764static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011765 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11766 ALC269_ASUS_EEEPC_P703),
11767 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11768 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010011769 {}
11770};
11771
11772static struct alc_config_preset alc269_presets[] = {
11773 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011774 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010011775 .init_verbs = { alc269_init_verbs },
11776 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11777 .dac_nids = alc269_dac_nids,
11778 .hp_nid = 0x03,
11779 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11780 .channel_mode = alc269_modes,
11781 .input_mux = &alc269_capture_source,
11782 },
Kailang Yangf53281e2008-07-18 12:36:43 +020011783 [ALC269_ASUS_EEEPC_P703] = {
11784 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11785 .init_verbs = { alc269_init_verbs,
11786 alc269_eeepc_amic_init_verbs },
11787 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11788 .dac_nids = alc269_dac_nids,
11789 .hp_nid = 0x03,
11790 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11791 .channel_mode = alc269_modes,
11792 .input_mux = &alc269_eeepc_amic_capture_source,
11793 .unsol_event = alc269_eeepc_amic_unsol_event,
11794 .init_hook = alc269_eeepc_amic_inithook,
11795 },
11796 [ALC269_ASUS_EEEPC_P901] = {
11797 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11798 .init_verbs = { alc269_init_verbs,
11799 alc269_eeepc_dmic_init_verbs },
11800 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11801 .dac_nids = alc269_dac_nids,
11802 .hp_nid = 0x03,
11803 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11804 .channel_mode = alc269_modes,
11805 .input_mux = &alc269_eeepc_dmic_capture_source,
11806 .unsol_event = alc269_eeepc_dmic_unsol_event,
11807 .init_hook = alc269_eeepc_dmic_inithook,
11808 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011809};
11810
11811static int patch_alc269(struct hda_codec *codec)
11812{
11813 struct alc_spec *spec;
11814 int board_config;
11815 int err;
11816
11817 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11818 if (spec == NULL)
11819 return -ENOMEM;
11820
11821 codec->spec = spec;
11822
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011823 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11824
Kailang Yangf6a92242007-12-13 16:52:54 +010011825 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11826 alc269_models,
11827 alc269_cfg_tbl);
11828
11829 if (board_config < 0) {
11830 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11831 "trying auto-probe from BIOS...\n");
11832 board_config = ALC269_AUTO;
11833 }
11834
11835 if (board_config == ALC269_AUTO) {
11836 /* automatic parse from the BIOS config */
11837 err = alc269_parse_auto_config(codec);
11838 if (err < 0) {
11839 alc_free(codec);
11840 return err;
11841 } else if (!err) {
11842 printk(KERN_INFO
11843 "hda_codec: Cannot set up configuration "
11844 "from BIOS. Using base mode...\n");
11845 board_config = ALC269_BASIC;
11846 }
11847 }
11848
11849 if (board_config != ALC269_AUTO)
11850 setup_preset(spec, &alc269_presets[board_config]);
11851
11852 spec->stream_name_analog = "ALC269 Analog";
11853 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11854 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11855
11856 spec->stream_name_digital = "ALC269 Digital";
11857 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11858 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11859
11860 spec->adc_nids = alc269_adc_nids;
11861 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020011862 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010011863
11864 codec->patch_ops = alc_patch_ops;
11865 if (board_config == ALC269_AUTO)
11866 spec->init_hook = alc269_auto_init;
11867#ifdef CONFIG_SND_HDA_POWER_SAVE
11868 if (!spec->loopback.amplist)
11869 spec->loopback.amplist = alc269_loopbacks;
11870#endif
11871
11872 return 0;
11873}
11874
11875/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011876 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11877 */
11878
11879/*
11880 * set the path ways for 2 channel output
11881 * need to set the codec line out and mic 1 pin widgets to inputs
11882 */
11883static struct hda_verb alc861_threestack_ch2_init[] = {
11884 /* set pin widget 1Ah (line in) for input */
11885 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011886 /* set pin widget 18h (mic1/2) for input, for mic also enable
11887 * the vref
11888 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11890
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011891 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11892#if 0
11893 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11894 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11895#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011896 { } /* end */
11897};
11898/*
11899 * 6ch mode
11900 * need to set the codec line out and mic 1 pin widgets to outputs
11901 */
11902static struct hda_verb alc861_threestack_ch6_init[] = {
11903 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11904 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11905 /* set pin widget 18h (mic1) for output (CLFE)*/
11906 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11907
11908 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011909 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011910
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011911 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11912#if 0
11913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11914 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11915#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011916 { } /* end */
11917};
11918
11919static struct hda_channel_mode alc861_threestack_modes[2] = {
11920 { 2, alc861_threestack_ch2_init },
11921 { 6, alc861_threestack_ch6_init },
11922};
Takashi Iwai22309c32006-08-09 16:57:28 +020011923/* Set mic1 as input and unmute the mixer */
11924static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11925 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11926 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11927 { } /* end */
11928};
11929/* Set mic1 as output and mute mixer */
11930static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11931 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11932 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11933 { } /* end */
11934};
11935
11936static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11937 { 2, alc861_uniwill_m31_ch2_init },
11938 { 4, alc861_uniwill_m31_ch4_init },
11939};
Kailang Yangdf694da2005-12-05 19:42:22 +010011940
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011941/* Set mic1 and line-in as input and unmute the mixer */
11942static struct hda_verb alc861_asus_ch2_init[] = {
11943 /* set pin widget 1Ah (line in) for input */
11944 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011945 /* set pin widget 18h (mic1/2) for input, for mic also enable
11946 * the vref
11947 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020011948 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11949
11950 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11951#if 0
11952 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11953 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11954#endif
11955 { } /* end */
11956};
11957/* Set mic1 nad line-in as output and mute mixer */
11958static struct hda_verb alc861_asus_ch6_init[] = {
11959 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11960 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11961 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11962 /* set pin widget 18h (mic1) for output (CLFE)*/
11963 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11964 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11965 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11966 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11967
11968 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11969#if 0
11970 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11971 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11972#endif
11973 { } /* end */
11974};
11975
11976static struct hda_channel_mode alc861_asus_modes[2] = {
11977 { 2, alc861_asus_ch2_init },
11978 { 6, alc861_asus_ch6_init },
11979};
11980
Kailang Yangdf694da2005-12-05 19:42:22 +010011981/* patch-ALC861 */
11982
11983static struct snd_kcontrol_new alc861_base_mixer[] = {
11984 /* output mixer control */
11985 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11986 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11987 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11988 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11989 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11990
11991 /*Input mixer control */
11992 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11993 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11994 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11995 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11996 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11997 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11999 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012002
Kailang Yangdf694da2005-12-05 19:42:22 +010012003 /* Capture mixer control */
12004 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12005 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12006 {
12007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12008 .name = "Capture Source",
12009 .count = 1,
12010 .info = alc_mux_enum_info,
12011 .get = alc_mux_enum_get,
12012 .put = alc_mux_enum_put,
12013 },
12014 { } /* end */
12015};
12016
12017static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12018 /* output mixer control */
12019 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12020 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12021 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12022 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12023 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12024
12025 /* Input mixer control */
12026 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12027 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12028 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12029 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12030 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12031 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12033 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12034 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12035 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012036
Kailang Yangdf694da2005-12-05 19:42:22 +010012037 /* Capture mixer control */
12038 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12039 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12040 {
12041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12042 .name = "Capture Source",
12043 .count = 1,
12044 .info = alc_mux_enum_info,
12045 .get = alc_mux_enum_get,
12046 .put = alc_mux_enum_put,
12047 },
12048 {
12049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12050 .name = "Channel Mode",
12051 .info = alc_ch_mode_info,
12052 .get = alc_ch_mode_get,
12053 .put = alc_ch_mode_put,
12054 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12055 },
12056 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012057};
12058
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012059static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012060 /* output mixer control */
12061 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12063 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012064
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012065 /*Capture mixer control */
12066 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12067 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12068 {
12069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12070 .name = "Capture Source",
12071 .count = 1,
12072 .info = alc_mux_enum_info,
12073 .get = alc_mux_enum_get,
12074 .put = alc_mux_enum_put,
12075 },
12076
12077 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012078};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012079
Takashi Iwai22309c32006-08-09 16:57:28 +020012080static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12081 /* output mixer control */
12082 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12083 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12084 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12085 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12086 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12087
12088 /* Input mixer control */
12089 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12091 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12092 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12093 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12094 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12096 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12097 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012099
Takashi Iwai22309c32006-08-09 16:57:28 +020012100 /* Capture mixer control */
12101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12103 {
12104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12105 .name = "Capture Source",
12106 .count = 1,
12107 .info = alc_mux_enum_info,
12108 .get = alc_mux_enum_get,
12109 .put = alc_mux_enum_put,
12110 },
12111 {
12112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12113 .name = "Channel Mode",
12114 .info = alc_ch_mode_info,
12115 .get = alc_ch_mode_get,
12116 .put = alc_ch_mode_put,
12117 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12118 },
12119 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012120};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012121
12122static struct snd_kcontrol_new alc861_asus_mixer[] = {
12123 /* output mixer control */
12124 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12125 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12126 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12127 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12128 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12129
12130 /* Input mixer control */
12131 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12132 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12133 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12134 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12135 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12136 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12138 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12139 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12141
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012142 /* Capture mixer control */
12143 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12144 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12145 {
12146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12147 .name = "Capture Source",
12148 .count = 1,
12149 .info = alc_mux_enum_info,
12150 .get = alc_mux_enum_get,
12151 .put = alc_mux_enum_put,
12152 },
12153 {
12154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12155 .name = "Channel Mode",
12156 .info = alc_ch_mode_info,
12157 .get = alc_ch_mode_get,
12158 .put = alc_ch_mode_put,
12159 .private_value = ARRAY_SIZE(alc861_asus_modes),
12160 },
12161 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012162};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012163
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012164/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012165static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012166 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12167 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12168 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12169 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12170 { }
12171};
12172
Kailang Yangdf694da2005-12-05 19:42:22 +010012173/*
12174 * generic initialization of ADC, input mixers and output mixers
12175 */
12176static struct hda_verb alc861_base_init_verbs[] = {
12177 /*
12178 * Unmute ADC0 and set the default input to mic-in
12179 */
12180 /* port-A for surround (rear panel) */
12181 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12182 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12183 /* port-B for mic-in (rear panel) with vref */
12184 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12185 /* port-C for line-in (rear panel) */
12186 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12187 /* port-D for Front */
12188 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12189 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12190 /* port-E for HP out (front panel) */
12191 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12192 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012193 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012194 /* port-F for mic-in (front panel) with vref */
12195 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12196 /* port-G for CLFE (rear panel) */
12197 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12198 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12199 /* port-H for side (rear panel) */
12200 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12201 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12202 /* CD-in */
12203 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12204 /* route front mic to ADC1*/
12205 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012207
Kailang Yangdf694da2005-12-05 19:42:22 +010012208 /* Unmute DAC0~3 & spdif out*/
12209 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12210 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12211 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12212 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012214
Kailang Yangdf694da2005-12-05 19:42:22 +010012215 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12216 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12217 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12218 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12219 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012220
Kailang Yangdf694da2005-12-05 19:42:22 +010012221 /* Unmute Stereo Mixer 15 */
12222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012226
12227 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12228 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12229 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12230 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12232 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12234 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012235 /* hp used DAC 3 (Front) */
12236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012237 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12238
12239 { }
12240};
12241
12242static struct hda_verb alc861_threestack_init_verbs[] = {
12243 /*
12244 * Unmute ADC0 and set the default input to mic-in
12245 */
12246 /* port-A for surround (rear panel) */
12247 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12248 /* port-B for mic-in (rear panel) with vref */
12249 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12250 /* port-C for line-in (rear panel) */
12251 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12252 /* port-D for Front */
12253 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12254 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12255 /* port-E for HP out (front panel) */
12256 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12257 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012258 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012259 /* port-F for mic-in (front panel) with vref */
12260 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12261 /* port-G for CLFE (rear panel) */
12262 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12263 /* port-H for side (rear panel) */
12264 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12265 /* CD-in */
12266 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12267 /* route front mic to ADC1*/
12268 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12270 /* Unmute DAC0~3 & spdif out*/
12271 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12273 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12274 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012276
Kailang Yangdf694da2005-12-05 19:42:22 +010012277 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12278 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12279 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12280 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12281 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012282
Kailang Yangdf694da2005-12-05 19:42:22 +010012283 /* Unmute Stereo Mixer 15 */
12284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012288
12289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12291 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12295 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012297 /* hp used DAC 3 (Front) */
12298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12300 { }
12301};
Takashi Iwai22309c32006-08-09 16:57:28 +020012302
12303static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12304 /*
12305 * Unmute ADC0 and set the default input to mic-in
12306 */
12307 /* port-A for surround (rear panel) */
12308 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12309 /* port-B for mic-in (rear panel) with vref */
12310 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12311 /* port-C for line-in (rear panel) */
12312 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12313 /* port-D for Front */
12314 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12315 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12316 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012317 /* this has to be set to VREF80 */
12318 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012319 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012320 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012321 /* port-F for mic-in (front panel) with vref */
12322 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12323 /* port-G for CLFE (rear panel) */
12324 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12325 /* port-H for side (rear panel) */
12326 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12327 /* CD-in */
12328 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12329 /* route front mic to ADC1*/
12330 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12331 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12332 /* Unmute DAC0~3 & spdif out*/
12333 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12334 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12335 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12336 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012338
Takashi Iwai22309c32006-08-09 16:57:28 +020012339 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12340 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12341 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12342 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12343 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012344
Takashi Iwai22309c32006-08-09 16:57:28 +020012345 /* Unmute Stereo Mixer 15 */
12346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012350
12351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12352 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12353 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12354 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12358 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012359 /* hp used DAC 3 (Front) */
12360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012361 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12362 { }
12363};
12364
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012365static struct hda_verb alc861_asus_init_verbs[] = {
12366 /*
12367 * Unmute ADC0 and set the default input to mic-in
12368 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012369 /* port-A for surround (rear panel)
12370 * according to codec#0 this is the HP jack
12371 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012372 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12373 /* route front PCM to HP */
12374 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12375 /* port-B for mic-in (rear panel) with vref */
12376 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12377 /* port-C for line-in (rear panel) */
12378 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12379 /* port-D for Front */
12380 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12381 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12382 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012383 /* this has to be set to VREF80 */
12384 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012385 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012386 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012387 /* port-F for mic-in (front panel) with vref */
12388 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12389 /* port-G for CLFE (rear panel) */
12390 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12391 /* port-H for side (rear panel) */
12392 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12393 /* CD-in */
12394 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12395 /* route front mic to ADC1*/
12396 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12398 /* Unmute DAC0~3 & spdif out*/
12399 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12400 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12401 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12402 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12404 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12405 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12406 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12407 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12408 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012409
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012410 /* Unmute Stereo Mixer 15 */
12411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012415
12416 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12417 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12418 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12419 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012424 /* hp used DAC 3 (Front) */
12425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012426 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12427 { }
12428};
12429
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012430/* additional init verbs for ASUS laptops */
12431static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12432 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12433 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12434 { }
12435};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012436
Kailang Yangdf694da2005-12-05 19:42:22 +010012437/*
12438 * generic initialization of ADC, input mixers and output mixers
12439 */
12440static struct hda_verb alc861_auto_init_verbs[] = {
12441 /*
12442 * Unmute ADC0 and set the default input to mic-in
12443 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012444 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012446
Kailang Yangdf694da2005-12-05 19:42:22 +010012447 /* Unmute DAC0~3 & spdif out*/
12448 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12449 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12450 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12451 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012453
Kailang Yangdf694da2005-12-05 19:42:22 +010012454 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12455 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12456 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12457 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12458 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012459
Kailang Yangdf694da2005-12-05 19:42:22 +010012460 /* Unmute Stereo Mixer 15 */
12461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12465
12466 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12468 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12471 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12474
12475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012481 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12482 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012483
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012485
12486 { }
12487};
12488
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012489static struct hda_verb alc861_toshiba_init_verbs[] = {
12490 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012491
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012492 { }
12493};
12494
12495/* toggle speaker-output according to the hp-jack state */
12496static void alc861_toshiba_automute(struct hda_codec *codec)
12497{
12498 unsigned int present;
12499
12500 present = snd_hda_codec_read(codec, 0x0f, 0,
12501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012502 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12503 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12504 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12505 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012506}
12507
12508static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12509 unsigned int res)
12510{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012511 if ((res >> 26) == ALC880_HP_EVENT)
12512 alc861_toshiba_automute(codec);
12513}
12514
Kailang Yangdf694da2005-12-05 19:42:22 +010012515/* pcm configuration: identiacal with ALC880 */
12516#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12517#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12518#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12519#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12520
12521
12522#define ALC861_DIGOUT_NID 0x07
12523
12524static struct hda_channel_mode alc861_8ch_modes[1] = {
12525 { 8, NULL }
12526};
12527
12528static hda_nid_t alc861_dac_nids[4] = {
12529 /* front, surround, clfe, side */
12530 0x03, 0x06, 0x05, 0x04
12531};
12532
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012533static hda_nid_t alc660_dac_nids[3] = {
12534 /* front, clfe, surround */
12535 0x03, 0x05, 0x06
12536};
12537
Kailang Yangdf694da2005-12-05 19:42:22 +010012538static hda_nid_t alc861_adc_nids[1] = {
12539 /* ADC0-2 */
12540 0x08,
12541};
12542
12543static struct hda_input_mux alc861_capture_source = {
12544 .num_items = 5,
12545 .items = {
12546 { "Mic", 0x0 },
12547 { "Front Mic", 0x3 },
12548 { "Line", 0x1 },
12549 { "CD", 0x4 },
12550 { "Mixer", 0x5 },
12551 },
12552};
12553
12554/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012555static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12556 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012557{
12558 int i;
12559 hda_nid_t nid;
12560
12561 spec->multiout.dac_nids = spec->private_dac_nids;
12562 for (i = 0; i < cfg->line_outs; i++) {
12563 nid = cfg->line_out_pins[i];
12564 if (nid) {
12565 if (i >= ARRAY_SIZE(alc861_dac_nids))
12566 continue;
12567 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12568 }
12569 }
12570 spec->multiout.num_dacs = cfg->line_outs;
12571 return 0;
12572}
12573
12574/* add playback controls from the parsed DAC table */
12575static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12576 const struct auto_pin_cfg *cfg)
12577{
12578 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012579 static const char *chname[4] = {
12580 "Front", "Surround", NULL /*CLFE*/, "Side"
12581 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012582 hda_nid_t nid;
12583 int i, idx, err;
12584
12585 for (i = 0; i < cfg->line_outs; i++) {
12586 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012587 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012588 continue;
12589 if (nid == 0x05) {
12590 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012591 err = add_control(spec, ALC_CTL_BIND_MUTE,
12592 "Center Playback Switch",
12593 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12594 HDA_OUTPUT));
12595 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012597 err = add_control(spec, ALC_CTL_BIND_MUTE,
12598 "LFE Playback Switch",
12599 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12600 HDA_OUTPUT));
12601 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012602 return err;
12603 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012604 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12605 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012606 if (nid == alc861_dac_nids[idx])
12607 break;
12608 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012609 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12610 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12611 HDA_OUTPUT));
12612 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012613 return err;
12614 }
12615 }
12616 return 0;
12617}
12618
12619static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12620{
12621 int err;
12622 hda_nid_t nid;
12623
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012624 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012625 return 0;
12626
12627 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12628 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012629 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12630 "Headphone Playback Switch",
12631 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12632 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012633 return err;
12634 spec->multiout.hp_nid = nid;
12635 }
12636 return 0;
12637}
12638
12639/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012640static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12641 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012642{
Kailang Yangdf694da2005-12-05 19:42:22 +010012643 struct hda_input_mux *imux = &spec->private_imux;
12644 int i, err, idx, idx1;
12645
12646 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012647 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012648 case 0x0c:
12649 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012650 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012651 break;
12652 case 0x0f:
12653 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012654 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012655 break;
12656 case 0x0d:
12657 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012658 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012659 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012660 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012661 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012662 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012663 break;
12664 case 0x11:
12665 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012666 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012667 break;
12668 default:
12669 continue;
12670 }
12671
Takashi Iwai4a471b72005-12-07 13:56:29 +010012672 err = new_analog_input(spec, cfg->input_pins[i],
12673 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012674 if (err < 0)
12675 return err;
12676
Takashi Iwai4a471b72005-12-07 13:56:29 +010012677 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012678 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012679 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012680 }
12681 return 0;
12682}
12683
12684static struct snd_kcontrol_new alc861_capture_mixer[] = {
12685 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12686 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12687
12688 {
12689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12690 /* The multiple "Capture Source" controls confuse alsamixer
12691 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012692 */
12693 /* .name = "Capture Source", */
12694 .name = "Input Source",
12695 .count = 1,
12696 .info = alc_mux_enum_info,
12697 .get = alc_mux_enum_get,
12698 .put = alc_mux_enum_put,
12699 },
12700 { } /* end */
12701};
12702
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012703static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12704 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012705 int pin_type, int dac_idx)
12706{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012707 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12708 pin_type);
12709 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12710 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012711}
12712
12713static void alc861_auto_init_multi_out(struct hda_codec *codec)
12714{
12715 struct alc_spec *spec = codec->spec;
12716 int i;
12717
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012718 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012719 for (i = 0; i < spec->autocfg.line_outs; i++) {
12720 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012721 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012722 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012723 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012724 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012725 }
12726}
12727
12728static void alc861_auto_init_hp_out(struct hda_codec *codec)
12729{
12730 struct alc_spec *spec = codec->spec;
12731 hda_nid_t pin;
12732
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012733 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012734 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012735 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12736 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012737 pin = spec->autocfg.speaker_pins[0];
12738 if (pin)
12739 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012740}
12741
12742static void alc861_auto_init_analog_input(struct hda_codec *codec)
12743{
12744 struct alc_spec *spec = codec->spec;
12745 int i;
12746
12747 for (i = 0; i < AUTO_PIN_LAST; i++) {
12748 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012749 if (nid >= 0x0c && nid <= 0x11) {
12750 snd_hda_codec_write(codec, nid, 0,
12751 AC_VERB_SET_PIN_WIDGET_CONTROL,
12752 i <= AUTO_PIN_FRONT_MIC ?
12753 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012754 }
12755 }
12756}
12757
12758/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012759/* return 1 if successful, 0 if the proper config is not found,
12760 * or a negative error code
12761 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012762static int alc861_parse_auto_config(struct hda_codec *codec)
12763{
12764 struct alc_spec *spec = codec->spec;
12765 int err;
12766 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12767
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012768 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12769 alc861_ignore);
12770 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012771 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012772 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012773 return 0; /* can't find valid BIOS pin config */
12774
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012775 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12776 if (err < 0)
12777 return err;
12778 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12779 if (err < 0)
12780 return err;
12781 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12782 if (err < 0)
12783 return err;
12784 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12785 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012786 return err;
12787
12788 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12789
12790 if (spec->autocfg.dig_out_pin)
12791 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12792
12793 if (spec->kctl_alloc)
12794 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12795
12796 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12797
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012798 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012799 spec->input_mux = &spec->private_imux;
12800
12801 spec->adc_nids = alc861_adc_nids;
12802 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12803 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12804 spec->num_mixers++;
12805
12806 return 1;
12807}
12808
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012809/* additional initialization for auto-configuration model */
12810static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012811{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012812 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012813 alc861_auto_init_multi_out(codec);
12814 alc861_auto_init_hp_out(codec);
12815 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012816 if (spec->unsol_event)
12817 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012818}
12819
Takashi Iwaicb53c622007-08-10 17:21:45 +020012820#ifdef CONFIG_SND_HDA_POWER_SAVE
12821static struct hda_amp_list alc861_loopbacks[] = {
12822 { 0x15, HDA_INPUT, 0 },
12823 { 0x15, HDA_INPUT, 1 },
12824 { 0x15, HDA_INPUT, 2 },
12825 { 0x15, HDA_INPUT, 3 },
12826 { } /* end */
12827};
12828#endif
12829
Kailang Yangdf694da2005-12-05 19:42:22 +010012830
12831/*
12832 * configuration and preset
12833 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012834static const char *alc861_models[ALC861_MODEL_LAST] = {
12835 [ALC861_3ST] = "3stack",
12836 [ALC660_3ST] = "3stack-660",
12837 [ALC861_3ST_DIG] = "3stack-dig",
12838 [ALC861_6ST_DIG] = "6stack-dig",
12839 [ALC861_UNIWILL_M31] = "uniwill-m31",
12840 [ALC861_TOSHIBA] = "toshiba",
12841 [ALC861_ASUS] = "asus",
12842 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12843 [ALC861_AUTO] = "auto",
12844};
12845
12846static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012847 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012848 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12849 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12850 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012851 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012852 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012853 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012854 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12855 * Any other models that need this preset?
12856 */
12857 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012858 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12859 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012860 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12861 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12862 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12863 /* FIXME: the below seems conflict */
12864 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12865 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12866 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012867 {}
12868};
12869
12870static struct alc_config_preset alc861_presets[] = {
12871 [ALC861_3ST] = {
12872 .mixers = { alc861_3ST_mixer },
12873 .init_verbs = { alc861_threestack_init_verbs },
12874 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12875 .dac_nids = alc861_dac_nids,
12876 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12877 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012878 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012879 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12880 .adc_nids = alc861_adc_nids,
12881 .input_mux = &alc861_capture_source,
12882 },
12883 [ALC861_3ST_DIG] = {
12884 .mixers = { alc861_base_mixer },
12885 .init_verbs = { alc861_threestack_init_verbs },
12886 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12887 .dac_nids = alc861_dac_nids,
12888 .dig_out_nid = ALC861_DIGOUT_NID,
12889 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12890 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012891 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012892 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12893 .adc_nids = alc861_adc_nids,
12894 .input_mux = &alc861_capture_source,
12895 },
12896 [ALC861_6ST_DIG] = {
12897 .mixers = { alc861_base_mixer },
12898 .init_verbs = { alc861_base_init_verbs },
12899 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12900 .dac_nids = alc861_dac_nids,
12901 .dig_out_nid = ALC861_DIGOUT_NID,
12902 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12903 .channel_mode = alc861_8ch_modes,
12904 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12905 .adc_nids = alc861_adc_nids,
12906 .input_mux = &alc861_capture_source,
12907 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012908 [ALC660_3ST] = {
12909 .mixers = { alc861_3ST_mixer },
12910 .init_verbs = { alc861_threestack_init_verbs },
12911 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12912 .dac_nids = alc660_dac_nids,
12913 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12914 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012915 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012916 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12917 .adc_nids = alc861_adc_nids,
12918 .input_mux = &alc861_capture_source,
12919 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012920 [ALC861_UNIWILL_M31] = {
12921 .mixers = { alc861_uniwill_m31_mixer },
12922 .init_verbs = { alc861_uniwill_m31_init_verbs },
12923 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12924 .dac_nids = alc861_dac_nids,
12925 .dig_out_nid = ALC861_DIGOUT_NID,
12926 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12927 .channel_mode = alc861_uniwill_m31_modes,
12928 .need_dac_fix = 1,
12929 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12930 .adc_nids = alc861_adc_nids,
12931 .input_mux = &alc861_capture_source,
12932 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012933 [ALC861_TOSHIBA] = {
12934 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012935 .init_verbs = { alc861_base_init_verbs,
12936 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012937 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12938 .dac_nids = alc861_dac_nids,
12939 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12940 .channel_mode = alc883_3ST_2ch_modes,
12941 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12942 .adc_nids = alc861_adc_nids,
12943 .input_mux = &alc861_capture_source,
12944 .unsol_event = alc861_toshiba_unsol_event,
12945 .init_hook = alc861_toshiba_automute,
12946 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012947 [ALC861_ASUS] = {
12948 .mixers = { alc861_asus_mixer },
12949 .init_verbs = { alc861_asus_init_verbs },
12950 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12951 .dac_nids = alc861_dac_nids,
12952 .dig_out_nid = ALC861_DIGOUT_NID,
12953 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12954 .channel_mode = alc861_asus_modes,
12955 .need_dac_fix = 1,
12956 .hp_nid = 0x06,
12957 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12958 .adc_nids = alc861_adc_nids,
12959 .input_mux = &alc861_capture_source,
12960 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012961 [ALC861_ASUS_LAPTOP] = {
12962 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12963 .init_verbs = { alc861_asus_init_verbs,
12964 alc861_asus_laptop_init_verbs },
12965 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12966 .dac_nids = alc861_dac_nids,
12967 .dig_out_nid = ALC861_DIGOUT_NID,
12968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12969 .channel_mode = alc883_3ST_2ch_modes,
12970 .need_dac_fix = 1,
12971 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12972 .adc_nids = alc861_adc_nids,
12973 .input_mux = &alc861_capture_source,
12974 },
12975};
Kailang Yangdf694da2005-12-05 19:42:22 +010012976
12977
12978static int patch_alc861(struct hda_codec *codec)
12979{
12980 struct alc_spec *spec;
12981 int board_config;
12982 int err;
12983
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012984 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012985 if (spec == NULL)
12986 return -ENOMEM;
12987
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012988 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012989
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012990 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12991 alc861_models,
12992 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012993
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012994 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012995 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12996 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012997 board_config = ALC861_AUTO;
12998 }
12999
13000 if (board_config == ALC861_AUTO) {
13001 /* automatic parse from the BIOS config */
13002 err = alc861_parse_auto_config(codec);
13003 if (err < 0) {
13004 alc_free(codec);
13005 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013006 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013007 printk(KERN_INFO
13008 "hda_codec: Cannot set up configuration "
13009 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013010 board_config = ALC861_3ST_DIG;
13011 }
13012 }
13013
13014 if (board_config != ALC861_AUTO)
13015 setup_preset(spec, &alc861_presets[board_config]);
13016
13017 spec->stream_name_analog = "ALC861 Analog";
13018 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13019 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13020
13021 spec->stream_name_digital = "ALC861 Digital";
13022 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13023 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13024
Takashi Iwai2134ea42008-01-10 16:53:55 +010013025 spec->vmaster_nid = 0x03;
13026
Kailang Yangdf694da2005-12-05 19:42:22 +010013027 codec->patch_ops = alc_patch_ops;
13028 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013029 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013030#ifdef CONFIG_SND_HDA_POWER_SAVE
13031 if (!spec->loopback.amplist)
13032 spec->loopback.amplist = alc861_loopbacks;
13033#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013034
Kailang Yangdf694da2005-12-05 19:42:22 +010013035 return 0;
13036}
13037
13038/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013039 * ALC861-VD support
13040 *
13041 * Based on ALC882
13042 *
13043 * In addition, an independent DAC
13044 */
13045#define ALC861VD_DIGOUT_NID 0x06
13046
13047static hda_nid_t alc861vd_dac_nids[4] = {
13048 /* front, surr, clfe, side surr */
13049 0x02, 0x03, 0x04, 0x05
13050};
13051
13052/* dac_nids for ALC660vd are in a different order - according to
13053 * Realtek's driver.
13054 * This should probably tesult in a different mixer for 6stack models
13055 * of ALC660vd codecs, but for now there is only 3stack mixer
13056 * - and it is the same as in 861vd.
13057 * adc_nids in ALC660vd are (is) the same as in 861vd
13058 */
13059static hda_nid_t alc660vd_dac_nids[3] = {
13060 /* front, rear, clfe, rear_surr */
13061 0x02, 0x04, 0x03
13062};
13063
13064static hda_nid_t alc861vd_adc_nids[1] = {
13065 /* ADC0 */
13066 0x09,
13067};
13068
Takashi Iwaie1406342008-02-11 18:32:32 +010013069static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13070
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013071/* input MUX */
13072/* FIXME: should be a matrix-type input source selection */
13073static struct hda_input_mux alc861vd_capture_source = {
13074 .num_items = 4,
13075 .items = {
13076 { "Mic", 0x0 },
13077 { "Front Mic", 0x1 },
13078 { "Line", 0x2 },
13079 { "CD", 0x4 },
13080 },
13081};
13082
Kailang Yang272a5272007-05-14 11:00:38 +020013083static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013084 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013085 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013086 { "Ext Mic", 0x0 },
13087 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013088 },
13089};
13090
Kailang Yangd1a991a2007-08-15 16:21:59 +020013091static struct hda_input_mux alc861vd_hp_capture_source = {
13092 .num_items = 2,
13093 .items = {
13094 { "Front Mic", 0x0 },
13095 { "ATAPI Mic", 0x1 },
13096 },
13097};
13098
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013099#define alc861vd_mux_enum_info alc_mux_enum_info
13100#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013101/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13102#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013103
13104/*
13105 * 2ch mode
13106 */
13107static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13108 { 2, NULL }
13109};
13110
13111/*
13112 * 6ch mode
13113 */
13114static struct hda_verb alc861vd_6stack_ch6_init[] = {
13115 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13116 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13117 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13118 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13119 { } /* end */
13120};
13121
13122/*
13123 * 8ch mode
13124 */
13125static struct hda_verb alc861vd_6stack_ch8_init[] = {
13126 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13127 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13128 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13129 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13130 { } /* end */
13131};
13132
13133static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13134 { 6, alc861vd_6stack_ch6_init },
13135 { 8, alc861vd_6stack_ch8_init },
13136};
13137
13138static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13139 {
13140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13141 .name = "Channel Mode",
13142 .info = alc_ch_mode_info,
13143 .get = alc_ch_mode_get,
13144 .put = alc_ch_mode_put,
13145 },
13146 { } /* end */
13147};
13148
13149static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13150 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13151 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13152
13153 {
13154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13155 /* The multiple "Capture Source" controls confuse alsamixer
13156 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013157 */
13158 /* .name = "Capture Source", */
13159 .name = "Input Source",
13160 .count = 1,
13161 .info = alc861vd_mux_enum_info,
13162 .get = alc861vd_mux_enum_get,
13163 .put = alc861vd_mux_enum_put,
13164 },
13165 { } /* end */
13166};
13167
13168/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13169 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13170 */
13171static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13174
13175 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13176 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13177
13178 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13179 HDA_OUTPUT),
13180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13181 HDA_OUTPUT),
13182 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13183 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13184
13185 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13186 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13187
13188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13189
13190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13193
13194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13196 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13197
13198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13200
13201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13203
13204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13206
13207 { } /* end */
13208};
13209
13210static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13211 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13213
13214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13215
13216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13219
13220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13223
13224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13226
13227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13229
13230 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13231 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13232
13233 { } /* end */
13234};
13235
Kailang Yangbdd148a2007-05-08 15:19:08 +020013236static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13237 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13238 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13239 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13240
13241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13242
13243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13246
13247 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13248 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13249 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13250
13251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13253
13254 { } /* end */
13255};
13256
Tobin Davisb419f342008-03-07 11:57:51 +010013257/* Pin assignment: Speaker=0x14, HP = 0x15,
13258 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013259 */
13260static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013261 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13262 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13264 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013265 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13266 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13267 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13268 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13269 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13270 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13271 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13272 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013273 { } /* end */
13274};
13275
Kailang Yangd1a991a2007-08-15 16:21:59 +020013276/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13277 * Front Mic=0x18, ATAPI Mic = 0x19,
13278 */
13279static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13280 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13283 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13284 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13285 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13286 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13287 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013288
Kailang Yangd1a991a2007-08-15 16:21:59 +020013289 { } /* end */
13290};
13291
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013292/*
13293 * generic initialization of ADC, input mixers and output mixers
13294 */
13295static struct hda_verb alc861vd_volume_init_verbs[] = {
13296 /*
13297 * Unmute ADC0 and set the default input to mic-in
13298 */
13299 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13301
13302 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13303 * the analog-loopback mixer widget
13304 */
13305 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013311
13312 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013317
13318 /*
13319 * Set up output mixers (0x02 - 0x05)
13320 */
13321 /* set vol=0 to output mixers */
13322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13323 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13324 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13325 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13326
13327 /* set up input amps for analog loopback */
13328 /* Amp Indices: DAC = 0, mixer = 1 */
13329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13337
13338 { }
13339};
13340
13341/*
13342 * 3-stack pin configuration:
13343 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13344 */
13345static struct hda_verb alc861vd_3stack_init_verbs[] = {
13346 /*
13347 * Set pin mode and muting
13348 */
13349 /* set front pin widgets 0x14 for output */
13350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13353
13354 /* Mic (rear) pin: input vref at 80% */
13355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13357 /* Front Mic pin: input vref at 80% */
13358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13360 /* Line In pin: input */
13361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13363 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13366 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13367 /* CD pin widget for input */
13368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13369
13370 { }
13371};
13372
13373/*
13374 * 6-stack pin configuration:
13375 */
13376static struct hda_verb alc861vd_6stack_init_verbs[] = {
13377 /*
13378 * Set pin mode and muting
13379 */
13380 /* set front pin widgets 0x14 for output */
13381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13384
13385 /* Rear Pin: output 1 (0x0d) */
13386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13389 /* CLFE Pin: output 2 (0x0e) */
13390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13392 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13393 /* Side Pin: output 3 (0x0f) */
13394 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13396 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13397
13398 /* Mic (rear) pin: input vref at 80% */
13399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13401 /* Front Mic pin: input vref at 80% */
13402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13404 /* Line In pin: input */
13405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13407 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13409 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13410 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13411 /* CD pin widget for input */
13412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13413
13414 { }
13415};
13416
Kailang Yangbdd148a2007-05-08 15:19:08 +020013417static struct hda_verb alc861vd_eapd_verbs[] = {
13418 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13419 { }
13420};
13421
Kailang Yangf9423e72008-05-27 12:32:25 +020013422static struct hda_verb alc660vd_eapd_verbs[] = {
13423 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13424 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13425 { }
13426};
13427
Kailang Yangbdd148a2007-05-08 15:19:08 +020013428static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13432 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013434 {}
13435};
13436
13437/* toggle speaker-output according to the hp-jack state */
13438static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13439{
13440 unsigned int present;
13441 unsigned char bits;
13442
13443 present = snd_hda_codec_read(codec, 0x1b, 0,
13444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013445 bits = present ? HDA_AMP_MUTE : 0;
13446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13447 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013448}
13449
13450static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13451{
13452 unsigned int present;
13453 unsigned char bits;
13454
13455 present = snd_hda_codec_read(codec, 0x18, 0,
13456 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013457 bits = present ? HDA_AMP_MUTE : 0;
13458 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13459 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013460}
13461
13462static void alc861vd_lenovo_automute(struct hda_codec *codec)
13463{
13464 alc861vd_lenovo_hp_automute(codec);
13465 alc861vd_lenovo_mic_automute(codec);
13466}
13467
13468static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13469 unsigned int res)
13470{
13471 switch (res >> 26) {
13472 case ALC880_HP_EVENT:
13473 alc861vd_lenovo_hp_automute(codec);
13474 break;
13475 case ALC880_MIC_EVENT:
13476 alc861vd_lenovo_mic_automute(codec);
13477 break;
13478 }
13479}
13480
Kailang Yang272a5272007-05-14 11:00:38 +020013481static struct hda_verb alc861vd_dallas_verbs[] = {
13482 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13483 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13484 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13485 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13486
13487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013495
Kailang Yang272a5272007-05-14 11:00:38 +020013496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13502 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13504
13505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13512 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13513
13514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13518
13519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13522
13523 { } /* end */
13524};
13525
13526/* toggle speaker-output according to the hp-jack state */
13527static void alc861vd_dallas_automute(struct hda_codec *codec)
13528{
13529 unsigned int present;
13530
13531 present = snd_hda_codec_read(codec, 0x15, 0,
13532 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013533 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13534 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013535}
13536
13537static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13538{
13539 if ((res >> 26) == ALC880_HP_EVENT)
13540 alc861vd_dallas_automute(codec);
13541}
13542
Takashi Iwaicb53c622007-08-10 17:21:45 +020013543#ifdef CONFIG_SND_HDA_POWER_SAVE
13544#define alc861vd_loopbacks alc880_loopbacks
13545#endif
13546
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013547/* pcm configuration: identiacal with ALC880 */
13548#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13549#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13550#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13551#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13552
13553/*
13554 * configuration and preset
13555 */
13556static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13557 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013558 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013559 [ALC861VD_3ST] = "3stack",
13560 [ALC861VD_3ST_DIG] = "3stack-digout",
13561 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013562 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013563 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013564 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013565 [ALC861VD_AUTO] = "auto",
13566};
13567
13568static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013569 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13570 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013571 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013572 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013573 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013574 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013575 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013576 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013577 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013578 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013579 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013580 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013581 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013582 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13583 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013584 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013585 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013586 {}
13587};
13588
13589static struct alc_config_preset alc861vd_presets[] = {
13590 [ALC660VD_3ST] = {
13591 .mixers = { alc861vd_3st_mixer },
13592 .init_verbs = { alc861vd_volume_init_verbs,
13593 alc861vd_3stack_init_verbs },
13594 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13595 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013596 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13597 .channel_mode = alc861vd_3stack_2ch_modes,
13598 .input_mux = &alc861vd_capture_source,
13599 },
Mike Crash6963f842007-06-25 12:12:51 +020013600 [ALC660VD_3ST_DIG] = {
13601 .mixers = { alc861vd_3st_mixer },
13602 .init_verbs = { alc861vd_volume_init_verbs,
13603 alc861vd_3stack_init_verbs },
13604 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13605 .dac_nids = alc660vd_dac_nids,
13606 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013607 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13608 .channel_mode = alc861vd_3stack_2ch_modes,
13609 .input_mux = &alc861vd_capture_source,
13610 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013611 [ALC861VD_3ST] = {
13612 .mixers = { alc861vd_3st_mixer },
13613 .init_verbs = { alc861vd_volume_init_verbs,
13614 alc861vd_3stack_init_verbs },
13615 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13616 .dac_nids = alc861vd_dac_nids,
13617 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13618 .channel_mode = alc861vd_3stack_2ch_modes,
13619 .input_mux = &alc861vd_capture_source,
13620 },
13621 [ALC861VD_3ST_DIG] = {
13622 .mixers = { alc861vd_3st_mixer },
13623 .init_verbs = { alc861vd_volume_init_verbs,
13624 alc861vd_3stack_init_verbs },
13625 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13626 .dac_nids = alc861vd_dac_nids,
13627 .dig_out_nid = ALC861VD_DIGOUT_NID,
13628 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13629 .channel_mode = alc861vd_3stack_2ch_modes,
13630 .input_mux = &alc861vd_capture_source,
13631 },
13632 [ALC861VD_6ST_DIG] = {
13633 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13634 .init_verbs = { alc861vd_volume_init_verbs,
13635 alc861vd_6stack_init_verbs },
13636 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13637 .dac_nids = alc861vd_dac_nids,
13638 .dig_out_nid = ALC861VD_DIGOUT_NID,
13639 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13640 .channel_mode = alc861vd_6stack_modes,
13641 .input_mux = &alc861vd_capture_source,
13642 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013643 [ALC861VD_LENOVO] = {
13644 .mixers = { alc861vd_lenovo_mixer },
13645 .init_verbs = { alc861vd_volume_init_verbs,
13646 alc861vd_3stack_init_verbs,
13647 alc861vd_eapd_verbs,
13648 alc861vd_lenovo_unsol_verbs },
13649 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13650 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013651 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13652 .channel_mode = alc861vd_3stack_2ch_modes,
13653 .input_mux = &alc861vd_capture_source,
13654 .unsol_event = alc861vd_lenovo_unsol_event,
13655 .init_hook = alc861vd_lenovo_automute,
13656 },
Kailang Yang272a5272007-05-14 11:00:38 +020013657 [ALC861VD_DALLAS] = {
13658 .mixers = { alc861vd_dallas_mixer },
13659 .init_verbs = { alc861vd_dallas_verbs },
13660 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13661 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013662 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13663 .channel_mode = alc861vd_3stack_2ch_modes,
13664 .input_mux = &alc861vd_dallas_capture_source,
13665 .unsol_event = alc861vd_dallas_unsol_event,
13666 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013667 },
13668 [ALC861VD_HP] = {
13669 .mixers = { alc861vd_hp_mixer },
13670 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13671 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13672 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013673 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013674 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13675 .channel_mode = alc861vd_3stack_2ch_modes,
13676 .input_mux = &alc861vd_hp_capture_source,
13677 .unsol_event = alc861vd_dallas_unsol_event,
13678 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013679 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013680};
13681
13682/*
13683 * BIOS auto configuration
13684 */
13685static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13686 hda_nid_t nid, int pin_type, int dac_idx)
13687{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013688 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013689}
13690
13691static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13692{
13693 struct alc_spec *spec = codec->spec;
13694 int i;
13695
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013696 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013697 for (i = 0; i <= HDA_SIDE; i++) {
13698 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013699 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013700 if (nid)
13701 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013702 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013703 }
13704}
13705
13706
13707static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13708{
13709 struct alc_spec *spec = codec->spec;
13710 hda_nid_t pin;
13711
13712 pin = spec->autocfg.hp_pins[0];
13713 if (pin) /* connect to front and use dac 0 */
13714 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013715 pin = spec->autocfg.speaker_pins[0];
13716 if (pin)
13717 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013718}
13719
13720#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13721#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13722
13723static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13724{
13725 struct alc_spec *spec = codec->spec;
13726 int i;
13727
13728 for (i = 0; i < AUTO_PIN_LAST; i++) {
13729 hda_nid_t nid = spec->autocfg.input_pins[i];
13730 if (alc861vd_is_input_pin(nid)) {
13731 snd_hda_codec_write(codec, nid, 0,
13732 AC_VERB_SET_PIN_WIDGET_CONTROL,
13733 i <= AUTO_PIN_FRONT_MIC ?
13734 PIN_VREF80 : PIN_IN);
13735 if (nid != ALC861VD_PIN_CD_NID)
13736 snd_hda_codec_write(codec, nid, 0,
13737 AC_VERB_SET_AMP_GAIN_MUTE,
13738 AMP_OUT_MUTE);
13739 }
13740 }
13741}
13742
Takashi Iwaif511b012008-08-15 16:46:42 +020013743#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13744
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013745#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13746#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13747
13748/* add playback controls from the parsed DAC table */
13749/* Based on ALC880 version. But ALC861VD has separate,
13750 * different NIDs for mute/unmute switch and volume control */
13751static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13752 const struct auto_pin_cfg *cfg)
13753{
13754 char name[32];
13755 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13756 hda_nid_t nid_v, nid_s;
13757 int i, err;
13758
13759 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013760 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013761 continue;
13762 nid_v = alc861vd_idx_to_mixer_vol(
13763 alc880_dac_to_idx(
13764 spec->multiout.dac_nids[i]));
13765 nid_s = alc861vd_idx_to_mixer_switch(
13766 alc880_dac_to_idx(
13767 spec->multiout.dac_nids[i]));
13768
13769 if (i == 2) {
13770 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013771 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13772 "Center Playback Volume",
13773 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13774 HDA_OUTPUT));
13775 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013776 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13778 "LFE Playback Volume",
13779 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13780 HDA_OUTPUT));
13781 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013782 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013783 err = add_control(spec, ALC_CTL_BIND_MUTE,
13784 "Center Playback Switch",
13785 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13786 HDA_INPUT));
13787 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013789 err = add_control(spec, ALC_CTL_BIND_MUTE,
13790 "LFE Playback Switch",
13791 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13792 HDA_INPUT));
13793 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013794 return err;
13795 } else {
13796 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013797 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13798 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13799 HDA_OUTPUT));
13800 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013801 return err;
13802 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013803 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013804 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013805 HDA_INPUT));
13806 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013807 return err;
13808 }
13809 }
13810 return 0;
13811}
13812
13813/* add playback controls for speaker and HP outputs */
13814/* Based on ALC880 version. But ALC861VD has separate,
13815 * different NIDs for mute/unmute switch and volume control */
13816static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13817 hda_nid_t pin, const char *pfx)
13818{
13819 hda_nid_t nid_v, nid_s;
13820 int err;
13821 char name[32];
13822
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013823 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013824 return 0;
13825
13826 if (alc880_is_fixed_pin(pin)) {
13827 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13828 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013829 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013830 spec->multiout.hp_nid = nid_v;
13831 else
13832 spec->multiout.extra_out_nid[0] = nid_v;
13833 /* control HP volume/switch on the output mixer amp */
13834 nid_v = alc861vd_idx_to_mixer_vol(
13835 alc880_fixed_pin_idx(pin));
13836 nid_s = alc861vd_idx_to_mixer_switch(
13837 alc880_fixed_pin_idx(pin));
13838
13839 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013840 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13841 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13842 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013843 return err;
13844 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013845 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13846 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13847 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013848 return err;
13849 } else if (alc880_is_multi_pin(pin)) {
13850 /* set manual connection */
13851 /* we have only a switch on HP-out PIN */
13852 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013853 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13854 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13855 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013856 return err;
13857 }
13858 return 0;
13859}
13860
13861/* parse the BIOS configuration and set up the alc_spec
13862 * return 1 if successful, 0 if the proper config is not found,
13863 * or a negative error code
13864 * Based on ALC880 version - had to change it to override
13865 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13866static int alc861vd_parse_auto_config(struct hda_codec *codec)
13867{
13868 struct alc_spec *spec = codec->spec;
13869 int err;
13870 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13871
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013872 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13873 alc861vd_ignore);
13874 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013875 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013876 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013877 return 0; /* can't find valid BIOS pin config */
13878
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013879 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13880 if (err < 0)
13881 return err;
13882 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13883 if (err < 0)
13884 return err;
13885 err = alc861vd_auto_create_extra_out(spec,
13886 spec->autocfg.speaker_pins[0],
13887 "Speaker");
13888 if (err < 0)
13889 return err;
13890 err = alc861vd_auto_create_extra_out(spec,
13891 spec->autocfg.hp_pins[0],
13892 "Headphone");
13893 if (err < 0)
13894 return err;
13895 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13896 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013897 return err;
13898
13899 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13900
13901 if (spec->autocfg.dig_out_pin)
13902 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13903
13904 if (spec->kctl_alloc)
13905 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13906
13907 spec->init_verbs[spec->num_init_verbs++]
13908 = alc861vd_volume_init_verbs;
13909
13910 spec->num_mux_defs = 1;
13911 spec->input_mux = &spec->private_imux;
13912
Takashi Iwai776e1842007-08-29 15:07:11 +020013913 err = alc_auto_add_mic_boost(codec);
13914 if (err < 0)
13915 return err;
13916
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013917 return 1;
13918}
13919
13920/* additional initialization for auto-configuration model */
13921static void alc861vd_auto_init(struct hda_codec *codec)
13922{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013923 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013924 alc861vd_auto_init_multi_out(codec);
13925 alc861vd_auto_init_hp_out(codec);
13926 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020013927 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013928 if (spec->unsol_event)
13929 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013930}
13931
13932static int patch_alc861vd(struct hda_codec *codec)
13933{
13934 struct alc_spec *spec;
13935 int err, board_config;
13936
13937 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13938 if (spec == NULL)
13939 return -ENOMEM;
13940
13941 codec->spec = spec;
13942
13943 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13944 alc861vd_models,
13945 alc861vd_cfg_tbl);
13946
13947 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13948 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13949 "ALC861VD, trying auto-probe from BIOS...\n");
13950 board_config = ALC861VD_AUTO;
13951 }
13952
13953 if (board_config == ALC861VD_AUTO) {
13954 /* automatic parse from the BIOS config */
13955 err = alc861vd_parse_auto_config(codec);
13956 if (err < 0) {
13957 alc_free(codec);
13958 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013959 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013960 printk(KERN_INFO
13961 "hda_codec: Cannot set up configuration "
13962 "from BIOS. Using base mode...\n");
13963 board_config = ALC861VD_3ST;
13964 }
13965 }
13966
13967 if (board_config != ALC861VD_AUTO)
13968 setup_preset(spec, &alc861vd_presets[board_config]);
13969
Kailang Yang2f893282008-05-27 12:14:47 +020013970 if (codec->vendor_id == 0x10ec0660) {
13971 spec->stream_name_analog = "ALC660-VD Analog";
13972 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020013973 /* always turn on EAPD */
13974 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020013975 } else {
13976 spec->stream_name_analog = "ALC861VD Analog";
13977 spec->stream_name_digital = "ALC861VD Digital";
13978 }
13979
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013980 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13981 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13982
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013983 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13984 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13985
13986 spec->adc_nids = alc861vd_adc_nids;
13987 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010013988 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013989
13990 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13991 spec->num_mixers++;
13992
Takashi Iwai2134ea42008-01-10 16:53:55 +010013993 spec->vmaster_nid = 0x02;
13994
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013995 codec->patch_ops = alc_patch_ops;
13996
13997 if (board_config == ALC861VD_AUTO)
13998 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013999#ifdef CONFIG_SND_HDA_POWER_SAVE
14000 if (!spec->loopback.amplist)
14001 spec->loopback.amplist = alc861vd_loopbacks;
14002#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014003
14004 return 0;
14005}
14006
14007/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014008 * ALC662 support
14009 *
14010 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14011 * configuration. Each pin widget can choose any input DACs and a mixer.
14012 * Each ADC is connected from a mixer of all inputs. This makes possible
14013 * 6-channel independent captures.
14014 *
14015 * In addition, an independent DAC for the multi-playback (not used in this
14016 * driver yet).
14017 */
14018#define ALC662_DIGOUT_NID 0x06
14019#define ALC662_DIGIN_NID 0x0a
14020
14021static hda_nid_t alc662_dac_nids[4] = {
14022 /* front, rear, clfe, rear_surr */
14023 0x02, 0x03, 0x04
14024};
14025
14026static hda_nid_t alc662_adc_nids[1] = {
14027 /* ADC1-2 */
14028 0x09,
14029};
Takashi Iwaie1406342008-02-11 18:32:32 +010014030
Kailang Yang77a261b2008-02-19 11:38:05 +010014031static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014032
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014033/* input MUX */
14034/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014035static struct hda_input_mux alc662_capture_source = {
14036 .num_items = 4,
14037 .items = {
14038 { "Mic", 0x0 },
14039 { "Front Mic", 0x1 },
14040 { "Line", 0x2 },
14041 { "CD", 0x4 },
14042 },
14043};
14044
14045static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14046 .num_items = 2,
14047 .items = {
14048 { "Mic", 0x1 },
14049 { "Line", 0x2 },
14050 },
14051};
Kailang Yang291702f2007-10-16 14:28:03 +020014052
14053static struct hda_input_mux alc662_eeepc_capture_source = {
14054 .num_items = 2,
14055 .items = {
14056 { "i-Mic", 0x1 },
14057 { "e-Mic", 0x0 },
14058 },
14059};
14060
Kailang Yang6dda9f42008-05-27 12:05:31 +020014061static struct hda_input_mux alc663_capture_source = {
14062 .num_items = 3,
14063 .items = {
14064 { "Mic", 0x0 },
14065 { "Front Mic", 0x1 },
14066 { "Line", 0x2 },
14067 },
14068};
14069
14070static struct hda_input_mux alc663_m51va_capture_source = {
14071 .num_items = 2,
14072 .items = {
14073 { "Ext-Mic", 0x0 },
14074 { "D-Mic", 0x9 },
14075 },
14076};
14077
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014078#define alc662_mux_enum_info alc_mux_enum_info
14079#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014080#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014081
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014082/*
14083 * 2ch mode
14084 */
14085static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14086 { 2, NULL }
14087};
14088
14089/*
14090 * 2ch mode
14091 */
14092static struct hda_verb alc662_3ST_ch2_init[] = {
14093 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14094 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14095 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14096 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14097 { } /* end */
14098};
14099
14100/*
14101 * 6ch mode
14102 */
14103static struct hda_verb alc662_3ST_ch6_init[] = {
14104 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14105 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14106 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14107 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14108 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14109 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14110 { } /* end */
14111};
14112
14113static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14114 { 2, alc662_3ST_ch2_init },
14115 { 6, alc662_3ST_ch6_init },
14116};
14117
14118/*
14119 * 2ch mode
14120 */
14121static struct hda_verb alc662_sixstack_ch6_init[] = {
14122 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14123 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14124 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14125 { } /* end */
14126};
14127
14128/*
14129 * 6ch mode
14130 */
14131static struct hda_verb alc662_sixstack_ch8_init[] = {
14132 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14133 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14135 { } /* end */
14136};
14137
14138static struct hda_channel_mode alc662_5stack_modes[2] = {
14139 { 2, alc662_sixstack_ch6_init },
14140 { 6, alc662_sixstack_ch8_init },
14141};
14142
14143/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14144 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14145 */
14146
14147static struct snd_kcontrol_new alc662_base_mixer[] = {
14148 /* output mixer control */
14149 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014150 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014152 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14154 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014155 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14156 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14158
14159 /*Input mixer control */
14160 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14161 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14162 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14163 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14164 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14165 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14166 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14167 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014168 { } /* end */
14169};
14170
14171static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014173 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14176 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14178 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14182 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14183 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14184 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014185 { } /* end */
14186};
14187
14188static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14189 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014190 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014192 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14204 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14206 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14207 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014208 { } /* end */
14209};
14210
14211static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14212 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14213 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14215 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014221 { } /* end */
14222};
14223
Kailang Yang291702f2007-10-16 14:28:03 +020014224static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014225 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014226
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014227 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14228 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014229
14230 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14231 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14232 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14233
14234 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14235 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14236 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14237 { } /* end */
14238};
14239
Kailang Yang8c427222008-01-10 13:03:59 +010014240static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014241 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14242 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14244 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014249 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014250 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14255 { } /* end */
14256};
14257
Kailang Yang6dda9f42008-05-27 12:05:31 +020014258static struct snd_kcontrol_new alc663_m51va_mixer[] = {
14259 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14260 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14264 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
14265 { } /* end */
14266};
14267
14268static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14269 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14270 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14271 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14272 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14274
14275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14277 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14278 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14279 { } /* end */
14280};
14281
14282static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14283 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14284 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14285 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14286
14287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14289 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14290 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14293 { } /* end */
14294};
14295
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014296static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14297 {
14298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14299 .name = "Channel Mode",
14300 .info = alc_ch_mode_info,
14301 .get = alc_ch_mode_get,
14302 .put = alc_ch_mode_put,
14303 },
14304 { } /* end */
14305};
14306
14307static struct hda_verb alc662_init_verbs[] = {
14308 /* ADC: mute amp left and right */
14309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14310 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14311 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14312
Takashi Iwaicb53c622007-08-10 17:21:45 +020014313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014318
Kailang Yangb60dd392007-09-20 12:50:29 +020014319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014325
14326 /* Front Pin: output 0 (0x0c) */
14327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14329
14330 /* Rear Pin: output 1 (0x0d) */
14331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14333
14334 /* CLFE Pin: output 2 (0x0e) */
14335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14336 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14337
14338 /* Mic (rear) pin: input vref at 80% */
14339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14341 /* Front Mic pin: input vref at 80% */
14342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14343 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14344 /* Line In pin: input */
14345 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14347 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14348 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14349 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14350 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14351 /* CD pin widget for input */
14352 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14353
14354 /* FIXME: use matrix-type input source selection */
14355 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14356 /* Input mixer */
14357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014361
14362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014366
14367 /* always trun on EAPD */
14368 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14369 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14370
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014371 { }
14372};
14373
14374static struct hda_verb alc662_sue_init_verbs[] = {
14375 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14376 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014377 {}
14378};
14379
14380static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14381 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14382 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14383 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014384};
14385
Kailang Yang8c427222008-01-10 13:03:59 +010014386/* Set Unsolicited Event*/
14387static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14389 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14390 {}
14391};
14392
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014393/*
14394 * generic initialization of ADC, input mixers and output mixers
14395 */
14396static struct hda_verb alc662_auto_init_verbs[] = {
14397 /*
14398 * Unmute ADC and set the default input to mic-in
14399 */
14400 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14402
14403 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14404 * mixer widget
14405 * Note: PASD motherboards uses the Line In 2 as the input for front
14406 * panel mic (mic 2)
14407 */
14408 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014414
14415 /*
14416 * Set up output mixers (0x0c - 0x0f)
14417 */
14418 /* set vol=0 to output mixers */
14419 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14420 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14422
14423 /* set up input amps for analog loopback */
14424 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14429 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014431
14432
14433 /* FIXME: use matrix-type input source selection */
14434 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14435 /* Input mixer */
14436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014438 { }
14439};
14440
Takashi Iwai24fb9172008-09-02 14:48:20 +020014441/* additional verbs for ALC663 */
14442static struct hda_verb alc663_auto_init_verbs[] = {
14443 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14444 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14445 { }
14446};
14447
Kailang Yang6dda9f42008-05-27 12:05:31 +020014448static struct hda_verb alc663_m51va_init_verbs[] = {
14449 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14450 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14451 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14452
14453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14454
14455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14456 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14457 {}
14458};
14459
14460static struct hda_verb alc663_g71v_init_verbs[] = {
14461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14462 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14463 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14464
14465 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14466 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14467 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14468
14469 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14471 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14472 {}
14473};
14474
14475static struct hda_verb alc663_g50v_init_verbs[] = {
14476 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14477 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14478 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14479
14480 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14481 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14482 {}
14483};
14484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014485/* capture mixer elements */
14486static struct snd_kcontrol_new alc662_capture_mixer[] = {
14487 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14488 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14489 {
14490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14491 /* The multiple "Capture Source" controls confuse alsamixer
14492 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014493 */
14494 /* .name = "Capture Source", */
14495 .name = "Input Source",
14496 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010014497 .info = alc662_mux_enum_info,
14498 .get = alc662_mux_enum_get,
14499 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014500 },
14501 { } /* end */
14502};
14503
14504static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14505{
14506 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014507 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014508
14509 present = snd_hda_codec_read(codec, 0x14, 0,
14510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014511 bits = present ? HDA_AMP_MUTE : 0;
14512 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14513 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014514}
14515
14516static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14517{
14518 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014519 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014520
14521 present = snd_hda_codec_read(codec, 0x1b, 0,
14522 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014523 bits = present ? HDA_AMP_MUTE : 0;
14524 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14525 HDA_AMP_MUTE, bits);
14526 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14527 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014528}
14529
14530static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14531 unsigned int res)
14532{
14533 if ((res >> 26) == ALC880_HP_EVENT)
14534 alc662_lenovo_101e_all_automute(codec);
14535 if ((res >> 26) == ALC880_FRONT_EVENT)
14536 alc662_lenovo_101e_ispeaker_automute(codec);
14537}
14538
Kailang Yang291702f2007-10-16 14:28:03 +020014539static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14540{
14541 unsigned int present;
14542
14543 present = snd_hda_codec_read(codec, 0x18, 0,
14544 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14545 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14546 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14547 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14548 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14549 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14550 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14551 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14552 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14553}
14554
14555/* unsolicited event for HP jack sensing */
14556static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14557 unsigned int res)
14558{
14559 if ((res >> 26) == ALC880_HP_EVENT)
14560 alc262_hippo1_automute( codec );
14561
14562 if ((res >> 26) == ALC880_MIC_EVENT)
14563 alc662_eeepc_mic_automute(codec);
14564}
14565
14566static void alc662_eeepc_inithook(struct hda_codec *codec)
14567{
14568 alc262_hippo1_automute( codec );
14569 alc662_eeepc_mic_automute(codec);
14570}
14571
Kailang Yang8c427222008-01-10 13:03:59 +010014572static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14573{
14574 unsigned int mute;
14575 unsigned int present;
14576
14577 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14578 present = snd_hda_codec_read(codec, 0x14, 0,
14579 AC_VERB_GET_PIN_SENSE, 0);
14580 present = (present & 0x80000000) != 0;
14581 if (present) {
14582 /* mute internal speaker */
14583 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014584 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010014585 } else {
14586 /* unmute internal speaker if necessary */
14587 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14588 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014589 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010014590 }
14591}
14592
14593/* unsolicited event for HP jack sensing */
14594static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14595 unsigned int res)
14596{
14597 if ((res >> 26) == ALC880_HP_EVENT)
14598 alc662_eeepc_ep20_automute(codec);
14599}
14600
14601static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14602{
14603 alc662_eeepc_ep20_automute(codec);
14604}
14605
Kailang Yang6dda9f42008-05-27 12:05:31 +020014606static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14607{
14608 unsigned int present;
14609 unsigned char bits;
14610
14611 present = snd_hda_codec_read(codec, 0x21, 0,
14612 AC_VERB_GET_PIN_SENSE, 0)
14613 & AC_PINSENSE_PRESENCE;
14614 bits = present ? HDA_AMP_MUTE : 0;
14615 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14616 HDA_AMP_MUTE, bits);
14617}
14618
14619static void alc663_m51va_mic_automute(struct hda_codec *codec)
14620{
14621 unsigned int present;
14622
14623 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014624 AC_VERB_GET_PIN_SENSE, 0)
14625 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020014626 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014627 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014628 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014629 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014630 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014631 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014632 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014633 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014634}
14635
14636static void alc663_m51va_unsol_event(struct hda_codec *codec,
14637 unsigned int res)
14638{
14639 switch (res >> 26) {
14640 case ALC880_HP_EVENT:
14641 alc663_m51va_speaker_automute(codec);
14642 break;
14643 case ALC880_MIC_EVENT:
14644 alc663_m51va_mic_automute(codec);
14645 break;
14646 }
14647}
14648
14649static void alc663_m51va_inithook(struct hda_codec *codec)
14650{
14651 alc663_m51va_speaker_automute(codec);
14652 alc663_m51va_mic_automute(codec);
14653}
14654
14655static void alc663_g71v_hp_automute(struct hda_codec *codec)
14656{
14657 unsigned int present;
14658 unsigned char bits;
14659
14660 present = snd_hda_codec_read(codec, 0x21, 0,
14661 AC_VERB_GET_PIN_SENSE, 0)
14662 & AC_PINSENSE_PRESENCE;
14663 bits = present ? HDA_AMP_MUTE : 0;
14664 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14665 HDA_AMP_MUTE, bits);
14666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14667 HDA_AMP_MUTE, bits);
14668}
14669
14670static void alc663_g71v_front_automute(struct hda_codec *codec)
14671{
14672 unsigned int present;
14673 unsigned char bits;
14674
14675 present = snd_hda_codec_read(codec, 0x15, 0,
14676 AC_VERB_GET_PIN_SENSE, 0)
14677 & AC_PINSENSE_PRESENCE;
14678 bits = present ? HDA_AMP_MUTE : 0;
14679 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14680 HDA_AMP_MUTE, bits);
14681}
14682
14683static void alc663_g71v_unsol_event(struct hda_codec *codec,
14684 unsigned int res)
14685{
14686 switch (res >> 26) {
14687 case ALC880_HP_EVENT:
14688 alc663_g71v_hp_automute(codec);
14689 break;
14690 case ALC880_FRONT_EVENT:
14691 alc663_g71v_front_automute(codec);
14692 break;
14693 case ALC880_MIC_EVENT:
14694 alc662_eeepc_mic_automute(codec);
14695 break;
14696 }
14697}
14698
14699static void alc663_g71v_inithook(struct hda_codec *codec)
14700{
14701 alc663_g71v_front_automute(codec);
14702 alc663_g71v_hp_automute(codec);
14703 alc662_eeepc_mic_automute(codec);
14704}
14705
14706static void alc663_g50v_unsol_event(struct hda_codec *codec,
14707 unsigned int res)
14708{
14709 switch (res >> 26) {
14710 case ALC880_HP_EVENT:
14711 alc663_m51va_speaker_automute(codec);
14712 break;
14713 case ALC880_MIC_EVENT:
14714 alc662_eeepc_mic_automute(codec);
14715 break;
14716 }
14717}
14718
14719static void alc663_g50v_inithook(struct hda_codec *codec)
14720{
14721 alc663_m51va_speaker_automute(codec);
14722 alc662_eeepc_mic_automute(codec);
14723}
14724
Takashi Iwaicb53c622007-08-10 17:21:45 +020014725#ifdef CONFIG_SND_HDA_POWER_SAVE
14726#define alc662_loopbacks alc880_loopbacks
14727#endif
14728
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014729
14730/* pcm configuration: identiacal with ALC880 */
14731#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14732#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14733#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14734#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14735
14736/*
14737 * configuration and preset
14738 */
14739static const char *alc662_models[ALC662_MODEL_LAST] = {
14740 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14741 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14742 [ALC662_3ST_6ch] = "3stack-6ch",
14743 [ALC662_5ST_DIG] = "6stack-dig",
14744 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014745 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014746 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014747 [ALC663_ASUS_M51VA] = "m51va",
14748 [ALC663_ASUS_G71V] = "g71v",
14749 [ALC663_ASUS_H13] = "h13",
14750 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014751 [ALC662_AUTO] = "auto",
14752};
14753
14754static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014755 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14756 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14757 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014758 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014759 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014760 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014761 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014762 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14763 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14764 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014765 {}
14766};
14767
14768static struct alc_config_preset alc662_presets[] = {
14769 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014770 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014771 .init_verbs = { alc662_init_verbs },
14772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14773 .dac_nids = alc662_dac_nids,
14774 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014775 .dig_in_nid = ALC662_DIGIN_NID,
14776 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14777 .channel_mode = alc662_3ST_2ch_modes,
14778 .input_mux = &alc662_capture_source,
14779 },
14780 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014781 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14782 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014783 .init_verbs = { alc662_init_verbs },
14784 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14785 .dac_nids = alc662_dac_nids,
14786 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014787 .dig_in_nid = ALC662_DIGIN_NID,
14788 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14789 .channel_mode = alc662_3ST_6ch_modes,
14790 .need_dac_fix = 1,
14791 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014792 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014793 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014794 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14795 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014796 .init_verbs = { alc662_init_verbs },
14797 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14798 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014799 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14800 .channel_mode = alc662_3ST_6ch_modes,
14801 .need_dac_fix = 1,
14802 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014803 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014804 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014805 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14806 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014807 .init_verbs = { alc662_init_verbs },
14808 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14809 .dac_nids = alc662_dac_nids,
14810 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014811 .dig_in_nid = ALC662_DIGIN_NID,
14812 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14813 .channel_mode = alc662_5stack_modes,
14814 .input_mux = &alc662_capture_source,
14815 },
14816 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014817 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014818 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14819 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14820 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014821 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14822 .channel_mode = alc662_3ST_2ch_modes,
14823 .input_mux = &alc662_lenovo_101e_capture_source,
14824 .unsol_event = alc662_lenovo_101e_unsol_event,
14825 .init_hook = alc662_lenovo_101e_all_automute,
14826 },
Kailang Yang291702f2007-10-16 14:28:03 +020014827 [ALC662_ASUS_EEEPC_P701] = {
14828 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14829 .init_verbs = { alc662_init_verbs,
14830 alc662_eeepc_sue_init_verbs },
14831 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14832 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014833 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14834 .channel_mode = alc662_3ST_2ch_modes,
14835 .input_mux = &alc662_eeepc_capture_source,
14836 .unsol_event = alc662_eeepc_unsol_event,
14837 .init_hook = alc662_eeepc_inithook,
14838 },
Kailang Yang8c427222008-01-10 13:03:59 +010014839 [ALC662_ASUS_EEEPC_EP20] = {
14840 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14841 alc662_chmode_mixer },
14842 .init_verbs = { alc662_init_verbs,
14843 alc662_eeepc_ep20_sue_init_verbs },
14844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14845 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14847 .channel_mode = alc662_3ST_6ch_modes,
14848 .input_mux = &alc662_lenovo_101e_capture_source,
14849 .unsol_event = alc662_eeepc_ep20_unsol_event,
14850 .init_hook = alc662_eeepc_ep20_inithook,
14851 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014852 [ALC663_ASUS_M51VA] = {
14853 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14854 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14855 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14856 .dac_nids = alc662_dac_nids,
14857 .dig_out_nid = ALC662_DIGOUT_NID,
14858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14859 .channel_mode = alc662_3ST_2ch_modes,
14860 .input_mux = &alc663_m51va_capture_source,
14861 .unsol_event = alc663_m51va_unsol_event,
14862 .init_hook = alc663_m51va_inithook,
14863 },
14864 [ALC663_ASUS_G71V] = {
14865 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14866 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14868 .dac_nids = alc662_dac_nids,
14869 .dig_out_nid = ALC662_DIGOUT_NID,
14870 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14871 .channel_mode = alc662_3ST_2ch_modes,
14872 .input_mux = &alc662_eeepc_capture_source,
14873 .unsol_event = alc663_g71v_unsol_event,
14874 .init_hook = alc663_g71v_inithook,
14875 },
14876 [ALC663_ASUS_H13] = {
14877 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14878 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14879 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14880 .dac_nids = alc662_dac_nids,
14881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14882 .channel_mode = alc662_3ST_2ch_modes,
14883 .input_mux = &alc663_m51va_capture_source,
14884 .unsol_event = alc663_m51va_unsol_event,
14885 .init_hook = alc663_m51va_inithook,
14886 },
14887 [ALC663_ASUS_G50V] = {
14888 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14889 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14890 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14891 .dac_nids = alc662_dac_nids,
14892 .dig_out_nid = ALC662_DIGOUT_NID,
14893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14894 .channel_mode = alc662_3ST_6ch_modes,
14895 .input_mux = &alc663_capture_source,
14896 .unsol_event = alc663_g50v_unsol_event,
14897 .init_hook = alc663_g50v_inithook,
14898 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014899};
14900
14901
14902/*
14903 * BIOS auto configuration
14904 */
14905
14906/* add playback controls from the parsed DAC table */
14907static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14908 const struct auto_pin_cfg *cfg)
14909{
14910 char name[32];
14911 static const char *chname[4] = {
14912 "Front", "Surround", NULL /*CLFE*/, "Side"
14913 };
14914 hda_nid_t nid;
14915 int i, err;
14916
14917 for (i = 0; i < cfg->line_outs; i++) {
14918 if (!spec->multiout.dac_nids[i])
14919 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020014920 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014921 if (i == 2) {
14922 /* Center/LFE */
14923 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14924 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014925 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14926 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014927 if (err < 0)
14928 return err;
14929 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14930 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014931 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14932 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014933 if (err < 0)
14934 return err;
14935 err = add_control(spec, ALC_CTL_BIND_MUTE,
14936 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014937 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14938 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014939 if (err < 0)
14940 return err;
14941 err = add_control(spec, ALC_CTL_BIND_MUTE,
14942 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014943 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14944 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014945 if (err < 0)
14946 return err;
14947 } else {
14948 sprintf(name, "%s Playback Volume", chname[i]);
14949 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014950 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14951 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014952 if (err < 0)
14953 return err;
14954 sprintf(name, "%s Playback Switch", chname[i]);
14955 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014956 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14957 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014958 if (err < 0)
14959 return err;
14960 }
14961 }
14962 return 0;
14963}
14964
14965/* add playback controls for speaker and HP outputs */
14966static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14967 const char *pfx)
14968{
14969 hda_nid_t nid;
14970 int err;
14971 char name[32];
14972
14973 if (!pin)
14974 return 0;
14975
Takashi Iwai24fb9172008-09-02 14:48:20 +020014976 if (pin == 0x17) {
14977 /* ALC663 has a mono output pin on 0x17 */
14978 sprintf(name, "%s Playback Switch", pfx);
14979 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14980 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
14981 return err;
14982 }
14983
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014984 if (alc880_is_fixed_pin(pin)) {
14985 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14986 /* printk("DAC nid=%x\n",nid); */
14987 /* specify the DAC as the extra output */
14988 if (!spec->multiout.hp_nid)
14989 spec->multiout.hp_nid = nid;
14990 else
14991 spec->multiout.extra_out_nid[0] = nid;
14992 /* control HP volume/switch on the output mixer amp */
14993 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14994 sprintf(name, "%s Playback Volume", pfx);
14995 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14996 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14997 if (err < 0)
14998 return err;
14999 sprintf(name, "%s Playback Switch", pfx);
15000 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15001 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
15002 if (err < 0)
15003 return err;
15004 } else if (alc880_is_multi_pin(pin)) {
15005 /* set manual connection */
15006 /* we have only a switch on HP-out PIN */
15007 sprintf(name, "%s Playback Switch", pfx);
15008 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15009 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15010 if (err < 0)
15011 return err;
15012 }
15013 return 0;
15014}
15015
15016/* create playback/capture controls for input pins */
15017static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
15018 const struct auto_pin_cfg *cfg)
15019{
15020 struct hda_input_mux *imux = &spec->private_imux;
15021 int i, err, idx;
15022
15023 for (i = 0; i < AUTO_PIN_LAST; i++) {
15024 if (alc880_is_input_pin(cfg->input_pins[i])) {
15025 idx = alc880_input_pin_idx(cfg->input_pins[i]);
15026 err = new_analog_input(spec, cfg->input_pins[i],
15027 auto_pin_cfg_labels[i],
15028 idx, 0x0b);
15029 if (err < 0)
15030 return err;
15031 imux->items[imux->num_items].label =
15032 auto_pin_cfg_labels[i];
15033 imux->items[imux->num_items].index =
15034 alc880_input_pin_idx(cfg->input_pins[i]);
15035 imux->num_items++;
15036 }
15037 }
15038 return 0;
15039}
15040
15041static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
15042 hda_nid_t nid, int pin_type,
15043 int dac_idx)
15044{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015045 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015046 /* need the manual connection? */
15047 if (alc880_is_multi_pin(nid)) {
15048 struct alc_spec *spec = codec->spec;
15049 int idx = alc880_multi_pin_idx(nid);
15050 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
15051 AC_VERB_SET_CONNECT_SEL,
15052 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
15053 }
15054}
15055
15056static void alc662_auto_init_multi_out(struct hda_codec *codec)
15057{
15058 struct alc_spec *spec = codec->spec;
15059 int i;
15060
Kailang Yang8c427222008-01-10 13:03:59 +010015061 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015062 for (i = 0; i <= HDA_SIDE; i++) {
15063 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015064 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015065 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015066 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015067 i);
15068 }
15069}
15070
15071static void alc662_auto_init_hp_out(struct hda_codec *codec)
15072{
15073 struct alc_spec *spec = codec->spec;
15074 hda_nid_t pin;
15075
15076 pin = spec->autocfg.hp_pins[0];
15077 if (pin) /* connect to front */
15078 /* use dac 0 */
15079 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015080 pin = spec->autocfg.speaker_pins[0];
15081 if (pin)
15082 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015083}
15084
15085#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
15086#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
15087
15088static void alc662_auto_init_analog_input(struct hda_codec *codec)
15089{
15090 struct alc_spec *spec = codec->spec;
15091 int i;
15092
15093 for (i = 0; i < AUTO_PIN_LAST; i++) {
15094 hda_nid_t nid = spec->autocfg.input_pins[i];
15095 if (alc662_is_input_pin(nid)) {
15096 snd_hda_codec_write(codec, nid, 0,
15097 AC_VERB_SET_PIN_WIDGET_CONTROL,
15098 (i <= AUTO_PIN_FRONT_MIC ?
15099 PIN_VREF80 : PIN_IN));
15100 if (nid != ALC662_PIN_CD_NID)
15101 snd_hda_codec_write(codec, nid, 0,
15102 AC_VERB_SET_AMP_GAIN_MUTE,
15103 AMP_OUT_MUTE);
15104 }
15105 }
15106}
15107
Takashi Iwaif511b012008-08-15 16:46:42 +020015108#define alc662_auto_init_input_src alc882_auto_init_input_src
15109
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015110static int alc662_parse_auto_config(struct hda_codec *codec)
15111{
15112 struct alc_spec *spec = codec->spec;
15113 int err;
15114 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
15115
15116 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15117 alc662_ignore);
15118 if (err < 0)
15119 return err;
15120 if (!spec->autocfg.line_outs)
15121 return 0; /* can't find valid BIOS pin config */
15122
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015123 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15124 if (err < 0)
15125 return err;
15126 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
15127 if (err < 0)
15128 return err;
15129 err = alc662_auto_create_extra_out(spec,
15130 spec->autocfg.speaker_pins[0],
15131 "Speaker");
15132 if (err < 0)
15133 return err;
15134 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
15135 "Headphone");
15136 if (err < 0)
15137 return err;
15138 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
15139 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015140 return err;
15141
15142 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15143
15144 if (spec->autocfg.dig_out_pin)
15145 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
15146
15147 if (spec->kctl_alloc)
15148 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
15149
15150 spec->num_mux_defs = 1;
15151 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020015152
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015153 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020015154 if (codec->vendor_id == 0x10ec0663)
15155 spec->init_verbs[spec->num_init_verbs++] =
15156 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020015157
15158 err = alc_auto_add_mic_boost(codec);
15159 if (err < 0)
15160 return err;
15161
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015162 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
15163 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015164 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015165}
15166
15167/* additional initialization for auto-configuration model */
15168static void alc662_auto_init(struct hda_codec *codec)
15169{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015170 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015171 alc662_auto_init_multi_out(codec);
15172 alc662_auto_init_hp_out(codec);
15173 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015174 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015175 if (spec->unsol_event)
15176 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015177}
15178
15179static int patch_alc662(struct hda_codec *codec)
15180{
15181 struct alc_spec *spec;
15182 int err, board_config;
15183
15184 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15185 if (!spec)
15186 return -ENOMEM;
15187
15188 codec->spec = spec;
15189
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020015190 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15191
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015192 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
15193 alc662_models,
15194 alc662_cfg_tbl);
15195 if (board_config < 0) {
15196 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
15197 "trying auto-probe from BIOS...\n");
15198 board_config = ALC662_AUTO;
15199 }
15200
15201 if (board_config == ALC662_AUTO) {
15202 /* automatic parse from the BIOS config */
15203 err = alc662_parse_auto_config(codec);
15204 if (err < 0) {
15205 alc_free(codec);
15206 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015207 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015208 printk(KERN_INFO
15209 "hda_codec: Cannot set up configuration "
15210 "from BIOS. Using base mode...\n");
15211 board_config = ALC662_3ST_2ch_DIG;
15212 }
15213 }
15214
15215 if (board_config != ALC662_AUTO)
15216 setup_preset(spec, &alc662_presets[board_config]);
15217
Kailang Yang6dda9f42008-05-27 12:05:31 +020015218 if (codec->vendor_id == 0x10ec0663) {
15219 spec->stream_name_analog = "ALC663 Analog";
15220 spec->stream_name_digital = "ALC663 Digital";
15221 } else {
15222 spec->stream_name_analog = "ALC662 Analog";
15223 spec->stream_name_digital = "ALC662 Digital";
15224 }
15225
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015226 spec->stream_analog_playback = &alc662_pcm_analog_playback;
15227 spec->stream_analog_capture = &alc662_pcm_analog_capture;
15228
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015229 spec->stream_digital_playback = &alc662_pcm_digital_playback;
15230 spec->stream_digital_capture = &alc662_pcm_digital_capture;
15231
Takashi Iwaie1406342008-02-11 18:32:32 +010015232 spec->adc_nids = alc662_adc_nids;
15233 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
15234 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015235
Takashi Iwai2134ea42008-01-10 16:53:55 +010015236 spec->vmaster_nid = 0x02;
15237
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015238 codec->patch_ops = alc_patch_ops;
15239 if (board_config == ALC662_AUTO)
15240 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015241#ifdef CONFIG_SND_HDA_POWER_SAVE
15242 if (!spec->loopback.amplist)
15243 spec->loopback.amplist = alc662_loopbacks;
15244#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015245
15246 return 0;
15247}
15248
15249/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070015250 * patch entries
15251 */
15252struct hda_codec_preset snd_hda_preset_realtek[] = {
15253 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015254 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015255 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020015256 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015257 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015258 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015259 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015260 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
15261 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
15262 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
15264 .patch = patch_alc883 },
15265 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
15266 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015267 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015268 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015269 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015270 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020015271 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020015272 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010015273 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015274 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015275 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015276 {} /* terminator */
15277};