blob: 3e21a71986564040bd9a141a0606715f8c3bb240 [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,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 ALC262_AUTO,
108 ALC262_MODEL_LAST /* last tag */
109};
110
Kailang Yanga361d842007-06-05 12:30:55 +0200111/* ALC268 models */
112enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200113 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200115 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200116 ALC268_ACER,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100133 ALC269_AUTO,
134 ALC269_MODEL_LAST /* last tag */
135};
136
Kailang Yangdf694da2005-12-05 19:42:22 +0100137/* ALC861 models */
138enum {
139 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200140 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100141 ALC861_3ST_DIG,
142 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200143 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200144 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200145 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100146 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100147 ALC861_AUTO,
148 ALC861_MODEL_LAST,
149};
150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100151/* ALC861-VD models */
152enum {
153 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200154 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100155 ALC861VD_3ST,
156 ALC861VD_3ST_DIG,
157 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200158 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200159 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200160 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_AUTO,
162 ALC861VD_MODEL_LAST,
163};
164
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200165/* ALC662 models */
166enum {
167 ALC662_3ST_2ch_DIG,
168 ALC662_3ST_6ch_DIG,
169 ALC662_3ST_6ch,
170 ALC662_5ST_DIG,
171 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200172 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100173 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200174 ALC663_ASUS_M51VA,
175 ALC663_ASUS_G71V,
176 ALC663_ASUS_H13,
177 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200178 ALC662_ECS,
179 ALC663_ASUS_MODE1,
180 ALC662_ASUS_MODE2,
181 ALC663_ASUS_MODE3,
182 ALC663_ASUS_MODE4,
183 ALC663_ASUS_MODE5,
184 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200185 ALC662_AUTO,
186 ALC662_MODEL_LAST,
187};
188
Kailang Yangdf694da2005-12-05 19:42:22 +0100189/* ALC882 models */
190enum {
191 ALC882_3ST_DIG,
192 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200193 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200194 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC882_TARGA,
196 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200197 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100198 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200199 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200200 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100202 ALC882_MODEL_LAST,
203};
204
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200205/* ALC883 models */
206enum {
207 ALC883_3ST_2ch_DIG,
208 ALC883_3ST_6ch_DIG,
209 ALC883_3ST_6ch,
210 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200211 ALC883_TARGA_DIG,
212 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200213 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200214 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200215 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200216 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100217 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200218 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200219 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200220 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200221 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200222 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200223 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100224 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100225 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100226 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100227 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200228 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_ASUS_M90V,
230 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200231 ALC883_AUTO,
232 ALC883_MODEL_LAST,
233};
234
Kailang Yangdf694da2005-12-05 19:42:22 +0100235/* for GPIO Poll */
236#define GPIO_MASK 0x03
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238struct alc_spec {
239 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 unsigned int num_mixers;
242
Kailang Yangdf694da2005-12-05 19:42:22 +0100243 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200244 * don't forget NULL
245 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200246 */
247 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Takashi Iwai16ded522005-06-10 19:58:24 +0200249 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 struct hda_pcm_stream *stream_analog_playback;
251 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100252 struct hda_pcm_stream *stream_analog_alt_playback;
253 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200255 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 struct hda_pcm_stream *stream_digital_playback;
257 struct hda_pcm_stream *stream_digital_capture;
258
259 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200260 struct hda_multi_out multiout; /* playback set-up
261 * max_channels, dacs must be set
262 * dig_out_nid and hp_nid are optional
263 */
Takashi Iwai63300792008-01-24 15:31:36 +0100264 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266 /* capture */
267 unsigned int num_adc_nids;
268 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100269 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200270 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200273 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 const struct hda_input_mux *input_mux;
275 unsigned int cur_mux[3];
276
277 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100278 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200280 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100283 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200284
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200285 /* dynamic controls, init_verbs and input_mux */
286 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200287 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200288 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200289 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100290
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100291 /* hooks */
292 void (*init_hook)(struct hda_codec *codec);
293 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
294
Takashi Iwai834be882006-03-01 14:16:17 +0100295 /* for pin sensing */
296 unsigned int sense_updated: 1;
297 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100298 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200299
Takashi Iwai2134ea42008-01-10 16:53:55 +0100300 /* for virtual master */
301 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200302#ifdef CONFIG_SND_HDA_POWER_SAVE
303 struct hda_loopback_check loopback;
304#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200305
306 /* for PLL fix */
307 hda_nid_t pll_nid;
308 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100309};
310
311/*
312 * configuration template - to be copied to the spec instance
313 */
314struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200315 struct snd_kcontrol_new *mixers[5]; /* should be identical size
316 * with spec
317 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100318 const struct hda_verb *init_verbs[5];
319 unsigned int num_dacs;
320 hda_nid_t *dac_nids;
321 hda_nid_t dig_out_nid; /* optional */
322 hda_nid_t hp_nid; /* optional */
323 unsigned int num_adc_nids;
324 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100325 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100326 hda_nid_t dig_in_nid;
327 unsigned int num_channel_mode;
328 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200329 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200330 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100331 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100332 void (*unsol_event)(struct hda_codec *, unsigned int);
333 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200334#ifdef CONFIG_SND_HDA_POWER_SAVE
335 struct hda_amp_list *loopbacks;
336#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337};
338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
340/*
341 * input MUX handling
342 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200348 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
349 if (mux_idx >= spec->num_mux_defs)
350 mux_idx = 0;
351 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352}
353
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354static int alc_mux_enum_get(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);
360
361 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
362 return 0;
363}
364
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200365static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
366 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367{
368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
369 struct alc_spec *spec = codec->spec;
370 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200371 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100372 hda_nid_t nid = spec->capsrc_nids ?
373 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100375 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376}
377
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379/*
380 * channel mode setting
381 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200382static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100387 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
388 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389}
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100396 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200397 spec->num_channel_mode,
398 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399}
400
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200401static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403{
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200406 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
407 spec->num_channel_mode,
408 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200409 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200410 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
411 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412}
413
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100415 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200416 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417 * being part of a format specifier. Maximum allowed length of a value is
418 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100419 *
420 * Note: some retasking pin complexes seem to ignore requests for input
421 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
422 * are requested. Therefore order this list so that this behaviour will not
423 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200424 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
425 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200426 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100428 "Mic 50pc bias", "Mic 80pc bias",
429 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100430};
431static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100432 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100433};
434/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200435 * in the pin being assumed to be exclusively an input or an output pin. In
436 * addition, "input" pins may or may not process the mic bias option
437 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
438 * accept requests for bias as of chip versions up to March 2006) and/or
439 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100440 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200441#define ALC_PIN_DIR_IN 0x00
442#define ALC_PIN_DIR_OUT 0x01
443#define ALC_PIN_DIR_INOUT 0x02
444#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
445#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446
Kailang Yangea1fb292008-08-26 12:58:38 +0200447/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448 * For each direction the minimum and maximum values are given.
449 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 { 0, 2 }, /* ALC_PIN_DIR_IN */
452 { 3, 4 }, /* ALC_PIN_DIR_OUT */
453 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200454 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
455 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456};
457#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
458#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
459#define alc_pin_mode_n_items(_dir) \
460 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
461
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200464{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100465 unsigned int item_num = uinfo->value.enumerated.item;
466 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
467
468 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200469 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100470 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
471
472 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
473 item_num = alc_pin_mode_min(dir);
474 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200475 return 0;
476}
477
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200478static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
479 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200480{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200485 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_PIN_WIDGET_CONTROL,
488 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200489
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100490 /* Find enumerated value for current pinctl setting */
491 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200492 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495 return 0;
496}
497
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500{
501 signed int change;
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 hda_nid_t nid = kcontrol->private_value & 0xffff;
504 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
505 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200506 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
507 AC_VERB_GET_PIN_WIDGET_CONTROL,
508 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200510 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511 val = alc_pin_mode_min(dir);
512
513 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100514 if (change) {
515 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200516 snd_hda_codec_write_cache(codec, nid, 0,
517 AC_VERB_SET_PIN_WIDGET_CONTROL,
518 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100519
Kailang Yangea1fb292008-08-26 12:58:38 +0200520 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100521 * for the requested pin mode. Enum values of 2 or less are
522 * input modes.
523 *
524 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200525 * reduces noise slightly (particularly on input) so we'll
526 * do it. However, having both input and output buffers
527 * enabled simultaneously doesn't seem to be problematic if
528 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100529 */
530 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200531 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
532 HDA_AMP_MUTE, HDA_AMP_MUTE);
533 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
534 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100535 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200536 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
537 HDA_AMP_MUTE, HDA_AMP_MUTE);
538 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
539 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100540 }
541 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200542 return change;
543}
544
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 .info = alc_pin_mode_info, \
548 .get = alc_pin_mode_get, \
549 .put = alc_pin_mode_put, \
550 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100551
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100552/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
553 * together using a mask with more than one bit set. This control is
554 * currently used only by the ALC260 test model. At this stage they are not
555 * needed for any "production" models.
556 */
557#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200558#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100562{
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
565 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
566 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200567 unsigned int val = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100569
570 *valp = (val & mask) != 0;
571 return 0;
572}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100575{
576 signed int change;
577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
578 hda_nid_t nid = kcontrol->private_value & 0xffff;
579 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
580 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
582 AC_VERB_GET_GPIO_DATA,
583 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100584
585 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
587 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100588 gpio_data &= ~mask;
589 else
590 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200591 snd_hda_codec_write_cache(codec, nid, 0,
592 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100593
594 return change;
595}
596#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
597 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
598 .info = alc_gpio_data_info, \
599 .get = alc_gpio_data_get, \
600 .put = alc_gpio_data_put, \
601 .private_value = nid | (mask<<16) }
602#endif /* CONFIG_SND_DEBUG */
603
Jonathan Woithe92621f12006-02-28 11:47:47 +0100604/* A switch control to allow the enabling of the digital IO pins on the
605 * ALC260. This is incredibly simplistic; the intention of this control is
606 * to provide something in the test model allowing digital outputs to be
607 * identified if present. If models are found which can utilise these
608 * outputs a more complete mixer control can be devised for those models if
609 * necessary.
610 */
611#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200612#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200613
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100616{
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
619 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
620 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100622 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100623
624 *valp = (val & mask) != 0;
625 return 0;
626}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100629{
630 signed int change;
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 hda_nid_t nid = kcontrol->private_value & 0xffff;
633 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
634 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100636 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100638
639 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100641 if (val==0)
642 ctrl_data &= ~mask;
643 else
644 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200645 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
646 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100647
648 return change;
649}
650#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
651 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
652 .info = alc_spdif_ctrl_info, \
653 .get = alc_spdif_ctrl_get, \
654 .put = alc_spdif_ctrl_put, \
655 .private_value = nid | (mask<<16) }
656#endif /* CONFIG_SND_DEBUG */
657
Jonathan Woithef8225f62008-01-08 12:16:54 +0100658/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
659 * Again, this is only used in the ALC26x test models to help identify when
660 * the EAPD line must be asserted for features to work.
661 */
662#ifdef CONFIG_SND_DEBUG
663#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
664
665static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_value *ucontrol)
667{
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 hda_nid_t nid = kcontrol->private_value & 0xffff;
670 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
671 long *valp = ucontrol->value.integer.value;
672 unsigned int val = snd_hda_codec_read(codec, nid, 0,
673 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
674
675 *valp = (val & mask) != 0;
676 return 0;
677}
678
679static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
681{
682 int change;
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_EAPD_BTLENABLE,
689 0x00);
690
691 /* Set/unset the masked control bit(s) as needed */
692 change = (!val ? 0 : mask) != (ctrl_data & mask);
693 if (!val)
694 ctrl_data &= ~mask;
695 else
696 ctrl_data |= mask;
697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
698 ctrl_data);
699
700 return change;
701}
702
703#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
704 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
705 .info = alc_eapd_ctrl_info, \
706 .get = alc_eapd_ctrl_get, \
707 .put = alc_eapd_ctrl_put, \
708 .private_value = nid | (mask<<16) }
709#endif /* CONFIG_SND_DEBUG */
710
Kailang Yangdf694da2005-12-05 19:42:22 +0100711/*
712 * set up from the preset table
713 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714static void setup_preset(struct alc_spec *spec,
715 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100716{
717 int i;
718
719 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
720 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200721 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
722 i++)
723 spec->init_verbs[spec->num_init_verbs++] =
724 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200725
Kailang Yangdf694da2005-12-05 19:42:22 +0100726 spec->channel_mode = preset->channel_mode;
727 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200728 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100729
730 spec->multiout.max_channels = spec->channel_mode[0].channels;
731
732 spec->multiout.num_dacs = preset->num_dacs;
733 spec->multiout.dac_nids = preset->dac_nids;
734 spec->multiout.dig_out_nid = preset->dig_out_nid;
735 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200736
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200737 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200738 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200739 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100740 spec->input_mux = preset->input_mux;
741
742 spec->num_adc_nids = preset->num_adc_nids;
743 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100744 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100745 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100746
747 spec->unsol_event = preset->unsol_event;
748 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200749#ifdef CONFIG_SND_HDA_POWER_SAVE
750 spec->loopback.amplist = preset->loopbacks;
751#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100752}
753
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200754/* Enable GPIO mask and set output */
755static struct hda_verb alc_gpio1_init_verbs[] = {
756 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
757 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
758 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
759 { }
760};
761
762static struct hda_verb alc_gpio2_init_verbs[] = {
763 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
764 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
765 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
766 { }
767};
768
Kailang Yangbdd148a2007-05-08 15:19:08 +0200769static struct hda_verb alc_gpio3_init_verbs[] = {
770 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
771 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
772 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
773 { }
774};
775
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200776/*
777 * Fix hardware PLL issue
778 * On some codecs, the analog PLL gating control must be off while
779 * the default value is 1.
780 */
781static void alc_fix_pll(struct hda_codec *codec)
782{
783 struct alc_spec *spec = codec->spec;
784 unsigned int val;
785
786 if (!spec->pll_nid)
787 return;
788 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
789 spec->pll_coef_idx);
790 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
791 AC_VERB_GET_PROC_COEF, 0);
792 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
793 spec->pll_coef_idx);
794 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
795 val & ~(1 << spec->pll_coef_bit));
796}
797
798static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
799 unsigned int coef_idx, unsigned int coef_bit)
800{
801 struct alc_spec *spec = codec->spec;
802 spec->pll_nid = nid;
803 spec->pll_coef_idx = coef_idx;
804 spec->pll_coef_bit = coef_bit;
805 alc_fix_pll(codec);
806}
807
Kailang Yangc9b58002007-10-16 14:30:01 +0200808static void alc_sku_automute(struct hda_codec *codec)
809{
810 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200811 unsigned int present;
812 unsigned int hp_nid = spec->autocfg.hp_pins[0];
813 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
814
815 /* need to execute and sync at first */
816 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
817 present = snd_hda_codec_read(codec, hp_nid, 0,
818 AC_VERB_GET_PIN_SENSE, 0);
819 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100820 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
821 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200822}
823
824/* unsolicited event for HP jack sensing */
825static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
826{
827 if (codec->vendor_id == 0x10ec0880)
828 res >>= 28;
829 else
830 res >>= 26;
831 if (res != ALC880_HP_EVENT)
832 return;
833
834 alc_sku_automute(codec);
835}
836
Kailang Yangf9423e72008-05-27 12:32:25 +0200837/* additional initialization for ALC888 variants */
838static void alc888_coef_init(struct hda_codec *codec)
839{
840 unsigned int tmp;
841
842 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
843 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
844 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
845 if ((tmp & 0xf0) == 2)
846 /* alc888S-VC */
847 snd_hda_codec_read(codec, 0x20, 0,
848 AC_VERB_SET_PROC_COEF, 0x830);
849 else
850 /* alc888-VB */
851 snd_hda_codec_read(codec, 0x20, 0,
852 AC_VERB_SET_PROC_COEF, 0x3030);
853}
854
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200855/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
856 * 31 ~ 16 : Manufacture ID
857 * 15 ~ 8 : SKU ID
858 * 7 ~ 0 : Assembly ID
859 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
860 */
861static void alc_subsystem_id(struct hda_codec *codec,
862 unsigned int porta, unsigned int porte,
863 unsigned int portd)
864{
Kailang Yangc9b58002007-10-16 14:30:01 +0200865 unsigned int ass, tmp, i;
866 unsigned nid;
867 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200868
Kailang Yangc9b58002007-10-16 14:30:01 +0200869 ass = codec->subsystem_id & 0xffff;
870 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
871 goto do_sku;
872
Kailang Yangea1fb292008-08-26 12:58:38 +0200873 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200874 * 31~30 : port conetcivity
875 * 29~21 : reserve
876 * 20 : PCBEEP input
877 * 19~16 : Check sum (15:1)
878 * 15~1 : Custom
879 * 0 : override
880 */
881 nid = 0x1d;
882 if (codec->vendor_id == 0x10ec0260)
883 nid = 0x17;
884 ass = snd_hda_codec_read(codec, nid, 0,
885 AC_VERB_GET_CONFIG_DEFAULT, 0);
886 if (!(ass & 1) && !(ass & 0x100000))
887 return;
888 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200889 return;
890
Kailang Yangc9b58002007-10-16 14:30:01 +0200891 /* check sum */
892 tmp = 0;
893 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100894 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200895 tmp++;
896 }
897 if (((ass >> 16) & 0xf) != tmp)
898 return;
899do_sku:
900 /*
901 * 0 : override
902 * 1 : Swap Jack
903 * 2 : 0 --> Desktop, 1 --> Laptop
904 * 3~5 : External Amplifier control
905 * 7~6 : Reserved
906 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200907 tmp = (ass & 0x38) >> 3; /* external Amp control */
908 switch (tmp) {
909 case 1:
910 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
911 break;
912 case 3:
913 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
914 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200915 case 7:
916 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
917 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200918 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200919 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200920 case 0x10ec0260:
921 snd_hda_codec_write(codec, 0x0f, 0,
922 AC_VERB_SET_EAPD_BTLENABLE, 2);
923 snd_hda_codec_write(codec, 0x10, 0,
924 AC_VERB_SET_EAPD_BTLENABLE, 2);
925 break;
926 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200927 case 0x10ec0267:
928 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200929 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200930 case 0x10ec0660:
931 case 0x10ec0662:
932 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200933 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200934 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200935 snd_hda_codec_write(codec, 0x14, 0,
936 AC_VERB_SET_EAPD_BTLENABLE, 2);
937 snd_hda_codec_write(codec, 0x15, 0,
938 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200939 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200940 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200941 switch (codec->vendor_id) {
942 case 0x10ec0260:
943 snd_hda_codec_write(codec, 0x1a, 0,
944 AC_VERB_SET_COEF_INDEX, 7);
945 tmp = snd_hda_codec_read(codec, 0x1a, 0,
946 AC_VERB_GET_PROC_COEF, 0);
947 snd_hda_codec_write(codec, 0x1a, 0,
948 AC_VERB_SET_COEF_INDEX, 7);
949 snd_hda_codec_write(codec, 0x1a, 0,
950 AC_VERB_SET_PROC_COEF,
951 tmp | 0x2010);
952 break;
953 case 0x10ec0262:
954 case 0x10ec0880:
955 case 0x10ec0882:
956 case 0x10ec0883:
957 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200958 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200959 snd_hda_codec_write(codec, 0x20, 0,
960 AC_VERB_SET_COEF_INDEX, 7);
961 tmp = snd_hda_codec_read(codec, 0x20, 0,
962 AC_VERB_GET_PROC_COEF, 0);
963 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200964 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200965 snd_hda_codec_write(codec, 0x20, 0,
966 AC_VERB_SET_PROC_COEF,
967 tmp | 0x2010);
968 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200969 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200970 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200971 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200972 case 0x10ec0267:
973 case 0x10ec0268:
974 snd_hda_codec_write(codec, 0x20, 0,
975 AC_VERB_SET_COEF_INDEX, 7);
976 tmp = snd_hda_codec_read(codec, 0x20, 0,
977 AC_VERB_GET_PROC_COEF, 0);
978 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200979 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200980 snd_hda_codec_write(codec, 0x20, 0,
981 AC_VERB_SET_PROC_COEF,
982 tmp | 0x3000);
983 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200984 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200985 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200986 break;
987 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200988
Kailang Yang8c427222008-01-10 13:03:59 +0100989 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200990 * when the external headphone out jack is plugged"
991 */
Kailang Yang8c427222008-01-10 13:03:59 +0100992 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200993 return;
994 /*
995 * 10~8 : Jack location
996 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
997 * 14~13: Resvered
998 * 15 : 1 --> enable the function "Mute internal speaker
999 * when the external headphone out jack is plugged"
1000 */
1001 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001002 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001003 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001004 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001005 else
1006 return;
1007 }
1008
1009 if (!spec->autocfg.hp_pins[0]) {
1010 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1011 if (tmp == 0)
1012 spec->autocfg.hp_pins[0] = porta;
1013 else if (tmp == 1)
1014 spec->autocfg.hp_pins[0] = porte;
1015 else if (tmp == 2)
1016 spec->autocfg.hp_pins[0] = portd;
1017 else
1018 return;
1019 }
1020
1021 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1022 AC_VERB_SET_UNSOLICITED_ENABLE,
1023 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001024
Kailang Yangc9b58002007-10-16 14:30:01 +02001025 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001026}
1027
Takashi Iwai41e41f12005-06-08 14:48:49 +02001028/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001029 * Fix-up pin default configurations
1030 */
1031
1032struct alc_pincfg {
1033 hda_nid_t nid;
1034 u32 val;
1035};
1036
1037static void alc_fix_pincfg(struct hda_codec *codec,
1038 const struct snd_pci_quirk *quirk,
1039 const struct alc_pincfg **pinfix)
1040{
1041 const struct alc_pincfg *cfg;
1042
1043 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1044 if (!quirk)
1045 return;
1046
1047 cfg = pinfix[quirk->value];
1048 for (; cfg->nid; cfg++) {
1049 int i;
1050 u32 val = cfg->val;
1051 for (i = 0; i < 4; i++) {
1052 snd_hda_codec_write(codec, cfg->nid, 0,
1053 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1054 val & 0xff);
1055 val >>= 8;
1056 }
1057 }
1058}
1059
1060/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001061 * ALC880 3-stack model
1062 *
1063 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001064 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1065 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 */
1067
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068static hda_nid_t alc880_dac_nids[4] = {
1069 /* front, rear, clfe, rear_surr */
1070 0x02, 0x05, 0x04, 0x03
1071};
1072
1073static hda_nid_t alc880_adc_nids[3] = {
1074 /* ADC0-2 */
1075 0x07, 0x08, 0x09,
1076};
1077
1078/* The datasheet says the node 0x07 is connected from inputs,
1079 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001080 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001082static hda_nid_t alc880_adc_nids_alt[2] = {
1083 /* ADC1-2 */
1084 0x08, 0x09,
1085};
1086
1087#define ALC880_DIGOUT_NID 0x06
1088#define ALC880_DIGIN_NID 0x0a
1089
1090static struct hda_input_mux alc880_capture_source = {
1091 .num_items = 4,
1092 .items = {
1093 { "Mic", 0x0 },
1094 { "Front Mic", 0x3 },
1095 { "Line", 0x2 },
1096 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001098};
1099
1100/* channel source setting (2/6 channel selection for 3-stack) */
1101/* 2ch mode */
1102static struct hda_verb alc880_threestack_ch2_init[] = {
1103 /* set line-in to input, mute it */
1104 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1105 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1106 /* set mic-in to input vref 80%, mute it */
1107 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1108 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 { } /* end */
1110};
1111
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001112/* 6ch mode */
1113static struct hda_verb alc880_threestack_ch6_init[] = {
1114 /* set line-in to output, unmute it */
1115 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1116 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1117 /* set mic-in to output, unmute it */
1118 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1119 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1120 { } /* end */
1121};
1122
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001123static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001124 { 2, alc880_threestack_ch2_init },
1125 { 6, alc880_threestack_ch6_init },
1126};
1127
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001128static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001131 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001132 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001133 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001135 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1136 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1144 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1145 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1146 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 {
1149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1150 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001151 .info = alc_ch_mode_info,
1152 .get = alc_ch_mode_get,
1153 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001154 },
1155 { } /* end */
1156};
1157
1158/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001159static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001160 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1162 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1163 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1164 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1166 {
1167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1168 /* The multiple "Capture Source" controls confuse alsamixer
1169 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170 */
1171 /* .name = "Capture Source", */
1172 .name = "Input Source",
1173 .count = 3,
1174 .info = alc_mux_enum_info,
1175 .get = alc_mux_enum_get,
1176 .put = alc_mux_enum_put,
1177 },
1178 { } /* end */
1179};
1180
1181/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001182static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001183 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 {
1188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1189 /* The multiple "Capture Source" controls confuse alsamixer
1190 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 */
1192 /* .name = "Capture Source", */
1193 .name = "Input Source",
1194 .count = 2,
1195 .info = alc_mux_enum_info,
1196 .get = alc_mux_enum_get,
1197 .put = alc_mux_enum_put,
1198 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 { } /* end */
1200};
1201
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001202
1203
1204/*
1205 * ALC880 5-stack model
1206 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001207 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1208 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001209 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1210 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1211 */
1212
1213/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001214static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001215 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001216 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 { } /* end */
1218};
1219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001220/* channel source setting (6/8 channel selection for 5-stack) */
1221/* 6ch mode */
1222static struct hda_verb alc880_fivestack_ch6_init[] = {
1223 /* set line-in to input, mute it */
1224 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1225 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001226 { } /* end */
1227};
1228
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001229/* 8ch mode */
1230static struct hda_verb alc880_fivestack_ch8_init[] = {
1231 /* set line-in to output, unmute it */
1232 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1233 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1234 { } /* end */
1235};
1236
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001237static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238 { 6, alc880_fivestack_ch6_init },
1239 { 8, alc880_fivestack_ch8_init },
1240};
1241
1242
1243/*
1244 * ALC880 6-stack model
1245 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001246 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1247 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001248 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1249 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1250 */
1251
1252static hda_nid_t alc880_6st_dac_nids[4] = {
1253 /* front, rear, clfe, rear_surr */
1254 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001255};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256
1257static struct hda_input_mux alc880_6stack_capture_source = {
1258 .num_items = 4,
1259 .items = {
1260 { "Mic", 0x0 },
1261 { "Front Mic", 0x1 },
1262 { "Line", 0x2 },
1263 { "CD", 0x4 },
1264 },
1265};
1266
1267/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001268static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001269 { 8, NULL },
1270};
1271
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001272static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001276 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001277 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1278 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001279 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1280 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001281 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001282 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001283 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1284 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1289 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1290 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1291 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1292 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001293 {
1294 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1295 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001296 .info = alc_ch_mode_info,
1297 .get = alc_ch_mode_get,
1298 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001299 },
1300 { } /* end */
1301};
1302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001303
1304/*
1305 * ALC880 W810 model
1306 *
1307 * W810 has rear IO for:
1308 * Front (DAC 02)
1309 * Surround (DAC 03)
1310 * Center/LFE (DAC 04)
1311 * Digital out (06)
1312 *
1313 * The system also has a pair of internal speakers, and a headphone jack.
1314 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001315 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001316 * There is a variable resistor to control the speaker or headphone
1317 * volume. This is a hardware-only device without a software API.
1318 *
1319 * Plugging headphones in will disable the internal speakers. This is
1320 * implemented in hardware, not via the driver using jack sense. In
1321 * a similar fashion, plugging into the rear socket marked "front" will
1322 * disable both the speakers and headphones.
1323 *
1324 * For input, there's a microphone jack, and an "audio in" jack.
1325 * These may not do anything useful with this driver yet, because I
1326 * haven't setup any initialization verbs for these yet...
1327 */
1328
1329static hda_nid_t alc880_w810_dac_nids[3] = {
1330 /* front, rear/surround, clfe */
1331 0x02, 0x03, 0x04
1332};
1333
1334/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001335static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001336 { 6, NULL }
1337};
1338
1339/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001340static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001341 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001342 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001343 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001344 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001345 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1346 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001347 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1348 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1350 { } /* end */
1351};
1352
1353
1354/*
1355 * Z710V model
1356 *
1357 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001358 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1359 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001360 */
1361
1362static hda_nid_t alc880_z71v_dac_nids[1] = {
1363 0x02
1364};
1365#define ALC880_Z71V_HP_DAC 0x03
1366
1367/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001368static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001369 { 2, NULL }
1370};
1371
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001372static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001373 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001374 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001375 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001376 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1381 { } /* end */
1382};
1383
1384
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001385/*
1386 * ALC880 F1734 model
1387 *
1388 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1389 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1390 */
1391
1392static hda_nid_t alc880_f1734_dac_nids[1] = {
1393 0x03
1394};
1395#define ALC880_F1734_HP_DAC 0x02
1396
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001397static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001398 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001399 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1401 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001402 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1403 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001406 { } /* end */
1407};
1408
Takashi Iwai937b4162008-02-11 14:52:36 +01001409static struct hda_input_mux alc880_f1734_capture_source = {
1410 .num_items = 2,
1411 .items = {
1412 { "Mic", 0x1 },
1413 { "CD", 0x4 },
1414 },
1415};
1416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418/*
1419 * ALC880 ASUS model
1420 *
1421 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1422 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1423 * Mic = 0x18, Line = 0x1a
1424 */
1425
1426#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1427#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1428
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001429static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001431 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001433 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1435 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001436 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1437 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001444 {
1445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1446 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001447 .info = alc_ch_mode_info,
1448 .get = alc_ch_mode_get,
1449 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001450 },
1451 { } /* end */
1452};
1453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454/*
1455 * ALC880 ASUS W1V model
1456 *
1457 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1458 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1459 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1460 */
1461
1462/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001463static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1465 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 { } /* end */
1467};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001469/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001470static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001471 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1472 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1473 { } /* end */
1474};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001475
Kailang Yangdf694da2005-12-05 19:42:22 +01001476/* TCL S700 */
1477static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1478 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1479 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1481 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1482 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1485 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1486 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1487 {
1488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1489 /* The multiple "Capture Source" controls confuse alsamixer
1490 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001491 */
1492 /* .name = "Capture Source", */
1493 .name = "Input Source",
1494 .count = 1,
1495 .info = alc_mux_enum_info,
1496 .get = alc_mux_enum_get,
1497 .put = alc_mux_enum_put,
1498 },
1499 { } /* end */
1500};
1501
Kailang Yangccc656c2006-10-17 12:32:26 +02001502/* Uniwill */
1503static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001504 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1505 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1506 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1507 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001508 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1509 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1510 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1511 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1512 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1513 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1514 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1515 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1517 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1520 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1521 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1522 {
1523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1524 .name = "Channel Mode",
1525 .info = alc_ch_mode_info,
1526 .get = alc_ch_mode_get,
1527 .put = alc_ch_mode_put,
1528 },
1529 { } /* end */
1530};
1531
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001532static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1533 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1534 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1535 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1536 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1539 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1540 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1542 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1543 { } /* end */
1544};
1545
Kailang Yangccc656c2006-10-17 12:32:26 +02001546static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001547 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1548 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1549 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1550 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1553 { } /* end */
1554};
1555
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001557 * virtual master controls
1558 */
1559
1560/*
1561 * slave controls for virtual master
1562 */
1563static const char *alc_slave_vols[] = {
1564 "Front Playback Volume",
1565 "Surround Playback Volume",
1566 "Center Playback Volume",
1567 "LFE Playback Volume",
1568 "Side Playback Volume",
1569 "Headphone Playback Volume",
1570 "Speaker Playback Volume",
1571 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001572 "Line-Out Playback Volume",
1573 NULL,
1574};
1575
1576static const char *alc_slave_sws[] = {
1577 "Front Playback Switch",
1578 "Surround Playback Switch",
1579 "Center Playback Switch",
1580 "LFE Playback Switch",
1581 "Side Playback Switch",
1582 "Headphone Playback Switch",
1583 "Speaker Playback Switch",
1584 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001585 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001586 NULL,
1587};
1588
1589/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001590 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001592
1593static void alc_free_kctls(struct hda_codec *codec);
1594
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595static int alc_build_controls(struct hda_codec *codec)
1596{
1597 struct alc_spec *spec = codec->spec;
1598 int err;
1599 int i;
1600
1601 for (i = 0; i < spec->num_mixers; i++) {
1602 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1603 if (err < 0)
1604 return err;
1605 }
1606
1607 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001608 err = snd_hda_create_spdif_out_ctls(codec,
1609 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 if (err < 0)
1611 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001612 err = snd_hda_create_spdif_share_sw(codec,
1613 &spec->multiout);
1614 if (err < 0)
1615 return err;
1616 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617 }
1618 if (spec->dig_in_nid) {
1619 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1620 if (err < 0)
1621 return err;
1622 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001623
1624 /* if we have no master control, let's create it */
1625 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001626 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001627 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001628 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001629 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001630 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001631 if (err < 0)
1632 return err;
1633 }
1634 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1635 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1636 NULL, alc_slave_sws);
1637 if (err < 0)
1638 return err;
1639 }
1640
Takashi Iwai603c4012008-07-30 15:01:44 +02001641 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 return 0;
1643}
1644
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646/*
1647 * initialize the codec volumes, etc
1648 */
1649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001650/*
1651 * generic initialization of ADC, input mixers and output mixers
1652 */
1653static struct hda_verb alc880_volume_init_verbs[] = {
1654 /*
1655 * Unmute ADC0-2 and set the default input to mic-in
1656 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001657 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001659 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001660 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001661 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1665 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001666 * Note: PASD motherboards uses the Line In 2 as the input for front
1667 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001669 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 /*
1679 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681 /* set vol=0 to output mixers */
1682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1686 /* set up input amps for analog loopback */
1687 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001692 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1693 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001694 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696
1697 { }
1698};
1699
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001700/*
1701 * 3-stack pin configuration:
1702 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1703 */
1704static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1705 /*
1706 * preset connection lists of input pins
1707 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1708 */
1709 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1710 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1711 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1712
1713 /*
1714 * Set pin mode and muting
1715 */
1716 /* set front pin widgets 0x14 for output */
1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1719 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1722 /* Mic2 (as headphone out) for HP output */
1723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 /* Line In pin widget for input */
1726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1728 /* Line2 (as front mic) pin widget for input and vref at 80% */
1729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1731 /* CD pin widget for input */
1732 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1733
1734 { }
1735};
1736
1737/*
1738 * 5-stack pin configuration:
1739 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1740 * line-in/side = 0x1a, f-mic = 0x1b
1741 */
1742static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1743 /*
1744 * preset connection lists of input pins
1745 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1746 */
1747 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1748 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1749
1750 /*
1751 * Set pin mode and muting
1752 */
1753 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1756 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1757 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758 /* unmute pins for output (no gain on this amp) */
1759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1767 /* Mic2 (as headphone out) for HP output */
1768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001770 /* Line In pin widget for input */
1771 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1773 /* Line2 (as front mic) pin widget for input and vref at 80% */
1774 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 /* CD pin widget for input */
1777 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778
1779 { }
1780};
1781
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001782/*
1783 * W810 pin configuration:
1784 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1785 */
1786static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787 /* hphone/speaker input selector: front DAC */
1788 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1789
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1796
1797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 { }
1801};
1802
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803/*
1804 * Z71V pin configuration:
1805 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1806 */
1807static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001812
Takashi Iwai16ded522005-06-10 19:58:24 +02001813 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001817
1818 { }
1819};
1820
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821/*
1822 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001823 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1824 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825 */
1826static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1827 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1828
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001835 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1837
Takashi Iwai16ded522005-06-10 19:58:24 +02001838 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001847
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848 { }
1849};
Takashi Iwai16ded522005-06-10 19:58:24 +02001850
Kailang Yangccc656c2006-10-17 12:32:26 +02001851/*
1852 * Uniwill pin configuration:
1853 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1854 * line = 0x1a
1855 */
1856static struct hda_verb alc880_uniwill_init_verbs[] = {
1857 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1858
1859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1861 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1873
1874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1880 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1881 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1882 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1883
1884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1886
1887 { }
1888};
1889
1890/*
1891* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001892* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001893 */
1894static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1895 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1896
1897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1909
1910 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1911 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1912 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1914 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1916
1917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1918 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1919
1920 { }
1921};
1922
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001923static struct hda_verb alc880_beep_init_verbs[] = {
1924 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1925 { }
1926};
1927
Kailang Yangccc656c2006-10-17 12:32:26 +02001928/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001929static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001930{
1931 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001932 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001933
1934 present = snd_hda_codec_read(codec, 0x14, 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, 0x15, HDA_OUTPUT, 0,
1938 HDA_AMP_MUTE, bits);
1939 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1940 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001941}
1942
1943/* auto-toggle front mic */
1944static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1945{
1946 unsigned int present;
1947 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001948
1949 present = snd_hda_codec_read(codec, 0x18, 0,
1950 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001951 bits = present ? HDA_AMP_MUTE : 0;
1952 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001953}
1954
1955static void alc880_uniwill_automute(struct hda_codec *codec)
1956{
1957 alc880_uniwill_hp_automute(codec);
1958 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001959}
1960
1961static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1962 unsigned int res)
1963{
1964 /* Looks like the unsol event is incompatible with the standard
1965 * definition. 4bit tag is placed at 28 bit!
1966 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001967 switch (res >> 28) {
1968 case ALC880_HP_EVENT:
1969 alc880_uniwill_hp_automute(codec);
1970 break;
1971 case ALC880_MIC_EVENT:
1972 alc880_uniwill_mic_automute(codec);
1973 break;
1974 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001975}
1976
1977static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1978{
1979 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001980 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001981
1982 present = snd_hda_codec_read(codec, 0x14, 0,
1983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001984 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001985 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001986}
1987
1988static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1989{
1990 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001991
Kailang Yangccc656c2006-10-17 12:32:26 +02001992 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001993 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1994 present &= HDA_AMP_VOLMASK;
1995 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1996 HDA_AMP_VOLMASK, present);
1997 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1998 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001999}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002000
Kailang Yangccc656c2006-10-17 12:32:26 +02002001static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2002 unsigned int res)
2003{
2004 /* Looks like the unsol event is incompatible with the standard
2005 * definition. 4bit tag is placed at 28 bit!
2006 */
2007 if ((res >> 28) == ALC880_HP_EVENT)
2008 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002009 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002010 alc880_uniwill_p53_dcvol_automute(codec);
2011}
2012
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002013/*
2014 * F1734 pin configuration:
2015 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2016 */
2017static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002018 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002019 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2020 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2021 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2022 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2023
2024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028
2029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2030 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002032 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2035 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002038
Takashi Iwai937b4162008-02-11 14:52:36 +01002039 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2040 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2041
Takashi Iwai16ded522005-06-10 19:58:24 +02002042 { }
2043};
2044
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045/*
2046 * ASUS pin configuration:
2047 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2048 */
2049static struct hda_verb alc880_pin_asus_init_verbs[] = {
2050 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2051 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2052 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2053 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2054
2055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2059 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2063
2064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 { }
2075};
2076
2077/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002078#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2079#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002080
Kailang Yangdf694da2005-12-05 19:42:22 +01002081/* Clevo m520g init */
2082static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2083 /* headphone output */
2084 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2085 /* line-out */
2086 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2088 /* Line-in */
2089 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 /* CD */
2092 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2093 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 /* Mic1 (rear panel) */
2095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 /* Mic2 (front panel) */
2098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2099 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2100 /* headphone */
2101 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2103 /* change to EAPD mode */
2104 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2105 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2106
2107 { }
2108};
2109
2110static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002111 /* change to EAPD mode */
2112 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2113 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2114
Kailang Yangdf694da2005-12-05 19:42:22 +01002115 /* Headphone output */
2116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2117 /* Front output*/
2118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2119 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2120
2121 /* Line In pin widget for input */
2122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2123 /* CD pin widget for input */
2124 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2125 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2127
2128 /* change to EAPD mode */
2129 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2130 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2131
2132 { }
2133};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002134
2135/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002136 * LG m1 express dual
2137 *
2138 * Pin assignment:
2139 * Rear Line-In/Out (blue): 0x14
2140 * Build-in Mic-In: 0x15
2141 * Speaker-out: 0x17
2142 * HP-Out (green): 0x1b
2143 * Mic-In/Out (red): 0x19
2144 * SPDIF-Out: 0x1e
2145 */
2146
2147/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2148static hda_nid_t alc880_lg_dac_nids[3] = {
2149 0x05, 0x02, 0x03
2150};
2151
2152/* seems analog CD is not working */
2153static struct hda_input_mux alc880_lg_capture_source = {
2154 .num_items = 3,
2155 .items = {
2156 { "Mic", 0x1 },
2157 { "Line", 0x5 },
2158 { "Internal Mic", 0x6 },
2159 },
2160};
2161
2162/* 2,4,6 channel modes */
2163static struct hda_verb alc880_lg_ch2_init[] = {
2164 /* set line-in and mic-in to input */
2165 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2166 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2167 { }
2168};
2169
2170static struct hda_verb alc880_lg_ch4_init[] = {
2171 /* set line-in to out and mic-in to input */
2172 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2173 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2174 { }
2175};
2176
2177static struct hda_verb alc880_lg_ch6_init[] = {
2178 /* set line-in and mic-in to output */
2179 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2180 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2181 { }
2182};
2183
2184static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2185 { 2, alc880_lg_ch2_init },
2186 { 4, alc880_lg_ch4_init },
2187 { 6, alc880_lg_ch6_init },
2188};
2189
2190static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2203 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2204 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2205 {
2206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2207 .name = "Channel Mode",
2208 .info = alc_ch_mode_info,
2209 .get = alc_ch_mode_get,
2210 .put = alc_ch_mode_put,
2211 },
2212 { } /* end */
2213};
2214
2215static struct hda_verb alc880_lg_init_verbs[] = {
2216 /* set capture source to mic-in */
2217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2220 /* mute all amp mixer inputs */
2221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002224 /* line-in to input */
2225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2227 /* built-in mic */
2228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2230 /* speaker-out */
2231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2232 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2233 /* mic-in to input */
2234 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2235 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2236 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 /* HP-out */
2238 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2239 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2240 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2241 /* jack sense */
2242 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2243 { }
2244};
2245
2246/* toggle speaker-output according to the hp-jack state */
2247static void alc880_lg_automute(struct hda_codec *codec)
2248{
2249 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002250 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002251
2252 present = snd_hda_codec_read(codec, 0x1b, 0,
2253 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002254 bits = present ? HDA_AMP_MUTE : 0;
2255 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2256 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002257}
2258
2259static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2260{
2261 /* Looks like the unsol event is incompatible with the standard
2262 * definition. 4bit tag is placed at 28 bit!
2263 */
2264 if ((res >> 28) == 0x01)
2265 alc880_lg_automute(codec);
2266}
2267
2268/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002269 * LG LW20
2270 *
2271 * Pin assignment:
2272 * Speaker-out: 0x14
2273 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002274 * Built-in Mic-In: 0x19
2275 * Line-In: 0x1b
2276 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002277 * SPDIF-Out: 0x1e
2278 */
2279
Takashi Iwaid6815182006-03-23 16:06:23 +01002280static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002281 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002282 .items = {
2283 { "Mic", 0x0 },
2284 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002285 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002286 },
2287};
2288
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002289#define alc880_lg_lw_modes alc880_threestack_modes
2290
Takashi Iwaid6815182006-03-23 16:06:23 +01002291static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2293 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2294 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2295 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2296 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2297 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2298 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2299 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2301 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2304 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2305 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002306 {
2307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2308 .name = "Channel Mode",
2309 .info = alc_ch_mode_info,
2310 .get = alc_ch_mode_get,
2311 .put = alc_ch_mode_put,
2312 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002313 { } /* end */
2314};
2315
2316static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002317 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2318 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2319 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2320
Takashi Iwaid6815182006-03-23 16:06:23 +01002321 /* set capture source to mic-in */
2322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002326 /* speaker-out */
2327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2329 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2331 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2332 /* mic-in to input */
2333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2334 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2335 /* built-in mic */
2336 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2338 /* jack sense */
2339 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2340 { }
2341};
2342
2343/* toggle speaker-output according to the hp-jack state */
2344static void alc880_lg_lw_automute(struct hda_codec *codec)
2345{
2346 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002347 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002348
2349 present = snd_hda_codec_read(codec, 0x1b, 0,
2350 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002351 bits = present ? HDA_AMP_MUTE : 0;
2352 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2353 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002354}
2355
2356static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2357{
2358 /* Looks like the unsol event is incompatible with the standard
2359 * definition. 4bit tag is placed at 28 bit!
2360 */
2361 if ((res >> 28) == 0x01)
2362 alc880_lg_lw_automute(codec);
2363}
2364
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002365static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2366 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2371 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2372 { } /* end */
2373};
2374
2375static struct hda_input_mux alc880_medion_rim_capture_source = {
2376 .num_items = 2,
2377 .items = {
2378 { "Mic", 0x0 },
2379 { "Internal Mic", 0x1 },
2380 },
2381};
2382
2383static struct hda_verb alc880_medion_rim_init_verbs[] = {
2384 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2385
2386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2388
2389 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2390 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2391 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2392 /* Mic2 (as headphone out) for HP output */
2393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2395 /* Internal Speaker */
2396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2397 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2398
2399 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2400 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2401
2402 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2403 { }
2404};
2405
2406/* toggle speaker-output according to the hp-jack state */
2407static void alc880_medion_rim_automute(struct hda_codec *codec)
2408{
2409 unsigned int present;
2410 unsigned char bits;
2411
2412 present = snd_hda_codec_read(codec, 0x14, 0,
2413 AC_VERB_GET_PIN_SENSE, 0)
2414 & AC_PINSENSE_PRESENCE;
2415 bits = present ? HDA_AMP_MUTE : 0;
2416 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2417 HDA_AMP_MUTE, bits);
2418 if (present)
2419 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2420 else
2421 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2422}
2423
2424static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2425 unsigned int res)
2426{
2427 /* Looks like the unsol event is incompatible with the standard
2428 * definition. 4bit tag is placed at 28 bit!
2429 */
2430 if ((res >> 28) == ALC880_HP_EVENT)
2431 alc880_medion_rim_automute(codec);
2432}
2433
Takashi Iwaicb53c622007-08-10 17:21:45 +02002434#ifdef CONFIG_SND_HDA_POWER_SAVE
2435static struct hda_amp_list alc880_loopbacks[] = {
2436 { 0x0b, HDA_INPUT, 0 },
2437 { 0x0b, HDA_INPUT, 1 },
2438 { 0x0b, HDA_INPUT, 2 },
2439 { 0x0b, HDA_INPUT, 3 },
2440 { 0x0b, HDA_INPUT, 4 },
2441 { } /* end */
2442};
2443
2444static struct hda_amp_list alc880_lg_loopbacks[] = {
2445 { 0x0b, HDA_INPUT, 1 },
2446 { 0x0b, HDA_INPUT, 6 },
2447 { 0x0b, HDA_INPUT, 7 },
2448 { } /* end */
2449};
2450#endif
2451
Takashi Iwaid6815182006-03-23 16:06:23 +01002452/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002453 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002455
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456static int alc_init(struct hda_codec *codec)
2457{
2458 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002459 unsigned int i;
2460
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002461 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002462 if (codec->vendor_id == 0x10ec0888)
2463 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002464
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002465 for (i = 0; i < spec->num_init_verbs; i++)
2466 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002467
2468 if (spec->init_hook)
2469 spec->init_hook(codec);
2470
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 return 0;
2472}
2473
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002474static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2475{
2476 struct alc_spec *spec = codec->spec;
2477
2478 if (spec->unsol_event)
2479 spec->unsol_event(codec, res);
2480}
2481
Takashi Iwaicb53c622007-08-10 17:21:45 +02002482#ifdef CONFIG_SND_HDA_POWER_SAVE
2483static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2484{
2485 struct alc_spec *spec = codec->spec;
2486 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2487}
2488#endif
2489
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490/*
2491 * Analog playback callbacks
2492 */
2493static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2494 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002495 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496{
2497 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002498 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2499 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500}
2501
2502static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2503 struct hda_codec *codec,
2504 unsigned int stream_tag,
2505 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002506 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507{
2508 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002509 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2510 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511}
2512
2513static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2514 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002515 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516{
2517 struct alc_spec *spec = codec->spec;
2518 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2519}
2520
2521/*
2522 * Digital out
2523 */
2524static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2525 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002526 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527{
2528 struct alc_spec *spec = codec->spec;
2529 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2530}
2531
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002532static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2533 struct hda_codec *codec,
2534 unsigned int stream_tag,
2535 unsigned int format,
2536 struct snd_pcm_substream *substream)
2537{
2538 struct alc_spec *spec = codec->spec;
2539 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2540 stream_tag, format, substream);
2541}
2542
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2544 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002545 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546{
2547 struct alc_spec *spec = codec->spec;
2548 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2549}
2550
2551/*
2552 * Analog capture
2553 */
Takashi Iwai63300792008-01-24 15:31:36 +01002554static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 struct hda_codec *codec,
2556 unsigned int stream_tag,
2557 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002558 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559{
2560 struct alc_spec *spec = codec->spec;
2561
Takashi Iwai63300792008-01-24 15:31:36 +01002562 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 stream_tag, 0, format);
2564 return 0;
2565}
2566
Takashi Iwai63300792008-01-24 15:31:36 +01002567static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002569 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570{
2571 struct alc_spec *spec = codec->spec;
2572
Takashi Iwai888afa12008-03-18 09:57:50 +01002573 snd_hda_codec_cleanup_stream(codec,
2574 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 return 0;
2576}
2577
2578
2579/*
2580 */
2581static struct hda_pcm_stream alc880_pcm_analog_playback = {
2582 .substreams = 1,
2583 .channels_min = 2,
2584 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 .ops = {
2587 .open = alc880_playback_pcm_open,
2588 .prepare = alc880_playback_pcm_prepare,
2589 .cleanup = alc880_playback_pcm_cleanup
2590 },
2591};
2592
2593static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002594 .substreams = 1,
2595 .channels_min = 2,
2596 .channels_max = 2,
2597 /* NID is set in alc_build_pcms */
2598};
2599
2600static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2601 .substreams = 1,
2602 .channels_min = 2,
2603 .channels_max = 2,
2604 /* NID is set in alc_build_pcms */
2605};
2606
2607static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2608 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609 .channels_min = 2,
2610 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002613 .prepare = alc880_alt_capture_pcm_prepare,
2614 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615 },
2616};
2617
2618static struct hda_pcm_stream alc880_pcm_digital_playback = {
2619 .substreams = 1,
2620 .channels_min = 2,
2621 .channels_max = 2,
2622 /* NID is set in alc_build_pcms */
2623 .ops = {
2624 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002625 .close = alc880_dig_playback_pcm_close,
2626 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 },
2628};
2629
2630static struct hda_pcm_stream alc880_pcm_digital_capture = {
2631 .substreams = 1,
2632 .channels_min = 2,
2633 .channels_max = 2,
2634 /* NID is set in alc_build_pcms */
2635};
2636
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002637/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002638static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002639 .substreams = 0,
2640 .channels_min = 0,
2641 .channels_max = 0,
2642};
2643
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644static int alc_build_pcms(struct hda_codec *codec)
2645{
2646 struct alc_spec *spec = codec->spec;
2647 struct hda_pcm *info = spec->pcm_rec;
2648 int i;
2649
2650 codec->num_pcms = 1;
2651 codec->pcm_info = info;
2652
2653 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002654 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002655 if (snd_BUG_ON(!spec->multiout.dac_nids))
2656 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002657 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2658 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2659 }
2660 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002661 if (snd_BUG_ON(!spec->adc_nids))
2662 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002663 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2664 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2665 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666
Takashi Iwai4a471b72005-12-07 13:56:29 +01002667 if (spec->channel_mode) {
2668 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2669 for (i = 0; i < spec->num_channel_mode; i++) {
2670 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2671 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2672 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 }
2674 }
2675
Takashi Iwaie08a0072006-09-07 17:52:14 +02002676 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002678 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002679 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002681 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002682 if (spec->multiout.dig_out_nid &&
2683 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2685 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2686 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002687 if (spec->dig_in_nid &&
2688 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002689 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2690 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2691 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002692 /* FIXME: do we need this for all Realtek codec models? */
2693 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 }
2695
Takashi Iwaie08a0072006-09-07 17:52:14 +02002696 /* If the use of more than one ADC is requested for the current
2697 * model, configure a second analog capture-only PCM.
2698 */
2699 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002700 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2701 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002702 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002703 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002704 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002705 if (spec->alt_dac_nid) {
2706 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2707 *spec->stream_analog_alt_playback;
2708 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2709 spec->alt_dac_nid;
2710 } else {
2711 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2712 alc_pcm_null_stream;
2713 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2714 }
2715 if (spec->num_adc_nids > 1) {
2716 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2717 *spec->stream_analog_alt_capture;
2718 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2719 spec->adc_nids[1];
2720 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2721 spec->num_adc_nids - 1;
2722 } else {
2723 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2724 alc_pcm_null_stream;
2725 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002726 }
2727 }
2728
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729 return 0;
2730}
2731
Takashi Iwai603c4012008-07-30 15:01:44 +02002732static void alc_free_kctls(struct hda_codec *codec)
2733{
2734 struct alc_spec *spec = codec->spec;
2735
2736 if (spec->kctls.list) {
2737 struct snd_kcontrol_new *kctl = spec->kctls.list;
2738 int i;
2739 for (i = 0; i < spec->kctls.used; i++)
2740 kfree(kctl[i].name);
2741 }
2742 snd_array_free(&spec->kctls);
2743}
2744
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745static void alc_free(struct hda_codec *codec)
2746{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002749 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 return;
2751
Takashi Iwai603c4012008-07-30 15:01:44 +02002752 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002754 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755}
2756
2757/*
2758 */
2759static struct hda_codec_ops alc_patch_ops = {
2760 .build_controls = alc_build_controls,
2761 .build_pcms = alc_build_pcms,
2762 .init = alc_init,
2763 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002764 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002765#ifdef CONFIG_SND_HDA_POWER_SAVE
2766 .check_power_status = alc_check_power_status,
2767#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768};
2769
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002770
2771/*
2772 * Test configuration for debugging
2773 *
2774 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2775 * enum controls.
2776 */
2777#ifdef CONFIG_SND_DEBUG
2778static hda_nid_t alc880_test_dac_nids[4] = {
2779 0x02, 0x03, 0x04, 0x05
2780};
2781
2782static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002783 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002784 .items = {
2785 { "In-1", 0x0 },
2786 { "In-2", 0x1 },
2787 { "In-3", 0x2 },
2788 { "In-4", 0x3 },
2789 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002790 { "Front", 0x5 },
2791 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002792 },
2793};
2794
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002795static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002796 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002797 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002798 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002799 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002800};
2801
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002802static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2803 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002804{
2805 static char *texts[] = {
2806 "N/A", "Line Out", "HP Out",
2807 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2808 };
2809 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2810 uinfo->count = 1;
2811 uinfo->value.enumerated.items = 8;
2812 if (uinfo->value.enumerated.item >= 8)
2813 uinfo->value.enumerated.item = 7;
2814 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2815 return 0;
2816}
2817
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002818static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2819 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002820{
2821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2822 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2823 unsigned int pin_ctl, item = 0;
2824
2825 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2826 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2827 if (pin_ctl & AC_PINCTL_OUT_EN) {
2828 if (pin_ctl & AC_PINCTL_HP_EN)
2829 item = 2;
2830 else
2831 item = 1;
2832 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2833 switch (pin_ctl & AC_PINCTL_VREFEN) {
2834 case AC_PINCTL_VREF_HIZ: item = 3; break;
2835 case AC_PINCTL_VREF_50: item = 4; break;
2836 case AC_PINCTL_VREF_GRD: item = 5; break;
2837 case AC_PINCTL_VREF_80: item = 6; break;
2838 case AC_PINCTL_VREF_100: item = 7; break;
2839 }
2840 }
2841 ucontrol->value.enumerated.item[0] = item;
2842 return 0;
2843}
2844
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002845static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2846 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002847{
2848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2849 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2850 static unsigned int ctls[] = {
2851 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2852 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2853 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2854 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2855 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2856 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2857 };
2858 unsigned int old_ctl, new_ctl;
2859
2860 old_ctl = snd_hda_codec_read(codec, nid, 0,
2861 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2862 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2863 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002864 int val;
2865 snd_hda_codec_write_cache(codec, nid, 0,
2866 AC_VERB_SET_PIN_WIDGET_CONTROL,
2867 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002868 val = ucontrol->value.enumerated.item[0] >= 3 ?
2869 HDA_AMP_MUTE : 0;
2870 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2871 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002872 return 1;
2873 }
2874 return 0;
2875}
2876
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002877static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2878 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002879{
2880 static char *texts[] = {
2881 "Front", "Surround", "CLFE", "Side"
2882 };
2883 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2884 uinfo->count = 1;
2885 uinfo->value.enumerated.items = 4;
2886 if (uinfo->value.enumerated.item >= 4)
2887 uinfo->value.enumerated.item = 3;
2888 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2889 return 0;
2890}
2891
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002892static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2893 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002894{
2895 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2896 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2897 unsigned int sel;
2898
2899 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2900 ucontrol->value.enumerated.item[0] = sel & 3;
2901 return 0;
2902}
2903
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002904static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2905 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002906{
2907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2908 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2909 unsigned int sel;
2910
2911 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2912 if (ucontrol->value.enumerated.item[0] != sel) {
2913 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002914 snd_hda_codec_write_cache(codec, nid, 0,
2915 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002916 return 1;
2917 }
2918 return 0;
2919}
2920
2921#define PIN_CTL_TEST(xname,nid) { \
2922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2923 .name = xname, \
2924 .info = alc_test_pin_ctl_info, \
2925 .get = alc_test_pin_ctl_get, \
2926 .put = alc_test_pin_ctl_put, \
2927 .private_value = nid \
2928 }
2929
2930#define PIN_SRC_TEST(xname,nid) { \
2931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2932 .name = xname, \
2933 .info = alc_test_pin_src_info, \
2934 .get = alc_test_pin_src_get, \
2935 .put = alc_test_pin_src_put, \
2936 .private_value = nid \
2937 }
2938
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002939static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2942 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2943 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2945 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2946 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2947 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002948 PIN_CTL_TEST("Front Pin Mode", 0x14),
2949 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2950 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2951 PIN_CTL_TEST("Side Pin Mode", 0x17),
2952 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2953 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2954 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2955 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2956 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2957 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2958 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2959 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2960 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2961 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2962 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2963 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2964 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2965 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2966 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2967 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002970 {
2971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2972 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002973 .info = alc_ch_mode_info,
2974 .get = alc_ch_mode_get,
2975 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002976 },
2977 { } /* end */
2978};
2979
2980static struct hda_verb alc880_test_init_verbs[] = {
2981 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2986 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002990 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2992 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002995 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002996 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2999 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003000 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003005 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3007 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003008 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3009 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003011 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3015 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003016 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003018 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003022 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003023 /* Analog input/passthru */
3024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003029 { }
3030};
3031#endif
3032
Linus Torvalds1da177e2005-04-16 15:20:36 -07003033/*
3034 */
3035
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003036static const char *alc880_models[ALC880_MODEL_LAST] = {
3037 [ALC880_3ST] = "3stack",
3038 [ALC880_TCL_S700] = "tcl",
3039 [ALC880_3ST_DIG] = "3stack-digout",
3040 [ALC880_CLEVO] = "clevo",
3041 [ALC880_5ST] = "5stack",
3042 [ALC880_5ST_DIG] = "5stack-digout",
3043 [ALC880_W810] = "w810",
3044 [ALC880_Z71V] = "z71v",
3045 [ALC880_6ST] = "6stack",
3046 [ALC880_6ST_DIG] = "6stack-digout",
3047 [ALC880_ASUS] = "asus",
3048 [ALC880_ASUS_W1V] = "asus-w1v",
3049 [ALC880_ASUS_DIG] = "asus-dig",
3050 [ALC880_ASUS_DIG2] = "asus-dig2",
3051 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003052 [ALC880_UNIWILL_P53] = "uniwill-p53",
3053 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003054 [ALC880_F1734] = "F1734",
3055 [ALC880_LG] = "lg",
3056 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003057 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003058#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003059 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003060#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003061 [ALC880_AUTO] = "auto",
3062};
3063
3064static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003065 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003066 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3067 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3068 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3069 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3070 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3071 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3072 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3073 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003074 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3075 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003076 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3077 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3078 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3079 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3080 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3081 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3082 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3083 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3084 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3085 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003086 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003087 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3088 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3089 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003090 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003091 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003092 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3093 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003094 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3095 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003096 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3097 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3098 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3099 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003100 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3101 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003102 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003103 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003104 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003105 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003106 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3107 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003108 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003109 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003110 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003111 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003112 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003113 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003114 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003115 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003116 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003117 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3118 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003119 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003120 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3121 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3122 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3123 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003124 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3125 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003126 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003127 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003128 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3129 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003130 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3131 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3132 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003133 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3134 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3135 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136 {}
3137};
3138
Takashi Iwai16ded522005-06-10 19:58:24 +02003139/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003140 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003142static struct alc_config_preset alc880_presets[] = {
3143 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003145 .init_verbs = { alc880_volume_init_verbs,
3146 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003147 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003148 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003149 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3150 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003151 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003152 .input_mux = &alc880_capture_source,
3153 },
3154 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003156 .init_verbs = { alc880_volume_init_verbs,
3157 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003158 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003159 .dac_nids = alc880_dac_nids,
3160 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003161 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3162 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003163 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003164 .input_mux = &alc880_capture_source,
3165 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003166 [ALC880_TCL_S700] = {
3167 .mixers = { alc880_tcl_s700_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_tcl_S700_init_verbs,
3170 alc880_gpio2_init_verbs },
3171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3172 .dac_nids = alc880_dac_nids,
3173 .hp_nid = 0x03,
3174 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3175 .channel_mode = alc880_2_jack_modes,
3176 .input_mux = &alc880_capture_source,
3177 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003178 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003179 .mixers = { alc880_three_stack_mixer,
3180 alc880_five_stack_mixer},
3181 .init_verbs = { alc880_volume_init_verbs,
3182 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003183 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3184 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003185 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3186 .channel_mode = alc880_fivestack_modes,
3187 .input_mux = &alc880_capture_source,
3188 },
3189 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003190 .mixers = { alc880_three_stack_mixer,
3191 alc880_five_stack_mixer },
3192 .init_verbs = { alc880_volume_init_verbs,
3193 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003194 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3195 .dac_nids = alc880_dac_nids,
3196 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003197 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3198 .channel_mode = alc880_fivestack_modes,
3199 .input_mux = &alc880_capture_source,
3200 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003201 [ALC880_6ST] = {
3202 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003203 .init_verbs = { alc880_volume_init_verbs,
3204 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003205 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3206 .dac_nids = alc880_6st_dac_nids,
3207 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3208 .channel_mode = alc880_sixstack_modes,
3209 .input_mux = &alc880_6stack_capture_source,
3210 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003211 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003213 .init_verbs = { alc880_volume_init_verbs,
3214 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3216 .dac_nids = alc880_6st_dac_nids,
3217 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003218 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3219 .channel_mode = alc880_sixstack_modes,
3220 .input_mux = &alc880_6stack_capture_source,
3221 },
3222 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003226 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003227 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3228 .dac_nids = alc880_w810_dac_nids,
3229 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003230 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3231 .channel_mode = alc880_w810_modes,
3232 .input_mux = &alc880_capture_source,
3233 },
3234 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003236 .init_verbs = { alc880_volume_init_verbs,
3237 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003238 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3239 .dac_nids = alc880_z71v_dac_nids,
3240 .dig_out_nid = ALC880_DIGOUT_NID,
3241 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3243 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003244 .input_mux = &alc880_capture_source,
3245 },
3246 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 .init_verbs = { alc880_volume_init_verbs,
3249 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3251 .dac_nids = alc880_f1734_dac_nids,
3252 .hp_nid = 0x02,
3253 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3254 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003255 .input_mux = &alc880_f1734_capture_source,
3256 .unsol_event = alc880_uniwill_p53_unsol_event,
3257 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 },
3259 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003261 .init_verbs = { alc880_volume_init_verbs,
3262 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 alc880_gpio1_init_verbs },
3264 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3265 .dac_nids = alc880_asus_dac_nids,
3266 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3267 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003268 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 .input_mux = &alc880_capture_source,
3270 },
3271 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 .init_verbs = { alc880_volume_init_verbs,
3274 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 alc880_gpio1_init_verbs },
3276 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3277 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003278 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3280 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003281 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003282 .input_mux = &alc880_capture_source,
3283 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003284 [ALC880_ASUS_DIG2] = {
3285 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003286 .init_verbs = { alc880_volume_init_verbs,
3287 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003288 alc880_gpio2_init_verbs }, /* use GPIO2 */
3289 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3290 .dac_nids = alc880_asus_dac_nids,
3291 .dig_out_nid = ALC880_DIGOUT_NID,
3292 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3293 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003294 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003295 .input_mux = &alc880_capture_source,
3296 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003297 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003299 .init_verbs = { alc880_volume_init_verbs,
3300 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003301 alc880_gpio1_init_verbs },
3302 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3303 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003304 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003305 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3306 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003307 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003308 .input_mux = &alc880_capture_source,
3309 },
3310 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003311 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003312 .init_verbs = { alc880_volume_init_verbs,
3313 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003314 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3315 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003316 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3318 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003319 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003320 .input_mux = &alc880_capture_source,
3321 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 [ALC880_UNIWILL] = {
3323 .mixers = { alc880_uniwill_mixer },
3324 .init_verbs = { alc880_volume_init_verbs,
3325 alc880_uniwill_init_verbs },
3326 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3327 .dac_nids = alc880_asus_dac_nids,
3328 .dig_out_nid = ALC880_DIGOUT_NID,
3329 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3330 .channel_mode = alc880_threestack_modes,
3331 .need_dac_fix = 1,
3332 .input_mux = &alc880_capture_source,
3333 .unsol_event = alc880_uniwill_unsol_event,
3334 .init_hook = alc880_uniwill_automute,
3335 },
3336 [ALC880_UNIWILL_P53] = {
3337 .mixers = { alc880_uniwill_p53_mixer },
3338 .init_verbs = { alc880_volume_init_verbs,
3339 alc880_uniwill_p53_init_verbs },
3340 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3341 .dac_nids = alc880_asus_dac_nids,
3342 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003343 .channel_mode = alc880_threestack_modes,
3344 .input_mux = &alc880_capture_source,
3345 .unsol_event = alc880_uniwill_p53_unsol_event,
3346 .init_hook = alc880_uniwill_p53_hp_automute,
3347 },
3348 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003349 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003350 alc880_pcbeep_mixer, },
3351 .init_verbs = { alc880_volume_init_verbs,
3352 alc880_uniwill_p53_init_verbs,
3353 alc880_beep_init_verbs },
3354 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3355 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003356 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003357 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3358 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003359 .input_mux = &alc880_capture_source,
3360 .unsol_event = alc880_uniwill_p53_unsol_event,
3361 .init_hook = alc880_uniwill_p53_hp_automute,
3362 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003363 [ALC880_CLEVO] = {
3364 .mixers = { alc880_three_stack_mixer },
3365 .init_verbs = { alc880_volume_init_verbs,
3366 alc880_pin_clevo_init_verbs },
3367 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3368 .dac_nids = alc880_dac_nids,
3369 .hp_nid = 0x03,
3370 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3371 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003372 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003373 .input_mux = &alc880_capture_source,
3374 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003375 [ALC880_LG] = {
3376 .mixers = { alc880_lg_mixer },
3377 .init_verbs = { alc880_volume_init_verbs,
3378 alc880_lg_init_verbs },
3379 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3380 .dac_nids = alc880_lg_dac_nids,
3381 .dig_out_nid = ALC880_DIGOUT_NID,
3382 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3383 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003384 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003385 .input_mux = &alc880_lg_capture_source,
3386 .unsol_event = alc880_lg_unsol_event,
3387 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003388#ifdef CONFIG_SND_HDA_POWER_SAVE
3389 .loopbacks = alc880_lg_loopbacks,
3390#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003391 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003392 [ALC880_LG_LW] = {
3393 .mixers = { alc880_lg_lw_mixer },
3394 .init_verbs = { alc880_volume_init_verbs,
3395 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003396 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003397 .dac_nids = alc880_dac_nids,
3398 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003399 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3400 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003401 .input_mux = &alc880_lg_lw_capture_source,
3402 .unsol_event = alc880_lg_lw_unsol_event,
3403 .init_hook = alc880_lg_lw_automute,
3404 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003405 [ALC880_MEDION_RIM] = {
3406 .mixers = { alc880_medion_rim_mixer },
3407 .init_verbs = { alc880_volume_init_verbs,
3408 alc880_medion_rim_init_verbs,
3409 alc_gpio2_init_verbs },
3410 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3411 .dac_nids = alc880_dac_nids,
3412 .dig_out_nid = ALC880_DIGOUT_NID,
3413 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3414 .channel_mode = alc880_2_jack_modes,
3415 .input_mux = &alc880_medion_rim_capture_source,
3416 .unsol_event = alc880_medion_rim_unsol_event,
3417 .init_hook = alc880_medion_rim_automute,
3418 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003419#ifdef CONFIG_SND_DEBUG
3420 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003421 .mixers = { alc880_test_mixer },
3422 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003423 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3424 .dac_nids = alc880_test_dac_nids,
3425 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003426 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3427 .channel_mode = alc880_test_modes,
3428 .input_mux = &alc880_test_capture_source,
3429 },
3430#endif
3431};
3432
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433/*
3434 * Automatic parse of I/O pins from the BIOS configuration
3435 */
3436
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437enum {
3438 ALC_CTL_WIDGET_VOL,
3439 ALC_CTL_WIDGET_MUTE,
3440 ALC_CTL_BIND_MUTE,
3441};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003442static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003443 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3444 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003445 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003446};
3447
3448/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003449static int add_control(struct alc_spec *spec, int type, const char *name,
3450 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003452 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003453
Takashi Iwai603c4012008-07-30 15:01:44 +02003454 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3455 knew = snd_array_new(&spec->kctls);
3456 if (!knew)
3457 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003459 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003460 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461 return -ENOMEM;
3462 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003463 return 0;
3464}
3465
3466#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3467#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3468#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3469#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3470#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3471#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3472#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3473#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3474#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3475#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3476#define ALC880_PIN_CD_NID 0x1c
3477
3478/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003479static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3480 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003481{
3482 hda_nid_t nid;
3483 int assigned[4];
3484 int i, j;
3485
3486 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003487 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488
3489 /* check the pins hardwired to audio widget */
3490 for (i = 0; i < cfg->line_outs; i++) {
3491 nid = cfg->line_out_pins[i];
3492 if (alc880_is_fixed_pin(nid)) {
3493 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003494 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003495 assigned[idx] = 1;
3496 }
3497 }
3498 /* left pins can be connect to any audio widget */
3499 for (i = 0; i < cfg->line_outs; i++) {
3500 nid = cfg->line_out_pins[i];
3501 if (alc880_is_fixed_pin(nid))
3502 continue;
3503 /* search for an empty channel */
3504 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003505 if (!assigned[j]) {
3506 spec->multiout.dac_nids[i] =
3507 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003508 assigned[j] = 1;
3509 break;
3510 }
3511 }
3512 }
3513 spec->multiout.num_dacs = cfg->line_outs;
3514 return 0;
3515}
3516
3517/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003518static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3519 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520{
3521 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003522 static const char *chname[4] = {
3523 "Front", "Surround", NULL /*CLFE*/, "Side"
3524 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 hda_nid_t nid;
3526 int i, err;
3527
3528 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003529 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003530 continue;
3531 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3532 if (i == 2) {
3533 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003534 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3535 "Center Playback Volume",
3536 HDA_COMPOSE_AMP_VAL(nid, 1, 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_WIDGET_VOL,
3541 "LFE Playback Volume",
3542 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3543 HDA_OUTPUT));
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 "Center Playback Switch",
3548 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3549 HDA_INPUT));
3550 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003552 err = add_control(spec, ALC_CTL_BIND_MUTE,
3553 "LFE Playback Switch",
3554 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3555 HDA_INPUT));
3556 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 return err;
3558 } else {
3559 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003560 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3561 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3562 HDA_OUTPUT));
3563 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003564 return err;
3565 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003566 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3567 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3568 HDA_INPUT));
3569 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570 return err;
3571 }
3572 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003573 return 0;
3574}
3575
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003576/* add playback controls for speaker and HP outputs */
3577static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3578 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579{
3580 hda_nid_t nid;
3581 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003582 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003583
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003584 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 return 0;
3586
3587 if (alc880_is_fixed_pin(pin)) {
3588 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003589 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003591 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003592 else
3593 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 /* control HP volume/switch on the output mixer amp */
3595 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003596 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003597 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3598 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3599 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003601 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003602 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3603 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605 return err;
3606 } else if (alc880_is_multi_pin(pin)) {
3607 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003608 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003609 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003610 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3611 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3612 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613 return err;
3614 }
3615 return 0;
3616}
3617
3618/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003619static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3620 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003621 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622{
3623 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003624 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625
3626 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003627 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3628 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3629 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630 return err;
3631 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003632 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3633 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3634 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635 return err;
3636 return 0;
3637}
3638
3639/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003640static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3641 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003642{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003643 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003644 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003645
3646 for (i = 0; i < AUTO_PIN_LAST; i++) {
3647 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003648 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003649 err = new_analog_input(spec, cfg->input_pins[i],
3650 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003651 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003652 if (err < 0)
3653 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003654 imux->items[imux->num_items].label =
3655 auto_pin_cfg_labels[i];
3656 imux->items[imux->num_items].index =
3657 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003658 imux->num_items++;
3659 }
3660 }
3661 return 0;
3662}
3663
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003664static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3665 unsigned int pin_type)
3666{
3667 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3668 pin_type);
3669 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003670 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3671 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003672}
3673
Kailang Yangdf694da2005-12-05 19:42:22 +01003674static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3675 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003676 int dac_idx)
3677{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003678 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003679 /* need the manual connection? */
3680 if (alc880_is_multi_pin(nid)) {
3681 struct alc_spec *spec = codec->spec;
3682 int idx = alc880_multi_pin_idx(nid);
3683 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3684 AC_VERB_SET_CONNECT_SEL,
3685 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3686 }
3687}
3688
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003689static int get_pin_type(int line_out_type)
3690{
3691 if (line_out_type == AUTO_PIN_HP_OUT)
3692 return PIN_HP;
3693 else
3694 return PIN_OUT;
3695}
3696
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003697static void alc880_auto_init_multi_out(struct hda_codec *codec)
3698{
3699 struct alc_spec *spec = codec->spec;
3700 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003701
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003702 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 for (i = 0; i < spec->autocfg.line_outs; i++) {
3704 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003705 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3706 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 }
3708}
3709
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003710static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711{
3712 struct alc_spec *spec = codec->spec;
3713 hda_nid_t pin;
3714
Takashi Iwai82bc9552006-03-21 11:24:42 +01003715 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003716 if (pin) /* connect to front */
3717 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003718 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003719 if (pin) /* connect to front */
3720 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3721}
3722
3723static void alc880_auto_init_analog_input(struct hda_codec *codec)
3724{
3725 struct alc_spec *spec = codec->spec;
3726 int i;
3727
3728 for (i = 0; i < AUTO_PIN_LAST; i++) {
3729 hda_nid_t nid = spec->autocfg.input_pins[i];
3730 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003731 snd_hda_codec_write(codec, nid, 0,
3732 AC_VERB_SET_PIN_WIDGET_CONTROL,
3733 i <= AUTO_PIN_FRONT_MIC ?
3734 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003735 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003736 snd_hda_codec_write(codec, nid, 0,
3737 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003738 AMP_OUT_MUTE);
3739 }
3740 }
3741}
3742
3743/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003744/* return 1 if successful, 0 if the proper config is not found,
3745 * or a negative error code
3746 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003747static int alc880_parse_auto_config(struct hda_codec *codec)
3748{
3749 struct alc_spec *spec = codec->spec;
3750 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003751 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003753 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3754 alc880_ignore);
3755 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003756 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003757 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003759
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3761 if (err < 0)
3762 return err;
3763 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3764 if (err < 0)
3765 return err;
3766 err = alc880_auto_create_extra_out(spec,
3767 spec->autocfg.speaker_pins[0],
3768 "Speaker");
3769 if (err < 0)
3770 return err;
3771 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3772 "Headphone");
3773 if (err < 0)
3774 return err;
3775 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3776 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 return err;
3778
3779 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3780
3781 if (spec->autocfg.dig_out_pin)
3782 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3783 if (spec->autocfg.dig_in_pin)
3784 spec->dig_in_nid = ALC880_DIGIN_NID;
3785
Takashi Iwai603c4012008-07-30 15:01:44 +02003786 if (spec->kctls.list)
3787 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788
3789 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3790
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003791 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 spec->input_mux = &spec->private_imux;
3793
3794 return 1;
3795}
3796
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003797/* additional initialization for auto-configuration model */
3798static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003800 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003801 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003802 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003804 if (spec->unsol_event)
3805 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806}
3807
3808/*
3809 * OK, here we have finally the patch for ALC880
3810 */
3811
Linus Torvalds1da177e2005-04-16 15:20:36 -07003812static int patch_alc880(struct hda_codec *codec)
3813{
3814 struct alc_spec *spec;
3815 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003816 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003818 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003819 if (spec == NULL)
3820 return -ENOMEM;
3821
3822 codec->spec = spec;
3823
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003824 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3825 alc880_models,
3826 alc880_cfg_tbl);
3827 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003828 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3829 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003830 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003831 }
3832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003833 if (board_config == ALC880_AUTO) {
3834 /* automatic parse from the BIOS config */
3835 err = alc880_parse_auto_config(codec);
3836 if (err < 0) {
3837 alc_free(codec);
3838 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003839 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003840 printk(KERN_INFO
3841 "hda_codec: Cannot set up configuration "
3842 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003843 board_config = ALC880_3ST;
3844 }
3845 }
3846
Kailang Yangdf694da2005-12-05 19:42:22 +01003847 if (board_config != ALC880_AUTO)
3848 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849
3850 spec->stream_name_analog = "ALC880 Analog";
3851 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3852 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003853 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003854
3855 spec->stream_name_digital = "ALC880 Digital";
3856 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3857 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3858
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003859 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003860 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003861 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003862 /* get type */
3863 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003864 if (wcap != AC_WID_AUD_IN) {
3865 spec->adc_nids = alc880_adc_nids_alt;
3866 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003867 spec->mixers[spec->num_mixers] =
3868 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003869 spec->num_mixers++;
3870 } else {
3871 spec->adc_nids = alc880_adc_nids;
3872 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3873 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3874 spec->num_mixers++;
3875 }
3876 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003877
Takashi Iwai2134ea42008-01-10 16:53:55 +01003878 spec->vmaster_nid = 0x0c;
3879
Linus Torvalds1da177e2005-04-16 15:20:36 -07003880 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003881 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003882 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003883#ifdef CONFIG_SND_HDA_POWER_SAVE
3884 if (!spec->loopback.amplist)
3885 spec->loopback.amplist = alc880_loopbacks;
3886#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003887
3888 return 0;
3889}
3890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003891
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892/*
3893 * ALC260 support
3894 */
3895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003896static hda_nid_t alc260_dac_nids[1] = {
3897 /* front */
3898 0x02,
3899};
3900
3901static hda_nid_t alc260_adc_nids[1] = {
3902 /* ADC0 */
3903 0x04,
3904};
3905
Kailang Yangdf694da2005-12-05 19:42:22 +01003906static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003907 /* ADC1 */
3908 0x05,
3909};
3910
Kailang Yangdf694da2005-12-05 19:42:22 +01003911static hda_nid_t alc260_hp_adc_nids[2] = {
3912 /* ADC1, 0 */
3913 0x05, 0x04
3914};
3915
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003916/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3917 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3918 */
3919static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003920 /* ADC0, ADC1 */
3921 0x04, 0x05
3922};
3923
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003924#define ALC260_DIGOUT_NID 0x03
3925#define ALC260_DIGIN_NID 0x06
3926
3927static struct hda_input_mux alc260_capture_source = {
3928 .num_items = 4,
3929 .items = {
3930 { "Mic", 0x0 },
3931 { "Front Mic", 0x1 },
3932 { "Line", 0x2 },
3933 { "CD", 0x4 },
3934 },
3935};
3936
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003937/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003938 * headphone jack and the internal CD lines since these are the only pins at
3939 * which audio can appear. For flexibility, also allow the option of
3940 * recording the mixer output on the second ADC (ADC0 doesn't have a
3941 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003942 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003943static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3944 {
3945 .num_items = 3,
3946 .items = {
3947 { "Mic/Line", 0x0 },
3948 { "CD", 0x4 },
3949 { "Headphone", 0x2 },
3950 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003951 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003952 {
3953 .num_items = 4,
3954 .items = {
3955 { "Mic/Line", 0x0 },
3956 { "CD", 0x4 },
3957 { "Headphone", 0x2 },
3958 { "Mixer", 0x5 },
3959 },
3960 },
3961
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003962};
3963
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003964/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3965 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003966 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003967static struct hda_input_mux alc260_acer_capture_sources[2] = {
3968 {
3969 .num_items = 4,
3970 .items = {
3971 { "Mic", 0x0 },
3972 { "Line", 0x2 },
3973 { "CD", 0x4 },
3974 { "Headphone", 0x5 },
3975 },
3976 },
3977 {
3978 .num_items = 5,
3979 .items = {
3980 { "Mic", 0x0 },
3981 { "Line", 0x2 },
3982 { "CD", 0x4 },
3983 { "Headphone", 0x6 },
3984 { "Mixer", 0x5 },
3985 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003986 },
3987};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003988/*
3989 * This is just place-holder, so there's something for alc_build_pcms to look
3990 * at when it calculates the maximum number of channels. ALC260 has no mixer
3991 * element which allows changing the channel mode, so the verb list is
3992 * never used.
3993 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003994static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995 { 2, NULL },
3996};
3997
Kailang Yangdf694da2005-12-05 19:42:22 +01003998
3999/* Mixer combinations
4000 *
4001 * basic: base_output + input + pc_beep + capture
4002 * HP: base_output + input + capture_alt
4003 * HP_3013: hp_3013 + input + capture
4004 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004005 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004006 */
4007
4008static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004009 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004010 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4012 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4013 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4014 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4015 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004016};
Kailang Yangdf694da2005-12-05 19:42:22 +01004017
4018static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004019 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4020 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4021 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4022 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4024 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4025 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004027 { } /* end */
4028};
4029
Kailang Yangdf694da2005-12-05 19:42:22 +01004030static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4031 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4032 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4033 { } /* end */
4034};
4035
Takashi Iwaibec15c32008-01-28 18:16:30 +01004036/* update HP, line and mono out pins according to the master switch */
4037static void alc260_hp_master_update(struct hda_codec *codec,
4038 hda_nid_t hp, hda_nid_t line,
4039 hda_nid_t mono)
4040{
4041 struct alc_spec *spec = codec->spec;
4042 unsigned int val = spec->master_sw ? PIN_HP : 0;
4043 /* change HP and line-out pins */
4044 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4045 val);
4046 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4047 val);
4048 /* mono (speaker) depending on the HP jack sense */
4049 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4050 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4051 val);
4052}
4053
4054static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4055 struct snd_ctl_elem_value *ucontrol)
4056{
4057 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4058 struct alc_spec *spec = codec->spec;
4059 *ucontrol->value.integer.value = spec->master_sw;
4060 return 0;
4061}
4062
4063static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4064 struct snd_ctl_elem_value *ucontrol)
4065{
4066 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4067 struct alc_spec *spec = codec->spec;
4068 int val = !!*ucontrol->value.integer.value;
4069 hda_nid_t hp, line, mono;
4070
4071 if (val == spec->master_sw)
4072 return 0;
4073 spec->master_sw = val;
4074 hp = (kcontrol->private_value >> 16) & 0xff;
4075 line = (kcontrol->private_value >> 8) & 0xff;
4076 mono = kcontrol->private_value & 0xff;
4077 alc260_hp_master_update(codec, hp, line, mono);
4078 return 1;
4079}
4080
4081static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4082 {
4083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4084 .name = "Master Playback Switch",
4085 .info = snd_ctl_boolean_mono_info,
4086 .get = alc260_hp_master_sw_get,
4087 .put = alc260_hp_master_sw_put,
4088 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4089 },
4090 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4091 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4092 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4093 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4094 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4095 HDA_OUTPUT),
4096 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4097 { } /* end */
4098};
4099
4100static struct hda_verb alc260_hp_unsol_verbs[] = {
4101 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4102 {},
4103};
4104
4105static void alc260_hp_automute(struct hda_codec *codec)
4106{
4107 struct alc_spec *spec = codec->spec;
4108 unsigned int present;
4109
4110 present = snd_hda_codec_read(codec, 0x10, 0,
4111 AC_VERB_GET_PIN_SENSE, 0);
4112 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4113 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4114}
4115
4116static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4117{
4118 if ((res >> 26) == ALC880_HP_EVENT)
4119 alc260_hp_automute(codec);
4120}
4121
Kailang Yangdf694da2005-12-05 19:42:22 +01004122static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004123 {
4124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4125 .name = "Master Playback Switch",
4126 .info = snd_ctl_boolean_mono_info,
4127 .get = alc260_hp_master_sw_get,
4128 .put = alc260_hp_master_sw_put,
4129 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4130 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004131 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4132 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4133 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4134 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4135 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004137 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4138 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004139 { } /* end */
4140};
4141
Kailang Yang3f878302008-08-26 13:02:23 +02004142static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4143 .ops = &snd_hda_bind_vol,
4144 .values = {
4145 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4146 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4147 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4148 0
4149 },
4150};
4151
4152static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4153 .ops = &snd_hda_bind_sw,
4154 .values = {
4155 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4156 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4157 0
4158 },
4159};
4160
4161static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4162 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4163 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4164 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4166 { } /* end */
4167};
4168
Takashi Iwaibec15c32008-01-28 18:16:30 +01004169static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4171 {},
4172};
4173
4174static void alc260_hp_3013_automute(struct hda_codec *codec)
4175{
4176 struct alc_spec *spec = codec->spec;
4177 unsigned int present;
4178
4179 present = snd_hda_codec_read(codec, 0x15, 0,
4180 AC_VERB_GET_PIN_SENSE, 0);
4181 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4182 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4183}
4184
4185static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4186 unsigned int res)
4187{
4188 if ((res >> 26) == ALC880_HP_EVENT)
4189 alc260_hp_3013_automute(codec);
4190}
4191
Kailang Yang3f878302008-08-26 13:02:23 +02004192static void alc260_hp_3012_automute(struct hda_codec *codec)
4193{
4194 unsigned int present, bits;
4195
4196 present = snd_hda_codec_read(codec, 0x10, 0,
4197 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4198
4199 bits = present ? 0 : PIN_OUT;
4200 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4201 bits);
4202 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4203 bits);
4204 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4205 bits);
4206}
4207
4208static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4209 unsigned int res)
4210{
4211 if ((res >> 26) == ALC880_HP_EVENT)
4212 alc260_hp_3012_automute(codec);
4213}
4214
4215/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004216 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4217 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004218static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004220 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004221 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004222 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4223 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4224 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4225 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004226 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004227 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4228 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004229 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4230 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004231 { } /* end */
4232};
4233
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004234/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4235 * versions of the ALC260 don't act on requests to enable mic bias from NID
4236 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4237 * datasheet doesn't mention this restriction. At this stage it's not clear
4238 * whether this behaviour is intentional or is a hardware bug in chip
4239 * revisions available in early 2006. Therefore for now allow the
4240 * "Headphone Jack Mode" control to span all choices, but if it turns out
4241 * that the lack of mic bias for this NID is intentional we could change the
4242 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4243 *
4244 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4245 * don't appear to make the mic bias available from the "line" jack, even
4246 * though the NID used for this jack (0x14) can supply it. The theory is
4247 * that perhaps Acer have included blocking capacitors between the ALC260
4248 * and the output jack. If this turns out to be the case for all such
4249 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4250 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004251 *
4252 * The C20x Tablet series have a mono internal speaker which is controlled
4253 * via the chip's Mono sum widget and pin complex, so include the necessary
4254 * controls for such models. On models without a "mono speaker" the control
4255 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004256 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004257static struct snd_kcontrol_new alc260_acer_mixer[] = {
4258 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4259 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004260 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004261 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004262 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004263 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004264 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004265 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4266 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4268 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4269 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4270 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4271 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4272 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4273 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4274 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4275 { } /* end */
4276};
4277
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004278/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4279 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4280 */
4281static struct snd_kcontrol_new alc260_will_mixer[] = {
4282 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4283 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4285 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4286 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4287 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4288 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4289 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4290 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4291 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4292 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4293 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4294 { } /* end */
4295};
4296
4297/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4298 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4299 */
4300static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4301 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4302 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4304 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4305 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4306 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4307 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4308 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4309 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4310 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4311 { } /* end */
4312};
4313
Kailang Yangdf694da2005-12-05 19:42:22 +01004314/* capture mixer elements */
4315static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004316 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4317 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004318 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4319 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004320 {
4321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004322 /* The multiple "Capture Source" controls confuse alsamixer
4323 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 */
4325 /* .name = "Capture Source", */
4326 .name = "Input Source",
4327 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004328 .info = alc_mux_enum_info,
4329 .get = alc_mux_enum_get,
4330 .put = alc_mux_enum_put,
4331 },
4332 { } /* end */
4333};
4334
Kailang Yangdf694da2005-12-05 19:42:22 +01004335static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4336 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4337 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4338 {
4339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4340 /* The multiple "Capture Source" controls confuse alsamixer
4341 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 */
4343 /* .name = "Capture Source", */
4344 .name = "Input Source",
4345 .count = 1,
4346 .info = alc_mux_enum_info,
4347 .get = alc_mux_enum_get,
4348 .put = alc_mux_enum_put,
4349 },
4350 { } /* end */
4351};
4352
4353/*
4354 * initialization verbs
4355 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004356static struct hda_verb alc260_init_verbs[] = {
4357 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004362 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004363 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004364 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004367 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004368 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004369 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004370 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004372 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004373 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004374 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4375 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004376 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004377 /* set connection select to line in (default select for this ADC) */
4378 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004379 /* mute capture amp left and right */
4380 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4381 /* set connection select to line in (default select for this ADC) */
4382 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004383 /* set vol=0 Line-Out mixer amp left and right */
4384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4385 /* unmute pin widget amp left and right (no gain on this amp) */
4386 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4387 /* set vol=0 HP mixer amp left and right */
4388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4389 /* unmute pin widget amp left and right (no gain on this amp) */
4390 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4391 /* set vol=0 Mono mixer amp left and right */
4392 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4393 /* unmute pin widget amp left and right (no gain on this amp) */
4394 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4395 /* unmute LINE-2 out pin */
4396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004397 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4398 * Line In 2 = 0x03
4399 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004400 /* mute analog inputs */
4401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004406 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004407 /* mute Front out path */
4408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4410 /* mute Headphone out path */
4411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4413 /* mute Mono out path */
4414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4415 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004416 { }
4417};
4418
Takashi Iwai474167d2006-05-17 17:17:43 +02004419#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004420static struct hda_verb alc260_hp_init_verbs[] = {
4421 /* Headphone and output */
4422 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4423 /* mono output */
4424 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4425 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4426 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4427 /* Mic2 (front panel) pin widget for input and vref at 80% */
4428 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4429 /* Line In pin widget for input */
4430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4431 /* Line-2 pin widget for output */
4432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4433 /* CD pin widget for input */
4434 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4435 /* unmute amp left and right */
4436 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4437 /* set connection select to line in (default select for this ADC) */
4438 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4439 /* unmute Line-Out mixer amp left and right (volume = 0) */
4440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4441 /* mute pin widget amp left and right (no gain on this amp) */
4442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4443 /* unmute HP mixer amp left and right (volume = 0) */
4444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4445 /* mute pin widget amp left and right (no gain on this amp) */
4446 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4448 * Line In 2 = 0x03
4449 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004450 /* mute analog inputs */
4451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004456 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4457 /* Unmute Front out path */
4458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4460 /* Unmute Headphone out path */
4461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4462 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4463 /* Unmute Mono out path */
4464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4465 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4466 { }
4467};
Takashi Iwai474167d2006-05-17 17:17:43 +02004468#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004469
4470static struct hda_verb alc260_hp_3013_init_verbs[] = {
4471 /* Line out and output */
4472 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4473 /* mono output */
4474 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4475 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4476 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4477 /* Mic2 (front panel) pin widget for input and vref at 80% */
4478 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4479 /* Line In pin widget for input */
4480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4481 /* Headphone pin widget for output */
4482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4483 /* CD pin widget for input */
4484 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4485 /* unmute amp left and right */
4486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4487 /* set connection select to line in (default select for this ADC) */
4488 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4489 /* unmute Line-Out mixer amp left and right (volume = 0) */
4490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4491 /* mute pin widget amp left and right (no gain on this amp) */
4492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4493 /* unmute HP mixer amp left and right (volume = 0) */
4494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4495 /* mute pin widget amp left and right (no gain on this amp) */
4496 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004497 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4498 * Line In 2 = 0x03
4499 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004500 /* mute analog inputs */
4501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004506 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4507 /* Unmute Front out path */
4508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4510 /* Unmute Headphone out path */
4511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4513 /* Unmute Mono out path */
4514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4516 { }
4517};
4518
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004519/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004520 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4521 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004522 */
4523static struct hda_verb alc260_fujitsu_init_verbs[] = {
4524 /* Disable all GPIOs */
4525 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4526 /* Internal speaker is connected to headphone pin */
4527 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4528 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004530 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4531 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4532 /* Ensure all other unused pins are disabled and muted. */
4533 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004535 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004536 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004537 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004538 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004541
Jonathan Woithef7ace402006-02-28 11:46:14 +01004542 /* Disable digital (SPDIF) pins */
4543 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4544 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004545
Kailang Yangea1fb292008-08-26 12:58:38 +02004546 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004547 * when acting as an output.
4548 */
4549 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4550
4551 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4555 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4559 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4560 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004561
Jonathan Woithef7ace402006-02-28 11:46:14 +01004562 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4563 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4564 /* Unmute Line1 pin widget output buffer since it starts as an output.
4565 * If the pin mode is changed by the user the pin mode control will
4566 * take care of enabling the pin's input/output buffers as needed.
4567 * Therefore there's no need to enable the input buffer at this
4568 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004569 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004571 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004572 * mixer ctrl)
4573 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004574 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004575
Jonathan Woithef7ace402006-02-28 11:46:14 +01004576 /* Mute capture amp left and right */
4577 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004578 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004579 * in (on mic1 pin)
4580 */
4581 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004582
Jonathan Woithef7ace402006-02-28 11:46:14 +01004583 /* Do the same for the second ADC: mute capture input amp and
4584 * set ADC connection to line in (on mic1 pin)
4585 */
4586 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4587 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004588
Jonathan Woithef7ace402006-02-28 11:46:14 +01004589 /* Mute all inputs to mixer widget (even unconnected ones) */
4590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004598
4599 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004600};
4601
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004602/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4603 * similar laptops (adapted from Fujitsu init verbs).
4604 */
4605static struct hda_verb alc260_acer_init_verbs[] = {
4606 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4607 * the headphone jack. Turn this on and rely on the standard mute
4608 * methods whenever the user wants to turn these outputs off.
4609 */
4610 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4611 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4612 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4613 /* Internal speaker/Headphone jack is connected to Line-out pin */
4614 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4615 /* Internal microphone/Mic jack is connected to Mic1 pin */
4616 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4617 /* Line In jack is connected to Line1 pin */
4618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004619 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4620 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004621 /* Ensure all other unused pins are disabled and muted. */
4622 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4623 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004624 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4625 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4628 /* Disable digital (SPDIF) pins */
4629 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4630 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4631
Kailang Yangea1fb292008-08-26 12:58:38 +02004632 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004633 * bus when acting as outputs.
4634 */
4635 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4636 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4637
4638 /* Start with output sum widgets muted and their output gains at min */
4639 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4640 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4642 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4643 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4644 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4645 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4646 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4647 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4648
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004649 /* Unmute Line-out pin widget amp left and right
4650 * (no equiv mixer ctrl)
4651 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004653 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4654 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004655 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4656 * inputs. If the pin mode is changed by the user the pin mode control
4657 * will take care of enabling the pin's input/output buffers as needed.
4658 * Therefore there's no need to enable the input buffer at this
4659 * stage.
4660 */
4661 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4662 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4663
4664 /* Mute capture amp left and right */
4665 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4666 /* Set ADC connection select to match default mixer setting - mic
4667 * (on mic1 pin)
4668 */
4669 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4670
4671 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004672 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004673 */
4674 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004675 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004676
4677 /* Mute all inputs to mixer widget (even unconnected ones) */
4678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4686
4687 { }
4688};
4689
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004690static struct hda_verb alc260_will_verbs[] = {
4691 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4692 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4693 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4694 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4695 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4696 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4697 {}
4698};
4699
4700static struct hda_verb alc260_replacer_672v_verbs[] = {
4701 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4702 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4703 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4704
4705 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4706 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4707 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4708
4709 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4710 {}
4711};
4712
4713/* toggle speaker-output according to the hp-jack state */
4714static void alc260_replacer_672v_automute(struct hda_codec *codec)
4715{
4716 unsigned int present;
4717
4718 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4719 present = snd_hda_codec_read(codec, 0x0f, 0,
4720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4721 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004722 snd_hda_codec_write_cache(codec, 0x01, 0,
4723 AC_VERB_SET_GPIO_DATA, 1);
4724 snd_hda_codec_write_cache(codec, 0x0f, 0,
4725 AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004727 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004728 snd_hda_codec_write_cache(codec, 0x01, 0,
4729 AC_VERB_SET_GPIO_DATA, 0);
4730 snd_hda_codec_write_cache(codec, 0x0f, 0,
4731 AC_VERB_SET_PIN_WIDGET_CONTROL,
4732 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004733 }
4734}
4735
4736static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4737 unsigned int res)
4738{
4739 if ((res >> 26) == ALC880_HP_EVENT)
4740 alc260_replacer_672v_automute(codec);
4741}
4742
Kailang Yang3f878302008-08-26 13:02:23 +02004743static struct hda_verb alc260_hp_dc7600_verbs[] = {
4744 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4746 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4747 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4748 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4749 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4750 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4751 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4752 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4754 {}
4755};
4756
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004757/* Test configuration for debugging, modelled after the ALC880 test
4758 * configuration.
4759 */
4760#ifdef CONFIG_SND_DEBUG
4761static hda_nid_t alc260_test_dac_nids[1] = {
4762 0x02,
4763};
4764static hda_nid_t alc260_test_adc_nids[2] = {
4765 0x04, 0x05,
4766};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004767/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004768 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004769 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004770 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004771static struct hda_input_mux alc260_test_capture_sources[2] = {
4772 {
4773 .num_items = 7,
4774 .items = {
4775 { "MIC1 pin", 0x0 },
4776 { "MIC2 pin", 0x1 },
4777 { "LINE1 pin", 0x2 },
4778 { "LINE2 pin", 0x3 },
4779 { "CD pin", 0x4 },
4780 { "LINE-OUT pin", 0x5 },
4781 { "HP-OUT pin", 0x6 },
4782 },
4783 },
4784 {
4785 .num_items = 8,
4786 .items = {
4787 { "MIC1 pin", 0x0 },
4788 { "MIC2 pin", 0x1 },
4789 { "LINE1 pin", 0x2 },
4790 { "LINE2 pin", 0x3 },
4791 { "CD pin", 0x4 },
4792 { "Mixer", 0x5 },
4793 { "LINE-OUT pin", 0x6 },
4794 { "HP-OUT pin", 0x7 },
4795 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004796 },
4797};
4798static struct snd_kcontrol_new alc260_test_mixer[] = {
4799 /* Output driver widgets */
4800 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4801 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4802 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4803 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4804 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4805 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4806
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004807 /* Modes for retasking pin widgets
4808 * Note: the ALC260 doesn't seem to act on requests to enable mic
4809 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4810 * mention this restriction. At this stage it's not clear whether
4811 * this behaviour is intentional or is a hardware bug in chip
4812 * revisions available at least up until early 2006. Therefore for
4813 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4814 * choices, but if it turns out that the lack of mic bias for these
4815 * NIDs is intentional we could change their modes from
4816 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4817 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004818 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4819 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4820 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4821 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4822 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4823 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4824
4825 /* Loopback mixer controls */
4826 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4827 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4828 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4829 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4830 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4831 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4832 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4833 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4834 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4835 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4836 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4837 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4838 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4839 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4840 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4841 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004842
4843 /* Controls for GPIO pins, assuming they are configured as outputs */
4844 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4845 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4846 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4847 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4848
Jonathan Woithe92621f12006-02-28 11:47:47 +01004849 /* Switches to allow the digital IO pins to be enabled. The datasheet
4850 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004851 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004852 */
4853 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4854 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4855
Jonathan Woithef8225f62008-01-08 12:16:54 +01004856 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4857 * this output to turn on an external amplifier.
4858 */
4859 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4860 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4861
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004862 { } /* end */
4863};
4864static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004865 /* Enable all GPIOs as outputs with an initial value of 0 */
4866 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4867 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4868 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4869
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004870 /* Enable retasking pins as output, initially without power amp */
4871 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4872 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4875 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4877
Jonathan Woithe92621f12006-02-28 11:47:47 +01004878 /* Disable digital (SPDIF) pins initially, but users can enable
4879 * them via a mixer switch. In the case of SPDIF-out, this initverb
4880 * payload also sets the generation to 0, output to be in "consumer"
4881 * PCM format, copyright asserted, no pre-emphasis and no validity
4882 * control.
4883 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004884 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4885 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4886
Kailang Yangea1fb292008-08-26 12:58:38 +02004887 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004888 * OUT1 sum bus when acting as an output.
4889 */
4890 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4891 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4892 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4893 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4894
4895 /* Start with output sum widgets muted and their output gains at min */
4896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4902 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4905
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004906 /* Unmute retasking pin widget output buffers since the default
4907 * state appears to be output. As the pin mode is changed by the
4908 * user the pin mode control will take care of enabling the pin's
4909 * input/output buffers as needed.
4910 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004911 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4915 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4916 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4917 /* Also unmute the mono-out pin widget */
4918 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004920 /* Mute capture amp left and right */
4921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004922 /* Set ADC connection select to match default mixer setting (mic1
4923 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004924 */
4925 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4926
4927 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004928 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004929 */
4930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4931 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4932
4933 /* Mute all inputs to mixer widget (even unconnected ones) */
4934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4942
4943 { }
4944};
4945#endif
4946
Takashi Iwai63300792008-01-24 15:31:36 +01004947#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4948#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004949
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004950#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4951#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4952
Kailang Yangdf694da2005-12-05 19:42:22 +01004953/*
4954 * for BIOS auto-configuration
4955 */
4956
4957static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4958 const char *pfx)
4959{
4960 hda_nid_t nid_vol;
4961 unsigned long vol_val, sw_val;
4962 char name[32];
4963 int err;
4964
4965 if (nid >= 0x0f && nid < 0x11) {
4966 nid_vol = nid - 0x7;
4967 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4968 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4969 } else if (nid == 0x11) {
4970 nid_vol = nid - 0x7;
4971 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4972 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4973 } else if (nid >= 0x12 && nid <= 0x15) {
4974 nid_vol = 0x08;
4975 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4976 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4977 } else
4978 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004979
Kailang Yangdf694da2005-12-05 19:42:22 +01004980 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004981 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4982 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004983 return err;
4984 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004985 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4986 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004987 return err;
4988 return 1;
4989}
4990
4991/* add playback controls from the parsed DAC table */
4992static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4993 const struct auto_pin_cfg *cfg)
4994{
4995 hda_nid_t nid;
4996 int err;
4997
4998 spec->multiout.num_dacs = 1;
4999 spec->multiout.dac_nids = spec->private_dac_nids;
5000 spec->multiout.dac_nids[0] = 0x02;
5001
5002 nid = cfg->line_out_pins[0];
5003 if (nid) {
5004 err = alc260_add_playback_controls(spec, nid, "Front");
5005 if (err < 0)
5006 return err;
5007 }
5008
Takashi Iwai82bc9552006-03-21 11:24:42 +01005009 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005010 if (nid) {
5011 err = alc260_add_playback_controls(spec, nid, "Speaker");
5012 if (err < 0)
5013 return err;
5014 }
5015
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005016 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005017 if (nid) {
5018 err = alc260_add_playback_controls(spec, nid, "Headphone");
5019 if (err < 0)
5020 return err;
5021 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005022 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005023}
5024
5025/* create playback/capture controls for input pins */
5026static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5027 const struct auto_pin_cfg *cfg)
5028{
Kailang Yangdf694da2005-12-05 19:42:22 +01005029 struct hda_input_mux *imux = &spec->private_imux;
5030 int i, err, idx;
5031
5032 for (i = 0; i < AUTO_PIN_LAST; i++) {
5033 if (cfg->input_pins[i] >= 0x12) {
5034 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005035 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005036 auto_pin_cfg_labels[i], idx,
5037 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005038 if (err < 0)
5039 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 imux->items[imux->num_items].label =
5041 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005042 imux->items[imux->num_items].index = idx;
5043 imux->num_items++;
5044 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005046 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005047 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005048 auto_pin_cfg_labels[i], idx,
5049 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005050 if (err < 0)
5051 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005052 imux->items[imux->num_items].label =
5053 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005054 imux->items[imux->num_items].index = idx;
5055 imux->num_items++;
5056 }
5057 }
5058 return 0;
5059}
5060
5061static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5062 hda_nid_t nid, int pin_type,
5063 int sel_idx)
5064{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005065 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005066 /* need the manual connection? */
5067 if (nid >= 0x12) {
5068 int idx = nid - 0x12;
5069 snd_hda_codec_write(codec, idx + 0x0b, 0,
5070 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005071 }
5072}
5073
5074static void alc260_auto_init_multi_out(struct hda_codec *codec)
5075{
5076 struct alc_spec *spec = codec->spec;
5077 hda_nid_t nid;
5078
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005079 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005080 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005081 if (nid) {
5082 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5083 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5084 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005085
Takashi Iwai82bc9552006-03-21 11:24:42 +01005086 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005087 if (nid)
5088 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5089
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005090 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005091 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005092 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005093}
Kailang Yangdf694da2005-12-05 19:42:22 +01005094
5095#define ALC260_PIN_CD_NID 0x16
5096static void alc260_auto_init_analog_input(struct hda_codec *codec)
5097{
5098 struct alc_spec *spec = codec->spec;
5099 int i;
5100
5101 for (i = 0; i < AUTO_PIN_LAST; i++) {
5102 hda_nid_t nid = spec->autocfg.input_pins[i];
5103 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005104 snd_hda_codec_write(codec, nid, 0,
5105 AC_VERB_SET_PIN_WIDGET_CONTROL,
5106 i <= AUTO_PIN_FRONT_MIC ?
5107 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005108 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005109 snd_hda_codec_write(codec, nid, 0,
5110 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005111 AMP_OUT_MUTE);
5112 }
5113 }
5114}
5115
5116/*
5117 * generic initialization of ADC, input mixers and output mixers
5118 */
5119static struct hda_verb alc260_volume_init_verbs[] = {
5120 /*
5121 * Unmute ADC0-1 and set the default input to mic-in
5122 */
5123 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5125 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5126 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005127
Kailang Yangdf694da2005-12-05 19:42:22 +01005128 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5129 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005130 * Note: PASD motherboards uses the Line In 2 as the input for
5131 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005132 */
5133 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005134 /* mute analog inputs */
5135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005140
5141 /*
5142 * Set up output mixers (0x08 - 0x0a)
5143 */
5144 /* set vol=0 to output mixers */
5145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5148 /* set up input amps for analog loopback */
5149 /* Amp Indices: DAC = 0, mixer = 1 */
5150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5154 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5155 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005156
Kailang Yangdf694da2005-12-05 19:42:22 +01005157 { }
5158};
5159
5160static int alc260_parse_auto_config(struct hda_codec *codec)
5161{
5162 struct alc_spec *spec = codec->spec;
5163 unsigned int wcap;
5164 int err;
5165 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5166
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005167 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5168 alc260_ignore);
5169 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005171 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5172 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005173 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005174 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005175 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005176 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5177 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005178 return err;
5179
5180 spec->multiout.max_channels = 2;
5181
5182 if (spec->autocfg.dig_out_pin)
5183 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005184 if (spec->kctls.list)
5185 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yangdf694da2005-12-05 19:42:22 +01005186
5187 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5188
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005189 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005190 spec->input_mux = &spec->private_imux;
5191
5192 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005193 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005194 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005195 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 spec->adc_nids = alc260_adc_nids_alt;
5197 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5198 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 } else {
5200 spec->adc_nids = alc260_adc_nids;
5201 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5202 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005203 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005204 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005205
5206 return 1;
5207}
5208
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005209/* additional initialization for auto-configuration model */
5210static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005211{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005212 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005213 alc260_auto_init_multi_out(codec);
5214 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005215 if (spec->unsol_event)
5216 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005217}
5218
Takashi Iwaicb53c622007-08-10 17:21:45 +02005219#ifdef CONFIG_SND_HDA_POWER_SAVE
5220static struct hda_amp_list alc260_loopbacks[] = {
5221 { 0x07, HDA_INPUT, 0 },
5222 { 0x07, HDA_INPUT, 1 },
5223 { 0x07, HDA_INPUT, 2 },
5224 { 0x07, HDA_INPUT, 3 },
5225 { 0x07, HDA_INPUT, 4 },
5226 { } /* end */
5227};
5228#endif
5229
Kailang Yangdf694da2005-12-05 19:42:22 +01005230/*
5231 * ALC260 configurations
5232 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005233static const char *alc260_models[ALC260_MODEL_LAST] = {
5234 [ALC260_BASIC] = "basic",
5235 [ALC260_HP] = "hp",
5236 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005237 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005238 [ALC260_FUJITSU_S702X] = "fujitsu",
5239 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005240 [ALC260_WILL] = "will",
5241 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005242#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005243 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005244#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005245 [ALC260_AUTO] = "auto",
5246};
5247
5248static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005249 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005250 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005251 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005252 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005253 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005254 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005255 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005256 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5257 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5258 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5259 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5260 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5261 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5262 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5263 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5264 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005265 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005266 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005267 {}
5268};
5269
Kailang Yangdf694da2005-12-05 19:42:22 +01005270static struct alc_config_preset alc260_presets[] = {
5271 [ALC260_BASIC] = {
5272 .mixers = { alc260_base_output_mixer,
5273 alc260_input_mixer,
5274 alc260_pc_beep_mixer,
5275 alc260_capture_mixer },
5276 .init_verbs = { alc260_init_verbs },
5277 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5278 .dac_nids = alc260_dac_nids,
5279 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5280 .adc_nids = alc260_adc_nids,
5281 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5282 .channel_mode = alc260_modes,
5283 .input_mux = &alc260_capture_source,
5284 },
5285 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005286 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005287 alc260_input_mixer,
5288 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005289 .init_verbs = { alc260_init_verbs,
5290 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005291 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5292 .dac_nids = alc260_dac_nids,
5293 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5294 .adc_nids = alc260_hp_adc_nids,
5295 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5296 .channel_mode = alc260_modes,
5297 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005298 .unsol_event = alc260_hp_unsol_event,
5299 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005300 },
Kailang Yang3f878302008-08-26 13:02:23 +02005301 [ALC260_HP_DC7600] = {
5302 .mixers = { alc260_hp_dc7600_mixer,
5303 alc260_input_mixer,
5304 alc260_capture_alt_mixer },
5305 .init_verbs = { alc260_init_verbs,
5306 alc260_hp_dc7600_verbs },
5307 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5308 .dac_nids = alc260_dac_nids,
5309 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5310 .adc_nids = alc260_hp_adc_nids,
5311 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5312 .channel_mode = alc260_modes,
5313 .input_mux = &alc260_capture_source,
5314 .unsol_event = alc260_hp_3012_unsol_event,
5315 .init_hook = alc260_hp_3012_automute,
5316 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005317 [ALC260_HP_3013] = {
5318 .mixers = { alc260_hp_3013_mixer,
5319 alc260_input_mixer,
5320 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005321 .init_verbs = { alc260_hp_3013_init_verbs,
5322 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5324 .dac_nids = alc260_dac_nids,
5325 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5326 .adc_nids = alc260_hp_adc_nids,
5327 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5328 .channel_mode = alc260_modes,
5329 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005330 .unsol_event = alc260_hp_3013_unsol_event,
5331 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005332 },
5333 [ALC260_FUJITSU_S702X] = {
5334 .mixers = { alc260_fujitsu_mixer,
5335 alc260_capture_mixer },
5336 .init_verbs = { alc260_fujitsu_init_verbs },
5337 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5338 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005339 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5340 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005341 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5342 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005343 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5344 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005345 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005346 [ALC260_ACER] = {
5347 .mixers = { alc260_acer_mixer,
5348 alc260_capture_mixer },
5349 .init_verbs = { alc260_acer_init_verbs },
5350 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5351 .dac_nids = alc260_dac_nids,
5352 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5353 .adc_nids = alc260_dual_adc_nids,
5354 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5355 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005356 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5357 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005358 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005359 [ALC260_WILL] = {
5360 .mixers = { alc260_will_mixer,
5361 alc260_capture_mixer },
5362 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5363 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5364 .dac_nids = alc260_dac_nids,
5365 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5366 .adc_nids = alc260_adc_nids,
5367 .dig_out_nid = ALC260_DIGOUT_NID,
5368 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5369 .channel_mode = alc260_modes,
5370 .input_mux = &alc260_capture_source,
5371 },
5372 [ALC260_REPLACER_672V] = {
5373 .mixers = { alc260_replacer_672v_mixer,
5374 alc260_capture_mixer },
5375 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5376 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5377 .dac_nids = alc260_dac_nids,
5378 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5379 .adc_nids = alc260_adc_nids,
5380 .dig_out_nid = ALC260_DIGOUT_NID,
5381 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5382 .channel_mode = alc260_modes,
5383 .input_mux = &alc260_capture_source,
5384 .unsol_event = alc260_replacer_672v_unsol_event,
5385 .init_hook = alc260_replacer_672v_automute,
5386 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005387#ifdef CONFIG_SND_DEBUG
5388 [ALC260_TEST] = {
5389 .mixers = { alc260_test_mixer,
5390 alc260_capture_mixer },
5391 .init_verbs = { alc260_test_init_verbs },
5392 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5393 .dac_nids = alc260_test_dac_nids,
5394 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5395 .adc_nids = alc260_test_adc_nids,
5396 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5397 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005398 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5399 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005400 },
5401#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005402};
5403
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404static int patch_alc260(struct hda_codec *codec)
5405{
5406 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005407 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005408
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005409 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005410 if (spec == NULL)
5411 return -ENOMEM;
5412
5413 codec->spec = spec;
5414
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005415 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5416 alc260_models,
5417 alc260_cfg_tbl);
5418 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005419 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5420 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005421 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005422 }
5423
Kailang Yangdf694da2005-12-05 19:42:22 +01005424 if (board_config == ALC260_AUTO) {
5425 /* automatic parse from the BIOS config */
5426 err = alc260_parse_auto_config(codec);
5427 if (err < 0) {
5428 alc_free(codec);
5429 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005430 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005431 printk(KERN_INFO
5432 "hda_codec: Cannot set up configuration "
5433 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005434 board_config = ALC260_BASIC;
5435 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005437
Kailang Yangdf694da2005-12-05 19:42:22 +01005438 if (board_config != ALC260_AUTO)
5439 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005440
5441 spec->stream_name_analog = "ALC260 Analog";
5442 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5443 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5444
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005445 spec->stream_name_digital = "ALC260 Digital";
5446 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5447 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5448
Takashi Iwai2134ea42008-01-10 16:53:55 +01005449 spec->vmaster_nid = 0x08;
5450
Linus Torvalds1da177e2005-04-16 15:20:36 -07005451 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005452 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005453 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005454#ifdef CONFIG_SND_HDA_POWER_SAVE
5455 if (!spec->loopback.amplist)
5456 spec->loopback.amplist = alc260_loopbacks;
5457#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005458
5459 return 0;
5460}
5461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005462
Linus Torvalds1da177e2005-04-16 15:20:36 -07005463/*
5464 * ALC882 support
5465 *
5466 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5467 * configuration. Each pin widget can choose any input DACs and a mixer.
5468 * Each ADC is connected from a mixer of all inputs. This makes possible
5469 * 6-channel independent captures.
5470 *
5471 * In addition, an independent DAC for the multi-playback (not used in this
5472 * driver yet).
5473 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005474#define ALC882_DIGOUT_NID 0x06
5475#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005476
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005477static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005478 { 8, NULL }
5479};
5480
5481static hda_nid_t alc882_dac_nids[4] = {
5482 /* front, rear, clfe, rear_surr */
5483 0x02, 0x03, 0x04, 0x05
5484};
5485
Kailang Yangdf694da2005-12-05 19:42:22 +01005486/* identical with ALC880 */
5487#define alc882_adc_nids alc880_adc_nids
5488#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005489
Takashi Iwaie1406342008-02-11 18:32:32 +01005490static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5491static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5492
Linus Torvalds1da177e2005-04-16 15:20:36 -07005493/* input MUX */
5494/* FIXME: should be a matrix-type input source selection */
5495
5496static struct hda_input_mux alc882_capture_source = {
5497 .num_items = 4,
5498 .items = {
5499 { "Mic", 0x0 },
5500 { "Front Mic", 0x1 },
5501 { "Line", 0x2 },
5502 { "CD", 0x4 },
5503 },
5504};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505#define alc882_mux_enum_info alc_mux_enum_info
5506#define alc882_mux_enum_get alc_mux_enum_get
5507
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005508static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5509 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510{
5511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5512 struct alc_spec *spec = codec->spec;
5513 const struct hda_input_mux *imux = spec->input_mux;
5514 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005515 hda_nid_t nid = spec->capsrc_nids ?
5516 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5518 unsigned int i, idx;
5519
5520 idx = ucontrol->value.enumerated.item[0];
5521 if (idx >= imux->num_items)
5522 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005523 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005524 return 0;
5525 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005526 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5527 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005528 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005529 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005530 }
5531 *cur_val = idx;
5532 return 1;
5533}
5534
Kailang Yangdf694da2005-12-05 19:42:22 +01005535/*
Kailang Yang272a5272007-05-14 11:00:38 +02005536 * 2ch mode
5537 */
5538static struct hda_verb alc882_3ST_ch2_init[] = {
5539 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5540 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5541 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5542 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5543 { } /* end */
5544};
5545
5546/*
5547 * 6ch mode
5548 */
5549static struct hda_verb alc882_3ST_ch6_init[] = {
5550 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5551 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5552 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5553 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5554 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5555 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5556 { } /* end */
5557};
5558
5559static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5560 { 2, alc882_3ST_ch2_init },
5561 { 6, alc882_3ST_ch6_init },
5562};
5563
5564/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005565 * 6ch mode
5566 */
5567static struct hda_verb alc882_sixstack_ch6_init[] = {
5568 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5569 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5570 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5571 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5572 { } /* end */
5573};
5574
5575/*
5576 * 8ch mode
5577 */
5578static struct hda_verb alc882_sixstack_ch8_init[] = {
5579 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5580 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5581 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5583 { } /* end */
5584};
5585
5586static struct hda_channel_mode alc882_sixstack_modes[2] = {
5587 { 6, alc882_sixstack_ch6_init },
5588 { 8, alc882_sixstack_ch8_init },
5589};
5590
Takashi Iwai87350ad2007-08-16 18:19:38 +02005591/*
5592 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5593 */
5594
5595/*
5596 * 2ch mode
5597 */
5598static struct hda_verb alc885_mbp_ch2_init[] = {
5599 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5600 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5601 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5602 { } /* end */
5603};
5604
5605/*
5606 * 6ch mode
5607 */
5608static struct hda_verb alc885_mbp_ch6_init[] = {
5609 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5610 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5611 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5612 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5613 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5614 { } /* end */
5615};
5616
5617static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5618 { 2, alc885_mbp_ch2_init },
5619 { 6, alc885_mbp_ch6_init },
5620};
5621
5622
Linus Torvalds1da177e2005-04-16 15:20:36 -07005623/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5624 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5625 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005626static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005627 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005628 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005629 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005630 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005631 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5632 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005633 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5634 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005635 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005636 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5638 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5639 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5645 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005646 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5648 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5649 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005650 { } /* end */
5651};
5652
Takashi Iwai87350ad2007-08-16 18:19:38 +02005653static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005654 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5655 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5656 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5657 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5659 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5661 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005662 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005663 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5664 { } /* end */
5665};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005666static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5667 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5668 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5670 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5676 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5677 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5678 { } /* end */
5679};
5680
Kailang Yang272a5272007-05-14 11:00:38 +02005681static struct snd_kcontrol_new alc882_targa_mixer[] = {
5682 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5683 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5685 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5686 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5687 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5688 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5690 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005691 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005692 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5693 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005694 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005695 { } /* end */
5696};
5697
5698/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5699 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5700 */
5701static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5703 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5705 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5708 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5709 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5710 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5711 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005715 { } /* end */
5716};
5717
Takashi Iwai914759b2007-09-06 14:52:04 +02005718static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5722 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5723 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5724 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5725 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5729 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5730 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5731 { } /* end */
5732};
5733
Kailang Yangdf694da2005-12-05 19:42:22 +01005734static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5735 {
5736 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5737 .name = "Channel Mode",
5738 .info = alc_ch_mode_info,
5739 .get = alc_ch_mode_get,
5740 .put = alc_ch_mode_put,
5741 },
5742 { } /* end */
5743};
5744
Linus Torvalds1da177e2005-04-16 15:20:36 -07005745static struct hda_verb alc882_init_verbs[] = {
5746 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005750 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005754 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005758 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5760 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005763 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005766 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005767 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005771 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005774 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005775 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005776 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005778 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005779 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005780 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005781 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5782 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005783 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005784 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5785 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005787 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5788 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5789 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5790 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5791 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005792 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005793 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005794
5795 /* FIXME: use matrix-type input source selection */
5796 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5797 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005798 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5799 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5800 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005802 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005807 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5812 /* ADC1: mute amp left and right */
5813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005814 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005815 /* ADC2: mute amp left and right */
5816 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005817 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005818 /* ADC3: mute amp left and right */
5819 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005820 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005821
5822 { }
5823};
5824
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005825static struct hda_verb alc882_eapd_verbs[] = {
5826 /* change to EAPD mode */
5827 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005828 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005829 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005830};
5831
Tobin Davis9102cd12006-12-15 10:02:12 +01005832/* Mac Pro test */
5833static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5839 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5840 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5841 { } /* end */
5842};
5843
5844static struct hda_verb alc882_macpro_init_verbs[] = {
5845 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5849 /* Front Pin: output 0 (0x0c) */
5850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5853 /* Front Mic pin: input vref at 80% */
5854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5856 /* Speaker: output */
5857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5859 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5860 /* Headphone output (output 0 - 0x0c) */
5861 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5863 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5864
5865 /* FIXME: use matrix-type input source selection */
5866 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5867 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5869 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5870 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5871 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5872 /* Input mixer2 */
5873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5877 /* Input mixer3 */
5878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5882 /* ADC1: mute amp left and right */
5883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5884 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5885 /* ADC2: mute amp left and right */
5886 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5887 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5888 /* ADC3: mute amp left and right */
5889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5891
5892 { }
5893};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005894
Takashi Iwai87350ad2007-08-16 18:19:38 +02005895/* Macbook Pro rev3 */
5896static struct hda_verb alc885_mbp3_init_verbs[] = {
5897 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5901 /* Rear mixer */
5902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5904 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5905 /* Front Pin: output 0 (0x0c) */
5906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5908 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5909 /* HP Pin: output 0 (0x0d) */
5910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5914 /* Mic (rear) pin: input vref at 80% */
5915 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5916 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5917 /* Front Mic pin: input vref at 80% */
5918 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5920 /* Line In pin: use output 1 when in LineOut mode */
5921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5923 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5924
5925 /* FIXME: use matrix-type input source selection */
5926 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5927 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5932 /* Input mixer2 */
5933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5937 /* Input mixer3 */
5938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5942 /* ADC1: mute amp left and right */
5943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5944 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5945 /* ADC2: mute amp left and right */
5946 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5947 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5948 /* ADC3: mute amp left and right */
5949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5950 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5951
5952 { }
5953};
5954
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005955/* iMac 24 mixer. */
5956static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5957 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5958 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5959 { } /* end */
5960};
5961
5962/* iMac 24 init verbs. */
5963static struct hda_verb alc885_imac24_init_verbs[] = {
5964 /* Internal speakers: output 0 (0x0c) */
5965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5967 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5968 /* Internal speakers: output 0 (0x0c) */
5969 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5970 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5971 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5972 /* Headphone: output 0 (0x0c) */
5973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5976 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5977 /* Front Mic: input vref at 80% */
5978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5980 { }
5981};
5982
5983/* Toggle speaker-output according to the hp-jack state */
5984static void alc885_imac24_automute(struct hda_codec *codec)
5985{
5986 unsigned int present;
5987
5988 present = snd_hda_codec_read(codec, 0x14, 0,
5989 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005990 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5991 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5992 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5993 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005994}
5995
5996/* Processes unsolicited events. */
5997static void alc885_imac24_unsol_event(struct hda_codec *codec,
5998 unsigned int res)
5999{
6000 /* Headphone insertion or removal. */
6001 if ((res >> 26) == ALC880_HP_EVENT)
6002 alc885_imac24_automute(codec);
6003}
6004
Takashi Iwai87350ad2007-08-16 18:19:38 +02006005static void alc885_mbp3_automute(struct hda_codec *codec)
6006{
6007 unsigned int present;
6008
6009 present = snd_hda_codec_read(codec, 0x15, 0,
6010 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6011 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6012 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6013 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6014 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6015
6016}
6017static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6018 unsigned int res)
6019{
6020 /* Headphone insertion or removal. */
6021 if ((res >> 26) == ALC880_HP_EVENT)
6022 alc885_mbp3_automute(codec);
6023}
6024
6025
Kailang Yang272a5272007-05-14 11:00:38 +02006026static struct hda_verb alc882_targa_verbs[] = {
6027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6029
6030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6031 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006032
Kailang Yang272a5272007-05-14 11:00:38 +02006033 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6034 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6035 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6036
6037 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6038 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6039 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6040 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6041 { } /* end */
6042};
6043
6044/* toggle speaker-output according to the hp-jack state */
6045static void alc882_targa_automute(struct hda_codec *codec)
6046{
6047 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006048
Kailang Yang272a5272007-05-14 11:00:38 +02006049 present = snd_hda_codec_read(codec, 0x14, 0,
6050 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006051 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6052 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006053 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6054 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006055}
6056
6057static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6058{
6059 /* Looks like the unsol event is incompatible with the standard
6060 * definition. 4bit tag is placed at 26 bit!
6061 */
6062 if (((res >> 26) == ALC880_HP_EVENT)) {
6063 alc882_targa_automute(codec);
6064 }
6065}
6066
6067static struct hda_verb alc882_asus_a7j_verbs[] = {
6068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6070
6071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6073 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006074
Kailang Yang272a5272007-05-14 11:00:38 +02006075 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6078
6079 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6080 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6082 { } /* end */
6083};
6084
Takashi Iwai914759b2007-09-06 14:52:04 +02006085static struct hda_verb alc882_asus_a7m_verbs[] = {
6086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6088
6089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006092
Takashi Iwai914759b2007-09-06 14:52:04 +02006093 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6094 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6095 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6096
6097 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6098 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6099 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6100 { } /* end */
6101};
6102
Tobin Davis9102cd12006-12-15 10:02:12 +01006103static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6104{
6105 unsigned int gpiostate, gpiomask, gpiodir;
6106
6107 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6108 AC_VERB_GET_GPIO_DATA, 0);
6109
6110 if (!muted)
6111 gpiostate |= (1 << pin);
6112 else
6113 gpiostate &= ~(1 << pin);
6114
6115 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6116 AC_VERB_GET_GPIO_MASK, 0);
6117 gpiomask |= (1 << pin);
6118
6119 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6120 AC_VERB_GET_GPIO_DIRECTION, 0);
6121 gpiodir |= (1 << pin);
6122
6123
6124 snd_hda_codec_write(codec, codec->afg, 0,
6125 AC_VERB_SET_GPIO_MASK, gpiomask);
6126 snd_hda_codec_write(codec, codec->afg, 0,
6127 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6128
6129 msleep(1);
6130
6131 snd_hda_codec_write(codec, codec->afg, 0,
6132 AC_VERB_SET_GPIO_DATA, gpiostate);
6133}
6134
Takashi Iwai7debbe52007-08-16 15:01:03 +02006135/* set up GPIO at initialization */
6136static void alc885_macpro_init_hook(struct hda_codec *codec)
6137{
6138 alc882_gpio_mute(codec, 0, 0);
6139 alc882_gpio_mute(codec, 1, 0);
6140}
6141
6142/* set up GPIO and update auto-muting at initialization */
6143static void alc885_imac24_init_hook(struct hda_codec *codec)
6144{
6145 alc885_macpro_init_hook(codec);
6146 alc885_imac24_automute(codec);
6147}
6148
Kailang Yangdf694da2005-12-05 19:42:22 +01006149/*
6150 * generic initialization of ADC, input mixers and output mixers
6151 */
6152static struct hda_verb alc882_auto_init_verbs[] = {
6153 /*
6154 * Unmute ADC0-2 and set the default input to mic-in
6155 */
6156 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162
Takashi Iwaicb53c622007-08-10 17:21:45 +02006163 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006164 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006165 * Note: PASD motherboards uses the Line In 2 as the input for
6166 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006167 */
6168 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006174
6175 /*
6176 * Set up output mixers (0x0c - 0x0f)
6177 */
6178 /* set vol=0 to output mixers */
6179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6183 /* set up input amps for analog loopback */
6184 /* Amp Indices: DAC = 0, mixer = 1 */
6185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6191 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6192 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6193 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6194 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6195
6196 /* FIXME: use matrix-type input source selection */
6197 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6198 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6203 /* Input mixer2 */
6204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6208 /* Input mixer3 */
6209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6213
6214 { }
6215};
6216
6217/* capture mixer elements */
6218static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6219 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6220 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6221 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6222 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6223 {
6224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6225 /* The multiple "Capture Source" controls confuse alsamixer
6226 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006227 */
6228 /* .name = "Capture Source", */
6229 .name = "Input Source",
6230 .count = 2,
6231 .info = alc882_mux_enum_info,
6232 .get = alc882_mux_enum_get,
6233 .put = alc882_mux_enum_put,
6234 },
6235 { } /* end */
6236};
6237
6238static struct snd_kcontrol_new alc882_capture_mixer[] = {
6239 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6240 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6241 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6242 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6243 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6244 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6245 {
6246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6247 /* The multiple "Capture Source" controls confuse alsamixer
6248 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006249 */
6250 /* .name = "Capture Source", */
6251 .name = "Input Source",
6252 .count = 3,
6253 .info = alc882_mux_enum_info,
6254 .get = alc882_mux_enum_get,
6255 .put = alc882_mux_enum_put,
6256 },
6257 { } /* end */
6258};
6259
Takashi Iwaicb53c622007-08-10 17:21:45 +02006260#ifdef CONFIG_SND_HDA_POWER_SAVE
6261#define alc882_loopbacks alc880_loopbacks
6262#endif
6263
Kailang Yangdf694da2005-12-05 19:42:22 +01006264/* pcm configuration: identiacal with ALC880 */
6265#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6266#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6267#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6268#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6269
6270/*
6271 * configuration and preset
6272 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006273static const char *alc882_models[ALC882_MODEL_LAST] = {
6274 [ALC882_3ST_DIG] = "3stack-dig",
6275 [ALC882_6ST_DIG] = "6stack-dig",
6276 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006277 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006278 [ALC882_TARGA] = "targa",
6279 [ALC882_ASUS_A7J] = "asus-a7j",
6280 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006281 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006282 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006283 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006284 [ALC882_AUTO] = "auto",
6285};
6286
6287static struct snd_pci_quirk alc882_cfg_tbl[] = {
6288 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006289 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006290 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006291 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006292 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006293 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006294 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006295 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006296 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006297 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6298 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6299 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006300 {}
6301};
6302
6303static struct alc_config_preset alc882_presets[] = {
6304 [ALC882_3ST_DIG] = {
6305 .mixers = { alc882_base_mixer },
6306 .init_verbs = { alc882_init_verbs },
6307 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6308 .dac_nids = alc882_dac_nids,
6309 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006310 .dig_in_nid = ALC882_DIGIN_NID,
6311 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6312 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006313 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006314 .input_mux = &alc882_capture_source,
6315 },
6316 [ALC882_6ST_DIG] = {
6317 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6318 .init_verbs = { alc882_init_verbs },
6319 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6320 .dac_nids = alc882_dac_nids,
6321 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 .dig_in_nid = ALC882_DIGIN_NID,
6323 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6324 .channel_mode = alc882_sixstack_modes,
6325 .input_mux = &alc882_capture_source,
6326 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006327 [ALC882_ARIMA] = {
6328 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6329 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6330 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6331 .dac_nids = alc882_dac_nids,
6332 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6333 .channel_mode = alc882_sixstack_modes,
6334 .input_mux = &alc882_capture_source,
6335 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006336 [ALC882_W2JC] = {
6337 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6338 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6339 alc880_gpio1_init_verbs },
6340 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6341 .dac_nids = alc882_dac_nids,
6342 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6343 .channel_mode = alc880_threestack_modes,
6344 .need_dac_fix = 1,
6345 .input_mux = &alc882_capture_source,
6346 .dig_out_nid = ALC882_DIGOUT_NID,
6347 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006348 [ALC885_MBP3] = {
6349 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6350 .init_verbs = { alc885_mbp3_init_verbs,
6351 alc880_gpio1_init_verbs },
6352 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6353 .dac_nids = alc882_dac_nids,
6354 .channel_mode = alc885_mbp_6ch_modes,
6355 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6356 .input_mux = &alc882_capture_source,
6357 .dig_out_nid = ALC882_DIGOUT_NID,
6358 .dig_in_nid = ALC882_DIGIN_NID,
6359 .unsol_event = alc885_mbp3_unsol_event,
6360 .init_hook = alc885_mbp3_automute,
6361 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006362 [ALC885_MACPRO] = {
6363 .mixers = { alc882_macpro_mixer },
6364 .init_verbs = { alc882_macpro_init_verbs },
6365 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6366 .dac_nids = alc882_dac_nids,
6367 .dig_out_nid = ALC882_DIGOUT_NID,
6368 .dig_in_nid = ALC882_DIGIN_NID,
6369 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6370 .channel_mode = alc882_ch_modes,
6371 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006372 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006373 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006374 [ALC885_IMAC24] = {
6375 .mixers = { alc885_imac24_mixer },
6376 .init_verbs = { alc885_imac24_init_verbs },
6377 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6378 .dac_nids = alc882_dac_nids,
6379 .dig_out_nid = ALC882_DIGOUT_NID,
6380 .dig_in_nid = ALC882_DIGIN_NID,
6381 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6382 .channel_mode = alc882_ch_modes,
6383 .input_mux = &alc882_capture_source,
6384 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006385 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006386 },
Kailang Yang272a5272007-05-14 11:00:38 +02006387 [ALC882_TARGA] = {
6388 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6389 alc882_capture_mixer },
6390 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6391 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6392 .dac_nids = alc882_dac_nids,
6393 .dig_out_nid = ALC882_DIGOUT_NID,
6394 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6395 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006396 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006397 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6398 .channel_mode = alc882_3ST_6ch_modes,
6399 .need_dac_fix = 1,
6400 .input_mux = &alc882_capture_source,
6401 .unsol_event = alc882_targa_unsol_event,
6402 .init_hook = alc882_targa_automute,
6403 },
6404 [ALC882_ASUS_A7J] = {
6405 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6406 alc882_capture_mixer },
6407 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6408 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6409 .dac_nids = alc882_dac_nids,
6410 .dig_out_nid = ALC882_DIGOUT_NID,
6411 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6412 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006413 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006414 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6415 .channel_mode = alc882_3ST_6ch_modes,
6416 .need_dac_fix = 1,
6417 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006418 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006419 [ALC882_ASUS_A7M] = {
6420 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6421 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6422 alc880_gpio1_init_verbs,
6423 alc882_asus_a7m_verbs },
6424 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6425 .dac_nids = alc882_dac_nids,
6426 .dig_out_nid = ALC882_DIGOUT_NID,
6427 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6428 .channel_mode = alc880_threestack_modes,
6429 .need_dac_fix = 1,
6430 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006431 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006432};
6433
6434
6435/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006436 * Pin config fixes
6437 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006438enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006439 PINFIX_ABIT_AW9D_MAX
6440};
6441
6442static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6443 { 0x15, 0x01080104 }, /* side */
6444 { 0x16, 0x01011012 }, /* rear */
6445 { 0x17, 0x01016011 }, /* clfe */
6446 { }
6447};
6448
6449static const struct alc_pincfg *alc882_pin_fixes[] = {
6450 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6451};
6452
6453static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6454 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6455 {}
6456};
6457
6458/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006459 * BIOS auto configuration
6460 */
6461static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6462 hda_nid_t nid, int pin_type,
6463 int dac_idx)
6464{
6465 /* set as output */
6466 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006467 int idx;
6468
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006469 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006470 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6471 idx = 4;
6472 else
6473 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006474 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6475
6476}
6477
6478static void alc882_auto_init_multi_out(struct hda_codec *codec)
6479{
6480 struct alc_spec *spec = codec->spec;
6481 int i;
6482
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006483 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006484 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006485 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006486 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006488 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006489 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 }
6491}
6492
6493static void alc882_auto_init_hp_out(struct hda_codec *codec)
6494{
6495 struct alc_spec *spec = codec->spec;
6496 hda_nid_t pin;
6497
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006498 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006499 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006500 /* use dac 0 */
6501 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006502 pin = spec->autocfg.speaker_pins[0];
6503 if (pin)
6504 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006505}
6506
6507#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6508#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6509
6510static void alc882_auto_init_analog_input(struct hda_codec *codec)
6511{
6512 struct alc_spec *spec = codec->spec;
6513 int i;
6514
6515 for (i = 0; i < AUTO_PIN_LAST; i++) {
6516 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006517 unsigned int vref;
6518 if (!nid)
6519 continue;
6520 vref = PIN_IN;
6521 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006522 unsigned int pincap;
6523 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6524 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006525 AC_PINCAP_VREF_80)
6526 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006527 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006528 snd_hda_codec_write(codec, nid, 0,
6529 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6530 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6531 snd_hda_codec_write(codec, nid, 0,
6532 AC_VERB_SET_AMP_GAIN_MUTE,
6533 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 }
6535}
6536
Takashi Iwaif511b012008-08-15 16:46:42 +02006537static void alc882_auto_init_input_src(struct hda_codec *codec)
6538{
6539 struct alc_spec *spec = codec->spec;
6540 const struct hda_input_mux *imux = spec->input_mux;
6541 int c;
6542
6543 for (c = 0; c < spec->num_adc_nids; c++) {
6544 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6545 hda_nid_t nid = spec->capsrc_nids[c];
6546 int conns, mute, idx, item;
6547
6548 conns = snd_hda_get_connections(codec, nid, conn_list,
6549 ARRAY_SIZE(conn_list));
6550 if (conns < 0)
6551 continue;
6552 for (idx = 0; idx < conns; idx++) {
6553 /* if the current connection is the selected one,
6554 * unmute it as default - otherwise mute it
6555 */
6556 mute = AMP_IN_MUTE(idx);
6557 for (item = 0; item < imux->num_items; item++) {
6558 if (imux->items[item].index == idx) {
6559 if (spec->cur_mux[c] == item)
6560 mute = AMP_IN_UNMUTE(idx);
6561 break;
6562 }
6563 }
6564 snd_hda_codec_write(codec, nid, 0,
6565 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6566 }
6567 }
6568}
6569
Takashi Iwai776e1842007-08-29 15:07:11 +02006570/* add mic boosts if needed */
6571static int alc_auto_add_mic_boost(struct hda_codec *codec)
6572{
6573 struct alc_spec *spec = codec->spec;
6574 int err;
6575 hda_nid_t nid;
6576
6577 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006578 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006579 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6580 "Mic Boost",
6581 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6582 if (err < 0)
6583 return err;
6584 }
6585 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006586 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006587 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6588 "Front Mic Boost",
6589 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6590 if (err < 0)
6591 return err;
6592 }
6593 return 0;
6594}
6595
Kailang Yangdf694da2005-12-05 19:42:22 +01006596/* almost identical with ALC880 parser... */
6597static int alc882_parse_auto_config(struct hda_codec *codec)
6598{
6599 struct alc_spec *spec = codec->spec;
6600 int err = alc880_parse_auto_config(codec);
6601
6602 if (err < 0)
6603 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006604 else if (!err)
6605 return 0; /* no config found */
6606
6607 err = alc_auto_add_mic_boost(codec);
6608 if (err < 0)
6609 return err;
6610
6611 /* hack - override the init verbs */
6612 spec->init_verbs[0] = alc882_auto_init_verbs;
6613
6614 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006615}
6616
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006617/* additional initialization for auto-configuration model */
6618static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006619{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006620 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006621 alc882_auto_init_multi_out(codec);
6622 alc882_auto_init_hp_out(codec);
6623 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006624 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006625 if (spec->unsol_event)
6626 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006627}
6628
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006629static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6630
Linus Torvalds1da177e2005-04-16 15:20:36 -07006631static int patch_alc882(struct hda_codec *codec)
6632{
6633 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006635
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006636 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006637 if (spec == NULL)
6638 return -ENOMEM;
6639
Linus Torvalds1da177e2005-04-16 15:20:36 -07006640 codec->spec = spec;
6641
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006642 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6643 alc882_models,
6644 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006645
Kailang Yangdf694da2005-12-05 19:42:22 +01006646 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006647 /* Pick up systems that don't supply PCI SSID */
6648 switch (codec->subsystem_id) {
6649 case 0x106b0c00: /* Mac Pro */
6650 board_config = ALC885_MACPRO;
6651 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006652 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006653 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006654 board_config = ALC885_IMAC24;
6655 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006656 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006657 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006658 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006659 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006660 board_config = ALC885_MBP3;
6661 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006662 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006663 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006664 if (codec->revision_id == 0x100101 ||
6665 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006666 alc_free(codec);
6667 return patch_alc883(codec);
6668 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006669 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6670 "trying auto-probe from BIOS...\n");
6671 board_config = ALC882_AUTO;
6672 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006673 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006674
Takashi Iwaif95474e2007-07-10 00:47:43 +02006675 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6676
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 if (board_config == ALC882_AUTO) {
6678 /* automatic parse from the BIOS config */
6679 err = alc882_parse_auto_config(codec);
6680 if (err < 0) {
6681 alc_free(codec);
6682 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006683 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006684 printk(KERN_INFO
6685 "hda_codec: Cannot set up configuration "
6686 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006687 board_config = ALC882_3ST_DIG;
6688 }
6689 }
6690
6691 if (board_config != ALC882_AUTO)
6692 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006693
Kailang Yang2f893282008-05-27 12:14:47 +02006694 if (codec->vendor_id == 0x10ec0885) {
6695 spec->stream_name_analog = "ALC885 Analog";
6696 spec->stream_name_digital = "ALC885 Digital";
6697 } else {
6698 spec->stream_name_analog = "ALC882 Analog";
6699 spec->stream_name_digital = "ALC882 Digital";
6700 }
6701
Kailang Yangdf694da2005-12-05 19:42:22 +01006702 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6703 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006704 /* FIXME: setup DAC5 */
6705 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6706 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006707
Kailang Yangdf694da2005-12-05 19:42:22 +01006708 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6709 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006710
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006711 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006712 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006713 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006714 /* get type */
6715 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006716 if (wcap != AC_WID_AUD_IN) {
6717 spec->adc_nids = alc882_adc_nids_alt;
6718 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006719 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006720 spec->mixers[spec->num_mixers] =
6721 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006722 spec->num_mixers++;
6723 } else {
6724 spec->adc_nids = alc882_adc_nids;
6725 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006726 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006727 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6728 spec->num_mixers++;
6729 }
6730 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006731
Takashi Iwai2134ea42008-01-10 16:53:55 +01006732 spec->vmaster_nid = 0x0c;
6733
Linus Torvalds1da177e2005-04-16 15:20:36 -07006734 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006735 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006736 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006737#ifdef CONFIG_SND_HDA_POWER_SAVE
6738 if (!spec->loopback.amplist)
6739 spec->loopback.amplist = alc882_loopbacks;
6740#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006741
6742 return 0;
6743}
6744
6745/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006746 * ALC883 support
6747 *
6748 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6749 * configuration. Each pin widget can choose any input DACs and a mixer.
6750 * Each ADC is connected from a mixer of all inputs. This makes possible
6751 * 6-channel independent captures.
6752 *
6753 * In addition, an independent DAC for the multi-playback (not used in this
6754 * driver yet).
6755 */
6756#define ALC883_DIGOUT_NID 0x06
6757#define ALC883_DIGIN_NID 0x0a
6758
6759static hda_nid_t alc883_dac_nids[4] = {
6760 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006761 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006762};
6763
6764static hda_nid_t alc883_adc_nids[2] = {
6765 /* ADC1-2 */
6766 0x08, 0x09,
6767};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006768
Takashi Iwaie1406342008-02-11 18:32:32 +01006769static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6770
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006771/* input MUX */
6772/* FIXME: should be a matrix-type input source selection */
6773
6774static struct hda_input_mux alc883_capture_source = {
6775 .num_items = 4,
6776 .items = {
6777 { "Mic", 0x0 },
6778 { "Front Mic", 0x1 },
6779 { "Line", 0x2 },
6780 { "CD", 0x4 },
6781 },
6782};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006783
Jiang zhe17bba1b2008-06-04 12:11:07 +02006784static struct hda_input_mux alc883_3stack_6ch_intel = {
6785 .num_items = 4,
6786 .items = {
6787 { "Mic", 0x1 },
6788 { "Front Mic", 0x0 },
6789 { "Line", 0x2 },
6790 { "CD", 0x4 },
6791 },
6792};
6793
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006794static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6795 .num_items = 2,
6796 .items = {
6797 { "Mic", 0x1 },
6798 { "Line", 0x2 },
6799 },
6800};
6801
Kailang Yang272a5272007-05-14 11:00:38 +02006802static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6803 .num_items = 4,
6804 .items = {
6805 { "Mic", 0x0 },
6806 { "iMic", 0x1 },
6807 { "Line", 0x2 },
6808 { "CD", 0x4 },
6809 },
6810};
6811
Jiang zhefb97dc62008-03-06 11:07:11 +01006812static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6813 .num_items = 2,
6814 .items = {
6815 { "Mic", 0x0 },
6816 { "Int Mic", 0x1 },
6817 },
6818};
6819
Kailang Yange2757d52008-08-26 13:17:46 +02006820static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6821 .num_items = 3,
6822 .items = {
6823 { "Mic", 0x0 },
6824 { "Front Mic", 0x1 },
6825 { "Line", 0x4 },
6826 },
6827};
6828
6829static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6830 .num_items = 2,
6831 .items = {
6832 { "Mic", 0x0 },
6833 { "Line", 0x2 },
6834 },
6835};
6836
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006837#define alc883_mux_enum_info alc_mux_enum_info
6838#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006839/* ALC883 has the ALC882-type input selection */
6840#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006841
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006842/*
6843 * 2ch mode
6844 */
6845static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6846 { 2, NULL }
6847};
6848
6849/*
6850 * 2ch mode
6851 */
6852static struct hda_verb alc883_3ST_ch2_init[] = {
6853 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6854 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6857 { } /* end */
6858};
6859
6860/*
Tobin Davisb2011312007-09-17 12:45:11 +02006861 * 4ch mode
6862 */
6863static struct hda_verb alc883_3ST_ch4_init[] = {
6864 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6865 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6868 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6869 { } /* end */
6870};
6871
6872/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006873 * 6ch mode
6874 */
6875static struct hda_verb alc883_3ST_ch6_init[] = {
6876 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6877 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6878 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6879 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6880 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6881 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6882 { } /* end */
6883};
6884
Tobin Davisb2011312007-09-17 12:45:11 +02006885static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006886 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006887 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006888 { 6, alc883_3ST_ch6_init },
6889};
6890
6891/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006892 * 2ch mode
6893 */
6894static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6895 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6896 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6899 { } /* end */
6900};
6901
6902/*
6903 * 4ch mode
6904 */
6905static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6906 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6907 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6908 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6909 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6910 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6911 { } /* end */
6912};
6913
6914/*
6915 * 6ch mode
6916 */
6917static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6918 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6919 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6920 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6923 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6924 { } /* end */
6925};
6926
6927static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6928 { 2, alc883_3ST_ch2_intel_init },
6929 { 4, alc883_3ST_ch4_intel_init },
6930 { 6, alc883_3ST_ch6_intel_init },
6931};
6932
6933/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006934 * 6ch mode
6935 */
6936static struct hda_verb alc883_sixstack_ch6_init[] = {
6937 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6939 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6940 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6941 { } /* end */
6942};
6943
6944/*
6945 * 8ch mode
6946 */
6947static struct hda_verb alc883_sixstack_ch8_init[] = {
6948 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6949 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6950 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6951 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6952 { } /* end */
6953};
6954
6955static struct hda_channel_mode alc883_sixstack_modes[2] = {
6956 { 6, alc883_sixstack_ch6_init },
6957 { 8, alc883_sixstack_ch8_init },
6958};
6959
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006960static struct hda_verb alc883_medion_eapd_verbs[] = {
6961 /* eanable EAPD on medion laptop */
6962 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6963 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6964 { }
6965};
6966
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006967/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6968 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6969 */
6970
6971static struct snd_kcontrol_new alc883_base_mixer[] = {
6972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6980 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6981 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006988 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006991 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6993 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6994 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6996 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6997 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6998 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6999 {
7000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7001 /* .name = "Capture Source", */
7002 .name = "Input Source",
7003 .count = 2,
7004 .info = alc883_mux_enum_info,
7005 .get = alc883_mux_enum_get,
7006 .put = alc883_mux_enum_put,
7007 },
7008 { } /* end */
7009};
7010
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007011static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7015 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7017 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
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("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7024 HDA_CODEC_MUTE("Front 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
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007041static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007042 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
Jiang zhefb97dc62008-03-06 11:07:11 +01007068static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7069 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7070 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7071 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7072 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7078 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7080 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7081 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7082 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7083 {
7084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7085 /* .name = "Capture Source", */
7086 .name = "Input Source",
7087 .count = 2,
7088 .info = alc883_mux_enum_info,
7089 .get = alc883_mux_enum_get,
7090 .put = alc883_mux_enum_put,
7091 },
7092 { } /* end */
7093};
7094
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007095static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007104 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7106 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007107 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007108 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7109 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7110 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7112 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7113 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7114 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7115 {
7116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7117 /* .name = "Capture Source", */
7118 .name = "Input Source",
7119 .count = 2,
7120 .info = alc883_mux_enum_info,
7121 .get = alc883_mux_enum_get,
7122 .put = alc883_mux_enum_put,
7123 },
7124 { } /* end */
7125};
7126
7127static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7128 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7129 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7130 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7131 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7132 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7133 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7134 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7135 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007146 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7147 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7148 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7149 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7150 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007151 {
7152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7153 /* .name = "Capture Source", */
7154 .name = "Input Source",
Kailang Yange2757d52008-08-26 13:17:46 +02007155 .count = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007156 .info = alc883_mux_enum_info,
7157 .get = alc883_mux_enum_get,
7158 .put = alc883_mux_enum_put,
7159 },
7160 { } /* end */
7161};
7162
Jiang zhe17bba1b2008-06-04 12:11:07 +02007163static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7165 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7167 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7168 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7169 HDA_OUTPUT),
7170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7175 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7182 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7184 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7185 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7186 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7187 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7188 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7189 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7190 {
7191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7192 /* .name = "Capture Source", */
7193 .name = "Input Source",
7194 .count = 2,
7195 .info = alc883_mux_enum_info,
7196 .get = alc883_mux_enum_get,
7197 .put = alc883_mux_enum_put,
7198 },
7199 { } /* end */
7200};
7201
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007202static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007203 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007204 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007205 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007206 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007207 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7208 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007209 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7210 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007211 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7222 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7223 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7224 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7225 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7226
7227 {
7228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7229 /* .name = "Capture Source", */
7230 .name = "Input Source",
7231 .count = 1,
7232 .info = alc883_mux_enum_info,
7233 .get = alc883_mux_enum_get,
7234 .put = alc883_mux_enum_put,
7235 },
7236 { } /* end */
7237};
7238
Kailang Yangccc656c2006-10-17 12:32:26 +02007239static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7242 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7244 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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),
7256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7258 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7259 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7260 {
7261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7262 /* .name = "Capture Source", */
7263 .name = "Input Source",
7264 .count = 2,
7265 .info = alc883_mux_enum_info,
7266 .get = alc883_mux_enum_get,
7267 .put = alc883_mux_enum_put,
7268 },
7269 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007270};
Kailang Yangccc656c2006-10-17 12:32:26 +02007271
7272static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7275 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007279 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007281 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7282 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7283 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007284 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7285 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7286 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7287 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7288 {
7289 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7290 /* .name = "Capture Source", */
7291 .name = "Input Source",
7292 .count = 2,
7293 .info = alc883_mux_enum_info,
7294 .get = alc883_mux_enum_get,
7295 .put = alc883_mux_enum_put,
7296 },
7297 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007298};
Kailang Yangccc656c2006-10-17 12:32:26 +02007299
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007300static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7301 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7302 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007303 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7304 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7307 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7308 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7311 {
7312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7313 /* .name = "Capture Source", */
7314 .name = "Input Source",
7315 .count = 1,
7316 .info = alc883_mux_enum_info,
7317 .get = alc883_mux_enum_get,
7318 .put = alc883_mux_enum_put,
7319 },
7320 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007321};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007322
Kailang Yang272a5272007-05-14 11:00:38 +02007323static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7324 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7325 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7331 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7332 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7333 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7334 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7335 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7336 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7337 {
7338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7339 /* .name = "Capture Source", */
7340 .name = "Input Source",
7341 .count = 2,
7342 .info = alc883_mux_enum_info,
7343 .get = alc883_mux_enum_get,
7344 .put = alc883_mux_enum_put,
7345 },
7346 { } /* end */
7347};
7348
7349static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7352 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7359 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 Yangea1fb292008-08-26 12:58:38 +02007373};
Kailang Yang272a5272007-05-14 11:00:38 +02007374
Tobin Davis2880a862007-08-07 11:50:26 +02007375static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007376 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7377 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007384 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7385 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7386 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7387 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7388 {
7389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7390 /* .name = "Capture Source", */
7391 .name = "Input Source",
7392 .count = 2,
7393 .info = alc883_mux_enum_info,
7394 .get = alc883_mux_enum_get,
7395 .put = alc883_mux_enum_put,
7396 },
7397 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007398};
Tobin Davis2880a862007-08-07 11:50:26 +02007399
Kailang Yange2757d52008-08-26 13:17:46 +02007400static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7401 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7404 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7405 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7406 0x0d, 1, 0x0, HDA_OUTPUT),
7407 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7408 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7409 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7410 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7411 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7413 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7414 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7415 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7423 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7425 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7426 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7427 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7428 {
7429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7430 /* .name = "Capture Source", */
7431 .name = "Input Source",
7432 .count = 2,
7433 .info = alc883_mux_enum_info,
7434 .get = alc883_mux_enum_get,
7435 .put = alc883_mux_enum_put,
7436 },
7437 { } /* end */
7438};
7439
7440static struct hda_bind_ctls alc883_bind_cap_vol = {
7441 .ops = &snd_hda_bind_vol,
7442 .values = {
7443 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7444 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7445 0
7446 },
7447};
7448
7449static struct hda_bind_ctls alc883_bind_cap_switch = {
7450 .ops = &snd_hda_bind_sw,
7451 .values = {
7452 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7453 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7454 0
7455 },
7456};
7457
7458static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7459 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7460 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7467 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7468 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7469 {
7470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7471 /* .name = "Capture Source", */
7472 .name = "Input Source",
7473 .count = 1,
7474 .info = alc883_mux_enum_info,
7475 .get = alc883_mux_enum_get,
7476 .put = alc883_mux_enum_put,
7477 },
7478 { } /* end */
7479};
7480
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007481static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7482 {
7483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7484 .name = "Channel Mode",
7485 .info = alc_ch_mode_info,
7486 .get = alc_ch_mode_get,
7487 .put = alc_ch_mode_put,
7488 },
7489 { } /* end */
7490};
7491
7492static struct hda_verb alc883_init_verbs[] = {
7493 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007495 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7496 /* ADC2: mute amp left and right */
7497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7503 /* Rear mixer */
7504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7507 /* CLFE mixer */
7508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7511 /* Side mixer */
7512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7515
Takashi Iwaicb53c622007-08-10 17:21:45 +02007516 /* mute analog input loopbacks */
7517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007522
7523 /* Front Pin: output 0 (0x0c) */
7524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7526 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7527 /* Rear Pin: output 1 (0x0d) */
7528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7530 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7531 /* CLFE Pin: output 2 (0x0e) */
7532 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7533 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7534 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7535 /* Side Pin: output 3 (0x0f) */
7536 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7537 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7538 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7539 /* Mic (rear) pin: input vref at 80% */
7540 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7542 /* Front Mic pin: input vref at 80% */
7543 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7544 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7545 /* Line In pin: input */
7546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7548 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7550 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7551 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7552 /* CD pin widget for input */
7553 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7554
7555 /* FIXME: use matrix-type input source selection */
7556 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7557 /* Input mixer2 */
7558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007562 /* Input mixer3 */
7563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007567 { }
7568};
7569
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007570/* toggle speaker-output according to the hp-jack state */
7571static void alc883_mitac_hp_automute(struct hda_codec *codec)
7572{
7573 unsigned int present;
7574
7575 present = snd_hda_codec_read(codec, 0x15, 0,
7576 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7577 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7578 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7579 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7581}
7582
7583/* auto-toggle front mic */
7584/*
7585static void alc883_mitac_mic_automute(struct hda_codec *codec)
7586{
7587 unsigned int present;
7588 unsigned char bits;
7589
7590 present = snd_hda_codec_read(codec, 0x18, 0,
7591 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7592 bits = present ? HDA_AMP_MUTE : 0;
7593 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7594}
7595*/
7596
7597static void alc883_mitac_automute(struct hda_codec *codec)
7598{
7599 alc883_mitac_hp_automute(codec);
7600 /* alc883_mitac_mic_automute(codec); */
7601}
7602
7603static void alc883_mitac_unsol_event(struct hda_codec *codec,
7604 unsigned int res)
7605{
7606 switch (res >> 26) {
7607 case ALC880_HP_EVENT:
7608 alc883_mitac_hp_automute(codec);
7609 break;
7610 case ALC880_MIC_EVENT:
7611 /* alc883_mitac_mic_automute(codec); */
7612 break;
7613 }
7614}
7615
7616static struct hda_verb alc883_mitac_verbs[] = {
7617 /* HP */
7618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7620 /* Subwoofer */
7621 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7622 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7623
7624 /* enable unsolicited event */
7625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7626 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7627
7628 { } /* end */
7629};
7630
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007631static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007632 /* HP */
7633 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7635 /* Int speaker */
7636 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7638
7639 /* enable unsolicited event */
7640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007641 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007642
7643 { } /* end */
7644};
7645
Jiang zhefb97dc62008-03-06 11:07:11 +01007646static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7647 /* HP */
7648 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7650 /* Subwoofer */
7651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7653
7654 /* enable unsolicited event */
7655 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7656
7657 { } /* end */
7658};
7659
Kailang Yangccc656c2006-10-17 12:32:26 +02007660static struct hda_verb alc883_tagra_verbs[] = {
7661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663
7664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007666
Kailang Yangccc656c2006-10-17 12:32:26 +02007667 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7668 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7669 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7670
7671 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007672 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7673 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7674 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007675
7676 { } /* end */
7677};
7678
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007679static struct hda_verb alc883_lenovo_101e_verbs[] = {
7680 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7681 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7683 { } /* end */
7684};
7685
Kailang Yang272a5272007-05-14 11:00:38 +02007686static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7687 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7689 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7691 { } /* end */
7692};
7693
7694static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7698 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7699 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7700 { } /* end */
7701};
7702
Kailang Yang189609a2007-08-20 11:31:23 +02007703static struct hda_verb alc883_haier_w66_verbs[] = {
7704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7706
7707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7708
7709 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7711 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7713 { } /* end */
7714};
7715
Kailang Yange2757d52008-08-26 13:17:46 +02007716static struct hda_verb alc888_lenovo_sky_verbs[] = {
7717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7719 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7723 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7724 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7725 { } /* end */
7726};
7727
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007728static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007729 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007730 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7731 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007732 { }
7733};
7734
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007735static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007736 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7737 { }
7738};
7739
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007740static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007741 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7742 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7743 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7744 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7745 { }
7746};
7747
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007748static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7753 { }
7754};
7755
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007756static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7757 { 2, alc888_3st_hp_2ch_init },
7758 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007759};
7760
Kailang Yang272a5272007-05-14 11:00:38 +02007761/* toggle front-jack and RCA according to the hp-jack state */
7762static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7763{
7764 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007765
Kailang Yang272a5272007-05-14 11:00:38 +02007766 present = snd_hda_codec_read(codec, 0x1b, 0,
7767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007768 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7769 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7770 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007772}
7773
7774/* toggle RCA according to the front-jack state */
7775static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7776{
7777 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007778
Kailang Yang272a5272007-05-14 11:00:38 +02007779 present = snd_hda_codec_read(codec, 0x14, 0,
7780 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007781 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7782 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007783}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007784
Kailang Yang272a5272007-05-14 11:00:38 +02007785static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7786 unsigned int res)
7787{
7788 if ((res >> 26) == ALC880_HP_EVENT)
7789 alc888_lenovo_ms7195_front_automute(codec);
7790 if ((res >> 26) == ALC880_FRONT_EVENT)
7791 alc888_lenovo_ms7195_rca_automute(codec);
7792}
7793
7794static struct hda_verb alc883_medion_md2_verbs[] = {
7795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7797
7798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7799
7800 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7801 { } /* end */
7802};
7803
7804/* toggle speaker-output according to the hp-jack state */
7805static void alc883_medion_md2_automute(struct hda_codec *codec)
7806{
7807 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007808
Kailang Yang272a5272007-05-14 11:00:38 +02007809 present = snd_hda_codec_read(codec, 0x14, 0,
7810 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007811 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7812 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007813}
7814
7815static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7816 unsigned int res)
7817{
7818 if ((res >> 26) == ALC880_HP_EVENT)
7819 alc883_medion_md2_automute(codec);
7820}
7821
Kailang Yangccc656c2006-10-17 12:32:26 +02007822/* toggle speaker-output according to the hp-jack state */
7823static void alc883_tagra_automute(struct hda_codec *codec)
7824{
7825 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007826 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007827
7828 present = snd_hda_codec_read(codec, 0x14, 0,
7829 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007830 bits = present ? HDA_AMP_MUTE : 0;
7831 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7832 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007833 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7834 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007835}
7836
7837static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7838{
7839 if ((res >> 26) == ALC880_HP_EVENT)
7840 alc883_tagra_automute(codec);
7841}
7842
Jiang zhe368c7a92008-03-04 11:20:33 +01007843/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007844static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007845{
7846 unsigned int present;
7847 unsigned char bits;
7848
7849 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7850 & AC_PINSENSE_PRESENCE;
7851 bits = present ? HDA_AMP_MUTE : 0;
7852 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7853 HDA_AMP_MUTE, bits);
7854}
7855
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007856static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7857{
7858 unsigned int present;
7859
7860 present = snd_hda_codec_read(codec, 0x18, 0,
7861 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7862 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7863 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7864}
7865
7866static void alc883_clevo_m720_automute(struct hda_codec *codec)
7867{
7868 alc883_clevo_m720_hp_automute(codec);
7869 alc883_clevo_m720_mic_automute(codec);
7870}
7871
7872static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007873 unsigned int res)
7874{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007875 switch (res >> 26) {
7876 case ALC880_HP_EVENT:
7877 alc883_clevo_m720_hp_automute(codec);
7878 break;
7879 case ALC880_MIC_EVENT:
7880 alc883_clevo_m720_mic_automute(codec);
7881 break;
7882 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007883}
7884
Jiang zhefb97dc62008-03-06 11:07:11 +01007885/* toggle speaker-output according to the hp-jack state */
7886static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7887{
7888 unsigned int present;
7889 unsigned char bits;
7890
7891 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7892 & AC_PINSENSE_PRESENCE;
7893 bits = present ? HDA_AMP_MUTE : 0;
7894 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7895 HDA_AMP_MUTE, bits);
7896}
7897
7898static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7899 unsigned int res)
7900{
7901 if ((res >> 26) == ALC880_HP_EVENT)
7902 alc883_2ch_fujitsu_pi2515_automute(codec);
7903}
7904
Kailang Yang189609a2007-08-20 11:31:23 +02007905static void alc883_haier_w66_automute(struct hda_codec *codec)
7906{
7907 unsigned int present;
7908 unsigned char bits;
7909
7910 present = snd_hda_codec_read(codec, 0x1b, 0,
7911 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7912 bits = present ? 0x80 : 0;
7913 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7914 0x80, bits);
7915}
7916
7917static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7918 unsigned int res)
7919{
7920 if ((res >> 26) == ALC880_HP_EVENT)
7921 alc883_haier_w66_automute(codec);
7922}
7923
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007924static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7925{
7926 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007927 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007928
7929 present = snd_hda_codec_read(codec, 0x14, 0,
7930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007931 bits = present ? HDA_AMP_MUTE : 0;
7932 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7933 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007934}
7935
7936static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7937{
7938 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007939 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007940
7941 present = snd_hda_codec_read(codec, 0x1b, 0,
7942 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007943 bits = present ? HDA_AMP_MUTE : 0;
7944 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7945 HDA_AMP_MUTE, bits);
7946 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7947 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007948}
7949
7950static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7951 unsigned int res)
7952{
7953 if ((res >> 26) == ALC880_HP_EVENT)
7954 alc883_lenovo_101e_all_automute(codec);
7955 if ((res >> 26) == ALC880_FRONT_EVENT)
7956 alc883_lenovo_101e_ispeaker_automute(codec);
7957}
7958
Takashi Iwai676a9b52007-08-16 15:23:35 +02007959/* toggle speaker-output according to the hp-jack state */
7960static void alc883_acer_aspire_automute(struct hda_codec *codec)
7961{
7962 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007963
Takashi Iwai676a9b52007-08-16 15:23:35 +02007964 present = snd_hda_codec_read(codec, 0x14, 0,
7965 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7966 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7967 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7968 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7970}
7971
7972static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7973 unsigned int res)
7974{
7975 if ((res >> 26) == ALC880_HP_EVENT)
7976 alc883_acer_aspire_automute(codec);
7977}
7978
Kailang Yangd1a991a2007-08-15 16:21:59 +02007979static struct hda_verb alc883_acer_eapd_verbs[] = {
7980 /* HP Pin: output 0 (0x0c) */
7981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7983 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7984 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007988 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7989 /* eanable EAPD on medion laptop */
7990 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7991 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007992 /* enable unsolicited event */
7993 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007994 { }
7995};
7996
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007997static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7998{
7999 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008000
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008001 present = snd_hda_codec_read(codec, 0x1b, 0,
8002 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8003 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8004 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8005 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8006 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8007 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8008 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8009 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8010 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8011}
8012
8013static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8014 unsigned int res)
8015{
8016 switch (res >> 26) {
8017 case ALC880_HP_EVENT:
8018 printk("hp_event\n");
8019 alc888_6st_dell_front_automute(codec);
8020 break;
8021 }
8022}
8023
Kailang Yange2757d52008-08-26 13:17:46 +02008024static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8025{
8026 unsigned int mute;
8027 unsigned int present;
8028
8029 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8030 present = snd_hda_codec_read(codec, 0x1b, 0,
8031 AC_VERB_GET_PIN_SENSE, 0);
8032 present = (present & 0x80000000) != 0;
8033 if (present) {
8034 /* mute internal speaker */
8035 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8036 HDA_AMP_MUTE, HDA_AMP_MUTE);
8037 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8038 HDA_AMP_MUTE, HDA_AMP_MUTE);
8039 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8040 HDA_AMP_MUTE, HDA_AMP_MUTE);
8041 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8042 HDA_AMP_MUTE, HDA_AMP_MUTE);
8043 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8044 HDA_AMP_MUTE, HDA_AMP_MUTE);
8045 } else {
8046 /* unmute internal speaker if necessary */
8047 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8048 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8049 HDA_AMP_MUTE, mute);
8050 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8051 HDA_AMP_MUTE, mute);
8052 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8053 HDA_AMP_MUTE, mute);
8054 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8055 HDA_AMP_MUTE, mute);
8056 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8057 HDA_AMP_MUTE, mute);
8058 }
8059}
8060
8061static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8062 unsigned int res)
8063{
8064 if ((res >> 26) == ALC880_HP_EVENT)
8065 alc888_lenovo_sky_front_automute(codec);
8066}
8067
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008068/*
8069 * generic initialization of ADC, input mixers and output mixers
8070 */
8071static struct hda_verb alc883_auto_init_verbs[] = {
8072 /*
8073 * Unmute ADC0-2 and set the default input to mic-in
8074 */
8075 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8077 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8078 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8079
Takashi Iwaicb53c622007-08-10 17:21:45 +02008080 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008081 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008082 * Note: PASD motherboards uses the Line In 2 as the input for
8083 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008084 */
8085 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008091
8092 /*
8093 * Set up output mixers (0x0c - 0x0f)
8094 */
8095 /* set vol=0 to output mixers */
8096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8097 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8100 /* set up input amps for analog loopback */
8101 /* Amp Indices: DAC = 0, mixer = 1 */
8102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8108 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8110 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8111 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8112
8113 /* FIXME: use matrix-type input source selection */
8114 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8115 /* Input mixer1 */
8116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008119 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8121 /* Input mixer2 */
8122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008125 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008127
8128 { }
8129};
8130
8131/* capture mixer elements */
8132static struct snd_kcontrol_new alc883_capture_mixer[] = {
8133 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8134 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8135 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
8136 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
8137 {
8138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8139 /* The multiple "Capture Source" controls confuse alsamixer
8140 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008141 */
8142 /* .name = "Capture Source", */
8143 .name = "Input Source",
8144 .count = 2,
8145 .info = alc882_mux_enum_info,
8146 .get = alc882_mux_enum_get,
8147 .put = alc882_mux_enum_put,
8148 },
8149 { } /* end */
8150};
8151
Kailang Yange2757d52008-08-26 13:17:46 +02008152static struct hda_verb alc888_asus_m90v_verbs[] = {
8153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8154 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8156 /* enable unsolicited event */
8157 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8158 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8159 { } /* end */
8160};
8161
8162static void alc883_nb_mic_automute(struct hda_codec *codec)
8163{
8164 unsigned int present;
8165
8166 present = snd_hda_codec_read(codec, 0x18, 0,
8167 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8168 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8169 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8170 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8171 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8172}
8173
8174static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8175{
8176 unsigned int present;
8177 unsigned char bits;
8178
8179 present = snd_hda_codec_read(codec, 0x1b, 0,
8180 AC_VERB_GET_PIN_SENSE, 0)
8181 & AC_PINSENSE_PRESENCE;
8182 bits = present ? 0 : PIN_OUT;
8183 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8184 bits);
8185 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8186 bits);
8187 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8188 bits);
8189}
8190
8191static void alc883_mode2_unsol_event(struct hda_codec *codec,
8192 unsigned int res)
8193{
8194 switch (res >> 26) {
8195 case ALC880_HP_EVENT:
8196 alc883_M90V_speaker_automute(codec);
8197 break;
8198 case ALC880_MIC_EVENT:
8199 alc883_nb_mic_automute(codec);
8200 break;
8201 }
8202}
8203
8204static void alc883_mode2_inithook(struct hda_codec *codec)
8205{
8206 alc883_M90V_speaker_automute(codec);
8207 alc883_nb_mic_automute(codec);
8208}
8209
8210static struct hda_verb alc888_asus_eee1601_verbs[] = {
8211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8212 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8216 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8217 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8218 /* enable unsolicited event */
8219 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8220 { } /* end */
8221};
8222
8223static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8224{
8225 unsigned int present;
8226 unsigned char bits;
8227
8228 present = snd_hda_codec_read(codec, 0x14, 0,
8229 AC_VERB_GET_PIN_SENSE, 0)
8230 & AC_PINSENSE_PRESENCE;
8231 bits = present ? 0 : PIN_OUT;
8232 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8233 bits);
8234}
8235
8236static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8237 unsigned int res)
8238{
8239 switch (res >> 26) {
8240 case ALC880_HP_EVENT:
8241 alc883_eee1601_speaker_automute(codec);
8242 break;
8243 }
8244}
8245
8246static void alc883_eee1601_inithook(struct hda_codec *codec)
8247{
8248 alc883_eee1601_speaker_automute(codec);
8249}
8250
Takashi Iwaicb53c622007-08-10 17:21:45 +02008251#ifdef CONFIG_SND_HDA_POWER_SAVE
8252#define alc883_loopbacks alc880_loopbacks
8253#endif
8254
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008255/* pcm configuration: identiacal with ALC880 */
8256#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8257#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008258#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008259#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8260#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8261
8262/*
8263 * configuration and preset
8264 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008265static const char *alc883_models[ALC883_MODEL_LAST] = {
8266 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8267 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8268 [ALC883_3ST_6ch] = "3stack-6ch",
8269 [ALC883_6ST_DIG] = "6stack-dig",
8270 [ALC883_TARGA_DIG] = "targa-dig",
8271 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008272 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008273 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008274 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008275 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008276 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008277 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008278 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8279 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008280 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008281 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008282 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008283 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008284 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008285 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008286 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008287 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008288 [ALC883_AUTO] = "auto",
8289};
8290
8291static struct snd_pci_quirk alc883_cfg_tbl[] = {
8292 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008293 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8294 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8295 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008296 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008297 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008298 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008299 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008300 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8301 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008302 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008303 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008304 SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V),
8305 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008306 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008307 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008308 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8309 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008310 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008311 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008312 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008313 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8314 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8315 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008316 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008317 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008318 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008319 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8320 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8321 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8322 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8323 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8324 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8325 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8326 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8327 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008328 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8329 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008330 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008331 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008332 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008333 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008334 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008335 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008336 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8337 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008338 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008339 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008340 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008341 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008342 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008343 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008344 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8345 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008346 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008347 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008348 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008349 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008350 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8351 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008352 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008353 {}
8354};
8355
8356static struct alc_config_preset alc883_presets[] = {
8357 [ALC883_3ST_2ch_DIG] = {
8358 .mixers = { alc883_3ST_2ch_mixer },
8359 .init_verbs = { alc883_init_verbs },
8360 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8361 .dac_nids = alc883_dac_nids,
8362 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008363 .dig_in_nid = ALC883_DIGIN_NID,
8364 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8365 .channel_mode = alc883_3ST_2ch_modes,
8366 .input_mux = &alc883_capture_source,
8367 },
8368 [ALC883_3ST_6ch_DIG] = {
8369 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8370 .init_verbs = { alc883_init_verbs },
8371 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8372 .dac_nids = alc883_dac_nids,
8373 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008374 .dig_in_nid = ALC883_DIGIN_NID,
8375 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8376 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008377 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008378 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008379 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 [ALC883_3ST_6ch] = {
8381 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8382 .init_verbs = { alc883_init_verbs },
8383 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8384 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008385 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8386 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008387 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008388 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008389 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008390 [ALC883_3ST_6ch_INTEL] = {
8391 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8392 .init_verbs = { alc883_init_verbs },
8393 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8394 .dac_nids = alc883_dac_nids,
8395 .dig_out_nid = ALC883_DIGOUT_NID,
8396 .dig_in_nid = ALC883_DIGIN_NID,
8397 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8398 .channel_mode = alc883_3ST_6ch_intel_modes,
8399 .need_dac_fix = 1,
8400 .input_mux = &alc883_3stack_6ch_intel,
8401 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008402 [ALC883_6ST_DIG] = {
8403 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8404 .init_verbs = { alc883_init_verbs },
8405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8406 .dac_nids = alc883_dac_nids,
8407 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008408 .dig_in_nid = ALC883_DIGIN_NID,
8409 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8410 .channel_mode = alc883_sixstack_modes,
8411 .input_mux = &alc883_capture_source,
8412 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008413 [ALC883_TARGA_DIG] = {
8414 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8415 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8417 .dac_nids = alc883_dac_nids,
8418 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8420 .channel_mode = alc883_3ST_6ch_modes,
8421 .need_dac_fix = 1,
8422 .input_mux = &alc883_capture_source,
8423 .unsol_event = alc883_tagra_unsol_event,
8424 .init_hook = alc883_tagra_automute,
8425 },
8426 [ALC883_TARGA_2ch_DIG] = {
8427 .mixers = { alc883_tagra_2ch_mixer},
8428 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8430 .dac_nids = alc883_dac_nids,
8431 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008432 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8433 .channel_mode = alc883_3ST_2ch_modes,
8434 .input_mux = &alc883_capture_source,
8435 .unsol_event = alc883_tagra_unsol_event,
8436 .init_hook = alc883_tagra_automute,
8437 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008438 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008439 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008440 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8441 * and the headphone jack. Turn this on and rely on the
8442 * standard mute methods whenever the user wants to turn
8443 * these outputs off.
8444 */
8445 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8446 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8447 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8449 .channel_mode = alc883_3ST_2ch_modes,
8450 .input_mux = &alc883_capture_source,
8451 },
Tobin Davis2880a862007-08-07 11:50:26 +02008452 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008453 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008454 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8456 .dac_nids = alc883_dac_nids,
8457 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8459 .channel_mode = alc883_3ST_2ch_modes,
8460 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008461 .unsol_event = alc883_acer_aspire_unsol_event,
8462 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008463 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008464 [ALC883_MEDION] = {
8465 .mixers = { alc883_fivestack_mixer,
8466 alc883_chmode_mixer },
8467 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008468 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8470 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008471 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8472 .channel_mode = alc883_sixstack_modes,
8473 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008474 },
Kailang Yang272a5272007-05-14 11:00:38 +02008475 [ALC883_MEDION_MD2] = {
8476 .mixers = { alc883_medion_md2_mixer},
8477 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8479 .dac_nids = alc883_dac_nids,
8480 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008481 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8482 .channel_mode = alc883_3ST_2ch_modes,
8483 .input_mux = &alc883_capture_source,
8484 .unsol_event = alc883_medion_md2_unsol_event,
8485 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008486 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008487 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008488 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008489 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8490 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8491 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008492 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8493 .channel_mode = alc883_3ST_2ch_modes,
8494 .input_mux = &alc883_capture_source,
8495 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008496 [ALC883_CLEVO_M720] = {
8497 .mixers = { alc883_clevo_m720_mixer },
8498 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008499 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8500 .dac_nids = alc883_dac_nids,
8501 .dig_out_nid = ALC883_DIGOUT_NID,
8502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8503 .channel_mode = alc883_3ST_2ch_modes,
8504 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008505 .unsol_event = alc883_clevo_m720_unsol_event,
8506 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008507 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008508 [ALC883_LENOVO_101E_2ch] = {
8509 .mixers = { alc883_lenovo_101e_2ch_mixer},
8510 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8512 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8514 .channel_mode = alc883_3ST_2ch_modes,
8515 .input_mux = &alc883_lenovo_101e_capture_source,
8516 .unsol_event = alc883_lenovo_101e_unsol_event,
8517 .init_hook = alc883_lenovo_101e_all_automute,
8518 },
Kailang Yang272a5272007-05-14 11:00:38 +02008519 [ALC883_LENOVO_NB0763] = {
8520 .mixers = { alc883_lenovo_nb0763_mixer },
8521 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8523 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8525 .channel_mode = alc883_3ST_2ch_modes,
8526 .need_dac_fix = 1,
8527 .input_mux = &alc883_lenovo_nb0763_capture_source,
8528 .unsol_event = alc883_medion_md2_unsol_event,
8529 .init_hook = alc883_medion_md2_automute,
8530 },
8531 [ALC888_LENOVO_MS7195_DIG] = {
8532 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8533 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8535 .dac_nids = alc883_dac_nids,
8536 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008537 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8538 .channel_mode = alc883_3ST_6ch_modes,
8539 .need_dac_fix = 1,
8540 .input_mux = &alc883_capture_source,
8541 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8542 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008543 },
8544 [ALC883_HAIER_W66] = {
8545 .mixers = { alc883_tagra_2ch_mixer},
8546 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8548 .dac_nids = alc883_dac_nids,
8549 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8551 .channel_mode = alc883_3ST_2ch_modes,
8552 .input_mux = &alc883_capture_source,
8553 .unsol_event = alc883_haier_w66_unsol_event,
8554 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008555 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008556 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008557 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008558 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8560 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008561 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8562 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008563 .need_dac_fix = 1,
8564 .input_mux = &alc883_capture_source,
8565 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008566 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008567 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008568 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8569 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8570 .dac_nids = alc883_dac_nids,
8571 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008572 .dig_in_nid = ALC883_DIGIN_NID,
8573 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8574 .channel_mode = alc883_sixstack_modes,
8575 .input_mux = &alc883_capture_source,
8576 .unsol_event = alc888_6st_dell_unsol_event,
8577 .init_hook = alc888_6st_dell_front_automute,
8578 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008579 [ALC883_MITAC] = {
8580 .mixers = { alc883_mitac_mixer },
8581 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8582 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8583 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8585 .channel_mode = alc883_3ST_2ch_modes,
8586 .input_mux = &alc883_capture_source,
8587 .unsol_event = alc883_mitac_unsol_event,
8588 .init_hook = alc883_mitac_automute,
8589 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008590 [ALC883_FUJITSU_PI2515] = {
8591 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8592 .init_verbs = { alc883_init_verbs,
8593 alc883_2ch_fujitsu_pi2515_verbs},
8594 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8595 .dac_nids = alc883_dac_nids,
8596 .dig_out_nid = ALC883_DIGOUT_NID,
8597 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8598 .channel_mode = alc883_3ST_2ch_modes,
8599 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8600 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8601 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8602 },
Kailang Yange2757d52008-08-26 13:17:46 +02008603 [ALC888_LENOVO_SKY] = {
8604 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8605 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8607 .dac_nids = alc883_dac_nids,
8608 .dig_out_nid = ALC883_DIGOUT_NID,
8609 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
8610 .adc_nids = alc883_adc_nids,
8611 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8612 .channel_mode = alc883_sixstack_modes,
8613 .need_dac_fix = 1,
8614 .input_mux = &alc883_lenovo_sky_capture_source,
8615 .unsol_event = alc883_lenovo_sky_unsol_event,
8616 .init_hook = alc888_lenovo_sky_front_automute,
8617 },
8618 [ALC888_ASUS_M90V] = {
8619 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8620 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8621 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8622 .dac_nids = alc883_dac_nids,
8623 .dig_out_nid = ALC883_DIGOUT_NID,
8624 .dig_in_nid = ALC883_DIGIN_NID,
8625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8626 .channel_mode = alc883_3ST_6ch_modes,
8627 .need_dac_fix = 1,
8628 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8629 .unsol_event = alc883_mode2_unsol_event,
8630 .init_hook = alc883_mode2_inithook,
8631 },
8632 [ALC888_ASUS_EEE1601] = {
8633 .mixers = { alc883_asus_eee1601_mixer },
8634 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8636 .dac_nids = alc883_dac_nids,
8637 .dig_out_nid = ALC883_DIGOUT_NID,
8638 .dig_in_nid = ALC883_DIGIN_NID,
8639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8640 .channel_mode = alc883_3ST_2ch_modes,
8641 .need_dac_fix = 1,
8642 .input_mux = &alc883_asus_eee1601_capture_source,
8643 .unsol_event = alc883_eee1601_unsol_event,
8644 .init_hook = alc883_eee1601_inithook,
8645 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008646};
8647
8648
8649/*
8650 * BIOS auto configuration
8651 */
8652static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8653 hda_nid_t nid, int pin_type,
8654 int dac_idx)
8655{
8656 /* set as output */
8657 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008658 int idx;
8659
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008660 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008661 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8662 idx = 4;
8663 else
8664 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008665 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8666
8667}
8668
8669static void alc883_auto_init_multi_out(struct hda_codec *codec)
8670{
8671 struct alc_spec *spec = codec->spec;
8672 int i;
8673
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008674 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008675 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008676 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008677 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008678 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008679 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008680 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008681 }
8682}
8683
8684static void alc883_auto_init_hp_out(struct hda_codec *codec)
8685{
8686 struct alc_spec *spec = codec->spec;
8687 hda_nid_t pin;
8688
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008689 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008690 if (pin) /* connect to front */
8691 /* use dac 0 */
8692 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008693 pin = spec->autocfg.speaker_pins[0];
8694 if (pin)
8695 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008696}
8697
8698#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8699#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8700
8701static void alc883_auto_init_analog_input(struct hda_codec *codec)
8702{
8703 struct alc_spec *spec = codec->spec;
8704 int i;
8705
8706 for (i = 0; i < AUTO_PIN_LAST; i++) {
8707 hda_nid_t nid = spec->autocfg.input_pins[i];
8708 if (alc883_is_input_pin(nid)) {
8709 snd_hda_codec_write(codec, nid, 0,
8710 AC_VERB_SET_PIN_WIDGET_CONTROL,
8711 (i <= AUTO_PIN_FRONT_MIC ?
8712 PIN_VREF80 : PIN_IN));
8713 if (nid != ALC883_PIN_CD_NID)
8714 snd_hda_codec_write(codec, nid, 0,
8715 AC_VERB_SET_AMP_GAIN_MUTE,
8716 AMP_OUT_MUTE);
8717 }
8718 }
8719}
8720
Takashi Iwaif511b012008-08-15 16:46:42 +02008721#define alc883_auto_init_input_src alc882_auto_init_input_src
8722
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008723/* almost identical with ALC880 parser... */
8724static int alc883_parse_auto_config(struct hda_codec *codec)
8725{
8726 struct alc_spec *spec = codec->spec;
8727 int err = alc880_parse_auto_config(codec);
8728
8729 if (err < 0)
8730 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008731 else if (!err)
8732 return 0; /* no config found */
8733
8734 err = alc_auto_add_mic_boost(codec);
8735 if (err < 0)
8736 return err;
8737
8738 /* hack - override the init verbs */
8739 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008740 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8741 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008742
8743 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008744}
8745
8746/* additional initialization for auto-configuration model */
8747static void alc883_auto_init(struct hda_codec *codec)
8748{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008749 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008750 alc883_auto_init_multi_out(codec);
8751 alc883_auto_init_hp_out(codec);
8752 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008753 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008754 if (spec->unsol_event)
8755 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008756}
8757
8758static int patch_alc883(struct hda_codec *codec)
8759{
8760 struct alc_spec *spec;
8761 int err, board_config;
8762
8763 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8764 if (spec == NULL)
8765 return -ENOMEM;
8766
8767 codec->spec = spec;
8768
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008769 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8770
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008771 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8772 alc883_models,
8773 alc883_cfg_tbl);
8774 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008775 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8776 "trying auto-probe from BIOS...\n");
8777 board_config = ALC883_AUTO;
8778 }
8779
8780 if (board_config == ALC883_AUTO) {
8781 /* automatic parse from the BIOS config */
8782 err = alc883_parse_auto_config(codec);
8783 if (err < 0) {
8784 alc_free(codec);
8785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008786 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008787 printk(KERN_INFO
8788 "hda_codec: Cannot set up configuration "
8789 "from BIOS. Using base mode...\n");
8790 board_config = ALC883_3ST_2ch_DIG;
8791 }
8792 }
8793
8794 if (board_config != ALC883_AUTO)
8795 setup_preset(spec, &alc883_presets[board_config]);
8796
Kailang Yang2f893282008-05-27 12:14:47 +02008797 switch (codec->vendor_id) {
8798 case 0x10ec0888:
8799 spec->stream_name_analog = "ALC888 Analog";
8800 spec->stream_name_digital = "ALC888 Digital";
8801 break;
8802 case 0x10ec0889:
8803 spec->stream_name_analog = "ALC889 Analog";
8804 spec->stream_name_digital = "ALC889 Digital";
8805 break;
8806 default:
8807 spec->stream_name_analog = "ALC883 Analog";
8808 spec->stream_name_digital = "ALC883 Digital";
8809 break;
8810 }
8811
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008812 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8813 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008814 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008815
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008816 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8817 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8818
Takashi Iwaie1406342008-02-11 18:32:32 +01008819 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8820 spec->adc_nids = alc883_adc_nids;
8821 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008822
Takashi Iwai2134ea42008-01-10 16:53:55 +01008823 spec->vmaster_nid = 0x0c;
8824
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008825 codec->patch_ops = alc_patch_ops;
8826 if (board_config == ALC883_AUTO)
8827 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008828
Takashi Iwaicb53c622007-08-10 17:21:45 +02008829#ifdef CONFIG_SND_HDA_POWER_SAVE
8830 if (!spec->loopback.amplist)
8831 spec->loopback.amplist = alc883_loopbacks;
8832#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008833
8834 return 0;
8835}
8836
8837/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008838 * ALC262 support
8839 */
8840
8841#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8842#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8843
8844#define alc262_dac_nids alc260_dac_nids
8845#define alc262_adc_nids alc882_adc_nids
8846#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008847#define alc262_capsrc_nids alc882_capsrc_nids
8848#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008849
8850#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008851#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008852
Kailang Yang4e555fe2008-08-26 13:05:55 +02008853static hda_nid_t alc262_dmic_adc_nids[1] = {
8854 /* ADC0 */
8855 0x09
8856};
8857
8858static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8859
Kailang Yangdf694da2005-12-05 19:42:22 +01008860static struct snd_kcontrol_new alc262_base_mixer[] = {
8861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8862 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008869 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008870 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008872 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008873 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008874 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8877 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8878 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008879 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008880};
8881
Kailang Yangccc656c2006-10-17 12:32:26 +02008882static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8884 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008894 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008896 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008897 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8899 { } /* end */
8900};
8901
Takashi Iwaice875f02008-01-28 18:17:43 +01008902/* update HP, line and mono-out pins according to the master switch */
8903static void alc262_hp_master_update(struct hda_codec *codec)
8904{
8905 struct alc_spec *spec = codec->spec;
8906 int val = spec->master_sw;
8907
8908 /* HP & line-out */
8909 snd_hda_codec_write_cache(codec, 0x1b, 0,
8910 AC_VERB_SET_PIN_WIDGET_CONTROL,
8911 val ? PIN_HP : 0);
8912 snd_hda_codec_write_cache(codec, 0x15, 0,
8913 AC_VERB_SET_PIN_WIDGET_CONTROL,
8914 val ? PIN_HP : 0);
8915 /* mono (speaker) depending on the HP jack sense */
8916 val = val && !spec->jack_present;
8917 snd_hda_codec_write_cache(codec, 0x16, 0,
8918 AC_VERB_SET_PIN_WIDGET_CONTROL,
8919 val ? PIN_OUT : 0);
8920}
8921
8922static void alc262_hp_bpc_automute(struct hda_codec *codec)
8923{
8924 struct alc_spec *spec = codec->spec;
8925 unsigned int presence;
8926 presence = snd_hda_codec_read(codec, 0x1b, 0,
8927 AC_VERB_GET_PIN_SENSE, 0);
8928 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8929 alc262_hp_master_update(codec);
8930}
8931
8932static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8933{
8934 if ((res >> 26) != ALC880_HP_EVENT)
8935 return;
8936 alc262_hp_bpc_automute(codec);
8937}
8938
8939static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8940{
8941 struct alc_spec *spec = codec->spec;
8942 unsigned int presence;
8943 presence = snd_hda_codec_read(codec, 0x15, 0,
8944 AC_VERB_GET_PIN_SENSE, 0);
8945 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8946 alc262_hp_master_update(codec);
8947}
8948
8949static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8950 unsigned int res)
8951{
8952 if ((res >> 26) != ALC880_HP_EVENT)
8953 return;
8954 alc262_hp_wildwest_automute(codec);
8955}
8956
8957static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8958 struct snd_ctl_elem_value *ucontrol)
8959{
8960 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8961 struct alc_spec *spec = codec->spec;
8962 *ucontrol->value.integer.value = spec->master_sw;
8963 return 0;
8964}
8965
8966static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8967 struct snd_ctl_elem_value *ucontrol)
8968{
8969 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8970 struct alc_spec *spec = codec->spec;
8971 int val = !!*ucontrol->value.integer.value;
8972
8973 if (val == spec->master_sw)
8974 return 0;
8975 spec->master_sw = val;
8976 alc262_hp_master_update(codec);
8977 return 1;
8978}
8979
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008980static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008981 {
8982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8983 .name = "Master Playback Switch",
8984 .info = snd_ctl_boolean_mono_info,
8985 .get = alc262_hp_master_sw_get,
8986 .put = alc262_hp_master_sw_put,
8987 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008988 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8989 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008991 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8992 HDA_OUTPUT),
8993 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8994 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8999 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9003 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9004 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9005 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9006 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9007 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9008 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9009 { } /* end */
9010};
9011
Kailang Yangcd7509a2007-01-26 18:33:17 +01009012static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009013 {
9014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9015 .name = "Master Playback Switch",
9016 .info = snd_ctl_boolean_mono_info,
9017 .get = alc262_hp_master_sw_get,
9018 .put = alc262_hp_master_sw_put,
9019 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009020 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9021 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9023 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009024 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9025 HDA_OUTPUT),
9026 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9027 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009030 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009031 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9032 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9033 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9034 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9035 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9036 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9037 { } /* end */
9038};
9039
9040static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9041 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9042 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009043 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009044 { } /* end */
9045};
9046
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009047/* mute/unmute internal speaker according to the hp jack and mute state */
9048static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9049{
9050 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009051
9052 if (force || !spec->sense_updated) {
9053 unsigned int present;
9054 present = snd_hda_codec_read(codec, 0x15, 0,
9055 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009056 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009057 spec->sense_updated = 1;
9058 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009059 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9060 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009061}
9062
9063static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9064 unsigned int res)
9065{
9066 if ((res >> 26) != ALC880_HP_EVENT)
9067 return;
9068 alc262_hp_t5735_automute(codec, 1);
9069}
9070
9071static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9072{
9073 alc262_hp_t5735_automute(codec, 1);
9074}
9075
9076static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009077 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9078 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009079 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9084 { } /* end */
9085};
9086
9087static struct hda_verb alc262_hp_t5735_verbs[] = {
9088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9090
9091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9092 { }
9093};
9094
Kailang Yang8c427222008-01-10 13:03:59 +01009095static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009096 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009098 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9099 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009100 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9101 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9102 { } /* end */
9103};
9104
9105static struct hda_verb alc262_hp_rp5700_verbs[] = {
9106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9107 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9108 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9111 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9116 {}
9117};
9118
9119static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9120 .num_items = 1,
9121 .items = {
9122 { "Line", 0x1 },
9123 },
9124};
9125
Takashi Iwai0724ea22007-08-23 00:31:43 +02009126/* bind hp and internal speaker mute (with plug check) */
9127static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9128 struct snd_ctl_elem_value *ucontrol)
9129{
9130 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9131 long *valp = ucontrol->value.integer.value;
9132 int change;
9133
9134 /* change hp mute */
9135 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9136 HDA_AMP_MUTE,
9137 valp[0] ? 0 : HDA_AMP_MUTE);
9138 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9139 HDA_AMP_MUTE,
9140 valp[1] ? 0 : HDA_AMP_MUTE);
9141 if (change) {
9142 /* change speaker according to HP jack state */
9143 struct alc_spec *spec = codec->spec;
9144 unsigned int mute;
9145 if (spec->jack_present)
9146 mute = HDA_AMP_MUTE;
9147 else
9148 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9149 HDA_OUTPUT, 0);
9150 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9151 HDA_AMP_MUTE, mute);
9152 }
9153 return change;
9154}
Takashi Iwai5b319542007-07-26 11:49:22 +02009155
Kailang Yang272a5272007-05-14 11:00:38 +02009156static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009157 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9158 {
9159 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9160 .name = "Master Playback Switch",
9161 .info = snd_hda_mixer_amp_switch_info,
9162 .get = snd_hda_mixer_amp_switch_get,
9163 .put = alc262_sony_master_sw_put,
9164 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9165 },
Kailang Yang272a5272007-05-14 11:00:38 +02009166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9168 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9169 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9170 { } /* end */
9171};
9172
Kailang Yang83c34212007-07-05 11:43:05 +02009173static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9175 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9179 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9180 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9181 { } /* end */
9182};
Kailang Yang272a5272007-05-14 11:00:38 +02009183
Kailang Yangdf694da2005-12-05 19:42:22 +01009184#define alc262_capture_mixer alc882_capture_mixer
9185#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9186
9187/*
9188 * generic initialization of ADC, input mixers and output mixers
9189 */
9190static struct hda_verb alc262_init_verbs[] = {
9191 /*
9192 * Unmute ADC0-2 and set the default input to mic-in
9193 */
9194 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9196 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9198 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9200
Takashi Iwaicb53c622007-08-10 17:21:45 +02009201 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009202 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009203 * Note: PASD motherboards uses the Line In 2 as the input for
9204 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009205 */
9206 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009212
9213 /*
9214 * Set up output mixers (0x0c - 0x0e)
9215 */
9216 /* set vol=0 to output mixers */
9217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9220 /* set up input amps for analog loopback */
9221 /* Amp Indices: DAC = 0, mixer = 1 */
9222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9228
9229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9232 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9234 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9235
9236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9238 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9239 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009241
Kailang Yangdf694da2005-12-05 19:42:22 +01009242 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009244
Kailang Yangdf694da2005-12-05 19:42:22 +01009245 /* FIXME: use matrix-type input source selection */
9246 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9247 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9252 /* Input mixer2 */
9253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9257 /* Input mixer3 */
9258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009262
9263 { }
9264};
9265
Kailang Yang4e555fe2008-08-26 13:05:55 +02009266static struct hda_verb alc262_eapd_verbs[] = {
9267 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9268 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9269 { }
9270};
9271
Kailang Yangccc656c2006-10-17 12:32:26 +02009272static struct hda_verb alc262_hippo_unsol_verbs[] = {
9273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9275 {}
9276};
9277
9278static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9280 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9281 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9282
9283 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9285 {}
9286};
9287
Kailang Yang272a5272007-05-14 11:00:38 +02009288static struct hda_verb alc262_sony_unsol_verbs[] = {
9289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9290 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9292
9293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009295 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009296};
9297
Kailang Yang4e555fe2008-08-26 13:05:55 +02009298static struct hda_input_mux alc262_dmic_capture_source = {
9299 .num_items = 2,
9300 .items = {
9301 { "Int DMic", 0x9 },
9302 { "Mic", 0x0 },
9303 },
9304};
9305
9306static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9307 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9308 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9312 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9313 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9314 {
9315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9316 /* The multiple "Capture Source" controls confuse alsamixer
9317 * So call somewhat different..
9318 */
9319 /* .name = "Capture Source", */
9320 .name = "Input Source",
9321 .count = 1,
9322 .info = alc_mux_enum_info,
9323 .get = alc_mux_enum_get,
9324 .put = alc_mux_enum_put,
9325 },
9326 { } /* end */
9327};
9328
9329static struct hda_verb alc262_toshiba_s06_verbs[] = {
9330 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9333 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9334 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9335 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9336 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9338 {}
9339};
9340
9341static void alc262_dmic_automute(struct hda_codec *codec)
9342{
9343 unsigned int present;
9344
9345 present = snd_hda_codec_read(codec, 0x18, 0,
9346 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9347 snd_hda_codec_write(codec, 0x22, 0,
9348 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9349}
9350
9351/* toggle speaker-output according to the hp-jack state */
9352static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9353{
9354 unsigned int present;
9355 unsigned char bits;
9356
9357 present = snd_hda_codec_read(codec, 0x15, 0,
9358 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9359 bits = present ? 0 : PIN_OUT;
9360 snd_hda_codec_write(codec, 0x14, 0,
9361 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9362}
9363
9364
9365
9366/* unsolicited event for HP jack sensing */
9367static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9368 unsigned int res)
9369{
9370 if ((res >> 26) == ALC880_HP_EVENT)
9371 alc262_toshiba_s06_speaker_automute(codec);
9372 if ((res >> 26) == ALC880_MIC_EVENT)
9373 alc262_dmic_automute(codec);
9374
9375}
9376
9377static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9378{
9379 alc262_toshiba_s06_speaker_automute(codec);
9380 alc262_dmic_automute(codec);
9381}
9382
Kailang Yangccc656c2006-10-17 12:32:26 +02009383/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009384static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009385{
9386 struct alc_spec *spec = codec->spec;
9387 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009388 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009389
Takashi Iwai5b319542007-07-26 11:49:22 +02009390 /* need to execute and sync at first */
9391 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9392 present = snd_hda_codec_read(codec, 0x15, 0,
9393 AC_VERB_GET_PIN_SENSE, 0);
9394 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009395 if (spec->jack_present) {
9396 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009397 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9398 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009399 } else {
9400 /* unmute internal speaker if necessary */
9401 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009402 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9403 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009404 }
9405}
9406
9407/* unsolicited event for HP jack sensing */
9408static void alc262_hippo_unsol_event(struct hda_codec *codec,
9409 unsigned int res)
9410{
9411 if ((res >> 26) != ALC880_HP_EVENT)
9412 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009413 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009414}
9415
Takashi Iwai5b319542007-07-26 11:49:22 +02009416static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009417{
Kailang Yangccc656c2006-10-17 12:32:26 +02009418 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009419 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009420
Takashi Iwai5b319542007-07-26 11:49:22 +02009421 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9422 present = snd_hda_codec_read(codec, 0x1b, 0,
9423 AC_VERB_GET_PIN_SENSE, 0);
9424 present = (present & 0x80000000) != 0;
9425 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009426 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009427 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9428 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009429 } else {
9430 /* unmute internal speaker if necessary */
9431 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009432 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9433 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009434 }
9435}
9436
9437/* unsolicited event for HP jack sensing */
9438static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9439 unsigned int res)
9440{
9441 if ((res >> 26) != ALC880_HP_EVENT)
9442 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009443 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009444}
9445
Takashi Iwai834be882006-03-01 14:16:17 +01009446/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009447 * nec model
9448 * 0x15 = headphone
9449 * 0x16 = internal speaker
9450 * 0x18 = external mic
9451 */
9452
9453static struct snd_kcontrol_new alc262_nec_mixer[] = {
9454 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9455 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9456
9457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9459 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9460
9461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9463 { } /* end */
9464};
9465
9466static struct hda_verb alc262_nec_verbs[] = {
9467 /* Unmute Speaker */
9468 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9469
9470 /* Headphone */
9471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9472 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9473
9474 /* External mic to headphone */
9475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9476 /* External mic to speaker */
9477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9478 {}
9479};
9480
9481/*
Takashi Iwai834be882006-03-01 14:16:17 +01009482 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009483 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9484 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009485 */
9486
9487#define ALC_HP_EVENT 0x37
9488
9489static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9490 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9493 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009494 {}
9495};
9496
Jiang zhe0e31daf2008-03-20 12:12:39 +01009497static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9498 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9500 {}
9501};
9502
Takashi Iwai834be882006-03-01 14:16:17 +01009503static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009504 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009505 .items = {
9506 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009507 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009508 { "CD", 0x4 },
9509 },
9510};
9511
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009512static struct hda_input_mux alc262_HP_capture_source = {
9513 .num_items = 5,
9514 .items = {
9515 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009516 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009517 { "Line", 0x2 },
9518 { "CD", 0x4 },
9519 { "AUX IN", 0x6 },
9520 },
9521};
9522
zhejiangaccbe492007-08-31 12:36:05 +02009523static struct hda_input_mux alc262_HP_D7000_capture_source = {
9524 .num_items = 4,
9525 .items = {
9526 { "Mic", 0x0 },
9527 { "Front Mic", 0x2 },
9528 { "Line", 0x1 },
9529 { "CD", 0x4 },
9530 },
9531};
9532
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009533/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009534static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9535{
9536 struct alc_spec *spec = codec->spec;
9537 unsigned int mute;
9538
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009539 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009540 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009541 /* need to execute and sync at first */
9542 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009543 /* check laptop HP jack */
9544 present = snd_hda_codec_read(codec, 0x14, 0,
9545 AC_VERB_GET_PIN_SENSE, 0);
9546 /* need to execute and sync at first */
9547 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9548 /* check docking HP jack */
9549 present |= snd_hda_codec_read(codec, 0x1b, 0,
9550 AC_VERB_GET_PIN_SENSE, 0);
9551 if (present & AC_PINSENSE_PRESENCE)
9552 spec->jack_present = 1;
9553 else
9554 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009555 spec->sense_updated = 1;
9556 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009557 /* unmute internal speaker only if both HPs are unplugged and
9558 * master switch is on
9559 */
9560 if (spec->jack_present)
9561 mute = HDA_AMP_MUTE;
9562 else
Takashi Iwai834be882006-03-01 14:16:17 +01009563 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009564 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9565 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009566}
9567
9568/* unsolicited event for HP jack sensing */
9569static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9570 unsigned int res)
9571{
9572 if ((res >> 26) != ALC_HP_EVENT)
9573 return;
9574 alc262_fujitsu_automute(codec, 1);
9575}
9576
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009577static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9578{
9579 alc262_fujitsu_automute(codec, 1);
9580}
9581
Takashi Iwai834be882006-03-01 14:16:17 +01009582/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009583static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9584 .ops = &snd_hda_bind_vol,
9585 .values = {
9586 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9587 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9588 0
9589 },
9590};
Takashi Iwai834be882006-03-01 14:16:17 +01009591
Jiang zhe0e31daf2008-03-20 12:12:39 +01009592/* mute/unmute internal speaker according to the hp jack and mute state */
9593static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9594{
9595 struct alc_spec *spec = codec->spec;
9596 unsigned int mute;
9597
9598 if (force || !spec->sense_updated) {
9599 unsigned int present_int_hp;
9600 /* need to execute and sync at first */
9601 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9602 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9603 AC_VERB_GET_PIN_SENSE, 0);
9604 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9605 spec->sense_updated = 1;
9606 }
9607 if (spec->jack_present) {
9608 /* mute internal speaker */
9609 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9610 HDA_AMP_MUTE, HDA_AMP_MUTE);
9611 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9612 HDA_AMP_MUTE, HDA_AMP_MUTE);
9613 } else {
9614 /* unmute internal speaker if necessary */
9615 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9616 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9617 HDA_AMP_MUTE, mute);
9618 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9619 HDA_AMP_MUTE, mute);
9620 }
9621}
9622
9623/* unsolicited event for HP jack sensing */
9624static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9625 unsigned int res)
9626{
9627 if ((res >> 26) != ALC_HP_EVENT)
9628 return;
9629 alc262_lenovo_3000_automute(codec, 1);
9630}
9631
Takashi Iwai834be882006-03-01 14:16:17 +01009632/* bind hp and internal speaker mute (with plug check) */
9633static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9634 struct snd_ctl_elem_value *ucontrol)
9635{
9636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9637 long *valp = ucontrol->value.integer.value;
9638 int change;
9639
Tony Vroon5d9fab22008-03-14 17:09:18 +01009640 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9641 HDA_AMP_MUTE,
9642 valp ? 0 : HDA_AMP_MUTE);
9643 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9644 HDA_AMP_MUTE,
9645 valp ? 0 : HDA_AMP_MUTE);
9646
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009647 if (change)
9648 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009649 return change;
9650}
9651
9652static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009653 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009654 {
9655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9656 .name = "Master Playback Switch",
9657 .info = snd_hda_mixer_amp_switch_info,
9658 .get = snd_hda_mixer_amp_switch_get,
9659 .put = alc262_fujitsu_master_sw_put,
9660 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9661 },
9662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009664 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9665 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009666 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009669 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9670 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9671 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009672 { } /* end */
9673};
9674
Jiang zhe0e31daf2008-03-20 12:12:39 +01009675/* bind hp and internal speaker mute (with plug check) */
9676static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9677 struct snd_ctl_elem_value *ucontrol)
9678{
9679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9680 long *valp = ucontrol->value.integer.value;
9681 int change;
9682
9683 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9684 HDA_AMP_MUTE,
9685 valp ? 0 : HDA_AMP_MUTE);
9686
9687 if (change)
9688 alc262_lenovo_3000_automute(codec, 0);
9689 return change;
9690}
9691
9692static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9693 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9694 {
9695 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9696 .name = "Master Playback Switch",
9697 .info = snd_hda_mixer_amp_switch_info,
9698 .get = snd_hda_mixer_amp_switch_get,
9699 .put = alc262_lenovo_3000_master_sw_put,
9700 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9701 },
9702 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9703 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9704 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9708 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9709 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9710 { } /* end */
9711};
9712
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009713static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9714 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9715 {
9716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9717 .name = "Master Playback Switch",
9718 .info = snd_hda_mixer_amp_switch_info,
9719 .get = snd_hda_mixer_amp_switch_get,
9720 .put = alc262_sony_master_sw_put,
9721 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9722 },
9723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9727 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9728 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9729 { } /* end */
9730};
9731
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009732/* additional init verbs for Benq laptops */
9733static struct hda_verb alc262_EAPD_verbs[] = {
9734 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9735 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9736 {}
9737};
9738
Kailang Yang83c34212007-07-05 11:43:05 +02009739static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9742
9743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9744 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9745 {}
9746};
9747
Tobin Davisf651b502007-10-26 12:40:47 +02009748/* Samsung Q1 Ultra Vista model setup */
9749static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009750 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9751 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9754 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009755 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009756 { } /* end */
9757};
9758
9759static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009760 /* output mixer */
9761 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9764 /* speaker */
9765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9768 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9769 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9775 /* internal mic */
9776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9778 /* ADC, choose mic */
9779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9781 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9782 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009789 {}
9790};
9791
Tobin Davisf651b502007-10-26 12:40:47 +02009792/* mute/unmute internal speaker according to the hp jack and mute state */
9793static void alc262_ultra_automute(struct hda_codec *codec)
9794{
9795 struct alc_spec *spec = codec->spec;
9796 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009797
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009798 mute = 0;
9799 /* auto-mute only when HP is used as HP */
9800 if (!spec->cur_mux[0]) {
9801 unsigned int present;
9802 /* need to execute and sync at first */
9803 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9804 present = snd_hda_codec_read(codec, 0x15, 0,
9805 AC_VERB_GET_PIN_SENSE, 0);
9806 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9807 if (spec->jack_present)
9808 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009809 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009810 /* mute/unmute internal speaker */
9811 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9812 HDA_AMP_MUTE, mute);
9813 /* mute/unmute HP */
9814 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9815 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009816}
9817
9818/* unsolicited event for HP jack sensing */
9819static void alc262_ultra_unsol_event(struct hda_codec *codec,
9820 unsigned int res)
9821{
9822 if ((res >> 26) != ALC880_HP_EVENT)
9823 return;
9824 alc262_ultra_automute(codec);
9825}
9826
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009827static struct hda_input_mux alc262_ultra_capture_source = {
9828 .num_items = 2,
9829 .items = {
9830 { "Mic", 0x1 },
9831 { "Headphone", 0x7 },
9832 },
9833};
9834
9835static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9836 struct snd_ctl_elem_value *ucontrol)
9837{
9838 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9839 struct alc_spec *spec = codec->spec;
9840 int ret;
9841
9842 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9843 if (!ret)
9844 return 0;
9845 /* reprogram the HP pin as mic or HP according to the input source */
9846 snd_hda_codec_write_cache(codec, 0x15, 0,
9847 AC_VERB_SET_PIN_WIDGET_CONTROL,
9848 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9849 alc262_ultra_automute(codec); /* mute/unmute HP */
9850 return ret;
9851}
9852
9853static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9854 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9855 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9856 {
9857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9858 .name = "Capture Source",
9859 .info = alc882_mux_enum_info,
9860 .get = alc882_mux_enum_get,
9861 .put = alc262_ultra_mux_enum_put,
9862 },
9863 { } /* end */
9864};
9865
Kailang Yangdf694da2005-12-05 19:42:22 +01009866/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009867static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9868 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009869{
9870 hda_nid_t nid;
9871 int err;
9872
9873 spec->multiout.num_dacs = 1; /* only use one dac */
9874 spec->multiout.dac_nids = spec->private_dac_nids;
9875 spec->multiout.dac_nids[0] = 2;
9876
9877 nid = cfg->line_out_pins[0];
9878 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009879 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9880 "Front Playback Volume",
9881 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9882 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009883 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009884 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9885 "Front Playback Switch",
9886 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9887 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009888 return err;
9889 }
9890
Takashi Iwai82bc9552006-03-21 11:24:42 +01009891 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009892 if (nid) {
9893 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009894 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9895 "Speaker Playback Volume",
9896 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9897 HDA_OUTPUT));
9898 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009899 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009900 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9901 "Speaker Playback Switch",
9902 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9903 HDA_OUTPUT));
9904 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009905 return err;
9906 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009907 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9908 "Speaker Playback Switch",
9909 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9910 HDA_OUTPUT));
9911 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009912 return err;
9913 }
9914 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009915 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009916 if (nid) {
9917 /* spec->multiout.hp_nid = 2; */
9918 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009919 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9920 "Headphone Playback Volume",
9921 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9922 HDA_OUTPUT));
9923 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009924 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009925 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9926 "Headphone Playback Switch",
9927 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9928 HDA_OUTPUT));
9929 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009930 return err;
9931 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009932 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9933 "Headphone Playback Switch",
9934 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9935 HDA_OUTPUT));
9936 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009937 return err;
9938 }
9939 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009940 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009941}
9942
9943/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009944#define alc262_auto_create_analog_input_ctls \
9945 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009946
9947/*
9948 * generic initialization of ADC, input mixers and output mixers
9949 */
9950static struct hda_verb alc262_volume_init_verbs[] = {
9951 /*
9952 * Unmute ADC0-2 and set the default input to mic-in
9953 */
9954 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9956 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9958 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9960
Takashi Iwaicb53c622007-08-10 17:21:45 +02009961 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009962 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009963 * Note: PASD motherboards uses the Line In 2 as the input for
9964 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009965 */
9966 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009972
9973 /*
9974 * Set up output mixers (0x0c - 0x0f)
9975 */
9976 /* set vol=0 to output mixers */
9977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009980
Kailang Yangdf694da2005-12-05 19:42:22 +01009981 /* set up input amps for analog loopback */
9982 /* Amp Indices: DAC = 0, mixer = 1 */
9983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9989
9990 /* FIXME: use matrix-type input source selection */
9991 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9992 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9996 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9997 /* Input mixer2 */
9998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10002 /* Input mixer3 */
10003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10007
10008 { }
10009};
10010
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010011static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10012 /*
10013 * Unmute ADC0-2 and set the default input to mic-in
10014 */
10015 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10017 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10019 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10021
Takashi Iwaicb53c622007-08-10 17:21:45 +020010022 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010023 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010024 * Note: PASD motherboards uses the Line In 2 as the input for
10025 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010026 */
10027 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010035
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010036 /*
10037 * Set up output mixers (0x0c - 0x0e)
10038 */
10039 /* set vol=0 to output mixers */
10040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10043
10044 /* set up input amps for analog loopback */
10045 /* Amp Indices: DAC = 0, mixer = 1 */
10046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10052
Takashi Iwaice875f02008-01-28 18:17:43 +010010053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10056
10057 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10059
10060 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10062
10063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10065 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10067 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10068
10069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10073 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10074 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10075
10076
10077 /* FIXME: use matrix-type input source selection */
10078 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10079 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10084 /* Input mixer2 */
10085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10089 /* Input mixer3 */
10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10094
Takashi Iwaice875f02008-01-28 18:17:43 +010010095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10096
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010097 { }
10098};
10099
Kailang Yangcd7509a2007-01-26 18:33:17 +010010100static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10101 /*
10102 * Unmute ADC0-2 and set the default input to mic-in
10103 */
10104 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10106 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10108 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10110
Takashi Iwaicb53c622007-08-10 17:21:45 +020010111 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010112 * mixer widget
10113 * Note: PASD motherboards uses the Line In 2 as the input for front
10114 * panel mic (mic 2)
10115 */
10116 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010125 /*
10126 * Set up output mixers (0x0c - 0x0e)
10127 */
10128 /* set vol=0 to output mixers */
10129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10132
10133 /* set up input amps for analog loopback */
10134 /* Amp Indices: DAC = 0, mixer = 1 */
10135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10138 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10141
10142
10143 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10144 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10145 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10147 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10149 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10150
10151 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10153
10154 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10156
10157 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10160 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10161 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10162 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10163
10164 /* FIXME: use matrix-type input source selection */
10165 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10166 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10172 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10174 /* Input mixer2 */
10175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10180 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10182 /* Input mixer3 */
10183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10188 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10190
Takashi Iwaice875f02008-01-28 18:17:43 +010010191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10192
Kailang Yangcd7509a2007-01-26 18:33:17 +010010193 { }
10194};
10195
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010196static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10197
10198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10200 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10201
10202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10203 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10205 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10206
10207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10208 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10209 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10210 {}
10211};
10212
10213
Takashi Iwaicb53c622007-08-10 17:21:45 +020010214#ifdef CONFIG_SND_HDA_POWER_SAVE
10215#define alc262_loopbacks alc880_loopbacks
10216#endif
10217
Kailang Yangdf694da2005-12-05 19:42:22 +010010218/* pcm configuration: identiacal with ALC880 */
10219#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10220#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10221#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10222#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10223
10224/*
10225 * BIOS auto configuration
10226 */
10227static int alc262_parse_auto_config(struct hda_codec *codec)
10228{
10229 struct alc_spec *spec = codec->spec;
10230 int err;
10231 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10232
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010233 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10234 alc262_ignore);
10235 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010236 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010237 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010238 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010239 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10240 if (err < 0)
10241 return err;
10242 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10243 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010244 return err;
10245
10246 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10247
10248 if (spec->autocfg.dig_out_pin)
10249 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10250 if (spec->autocfg.dig_in_pin)
10251 spec->dig_in_nid = ALC262_DIGIN_NID;
10252
Takashi Iwai603c4012008-07-30 15:01:44 +020010253 if (spec->kctls.list)
10254 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yangdf694da2005-12-05 19:42:22 +010010255
10256 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010257 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010258 spec->input_mux = &spec->private_imux;
10259
Takashi Iwai776e1842007-08-29 15:07:11 +020010260 err = alc_auto_add_mic_boost(codec);
10261 if (err < 0)
10262 return err;
10263
Kailang Yangdf694da2005-12-05 19:42:22 +010010264 return 1;
10265}
10266
10267#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10268#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10269#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010270#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010271
10272
10273/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010274static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010275{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010276 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010277 alc262_auto_init_multi_out(codec);
10278 alc262_auto_init_hp_out(codec);
10279 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010280 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010281 if (spec->unsol_event)
10282 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010283}
10284
10285/*
10286 * configuration and preset
10287 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010288static const char *alc262_models[ALC262_MODEL_LAST] = {
10289 [ALC262_BASIC] = "basic",
10290 [ALC262_HIPPO] = "hippo",
10291 [ALC262_HIPPO_1] = "hippo_1",
10292 [ALC262_FUJITSU] = "fujitsu",
10293 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010294 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010295 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010296 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010297 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010298 [ALC262_BENQ_T31] = "benq-t31",
10299 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010300 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010301 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010302 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010303 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010304 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010305 [ALC262_AUTO] = "auto",
10306};
10307
10308static struct snd_pci_quirk alc262_cfg_tbl[] = {
10309 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010310 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010311 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010312 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010313 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10314 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010315 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010316 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010317 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010318 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010319 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010320 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010321 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010322 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010323 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010324 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010325 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010326 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010327 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10328 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10329 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010330 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10331 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010332 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010333 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010334 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010335 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10336 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10337 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010338 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010339 ALC262_TOSHIBA_RX1),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010340 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010341 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010342 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010343 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010344 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010345 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010346 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010347 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010348 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010349 {}
10350};
10351
10352static struct alc_config_preset alc262_presets[] = {
10353 [ALC262_BASIC] = {
10354 .mixers = { alc262_base_mixer },
10355 .init_verbs = { alc262_init_verbs },
10356 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10357 .dac_nids = alc262_dac_nids,
10358 .hp_nid = 0x03,
10359 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10360 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010361 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010362 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010363 [ALC262_HIPPO] = {
10364 .mixers = { alc262_base_mixer },
10365 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10366 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10367 .dac_nids = alc262_dac_nids,
10368 .hp_nid = 0x03,
10369 .dig_out_nid = ALC262_DIGOUT_NID,
10370 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10371 .channel_mode = alc262_modes,
10372 .input_mux = &alc262_capture_source,
10373 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010374 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010375 },
10376 [ALC262_HIPPO_1] = {
10377 .mixers = { alc262_hippo1_mixer },
10378 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10379 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10380 .dac_nids = alc262_dac_nids,
10381 .hp_nid = 0x02,
10382 .dig_out_nid = ALC262_DIGOUT_NID,
10383 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10384 .channel_mode = alc262_modes,
10385 .input_mux = &alc262_capture_source,
10386 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010387 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010388 },
Takashi Iwai834be882006-03-01 14:16:17 +010010389 [ALC262_FUJITSU] = {
10390 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010391 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10392 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010393 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10394 .dac_nids = alc262_dac_nids,
10395 .hp_nid = 0x03,
10396 .dig_out_nid = ALC262_DIGOUT_NID,
10397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10398 .channel_mode = alc262_modes,
10399 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010400 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010401 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010402 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010403 [ALC262_HP_BPC] = {
10404 .mixers = { alc262_HP_BPC_mixer },
10405 .init_verbs = { alc262_HP_BPC_init_verbs },
10406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10407 .dac_nids = alc262_dac_nids,
10408 .hp_nid = 0x03,
10409 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10410 .channel_mode = alc262_modes,
10411 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010412 .unsol_event = alc262_hp_bpc_unsol_event,
10413 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010414 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010415 [ALC262_HP_BPC_D7000_WF] = {
10416 .mixers = { alc262_HP_BPC_WildWest_mixer },
10417 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10419 .dac_nids = alc262_dac_nids,
10420 .hp_nid = 0x03,
10421 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10422 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010423 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010424 .unsol_event = alc262_hp_wildwest_unsol_event,
10425 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010426 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010427 [ALC262_HP_BPC_D7000_WL] = {
10428 .mixers = { alc262_HP_BPC_WildWest_mixer,
10429 alc262_HP_BPC_WildWest_option_mixer },
10430 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10431 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10432 .dac_nids = alc262_dac_nids,
10433 .hp_nid = 0x03,
10434 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10435 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010436 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010437 .unsol_event = alc262_hp_wildwest_unsol_event,
10438 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010439 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010440 [ALC262_HP_TC_T5735] = {
10441 .mixers = { alc262_hp_t5735_mixer },
10442 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10443 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10444 .dac_nids = alc262_dac_nids,
10445 .hp_nid = 0x03,
10446 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10447 .channel_mode = alc262_modes,
10448 .input_mux = &alc262_capture_source,
10449 .unsol_event = alc262_hp_t5735_unsol_event,
10450 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010451 },
10452 [ALC262_HP_RP5700] = {
10453 .mixers = { alc262_hp_rp5700_mixer },
10454 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10455 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10456 .dac_nids = alc262_dac_nids,
10457 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10458 .channel_mode = alc262_modes,
10459 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010460 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010461 [ALC262_BENQ_ED8] = {
10462 .mixers = { alc262_base_mixer },
10463 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10464 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10465 .dac_nids = alc262_dac_nids,
10466 .hp_nid = 0x03,
10467 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10468 .channel_mode = alc262_modes,
10469 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010470 },
Kailang Yang272a5272007-05-14 11:00:38 +020010471 [ALC262_SONY_ASSAMD] = {
10472 .mixers = { alc262_sony_mixer },
10473 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10474 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10475 .dac_nids = alc262_dac_nids,
10476 .hp_nid = 0x02,
10477 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10478 .channel_mode = alc262_modes,
10479 .input_mux = &alc262_capture_source,
10480 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010481 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010482 },
10483 [ALC262_BENQ_T31] = {
10484 .mixers = { alc262_benq_t31_mixer },
10485 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10486 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10487 .dac_nids = alc262_dac_nids,
10488 .hp_nid = 0x03,
10489 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10490 .channel_mode = alc262_modes,
10491 .input_mux = &alc262_capture_source,
10492 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010493 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010494 },
Tobin Davisf651b502007-10-26 12:40:47 +020010495 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010496 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10497 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10499 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010500 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10501 .channel_mode = alc262_modes,
10502 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010503 .adc_nids = alc262_adc_nids, /* ADC0 */
10504 .capsrc_nids = alc262_capsrc_nids,
10505 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010506 .unsol_event = alc262_ultra_unsol_event,
10507 .init_hook = alc262_ultra_automute,
10508 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010509 [ALC262_LENOVO_3000] = {
10510 .mixers = { alc262_lenovo_3000_mixer },
10511 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10512 alc262_lenovo_3000_unsol_verbs },
10513 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10514 .dac_nids = alc262_dac_nids,
10515 .hp_nid = 0x03,
10516 .dig_out_nid = ALC262_DIGOUT_NID,
10517 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10518 .channel_mode = alc262_modes,
10519 .input_mux = &alc262_fujitsu_capture_source,
10520 .unsol_event = alc262_lenovo_3000_unsol_event,
10521 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010522 [ALC262_NEC] = {
10523 .mixers = { alc262_nec_mixer },
10524 .init_verbs = { alc262_nec_verbs },
10525 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10526 .dac_nids = alc262_dac_nids,
10527 .hp_nid = 0x03,
10528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10529 .channel_mode = alc262_modes,
10530 .input_mux = &alc262_capture_source,
10531 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010532 [ALC262_TOSHIBA_S06] = {
10533 .mixers = { alc262_toshiba_s06_mixer },
10534 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10535 alc262_eapd_verbs },
10536 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10537 .capsrc_nids = alc262_dmic_capsrc_nids,
10538 .dac_nids = alc262_dac_nids,
10539 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10540 .dig_out_nid = ALC262_DIGOUT_NID,
10541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10542 .channel_mode = alc262_modes,
10543 .input_mux = &alc262_dmic_capture_source,
10544 .unsol_event = alc262_toshiba_s06_unsol_event,
10545 .init_hook = alc262_toshiba_s06_init_hook,
10546 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010547 [ALC262_TOSHIBA_RX1] = {
10548 .mixers = { alc262_toshiba_rx1_mixer },
10549 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10550 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10551 .dac_nids = alc262_dac_nids,
10552 .hp_nid = 0x03,
10553 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10554 .channel_mode = alc262_modes,
10555 .input_mux = &alc262_capture_source,
10556 .unsol_event = alc262_hippo_unsol_event,
10557 .init_hook = alc262_hippo_automute,
10558 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010559};
10560
10561static int patch_alc262(struct hda_codec *codec)
10562{
10563 struct alc_spec *spec;
10564 int board_config;
10565 int err;
10566
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010567 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010568 if (spec == NULL)
10569 return -ENOMEM;
10570
10571 codec->spec = spec;
10572#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010573 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10574 * under-run
10575 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010576 {
10577 int tmp;
10578 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10579 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10580 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10581 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10582 }
10583#endif
10584
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010585 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10586
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010587 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10588 alc262_models,
10589 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010590
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010591 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010592 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10593 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010594 board_config = ALC262_AUTO;
10595 }
10596
10597 if (board_config == ALC262_AUTO) {
10598 /* automatic parse from the BIOS config */
10599 err = alc262_parse_auto_config(codec);
10600 if (err < 0) {
10601 alc_free(codec);
10602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010603 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010604 printk(KERN_INFO
10605 "hda_codec: Cannot set up configuration "
10606 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010607 board_config = ALC262_BASIC;
10608 }
10609 }
10610
10611 if (board_config != ALC262_AUTO)
10612 setup_preset(spec, &alc262_presets[board_config]);
10613
10614 spec->stream_name_analog = "ALC262 Analog";
10615 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10616 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010617
Kailang Yangdf694da2005-12-05 19:42:22 +010010618 spec->stream_name_digital = "ALC262 Digital";
10619 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10620 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010622 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010623 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010624 unsigned int wcap = get_wcaps(codec, 0x07);
10625
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010626 /* get type */
10627 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010628 if (wcap != AC_WID_AUD_IN) {
10629 spec->adc_nids = alc262_adc_nids_alt;
10630 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010631 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010632 spec->mixers[spec->num_mixers] =
10633 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010634 spec->num_mixers++;
10635 } else {
10636 spec->adc_nids = alc262_adc_nids;
10637 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010638 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010639 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10640 spec->num_mixers++;
10641 }
10642 }
10643
Takashi Iwai2134ea42008-01-10 16:53:55 +010010644 spec->vmaster_nid = 0x0c;
10645
Kailang Yangdf694da2005-12-05 19:42:22 +010010646 codec->patch_ops = alc_patch_ops;
10647 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010648 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010649#ifdef CONFIG_SND_HDA_POWER_SAVE
10650 if (!spec->loopback.amplist)
10651 spec->loopback.amplist = alc262_loopbacks;
10652#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010653
Kailang Yangdf694da2005-12-05 19:42:22 +010010654 return 0;
10655}
10656
Kailang Yangdf694da2005-12-05 19:42:22 +010010657/*
Kailang Yanga361d842007-06-05 12:30:55 +020010658 * ALC268 channel source setting (2 channel)
10659 */
10660#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10661#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010662
Kailang Yanga361d842007-06-05 12:30:55 +020010663static hda_nid_t alc268_dac_nids[2] = {
10664 /* front, hp */
10665 0x02, 0x03
10666};
10667
10668static hda_nid_t alc268_adc_nids[2] = {
10669 /* ADC0-1 */
10670 0x08, 0x07
10671};
10672
10673static hda_nid_t alc268_adc_nids_alt[1] = {
10674 /* ADC0 */
10675 0x08
10676};
10677
Takashi Iwaie1406342008-02-11 18:32:32 +010010678static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10679
Kailang Yanga361d842007-06-05 12:30:55 +020010680static struct snd_kcontrol_new alc268_base_mixer[] = {
10681 /* output mixer control */
10682 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10683 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10688 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010689 { }
10690};
10691
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010692/* bind Beep switches of both NID 0x0f and 0x10 */
10693static struct hda_bind_ctls alc268_bind_beep_sw = {
10694 .ops = &snd_hda_bind_sw,
10695 .values = {
10696 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10697 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10698 0
10699 },
10700};
10701
10702static struct snd_kcontrol_new alc268_beep_mixer[] = {
10703 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10704 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10705 { }
10706};
10707
Kailang Yangd1a991a2007-08-15 16:21:59 +020010708static struct hda_verb alc268_eapd_verbs[] = {
10709 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10710 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10711 { }
10712};
10713
Takashi Iwaid2738092007-08-16 14:59:45 +020010714/* Toshiba specific */
10715#define alc268_toshiba_automute alc262_hippo_automute
10716
10717static struct hda_verb alc268_toshiba_verbs[] = {
10718 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10719 { } /* end */
10720};
10721
Kailang Yang8ef355d2008-08-26 13:10:22 +020010722static struct hda_input_mux alc268_acer_lc_capture_source = {
10723 .num_items = 2,
10724 .items = {
10725 { "i-Mic", 0x6 },
10726 { "E-Mic", 0x0 },
10727 },
10728};
10729
Takashi Iwaid2738092007-08-16 14:59:45 +020010730/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010731/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010732static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10733 .ops = &snd_hda_bind_vol,
10734 .values = {
10735 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10736 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10737 0
10738 },
10739};
10740
Takashi Iwai889c4392007-08-23 18:56:52 +020010741/* mute/unmute internal speaker according to the hp jack and mute state */
10742static void alc268_acer_automute(struct hda_codec *codec, int force)
10743{
10744 struct alc_spec *spec = codec->spec;
10745 unsigned int mute;
10746
10747 if (force || !spec->sense_updated) {
10748 unsigned int present;
10749 present = snd_hda_codec_read(codec, 0x14, 0,
10750 AC_VERB_GET_PIN_SENSE, 0);
10751 spec->jack_present = (present & 0x80000000) != 0;
10752 spec->sense_updated = 1;
10753 }
10754 if (spec->jack_present)
10755 mute = HDA_AMP_MUTE; /* mute internal speaker */
10756 else /* unmute internal speaker if necessary */
10757 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10758 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10759 HDA_AMP_MUTE, mute);
10760}
10761
10762
10763/* bind hp and internal speaker mute (with plug check) */
10764static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10765 struct snd_ctl_elem_value *ucontrol)
10766{
10767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10768 long *valp = ucontrol->value.integer.value;
10769 int change;
10770
10771 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10772 HDA_AMP_MUTE,
10773 valp[0] ? 0 : HDA_AMP_MUTE);
10774 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10775 HDA_AMP_MUTE,
10776 valp[1] ? 0 : HDA_AMP_MUTE);
10777 if (change)
10778 alc268_acer_automute(codec, 0);
10779 return change;
10780}
Takashi Iwaid2738092007-08-16 14:59:45 +020010781
Kailang Yang8ef355d2008-08-26 13:10:22 +020010782static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10783 /* output mixer control */
10784 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10785 {
10786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10787 .name = "Master Playback Switch",
10788 .info = snd_hda_mixer_amp_switch_info,
10789 .get = snd_hda_mixer_amp_switch_get,
10790 .put = alc268_acer_master_sw_put,
10791 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10792 },
10793 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10794 { }
10795};
10796
Takashi Iwaid2738092007-08-16 14:59:45 +020010797static struct snd_kcontrol_new alc268_acer_mixer[] = {
10798 /* output mixer control */
10799 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10800 {
10801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10802 .name = "Master Playback Switch",
10803 .info = snd_hda_mixer_amp_switch_info,
10804 .get = snd_hda_mixer_amp_switch_get,
10805 .put = alc268_acer_master_sw_put,
10806 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10807 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10809 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10810 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010811 { }
10812};
10813
Kailang Yang8ef355d2008-08-26 13:10:22 +020010814static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10815 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10817 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10818 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10819 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10821 { }
10822};
10823
Takashi Iwaid2738092007-08-16 14:59:45 +020010824static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010825 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10826 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010831 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10832 { }
10833};
10834
10835/* unsolicited event for HP jack sensing */
10836static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10837 unsigned int res)
10838{
Takashi Iwai889c4392007-08-23 18:56:52 +020010839 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010840 return;
10841 alc268_toshiba_automute(codec);
10842}
10843
10844static void alc268_acer_unsol_event(struct hda_codec *codec,
10845 unsigned int res)
10846{
Takashi Iwai889c4392007-08-23 18:56:52 +020010847 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010848 return;
10849 alc268_acer_automute(codec, 1);
10850}
10851
Takashi Iwai889c4392007-08-23 18:56:52 +020010852static void alc268_acer_init_hook(struct hda_codec *codec)
10853{
10854 alc268_acer_automute(codec, 1);
10855}
10856
Kailang Yang8ef355d2008-08-26 13:10:22 +020010857/* toggle speaker-output according to the hp-jack state */
10858static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10859{
10860 unsigned int present;
10861 unsigned char bits;
10862
10863 present = snd_hda_codec_read(codec, 0x15, 0,
10864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10865 bits = present ? AMP_IN_MUTE(0) : 0;
10866 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10867 AMP_IN_MUTE(0), bits);
10868 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10869 AMP_IN_MUTE(0), bits);
10870}
10871
10872
10873static void alc268_acer_mic_automute(struct hda_codec *codec)
10874{
10875 unsigned int present;
10876
10877 present = snd_hda_codec_read(codec, 0x18, 0,
10878 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10879 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10880 present ? 0x0 : 0x6);
10881}
10882
10883static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10884 unsigned int res)
10885{
10886 if ((res >> 26) == ALC880_HP_EVENT)
10887 alc268_aspire_one_speaker_automute(codec);
10888 if ((res >> 26) == ALC880_MIC_EVENT)
10889 alc268_acer_mic_automute(codec);
10890}
10891
10892static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10893{
10894 alc268_aspire_one_speaker_automute(codec);
10895 alc268_acer_mic_automute(codec);
10896}
10897
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010898static struct snd_kcontrol_new alc268_dell_mixer[] = {
10899 /* output mixer control */
10900 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10901 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10902 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10905 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10906 { }
10907};
10908
10909static struct hda_verb alc268_dell_verbs[] = {
10910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10912 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10913 { }
10914};
10915
10916/* mute/unmute internal speaker according to the hp jack and mute state */
10917static void alc268_dell_automute(struct hda_codec *codec)
10918{
10919 unsigned int present;
10920 unsigned int mute;
10921
10922 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10923 if (present & 0x80000000)
10924 mute = HDA_AMP_MUTE;
10925 else
10926 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10927 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10928 HDA_AMP_MUTE, mute);
10929}
10930
10931static void alc268_dell_unsol_event(struct hda_codec *codec,
10932 unsigned int res)
10933{
10934 if ((res >> 26) != ALC880_HP_EVENT)
10935 return;
10936 alc268_dell_automute(codec);
10937}
10938
10939#define alc268_dell_init_hook alc268_dell_automute
10940
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010941static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10942 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10943 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10944 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10946 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10947 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10949 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10950 { }
10951};
10952
10953static struct hda_verb alc267_quanta_il1_verbs[] = {
10954 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10955 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10956 { }
10957};
10958
10959static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10960{
10961 unsigned int present;
10962
10963 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10964 & AC_PINSENSE_PRESENCE;
10965 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10966 present ? 0 : PIN_OUT);
10967}
10968
10969static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10970{
10971 unsigned int present;
10972
10973 present = snd_hda_codec_read(codec, 0x18, 0,
10974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10975 snd_hda_codec_write(codec, 0x23, 0,
10976 AC_VERB_SET_CONNECT_SEL,
10977 present ? 0x00 : 0x01);
10978}
10979
10980static void alc267_quanta_il1_automute(struct hda_codec *codec)
10981{
10982 alc267_quanta_il1_hp_automute(codec);
10983 alc267_quanta_il1_mic_automute(codec);
10984}
10985
10986static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10987 unsigned int res)
10988{
10989 switch (res >> 26) {
10990 case ALC880_HP_EVENT:
10991 alc267_quanta_il1_hp_automute(codec);
10992 break;
10993 case ALC880_MIC_EVENT:
10994 alc267_quanta_il1_mic_automute(codec);
10995 break;
10996 }
10997}
10998
Kailang Yanga361d842007-06-05 12:30:55 +020010999/*
11000 * generic initialization of ADC, input mixers and output mixers
11001 */
11002static struct hda_verb alc268_base_init_verbs[] = {
11003 /* Unmute DAC0-1 and set vol = 0 */
11004 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11005 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11006 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11007 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11008 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11009 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11010
11011 /*
11012 * Set up output mixers (0x0c - 0x0e)
11013 */
11014 /* set vol=0 to output mixers */
11015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11018 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11019
11020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11021 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11022
11023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11025 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11028 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11029 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11030 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11031
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11034 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11038 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011039
11040 /* set PCBEEP vol = 0, mute connections */
11041 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11043 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011044
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011045 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011046
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011047 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11049 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011051
Kailang Yanga361d842007-06-05 12:30:55 +020011052 { }
11053};
11054
11055/*
11056 * generic initialization of ADC, input mixers and output mixers
11057 */
11058static struct hda_verb alc268_volume_init_verbs[] = {
11059 /* set output DAC */
11060 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11061 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11062 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11064
11065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11068 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11069 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11070
11071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11075 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11076
11077 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11080 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11081
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011082 /* set PCBEEP vol = 0, mute connections */
11083 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11085 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011086
11087 { }
11088};
11089
11090#define alc268_mux_enum_info alc_mux_enum_info
11091#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011092#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020011093
11094static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11095 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11096 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11097 {
11098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11099 /* The multiple "Capture Source" controls confuse alsamixer
11100 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011101 */
11102 /* .name = "Capture Source", */
11103 .name = "Input Source",
11104 .count = 1,
11105 .info = alc268_mux_enum_info,
11106 .get = alc268_mux_enum_get,
11107 .put = alc268_mux_enum_put,
11108 },
11109 { } /* end */
11110};
11111
11112static struct snd_kcontrol_new alc268_capture_mixer[] = {
11113 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11114 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11115 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11116 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11117 {
11118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11119 /* The multiple "Capture Source" controls confuse alsamixer
11120 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011121 */
11122 /* .name = "Capture Source", */
11123 .name = "Input Source",
11124 .count = 2,
11125 .info = alc268_mux_enum_info,
11126 .get = alc268_mux_enum_get,
11127 .put = alc268_mux_enum_put,
11128 },
11129 { } /* end */
11130};
11131
11132static struct hda_input_mux alc268_capture_source = {
11133 .num_items = 4,
11134 .items = {
11135 { "Mic", 0x0 },
11136 { "Front Mic", 0x1 },
11137 { "Line", 0x2 },
11138 { "CD", 0x3 },
11139 },
11140};
11141
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011142static struct hda_input_mux alc268_acer_capture_source = {
11143 .num_items = 3,
11144 .items = {
11145 { "Mic", 0x0 },
11146 { "Internal Mic", 0x6 },
11147 { "Line", 0x2 },
11148 },
11149};
11150
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011151#ifdef CONFIG_SND_DEBUG
11152static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011153 /* Volume widgets */
11154 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11156 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11157 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11158 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11159 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11160 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11161 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11162 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11163 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11164 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11165 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11166 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011167 /* The below appears problematic on some hardwares */
11168 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011169 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11170 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11171 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11172 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11173
11174 /* Modes for retasking pin widgets */
11175 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11176 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11177 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11178 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11179
11180 /* Controls for GPIO pins, assuming they are configured as outputs */
11181 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11182 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11183 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11184 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11185
11186 /* Switches to allow the digital SPDIF output pin to be enabled.
11187 * The ALC268 does not have an SPDIF input.
11188 */
11189 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11190
11191 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11192 * this output to turn on an external amplifier.
11193 */
11194 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11195 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11196
11197 { } /* end */
11198};
11199#endif
11200
Kailang Yanga361d842007-06-05 12:30:55 +020011201/* create input playback/capture controls for the given pin */
11202static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11203 const char *ctlname, int idx)
11204{
11205 char name[32];
11206 int err;
11207
11208 sprintf(name, "%s Playback Volume", ctlname);
11209 if (nid == 0x14) {
11210 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11211 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11212 HDA_OUTPUT));
11213 if (err < 0)
11214 return err;
11215 } else if (nid == 0x15) {
11216 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11217 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11218 HDA_OUTPUT));
11219 if (err < 0)
11220 return err;
11221 } else
11222 return -1;
11223 sprintf(name, "%s Playback Switch", ctlname);
11224 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11225 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11226 if (err < 0)
11227 return err;
11228 return 0;
11229}
11230
11231/* add playback controls from the parsed DAC table */
11232static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11233 const struct auto_pin_cfg *cfg)
11234{
11235 hda_nid_t nid;
11236 int err;
11237
11238 spec->multiout.num_dacs = 2; /* only use one dac */
11239 spec->multiout.dac_nids = spec->private_dac_nids;
11240 spec->multiout.dac_nids[0] = 2;
11241 spec->multiout.dac_nids[1] = 3;
11242
11243 nid = cfg->line_out_pins[0];
11244 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011245 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011246
11247 nid = cfg->speaker_pins[0];
11248 if (nid == 0x1d) {
11249 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11250 "Speaker Playback Volume",
11251 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11252 if (err < 0)
11253 return err;
11254 }
11255 nid = cfg->hp_pins[0];
11256 if (nid)
11257 alc268_new_analog_output(spec, nid, "Headphone", 0);
11258
11259 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11260 if (nid == 0x16) {
11261 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11262 "Mono Playback Switch",
11263 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11264 if (err < 0)
11265 return err;
11266 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011267 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011268}
11269
11270/* create playback/capture controls for input pins */
11271static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11272 const struct auto_pin_cfg *cfg)
11273{
11274 struct hda_input_mux *imux = &spec->private_imux;
11275 int i, idx1;
11276
11277 for (i = 0; i < AUTO_PIN_LAST; i++) {
11278 switch(cfg->input_pins[i]) {
11279 case 0x18:
11280 idx1 = 0; /* Mic 1 */
11281 break;
11282 case 0x19:
11283 idx1 = 1; /* Mic 2 */
11284 break;
11285 case 0x1a:
11286 idx1 = 2; /* Line In */
11287 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011288 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011289 idx1 = 3; /* CD */
11290 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011291 case 0x12:
11292 case 0x13:
11293 idx1 = 6; /* digital mics */
11294 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011295 default:
11296 continue;
11297 }
11298 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11299 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011300 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011301 }
11302 return 0;
11303}
11304
11305static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11306{
11307 struct alc_spec *spec = codec->spec;
11308 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11309 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11310 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11311 unsigned int dac_vol1, dac_vol2;
11312
11313 if (speaker_nid) {
11314 snd_hda_codec_write(codec, speaker_nid, 0,
11315 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11316 snd_hda_codec_write(codec, 0x0f, 0,
11317 AC_VERB_SET_AMP_GAIN_MUTE,
11318 AMP_IN_UNMUTE(1));
11319 snd_hda_codec_write(codec, 0x10, 0,
11320 AC_VERB_SET_AMP_GAIN_MUTE,
11321 AMP_IN_UNMUTE(1));
11322 } else {
11323 snd_hda_codec_write(codec, 0x0f, 0,
11324 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11325 snd_hda_codec_write(codec, 0x10, 0,
11326 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11327 }
11328
11329 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011330 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011331 dac_vol2 = AMP_OUT_ZERO;
11332 else if (line_nid == 0x15)
11333 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011334 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011335 dac_vol2 = AMP_OUT_ZERO;
11336 else if (hp_nid == 0x15)
11337 dac_vol1 = AMP_OUT_ZERO;
11338 if (line_nid != 0x16 || hp_nid != 0x16 ||
11339 spec->autocfg.line_out_pins[1] != 0x16 ||
11340 spec->autocfg.line_out_pins[2] != 0x16)
11341 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11342
11343 snd_hda_codec_write(codec, 0x02, 0,
11344 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11345 snd_hda_codec_write(codec, 0x03, 0,
11346 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11347}
11348
11349/* pcm configuration: identiacal with ALC880 */
11350#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11351#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011352#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011353#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11354
11355/*
11356 * BIOS auto configuration
11357 */
11358static int alc268_parse_auto_config(struct hda_codec *codec)
11359{
11360 struct alc_spec *spec = codec->spec;
11361 int err;
11362 static hda_nid_t alc268_ignore[] = { 0 };
11363
11364 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11365 alc268_ignore);
11366 if (err < 0)
11367 return err;
11368 if (!spec->autocfg.line_outs)
11369 return 0; /* can't find valid BIOS pin config */
11370
11371 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11372 if (err < 0)
11373 return err;
11374 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11375 if (err < 0)
11376 return err;
11377
11378 spec->multiout.max_channels = 2;
11379
11380 /* digital only support output */
11381 if (spec->autocfg.dig_out_pin)
11382 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11383
Takashi Iwai603c4012008-07-30 15:01:44 +020011384 if (spec->kctls.list)
11385 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yanga361d842007-06-05 12:30:55 +020011386
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011387 if (spec->autocfg.speaker_pins[0] != 0x1d)
11388 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11389
Kailang Yanga361d842007-06-05 12:30:55 +020011390 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11391 spec->num_mux_defs = 1;
11392 spec->input_mux = &spec->private_imux;
11393
Takashi Iwai776e1842007-08-29 15:07:11 +020011394 err = alc_auto_add_mic_boost(codec);
11395 if (err < 0)
11396 return err;
11397
Kailang Yanga361d842007-06-05 12:30:55 +020011398 return 1;
11399}
11400
11401#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11402#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11403#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11404
11405/* init callback for auto-configuration model -- overriding the default init */
11406static void alc268_auto_init(struct hda_codec *codec)
11407{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011408 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011409 alc268_auto_init_multi_out(codec);
11410 alc268_auto_init_hp_out(codec);
11411 alc268_auto_init_mono_speaker_out(codec);
11412 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011413 if (spec->unsol_event)
11414 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011415}
11416
11417/*
11418 * configuration and preset
11419 */
11420static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011421 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011422 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011423 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011424 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011425 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011426 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011427 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011428#ifdef CONFIG_SND_DEBUG
11429 [ALC268_TEST] = "test",
11430#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011431 [ALC268_AUTO] = "auto",
11432};
11433
11434static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011435 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011436 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011437 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011438 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011439 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011440 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11441 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011442 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011443 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011444 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011445 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011446 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011447 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011448 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011449 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011450 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011451 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011452 {}
11453};
11454
11455static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011456 [ALC267_QUANTA_IL1] = {
11457 .mixers = { alc267_quanta_il1_mixer },
11458 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11459 alc267_quanta_il1_verbs },
11460 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11461 .dac_nids = alc268_dac_nids,
11462 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11463 .adc_nids = alc268_adc_nids_alt,
11464 .hp_nid = 0x03,
11465 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11466 .channel_mode = alc268_modes,
11467 .input_mux = &alc268_capture_source,
11468 .unsol_event = alc267_quanta_il1_unsol_event,
11469 .init_hook = alc267_quanta_il1_automute,
11470 },
Kailang Yanga361d842007-06-05 12:30:55 +020011471 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011472 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11473 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011474 .init_verbs = { alc268_base_init_verbs },
11475 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11476 .dac_nids = alc268_dac_nids,
11477 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11478 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011479 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011480 .hp_nid = 0x03,
11481 .dig_out_nid = ALC268_DIGOUT_NID,
11482 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11483 .channel_mode = alc268_modes,
11484 .input_mux = &alc268_capture_source,
11485 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011486 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011487 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11488 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011489 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11490 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011491 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11492 .dac_nids = alc268_dac_nids,
11493 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11494 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011495 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011496 .hp_nid = 0x03,
11497 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11498 .channel_mode = alc268_modes,
11499 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011500 .unsol_event = alc268_toshiba_unsol_event,
11501 .init_hook = alc268_toshiba_automute,
11502 },
11503 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011504 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11505 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011506 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11507 alc268_acer_verbs },
11508 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11509 .dac_nids = alc268_dac_nids,
11510 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11511 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011512 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011513 .hp_nid = 0x02,
11514 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11515 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011516 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011517 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011518 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011519 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011520 [ALC268_ACER_ASPIRE_ONE] = {
11521 .mixers = { alc268_acer_aspire_one_mixer,
11522 alc268_capture_alt_mixer },
11523 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11524 alc268_acer_aspire_one_verbs },
11525 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11526 .dac_nids = alc268_dac_nids,
11527 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11528 .adc_nids = alc268_adc_nids_alt,
11529 .capsrc_nids = alc268_capsrc_nids,
11530 .hp_nid = 0x03,
11531 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11532 .channel_mode = alc268_modes,
11533 .input_mux = &alc268_acer_lc_capture_source,
11534 .unsol_event = alc268_acer_lc_unsol_event,
11535 .init_hook = alc268_acer_lc_init_hook,
11536 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011537 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011538 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011539 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11540 alc268_dell_verbs },
11541 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11542 .dac_nids = alc268_dac_nids,
11543 .hp_nid = 0x02,
11544 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11545 .channel_mode = alc268_modes,
11546 .unsol_event = alc268_dell_unsol_event,
11547 .init_hook = alc268_dell_init_hook,
11548 .input_mux = &alc268_capture_source,
11549 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011550 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011551 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11552 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011553 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11554 alc268_toshiba_verbs },
11555 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11556 .dac_nids = alc268_dac_nids,
11557 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11558 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011559 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011560 .hp_nid = 0x03,
11561 .dig_out_nid = ALC268_DIGOUT_NID,
11562 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11563 .channel_mode = alc268_modes,
11564 .input_mux = &alc268_capture_source,
11565 .unsol_event = alc268_toshiba_unsol_event,
11566 .init_hook = alc268_toshiba_automute
11567 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011568#ifdef CONFIG_SND_DEBUG
11569 [ALC268_TEST] = {
11570 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11571 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11572 alc268_volume_init_verbs },
11573 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11574 .dac_nids = alc268_dac_nids,
11575 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11576 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011577 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011578 .hp_nid = 0x03,
11579 .dig_out_nid = ALC268_DIGOUT_NID,
11580 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11581 .channel_mode = alc268_modes,
11582 .input_mux = &alc268_capture_source,
11583 },
11584#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011585};
11586
11587static int patch_alc268(struct hda_codec *codec)
11588{
11589 struct alc_spec *spec;
11590 int board_config;
11591 int err;
11592
11593 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11594 if (spec == NULL)
11595 return -ENOMEM;
11596
11597 codec->spec = spec;
11598
11599 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11600 alc268_models,
11601 alc268_cfg_tbl);
11602
11603 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11604 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11605 "trying auto-probe from BIOS...\n");
11606 board_config = ALC268_AUTO;
11607 }
11608
11609 if (board_config == ALC268_AUTO) {
11610 /* automatic parse from the BIOS config */
11611 err = alc268_parse_auto_config(codec);
11612 if (err < 0) {
11613 alc_free(codec);
11614 return err;
11615 } else if (!err) {
11616 printk(KERN_INFO
11617 "hda_codec: Cannot set up configuration "
11618 "from BIOS. Using base mode...\n");
11619 board_config = ALC268_3ST;
11620 }
11621 }
11622
11623 if (board_config != ALC268_AUTO)
11624 setup_preset(spec, &alc268_presets[board_config]);
11625
Kailang Yang2f893282008-05-27 12:14:47 +020011626 if (codec->vendor_id == 0x10ec0267) {
11627 spec->stream_name_analog = "ALC267 Analog";
11628 spec->stream_name_digital = "ALC267 Digital";
11629 } else {
11630 spec->stream_name_analog = "ALC268 Analog";
11631 spec->stream_name_digital = "ALC268 Digital";
11632 }
11633
Kailang Yanga361d842007-06-05 12:30:55 +020011634 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11635 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011636 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011637
Kailang Yanga361d842007-06-05 12:30:55 +020011638 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11639
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011640 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11641 /* override the amp caps for beep generator */
11642 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11643 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11644 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11645 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11646 (0 << AC_AMPCAP_MUTE_SHIFT));
11647
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011648 if (!spec->adc_nids && spec->input_mux) {
11649 /* check whether NID 0x07 is valid */
11650 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011651 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011652
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011653 /* get type */
11654 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011655 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011656 spec->adc_nids = alc268_adc_nids_alt;
11657 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11658 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011659 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011660 spec->num_mixers++;
11661 } else {
11662 spec->adc_nids = alc268_adc_nids;
11663 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11664 spec->mixers[spec->num_mixers] =
11665 alc268_capture_mixer;
11666 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011667 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011668 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011669 /* set default input source */
11670 for (i = 0; i < spec->num_adc_nids; i++)
11671 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11672 0, AC_VERB_SET_CONNECT_SEL,
11673 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011674 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011675
11676 spec->vmaster_nid = 0x02;
11677
Kailang Yanga361d842007-06-05 12:30:55 +020011678 codec->patch_ops = alc_patch_ops;
11679 if (board_config == ALC268_AUTO)
11680 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011681
Kailang Yanga361d842007-06-05 12:30:55 +020011682 return 0;
11683}
11684
11685/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011686 * ALC269 channel source setting (2 channel)
11687 */
11688#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11689
11690#define alc269_dac_nids alc260_dac_nids
11691
11692static hda_nid_t alc269_adc_nids[1] = {
11693 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011694 0x08,
11695};
11696
Takashi Iwaie01bf502008-08-21 16:25:07 +020011697static hda_nid_t alc269_capsrc_nids[1] = {
11698 0x23,
11699};
11700
11701/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11702 * not a mux!
11703 */
11704
Kailang Yangf53281e2008-07-18 12:36:43 +020011705static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11706 .num_items = 2,
11707 .items = {
11708 { "i-Mic", 0x5 },
11709 { "e-Mic", 0x0 },
11710 },
11711};
11712
11713static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11714 .num_items = 2,
11715 .items = {
11716 { "i-Mic", 0x1 },
11717 { "e-Mic", 0x0 },
11718 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011719};
11720
11721#define alc269_modes alc260_modes
11722#define alc269_capture_source alc880_lg_lw_capture_source
11723
11724static struct snd_kcontrol_new alc269_base_mixer[] = {
11725 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11726 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11727 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11728 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011731 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11732 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11734 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11736 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11738 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11739 { } /* end */
11740};
11741
Kailang Yang60db6b52008-08-26 13:13:00 +020011742static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11743 /* output mixer control */
11744 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11745 {
11746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11747 .name = "Master Playback Switch",
11748 .info = snd_hda_mixer_amp_switch_info,
11749 .get = snd_hda_mixer_amp_switch_get,
11750 .put = alc268_acer_master_sw_put,
11751 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11752 },
11753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11755 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11756 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11757 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11759 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11760 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11761 { }
11762};
11763
Kailang Yangf53281e2008-07-18 12:36:43 +020011764/* bind volumes of both NID 0x0c and 0x0d */
11765static struct hda_bind_ctls alc269_epc_bind_vol = {
11766 .ops = &snd_hda_bind_vol,
11767 .values = {
11768 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11769 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11770 0
11771 },
11772};
11773
11774static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11775 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11776 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11777 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11778 { } /* end */
11779};
11780
Kailang Yangf6a92242007-12-13 16:52:54 +010011781/* capture mixer elements */
11782static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011783 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11784 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011785 {
11786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11787 /* The multiple "Capture Source" controls confuse alsamixer
11788 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011789 */
11790 /* .name = "Capture Source", */
11791 .name = "Input Source",
11792 .count = 1,
11793 .info = alc_mux_enum_info,
11794 .get = alc_mux_enum_get,
11795 .put = alc_mux_enum_put,
11796 },
11797 { } /* end */
11798};
11799
Kailang Yangf53281e2008-07-18 12:36:43 +020011800/* capture mixer elements */
11801static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11804 { } /* end */
11805};
11806
Takashi Iwai2005af22008-08-20 18:38:26 +020011807/* beep control */
11808static struct snd_kcontrol_new alc269_beep_mixer[] = {
11809 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11810 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11811 { } /* end */
11812};
11813
Kailang Yang60db6b52008-08-26 13:13:00 +020011814static struct hda_verb alc269_quanta_fl1_verbs[] = {
11815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11816 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11818 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11820 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11821 { }
11822};
11823
11824/* toggle speaker-output according to the hp-jack state */
11825static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11826{
11827 unsigned int present;
11828 unsigned char bits;
11829
11830 present = snd_hda_codec_read(codec, 0x15, 0,
11831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11832 bits = present ? AMP_IN_MUTE(0) : 0;
11833 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11834 AMP_IN_MUTE(0), bits);
11835 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11836 AMP_IN_MUTE(0), bits);
11837
11838 snd_hda_codec_write(codec, 0x20, 0,
11839 AC_VERB_SET_COEF_INDEX, 0x0c);
11840 snd_hda_codec_write(codec, 0x20, 0,
11841 AC_VERB_SET_PROC_COEF, 0x680);
11842
11843 snd_hda_codec_write(codec, 0x20, 0,
11844 AC_VERB_SET_COEF_INDEX, 0x0c);
11845 snd_hda_codec_write(codec, 0x20, 0,
11846 AC_VERB_SET_PROC_COEF, 0x480);
11847}
11848
11849static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11850{
11851 unsigned int present;
11852
11853 present = snd_hda_codec_read(codec, 0x18, 0,
11854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11855 snd_hda_codec_write(codec, 0x23, 0,
11856 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11857}
11858
11859static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11860 unsigned int res)
11861{
11862 if ((res >> 26) == ALC880_HP_EVENT)
11863 alc269_quanta_fl1_speaker_automute(codec);
11864 if ((res >> 26) == ALC880_MIC_EVENT)
11865 alc269_quanta_fl1_mic_automute(codec);
11866}
11867
11868static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11869{
11870 alc269_quanta_fl1_speaker_automute(codec);
11871 alc269_quanta_fl1_mic_automute(codec);
11872}
11873
11874static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11875 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11876 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11877 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11880 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11881 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11882 {}
11883};
11884
11885static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11887 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11888 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11890 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11891 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11892 {}
11893};
11894
11895/* toggle speaker-output according to the hp-jack state */
11896static void alc269_speaker_automute(struct hda_codec *codec)
11897{
11898 unsigned int present;
11899 unsigned char bits;
11900
11901 present = snd_hda_codec_read(codec, 0x15, 0,
11902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11903 bits = present ? AMP_IN_MUTE(0) : 0;
11904 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11905 AMP_IN_MUTE(0), bits);
11906 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11907 AMP_IN_MUTE(0), bits);
11908}
11909
11910static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11911{
11912 unsigned int present;
11913
11914 present = snd_hda_codec_read(codec, 0x18, 0,
11915 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11916 snd_hda_codec_write(codec, 0x23, 0,
11917 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11918}
11919
11920static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11921{
11922 unsigned int present;
11923
11924 present = snd_hda_codec_read(codec, 0x18, 0,
11925 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11926 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11927 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11928 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11929 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11930}
11931
11932/* unsolicited event for HP jack sensing */
11933static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11934 unsigned int res)
11935{
11936 if ((res >> 26) == ALC880_HP_EVENT)
11937 alc269_speaker_automute(codec);
11938
11939 if ((res >> 26) == ALC880_MIC_EVENT)
11940 alc269_eeepc_dmic_automute(codec);
11941}
11942
11943static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11944{
11945 alc269_speaker_automute(codec);
11946 alc269_eeepc_dmic_automute(codec);
11947}
11948
11949/* unsolicited event for HP jack sensing */
11950static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11951 unsigned int res)
11952{
11953 if ((res >> 26) == ALC880_HP_EVENT)
11954 alc269_speaker_automute(codec);
11955
11956 if ((res >> 26) == ALC880_MIC_EVENT)
11957 alc269_eeepc_amic_automute(codec);
11958}
11959
11960static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11961{
11962 alc269_speaker_automute(codec);
11963 alc269_eeepc_amic_automute(codec);
11964}
11965
Kailang Yangf6a92242007-12-13 16:52:54 +010011966/*
11967 * generic initialization of ADC, input mixers and output mixers
11968 */
11969static struct hda_verb alc269_init_verbs[] = {
11970 /*
11971 * Unmute ADC0 and set the default input to mic-in
11972 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011974
11975 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11976 * analog-loopback mixer widget
11977 * Note: PASD motherboards uses the Line In 2 as the input for
11978 * front panel mic (mic 2)
11979 */
11980 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11986
11987 /*
11988 * Set up output mixers (0x0c - 0x0e)
11989 */
11990 /* set vol=0 to output mixers */
11991 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11992 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11993
11994 /* set up input amps for analog loopback */
11995 /* Amp Indices: DAC = 0, mixer = 1 */
11996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12002
12003 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12007 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12008 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12009 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12010
12011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12013 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12018
12019 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12020 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12021
12022 /* FIXME: use matrix-type input source selection */
12023 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12024 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12029
12030 /* set EAPD */
12031 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12032 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12033 { }
12034};
12035
12036/* add playback controls from the parsed DAC table */
12037static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12038 const struct auto_pin_cfg *cfg)
12039{
12040 hda_nid_t nid;
12041 int err;
12042
12043 spec->multiout.num_dacs = 1; /* only use one dac */
12044 spec->multiout.dac_nids = spec->private_dac_nids;
12045 spec->multiout.dac_nids[0] = 2;
12046
12047 nid = cfg->line_out_pins[0];
12048 if (nid) {
12049 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12050 "Front Playback Volume",
12051 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12052 if (err < 0)
12053 return err;
12054 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12055 "Front Playback Switch",
12056 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12057 if (err < 0)
12058 return err;
12059 }
12060
12061 nid = cfg->speaker_pins[0];
12062 if (nid) {
12063 if (!cfg->line_out_pins[0]) {
12064 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12065 "Speaker Playback Volume",
12066 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12067 HDA_OUTPUT));
12068 if (err < 0)
12069 return err;
12070 }
12071 if (nid == 0x16) {
12072 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12073 "Speaker Playback Switch",
12074 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12075 HDA_OUTPUT));
12076 if (err < 0)
12077 return err;
12078 } else {
12079 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12080 "Speaker Playback Switch",
12081 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12082 HDA_OUTPUT));
12083 if (err < 0)
12084 return err;
12085 }
12086 }
12087 nid = cfg->hp_pins[0];
12088 if (nid) {
12089 /* spec->multiout.hp_nid = 2; */
12090 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12091 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12092 "Headphone Playback Volume",
12093 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12094 HDA_OUTPUT));
12095 if (err < 0)
12096 return err;
12097 }
12098 if (nid == 0x16) {
12099 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12100 "Headphone Playback Switch",
12101 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12102 HDA_OUTPUT));
12103 if (err < 0)
12104 return err;
12105 } else {
12106 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12107 "Headphone Playback Switch",
12108 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12109 HDA_OUTPUT));
12110 if (err < 0)
12111 return err;
12112 }
12113 }
12114 return 0;
12115}
12116
12117#define alc269_auto_create_analog_input_ctls \
12118 alc880_auto_create_analog_input_ctls
12119
12120#ifdef CONFIG_SND_HDA_POWER_SAVE
12121#define alc269_loopbacks alc880_loopbacks
12122#endif
12123
12124/* pcm configuration: identiacal with ALC880 */
12125#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12126#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12127#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12128#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12129
12130/*
12131 * BIOS auto configuration
12132 */
12133static int alc269_parse_auto_config(struct hda_codec *codec)
12134{
12135 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012136 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012137 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12138
12139 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12140 alc269_ignore);
12141 if (err < 0)
12142 return err;
12143
12144 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12145 if (err < 0)
12146 return err;
12147 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12148 if (err < 0)
12149 return err;
12150
12151 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12152
12153 if (spec->autocfg.dig_out_pin)
12154 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12155
Takashi Iwai603c4012008-07-30 15:01:44 +020012156 if (spec->kctls.list)
12157 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yangf6a92242007-12-13 16:52:54 +010012158
Takashi Iwai2005af22008-08-20 18:38:26 +020012159 /* create a beep mixer control if the pin 0x1d isn't assigned */
12160 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12161 if (spec->autocfg.input_pins[i] == 0x1d)
12162 break;
12163 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12164 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
12165
Kailang Yangf6a92242007-12-13 16:52:54 +010012166 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
12167 spec->num_mux_defs = 1;
12168 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012169 /* set default input source */
12170 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12171 0, AC_VERB_SET_CONNECT_SEL,
12172 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012173
12174 err = alc_auto_add_mic_boost(codec);
12175 if (err < 0)
12176 return err;
12177
Kailang Yangf53281e2008-07-18 12:36:43 +020012178 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
12179 spec->num_mixers++;
12180
Kailang Yangf6a92242007-12-13 16:52:54 +010012181 return 1;
12182}
12183
12184#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12185#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12186#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12187
12188
12189/* init callback for auto-configuration model -- overriding the default init */
12190static void alc269_auto_init(struct hda_codec *codec)
12191{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012192 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012193 alc269_auto_init_multi_out(codec);
12194 alc269_auto_init_hp_out(codec);
12195 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012196 if (spec->unsol_event)
12197 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012198}
12199
12200/*
12201 * configuration and preset
12202 */
12203static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012204 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012205 [ALC269_QUANTA_FL1] = "quanta",
12206 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12207 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901"
Kailang Yangf6a92242007-12-13 16:52:54 +010012208};
12209
12210static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012211 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012212 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12213 ALC269_ASUS_EEEPC_P703),
12214 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12215 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012216 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12217 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010012218 {}
12219};
12220
12221static struct alc_config_preset alc269_presets[] = {
12222 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020012223 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012224 .init_verbs = { alc269_init_verbs },
12225 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12226 .dac_nids = alc269_dac_nids,
12227 .hp_nid = 0x03,
12228 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12229 .channel_mode = alc269_modes,
12230 .input_mux = &alc269_capture_source,
12231 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012232 [ALC269_QUANTA_FL1] = {
12233 .mixers = { alc269_quanta_fl1_mixer },
12234 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12235 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12236 .dac_nids = alc269_dac_nids,
12237 .hp_nid = 0x03,
12238 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12239 .channel_mode = alc269_modes,
12240 .input_mux = &alc269_capture_source,
12241 .unsol_event = alc269_quanta_fl1_unsol_event,
12242 .init_hook = alc269_quanta_fl1_init_hook,
12243 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012244 [ALC269_ASUS_EEEPC_P703] = {
12245 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
12246 .init_verbs = { alc269_init_verbs,
12247 alc269_eeepc_amic_init_verbs },
12248 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12249 .dac_nids = alc269_dac_nids,
12250 .hp_nid = 0x03,
12251 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12252 .channel_mode = alc269_modes,
12253 .input_mux = &alc269_eeepc_amic_capture_source,
12254 .unsol_event = alc269_eeepc_amic_unsol_event,
12255 .init_hook = alc269_eeepc_amic_inithook,
12256 },
12257 [ALC269_ASUS_EEEPC_P901] = {
12258 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
12259 .init_verbs = { alc269_init_verbs,
12260 alc269_eeepc_dmic_init_verbs },
12261 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12262 .dac_nids = alc269_dac_nids,
12263 .hp_nid = 0x03,
12264 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12265 .channel_mode = alc269_modes,
12266 .input_mux = &alc269_eeepc_dmic_capture_source,
12267 .unsol_event = alc269_eeepc_dmic_unsol_event,
12268 .init_hook = alc269_eeepc_dmic_inithook,
12269 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012270};
12271
12272static int patch_alc269(struct hda_codec *codec)
12273{
12274 struct alc_spec *spec;
12275 int board_config;
12276 int err;
12277
12278 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12279 if (spec == NULL)
12280 return -ENOMEM;
12281
12282 codec->spec = spec;
12283
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012284 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12285
Kailang Yangf6a92242007-12-13 16:52:54 +010012286 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12287 alc269_models,
12288 alc269_cfg_tbl);
12289
12290 if (board_config < 0) {
12291 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12292 "trying auto-probe from BIOS...\n");
12293 board_config = ALC269_AUTO;
12294 }
12295
12296 if (board_config == ALC269_AUTO) {
12297 /* automatic parse from the BIOS config */
12298 err = alc269_parse_auto_config(codec);
12299 if (err < 0) {
12300 alc_free(codec);
12301 return err;
12302 } else if (!err) {
12303 printk(KERN_INFO
12304 "hda_codec: Cannot set up configuration "
12305 "from BIOS. Using base mode...\n");
12306 board_config = ALC269_BASIC;
12307 }
12308 }
12309
12310 if (board_config != ALC269_AUTO)
12311 setup_preset(spec, &alc269_presets[board_config]);
12312
12313 spec->stream_name_analog = "ALC269 Analog";
12314 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12315 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12316
12317 spec->stream_name_digital = "ALC269 Digital";
12318 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12319 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12320
12321 spec->adc_nids = alc269_adc_nids;
12322 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012323 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010012324
12325 codec->patch_ops = alc_patch_ops;
12326 if (board_config == ALC269_AUTO)
12327 spec->init_hook = alc269_auto_init;
12328#ifdef CONFIG_SND_HDA_POWER_SAVE
12329 if (!spec->loopback.amplist)
12330 spec->loopback.amplist = alc269_loopbacks;
12331#endif
12332
12333 return 0;
12334}
12335
12336/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012337 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12338 */
12339
12340/*
12341 * set the path ways for 2 channel output
12342 * need to set the codec line out and mic 1 pin widgets to inputs
12343 */
12344static struct hda_verb alc861_threestack_ch2_init[] = {
12345 /* set pin widget 1Ah (line in) for input */
12346 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012347 /* set pin widget 18h (mic1/2) for input, for mic also enable
12348 * the vref
12349 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012350 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12351
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012352 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12353#if 0
12354 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12355 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12356#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012357 { } /* end */
12358};
12359/*
12360 * 6ch mode
12361 * need to set the codec line out and mic 1 pin widgets to outputs
12362 */
12363static struct hda_verb alc861_threestack_ch6_init[] = {
12364 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12365 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12366 /* set pin widget 18h (mic1) for output (CLFE)*/
12367 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12368
12369 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012370 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012371
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012372 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12373#if 0
12374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12375 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12376#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012377 { } /* end */
12378};
12379
12380static struct hda_channel_mode alc861_threestack_modes[2] = {
12381 { 2, alc861_threestack_ch2_init },
12382 { 6, alc861_threestack_ch6_init },
12383};
Takashi Iwai22309c32006-08-09 16:57:28 +020012384/* Set mic1 as input and unmute the mixer */
12385static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12386 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12388 { } /* end */
12389};
12390/* Set mic1 as output and mute mixer */
12391static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12392 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12393 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12394 { } /* end */
12395};
12396
12397static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12398 { 2, alc861_uniwill_m31_ch2_init },
12399 { 4, alc861_uniwill_m31_ch4_init },
12400};
Kailang Yangdf694da2005-12-05 19:42:22 +010012401
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012402/* Set mic1 and line-in as input and unmute the mixer */
12403static struct hda_verb alc861_asus_ch2_init[] = {
12404 /* set pin widget 1Ah (line in) for input */
12405 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012406 /* set pin widget 18h (mic1/2) for input, for mic also enable
12407 * the vref
12408 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012409 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12410
12411 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12412#if 0
12413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12414 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12415#endif
12416 { } /* end */
12417};
12418/* Set mic1 nad line-in as output and mute mixer */
12419static struct hda_verb alc861_asus_ch6_init[] = {
12420 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12421 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12422 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12423 /* set pin widget 18h (mic1) for output (CLFE)*/
12424 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12425 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12426 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12427 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12428
12429 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12430#if 0
12431 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12432 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12433#endif
12434 { } /* end */
12435};
12436
12437static struct hda_channel_mode alc861_asus_modes[2] = {
12438 { 2, alc861_asus_ch2_init },
12439 { 6, alc861_asus_ch6_init },
12440};
12441
Kailang Yangdf694da2005-12-05 19:42:22 +010012442/* patch-ALC861 */
12443
12444static struct snd_kcontrol_new alc861_base_mixer[] = {
12445 /* output mixer control */
12446 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12447 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12448 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12449 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12450 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12451
12452 /*Input mixer control */
12453 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12454 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12455 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12456 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12457 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12458 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12460 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012463
Kailang Yangdf694da2005-12-05 19:42:22 +010012464 /* Capture mixer control */
12465 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12466 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12467 {
12468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12469 .name = "Capture Source",
12470 .count = 1,
12471 .info = alc_mux_enum_info,
12472 .get = alc_mux_enum_get,
12473 .put = alc_mux_enum_put,
12474 },
12475 { } /* end */
12476};
12477
12478static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12479 /* output mixer control */
12480 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12481 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12482 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12483 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12484 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12485
12486 /* Input mixer control */
12487 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12488 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12489 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12490 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12491 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12492 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12494 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012497
Kailang Yangdf694da2005-12-05 19:42:22 +010012498 /* Capture mixer control */
12499 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12500 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12501 {
12502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12503 .name = "Capture Source",
12504 .count = 1,
12505 .info = alc_mux_enum_info,
12506 .get = alc_mux_enum_get,
12507 .put = alc_mux_enum_put,
12508 },
12509 {
12510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12511 .name = "Channel Mode",
12512 .info = alc_ch_mode_info,
12513 .get = alc_ch_mode_get,
12514 .put = alc_ch_mode_put,
12515 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12516 },
12517 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012518};
12519
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012520static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012521 /* output mixer control */
12522 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12524 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012525
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012526 /*Capture mixer control */
12527 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12528 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12529 {
12530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12531 .name = "Capture Source",
12532 .count = 1,
12533 .info = alc_mux_enum_info,
12534 .get = alc_mux_enum_get,
12535 .put = alc_mux_enum_put,
12536 },
12537
12538 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012539};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012540
Takashi Iwai22309c32006-08-09 16:57:28 +020012541static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12542 /* output mixer control */
12543 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12544 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12545 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12546 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12547 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12548
12549 /* Input mixer control */
12550 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12551 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12552 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12553 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12554 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12555 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12557 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012560
Takashi Iwai22309c32006-08-09 16:57:28 +020012561 /* Capture mixer control */
12562 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12563 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12564 {
12565 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12566 .name = "Capture Source",
12567 .count = 1,
12568 .info = alc_mux_enum_info,
12569 .get = alc_mux_enum_get,
12570 .put = alc_mux_enum_put,
12571 },
12572 {
12573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12574 .name = "Channel Mode",
12575 .info = alc_ch_mode_info,
12576 .get = alc_ch_mode_get,
12577 .put = alc_ch_mode_put,
12578 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12579 },
12580 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012581};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012582
12583static struct snd_kcontrol_new alc861_asus_mixer[] = {
12584 /* output mixer control */
12585 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12586 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12587 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12588 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12589 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12590
12591 /* Input mixer control */
12592 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12593 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12594 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12595 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12596 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12597 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12599 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12602
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012603 /* Capture mixer control */
12604 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12605 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12606 {
12607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12608 .name = "Capture Source",
12609 .count = 1,
12610 .info = alc_mux_enum_info,
12611 .get = alc_mux_enum_get,
12612 .put = alc_mux_enum_put,
12613 },
12614 {
12615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12616 .name = "Channel Mode",
12617 .info = alc_ch_mode_info,
12618 .get = alc_ch_mode_get,
12619 .put = alc_ch_mode_put,
12620 .private_value = ARRAY_SIZE(alc861_asus_modes),
12621 },
12622 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012623};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012624
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012625/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012626static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012627 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12628 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12629 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12630 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12631 { }
12632};
12633
Kailang Yangdf694da2005-12-05 19:42:22 +010012634/*
12635 * generic initialization of ADC, input mixers and output mixers
12636 */
12637static struct hda_verb alc861_base_init_verbs[] = {
12638 /*
12639 * Unmute ADC0 and set the default input to mic-in
12640 */
12641 /* port-A for surround (rear panel) */
12642 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12643 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12644 /* port-B for mic-in (rear panel) with vref */
12645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12646 /* port-C for line-in (rear panel) */
12647 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12648 /* port-D for Front */
12649 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12650 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12651 /* port-E for HP out (front panel) */
12652 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12653 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012654 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012655 /* port-F for mic-in (front panel) with vref */
12656 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12657 /* port-G for CLFE (rear panel) */
12658 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12659 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12660 /* port-H for side (rear panel) */
12661 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12662 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12663 /* CD-in */
12664 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12665 /* route front mic to ADC1*/
12666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012668
Kailang Yangdf694da2005-12-05 19:42:22 +010012669 /* Unmute DAC0~3 & spdif out*/
12670 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12671 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12672 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12673 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012675
Kailang Yangdf694da2005-12-05 19:42:22 +010012676 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12677 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12678 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12679 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12680 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012681
Kailang Yangdf694da2005-12-05 19:42:22 +010012682 /* Unmute Stereo Mixer 15 */
12683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012687
12688 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12689 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12690 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12691 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12692 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12694 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012696 /* hp used DAC 3 (Front) */
12697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12699
12700 { }
12701};
12702
12703static struct hda_verb alc861_threestack_init_verbs[] = {
12704 /*
12705 * Unmute ADC0 and set the default input to mic-in
12706 */
12707 /* port-A for surround (rear panel) */
12708 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12709 /* port-B for mic-in (rear panel) with vref */
12710 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12711 /* port-C for line-in (rear panel) */
12712 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12713 /* port-D for Front */
12714 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12715 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12716 /* port-E for HP out (front panel) */
12717 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12718 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012719 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012720 /* port-F for mic-in (front panel) with vref */
12721 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12722 /* port-G for CLFE (rear panel) */
12723 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12724 /* port-H for side (rear panel) */
12725 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12726 /* CD-in */
12727 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12728 /* route front mic to ADC1*/
12729 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12731 /* Unmute DAC0~3 & spdif out*/
12732 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12733 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12734 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12735 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012737
Kailang Yangdf694da2005-12-05 19:42:22 +010012738 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12739 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12740 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12741 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12742 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012743
Kailang Yangdf694da2005-12-05 19:42:22 +010012744 /* Unmute Stereo Mixer 15 */
12745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012749
12750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12752 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12756 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012758 /* hp used DAC 3 (Front) */
12759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12761 { }
12762};
Takashi Iwai22309c32006-08-09 16:57:28 +020012763
12764static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12765 /*
12766 * Unmute ADC0 and set the default input to mic-in
12767 */
12768 /* port-A for surround (rear panel) */
12769 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12770 /* port-B for mic-in (rear panel) with vref */
12771 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12772 /* port-C for line-in (rear panel) */
12773 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12774 /* port-D for Front */
12775 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12776 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12777 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012778 /* this has to be set to VREF80 */
12779 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012780 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012781 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012782 /* port-F for mic-in (front panel) with vref */
12783 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12784 /* port-G for CLFE (rear panel) */
12785 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12786 /* port-H for side (rear panel) */
12787 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12788 /* CD-in */
12789 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12790 /* route front mic to ADC1*/
12791 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12793 /* Unmute DAC0~3 & spdif out*/
12794 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12795 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12796 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12797 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012799
Takashi Iwai22309c32006-08-09 16:57:28 +020012800 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12801 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12802 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12803 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12804 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012805
Takashi Iwai22309c32006-08-09 16:57:28 +020012806 /* Unmute Stereo Mixer 15 */
12807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012811
12812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12813 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012820 /* hp used DAC 3 (Front) */
12821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12823 { }
12824};
12825
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012826static struct hda_verb alc861_asus_init_verbs[] = {
12827 /*
12828 * Unmute ADC0 and set the default input to mic-in
12829 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012830 /* port-A for surround (rear panel)
12831 * according to codec#0 this is the HP jack
12832 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012833 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12834 /* route front PCM to HP */
12835 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12836 /* port-B for mic-in (rear panel) with vref */
12837 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12838 /* port-C for line-in (rear panel) */
12839 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12840 /* port-D for Front */
12841 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12842 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12843 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012844 /* this has to be set to VREF80 */
12845 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012846 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012847 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012848 /* port-F for mic-in (front panel) with vref */
12849 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12850 /* port-G for CLFE (rear panel) */
12851 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12852 /* port-H for side (rear panel) */
12853 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12854 /* CD-in */
12855 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12856 /* route front mic to ADC1*/
12857 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12859 /* Unmute DAC0~3 & spdif out*/
12860 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12862 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12863 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12865 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12866 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12867 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12868 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12869 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012870
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012871 /* Unmute Stereo Mixer 15 */
12872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012876
12877 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12878 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12881 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12882 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12883 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012885 /* hp used DAC 3 (Front) */
12886 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12888 { }
12889};
12890
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012891/* additional init verbs for ASUS laptops */
12892static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12893 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12894 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12895 { }
12896};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012897
Kailang Yangdf694da2005-12-05 19:42:22 +010012898/*
12899 * generic initialization of ADC, input mixers and output mixers
12900 */
12901static struct hda_verb alc861_auto_init_verbs[] = {
12902 /*
12903 * Unmute ADC0 and set the default input to mic-in
12904 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012905 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012907
Kailang Yangdf694da2005-12-05 19:42:22 +010012908 /* Unmute DAC0~3 & spdif out*/
12909 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12910 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12911 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12912 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012914
Kailang Yangdf694da2005-12-05 19:42:22 +010012915 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12916 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12917 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12918 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12919 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012920
Kailang Yangdf694da2005-12-05 19:42:22 +010012921 /* Unmute Stereo Mixer 15 */
12922 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12926
12927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12929 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12931 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12932 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12933 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12934 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12935
12936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12937 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012940 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12941 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012942 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012944
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012945 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012946
12947 { }
12948};
12949
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012950static struct hda_verb alc861_toshiba_init_verbs[] = {
12951 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012952
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012953 { }
12954};
12955
12956/* toggle speaker-output according to the hp-jack state */
12957static void alc861_toshiba_automute(struct hda_codec *codec)
12958{
12959 unsigned int present;
12960
12961 present = snd_hda_codec_read(codec, 0x0f, 0,
12962 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012963 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12964 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12965 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12966 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012967}
12968
12969static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12970 unsigned int res)
12971{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012972 if ((res >> 26) == ALC880_HP_EVENT)
12973 alc861_toshiba_automute(codec);
12974}
12975
Kailang Yangdf694da2005-12-05 19:42:22 +010012976/* pcm configuration: identiacal with ALC880 */
12977#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12978#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12979#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12980#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12981
12982
12983#define ALC861_DIGOUT_NID 0x07
12984
12985static struct hda_channel_mode alc861_8ch_modes[1] = {
12986 { 8, NULL }
12987};
12988
12989static hda_nid_t alc861_dac_nids[4] = {
12990 /* front, surround, clfe, side */
12991 0x03, 0x06, 0x05, 0x04
12992};
12993
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012994static hda_nid_t alc660_dac_nids[3] = {
12995 /* front, clfe, surround */
12996 0x03, 0x05, 0x06
12997};
12998
Kailang Yangdf694da2005-12-05 19:42:22 +010012999static hda_nid_t alc861_adc_nids[1] = {
13000 /* ADC0-2 */
13001 0x08,
13002};
13003
13004static struct hda_input_mux alc861_capture_source = {
13005 .num_items = 5,
13006 .items = {
13007 { "Mic", 0x0 },
13008 { "Front Mic", 0x3 },
13009 { "Line", 0x1 },
13010 { "CD", 0x4 },
13011 { "Mixer", 0x5 },
13012 },
13013};
13014
13015/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013016static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13017 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013018{
13019 int i;
13020 hda_nid_t nid;
13021
13022 spec->multiout.dac_nids = spec->private_dac_nids;
13023 for (i = 0; i < cfg->line_outs; i++) {
13024 nid = cfg->line_out_pins[i];
13025 if (nid) {
13026 if (i >= ARRAY_SIZE(alc861_dac_nids))
13027 continue;
13028 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13029 }
13030 }
13031 spec->multiout.num_dacs = cfg->line_outs;
13032 return 0;
13033}
13034
13035/* add playback controls from the parsed DAC table */
13036static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13037 const struct auto_pin_cfg *cfg)
13038{
13039 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013040 static const char *chname[4] = {
13041 "Front", "Surround", NULL /*CLFE*/, "Side"
13042 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013043 hda_nid_t nid;
13044 int i, idx, err;
13045
13046 for (i = 0; i < cfg->line_outs; i++) {
13047 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013048 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013049 continue;
13050 if (nid == 0x05) {
13051 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013052 err = add_control(spec, ALC_CTL_BIND_MUTE,
13053 "Center Playback Switch",
13054 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13055 HDA_OUTPUT));
13056 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013057 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013058 err = add_control(spec, ALC_CTL_BIND_MUTE,
13059 "LFE Playback Switch",
13060 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13061 HDA_OUTPUT));
13062 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013063 return err;
13064 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013065 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13066 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013067 if (nid == alc861_dac_nids[idx])
13068 break;
13069 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013070 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13071 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13072 HDA_OUTPUT));
13073 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013074 return err;
13075 }
13076 }
13077 return 0;
13078}
13079
13080static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13081{
13082 int err;
13083 hda_nid_t nid;
13084
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013085 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013086 return 0;
13087
13088 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13089 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013090 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13091 "Headphone Playback Switch",
13092 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13093 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013094 return err;
13095 spec->multiout.hp_nid = nid;
13096 }
13097 return 0;
13098}
13099
13100/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013101static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13102 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013103{
Kailang Yangdf694da2005-12-05 19:42:22 +010013104 struct hda_input_mux *imux = &spec->private_imux;
13105 int i, err, idx, idx1;
13106
13107 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013108 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013109 case 0x0c:
13110 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013111 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013112 break;
13113 case 0x0f:
13114 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013115 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013116 break;
13117 case 0x0d:
13118 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013119 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013120 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013121 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013122 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013123 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013124 break;
13125 case 0x11:
13126 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013127 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013128 break;
13129 default:
13130 continue;
13131 }
13132
Takashi Iwai4a471b72005-12-07 13:56:29 +010013133 err = new_analog_input(spec, cfg->input_pins[i],
13134 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013135 if (err < 0)
13136 return err;
13137
Takashi Iwai4a471b72005-12-07 13:56:29 +010013138 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013139 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013140 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013141 }
13142 return 0;
13143}
13144
13145static struct snd_kcontrol_new alc861_capture_mixer[] = {
13146 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13147 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13148
13149 {
13150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13151 /* The multiple "Capture Source" controls confuse alsamixer
13152 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010013153 */
13154 /* .name = "Capture Source", */
13155 .name = "Input Source",
13156 .count = 1,
13157 .info = alc_mux_enum_info,
13158 .get = alc_mux_enum_get,
13159 .put = alc_mux_enum_put,
13160 },
13161 { } /* end */
13162};
13163
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013164static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13165 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013166 int pin_type, int dac_idx)
13167{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013168 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13169 pin_type);
13170 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13171 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013172}
13173
13174static void alc861_auto_init_multi_out(struct hda_codec *codec)
13175{
13176 struct alc_spec *spec = codec->spec;
13177 int i;
13178
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013179 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013180 for (i = 0; i < spec->autocfg.line_outs; i++) {
13181 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013182 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013183 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013184 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013185 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013186 }
13187}
13188
13189static void alc861_auto_init_hp_out(struct hda_codec *codec)
13190{
13191 struct alc_spec *spec = codec->spec;
13192 hda_nid_t pin;
13193
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013194 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013195 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013196 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13197 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013198 pin = spec->autocfg.speaker_pins[0];
13199 if (pin)
13200 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013201}
13202
13203static void alc861_auto_init_analog_input(struct hda_codec *codec)
13204{
13205 struct alc_spec *spec = codec->spec;
13206 int i;
13207
13208 for (i = 0; i < AUTO_PIN_LAST; i++) {
13209 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210 if (nid >= 0x0c && nid <= 0x11) {
13211 snd_hda_codec_write(codec, nid, 0,
13212 AC_VERB_SET_PIN_WIDGET_CONTROL,
13213 i <= AUTO_PIN_FRONT_MIC ?
13214 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013215 }
13216 }
13217}
13218
13219/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013220/* return 1 if successful, 0 if the proper config is not found,
13221 * or a negative error code
13222 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013223static int alc861_parse_auto_config(struct hda_codec *codec)
13224{
13225 struct alc_spec *spec = codec->spec;
13226 int err;
13227 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13228
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013229 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13230 alc861_ignore);
13231 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013232 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013233 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013234 return 0; /* can't find valid BIOS pin config */
13235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013236 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13237 if (err < 0)
13238 return err;
13239 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13240 if (err < 0)
13241 return err;
13242 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13243 if (err < 0)
13244 return err;
13245 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13246 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013247 return err;
13248
13249 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13250
13251 if (spec->autocfg.dig_out_pin)
13252 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13253
Takashi Iwai603c4012008-07-30 15:01:44 +020013254 if (spec->kctls.list)
13255 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yangdf694da2005-12-05 19:42:22 +010013256
13257 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
13258
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013259 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013260 spec->input_mux = &spec->private_imux;
13261
13262 spec->adc_nids = alc861_adc_nids;
13263 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13264 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
13265 spec->num_mixers++;
13266
13267 return 1;
13268}
13269
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013270/* additional initialization for auto-configuration model */
13271static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013272{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013273 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013274 alc861_auto_init_multi_out(codec);
13275 alc861_auto_init_hp_out(codec);
13276 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013277 if (spec->unsol_event)
13278 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013279}
13280
Takashi Iwaicb53c622007-08-10 17:21:45 +020013281#ifdef CONFIG_SND_HDA_POWER_SAVE
13282static struct hda_amp_list alc861_loopbacks[] = {
13283 { 0x15, HDA_INPUT, 0 },
13284 { 0x15, HDA_INPUT, 1 },
13285 { 0x15, HDA_INPUT, 2 },
13286 { 0x15, HDA_INPUT, 3 },
13287 { } /* end */
13288};
13289#endif
13290
Kailang Yangdf694da2005-12-05 19:42:22 +010013291
13292/*
13293 * configuration and preset
13294 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013295static const char *alc861_models[ALC861_MODEL_LAST] = {
13296 [ALC861_3ST] = "3stack",
13297 [ALC660_3ST] = "3stack-660",
13298 [ALC861_3ST_DIG] = "3stack-dig",
13299 [ALC861_6ST_DIG] = "6stack-dig",
13300 [ALC861_UNIWILL_M31] = "uniwill-m31",
13301 [ALC861_TOSHIBA] = "toshiba",
13302 [ALC861_ASUS] = "asus",
13303 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13304 [ALC861_AUTO] = "auto",
13305};
13306
13307static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013308 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013309 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13310 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13311 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013312 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013313 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013314 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013315 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13316 * Any other models that need this preset?
13317 */
13318 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013319 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13320 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013321 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13322 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13323 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13324 /* FIXME: the below seems conflict */
13325 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13326 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13327 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013328 {}
13329};
13330
13331static struct alc_config_preset alc861_presets[] = {
13332 [ALC861_3ST] = {
13333 .mixers = { alc861_3ST_mixer },
13334 .init_verbs = { alc861_threestack_init_verbs },
13335 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13336 .dac_nids = alc861_dac_nids,
13337 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13338 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013339 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013340 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13341 .adc_nids = alc861_adc_nids,
13342 .input_mux = &alc861_capture_source,
13343 },
13344 [ALC861_3ST_DIG] = {
13345 .mixers = { alc861_base_mixer },
13346 .init_verbs = { alc861_threestack_init_verbs },
13347 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13348 .dac_nids = alc861_dac_nids,
13349 .dig_out_nid = ALC861_DIGOUT_NID,
13350 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13351 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013352 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013353 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13354 .adc_nids = alc861_adc_nids,
13355 .input_mux = &alc861_capture_source,
13356 },
13357 [ALC861_6ST_DIG] = {
13358 .mixers = { alc861_base_mixer },
13359 .init_verbs = { alc861_base_init_verbs },
13360 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13361 .dac_nids = alc861_dac_nids,
13362 .dig_out_nid = ALC861_DIGOUT_NID,
13363 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13364 .channel_mode = alc861_8ch_modes,
13365 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13366 .adc_nids = alc861_adc_nids,
13367 .input_mux = &alc861_capture_source,
13368 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013369 [ALC660_3ST] = {
13370 .mixers = { alc861_3ST_mixer },
13371 .init_verbs = { alc861_threestack_init_verbs },
13372 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13373 .dac_nids = alc660_dac_nids,
13374 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13375 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013376 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013377 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13378 .adc_nids = alc861_adc_nids,
13379 .input_mux = &alc861_capture_source,
13380 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013381 [ALC861_UNIWILL_M31] = {
13382 .mixers = { alc861_uniwill_m31_mixer },
13383 .init_verbs = { alc861_uniwill_m31_init_verbs },
13384 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13385 .dac_nids = alc861_dac_nids,
13386 .dig_out_nid = ALC861_DIGOUT_NID,
13387 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13388 .channel_mode = alc861_uniwill_m31_modes,
13389 .need_dac_fix = 1,
13390 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13391 .adc_nids = alc861_adc_nids,
13392 .input_mux = &alc861_capture_source,
13393 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013394 [ALC861_TOSHIBA] = {
13395 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013396 .init_verbs = { alc861_base_init_verbs,
13397 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013398 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13399 .dac_nids = alc861_dac_nids,
13400 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13401 .channel_mode = alc883_3ST_2ch_modes,
13402 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13403 .adc_nids = alc861_adc_nids,
13404 .input_mux = &alc861_capture_source,
13405 .unsol_event = alc861_toshiba_unsol_event,
13406 .init_hook = alc861_toshiba_automute,
13407 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013408 [ALC861_ASUS] = {
13409 .mixers = { alc861_asus_mixer },
13410 .init_verbs = { alc861_asus_init_verbs },
13411 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13412 .dac_nids = alc861_dac_nids,
13413 .dig_out_nid = ALC861_DIGOUT_NID,
13414 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13415 .channel_mode = alc861_asus_modes,
13416 .need_dac_fix = 1,
13417 .hp_nid = 0x06,
13418 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13419 .adc_nids = alc861_adc_nids,
13420 .input_mux = &alc861_capture_source,
13421 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013422 [ALC861_ASUS_LAPTOP] = {
13423 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13424 .init_verbs = { alc861_asus_init_verbs,
13425 alc861_asus_laptop_init_verbs },
13426 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13427 .dac_nids = alc861_dac_nids,
13428 .dig_out_nid = ALC861_DIGOUT_NID,
13429 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13430 .channel_mode = alc883_3ST_2ch_modes,
13431 .need_dac_fix = 1,
13432 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13433 .adc_nids = alc861_adc_nids,
13434 .input_mux = &alc861_capture_source,
13435 },
13436};
Kailang Yangdf694da2005-12-05 19:42:22 +010013437
13438
13439static int patch_alc861(struct hda_codec *codec)
13440{
13441 struct alc_spec *spec;
13442 int board_config;
13443 int err;
13444
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013445 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013446 if (spec == NULL)
13447 return -ENOMEM;
13448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013449 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013450
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013451 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13452 alc861_models,
13453 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013454
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013455 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013456 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13457 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013458 board_config = ALC861_AUTO;
13459 }
13460
13461 if (board_config == ALC861_AUTO) {
13462 /* automatic parse from the BIOS config */
13463 err = alc861_parse_auto_config(codec);
13464 if (err < 0) {
13465 alc_free(codec);
13466 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013467 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013468 printk(KERN_INFO
13469 "hda_codec: Cannot set up configuration "
13470 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013471 board_config = ALC861_3ST_DIG;
13472 }
13473 }
13474
13475 if (board_config != ALC861_AUTO)
13476 setup_preset(spec, &alc861_presets[board_config]);
13477
13478 spec->stream_name_analog = "ALC861 Analog";
13479 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13480 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13481
13482 spec->stream_name_digital = "ALC861 Digital";
13483 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13484 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13485
Takashi Iwai2134ea42008-01-10 16:53:55 +010013486 spec->vmaster_nid = 0x03;
13487
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 codec->patch_ops = alc_patch_ops;
13489 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013490 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013491#ifdef CONFIG_SND_HDA_POWER_SAVE
13492 if (!spec->loopback.amplist)
13493 spec->loopback.amplist = alc861_loopbacks;
13494#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013495
Kailang Yangdf694da2005-12-05 19:42:22 +010013496 return 0;
13497}
13498
13499/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013500 * ALC861-VD support
13501 *
13502 * Based on ALC882
13503 *
13504 * In addition, an independent DAC
13505 */
13506#define ALC861VD_DIGOUT_NID 0x06
13507
13508static hda_nid_t alc861vd_dac_nids[4] = {
13509 /* front, surr, clfe, side surr */
13510 0x02, 0x03, 0x04, 0x05
13511};
13512
13513/* dac_nids for ALC660vd are in a different order - according to
13514 * Realtek's driver.
13515 * This should probably tesult in a different mixer for 6stack models
13516 * of ALC660vd codecs, but for now there is only 3stack mixer
13517 * - and it is the same as in 861vd.
13518 * adc_nids in ALC660vd are (is) the same as in 861vd
13519 */
13520static hda_nid_t alc660vd_dac_nids[3] = {
13521 /* front, rear, clfe, rear_surr */
13522 0x02, 0x04, 0x03
13523};
13524
13525static hda_nid_t alc861vd_adc_nids[1] = {
13526 /* ADC0 */
13527 0x09,
13528};
13529
Takashi Iwaie1406342008-02-11 18:32:32 +010013530static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13531
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013532/* input MUX */
13533/* FIXME: should be a matrix-type input source selection */
13534static struct hda_input_mux alc861vd_capture_source = {
13535 .num_items = 4,
13536 .items = {
13537 { "Mic", 0x0 },
13538 { "Front Mic", 0x1 },
13539 { "Line", 0x2 },
13540 { "CD", 0x4 },
13541 },
13542};
13543
Kailang Yang272a5272007-05-14 11:00:38 +020013544static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013545 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013546 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013547 { "Ext Mic", 0x0 },
13548 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013549 },
13550};
13551
Kailang Yangd1a991a2007-08-15 16:21:59 +020013552static struct hda_input_mux alc861vd_hp_capture_source = {
13553 .num_items = 2,
13554 .items = {
13555 { "Front Mic", 0x0 },
13556 { "ATAPI Mic", 0x1 },
13557 },
13558};
13559
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013560#define alc861vd_mux_enum_info alc_mux_enum_info
13561#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013562/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13563#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013564
13565/*
13566 * 2ch mode
13567 */
13568static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13569 { 2, NULL }
13570};
13571
13572/*
13573 * 6ch mode
13574 */
13575static struct hda_verb alc861vd_6stack_ch6_init[] = {
13576 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13577 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13578 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13579 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13580 { } /* end */
13581};
13582
13583/*
13584 * 8ch mode
13585 */
13586static struct hda_verb alc861vd_6stack_ch8_init[] = {
13587 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13588 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13589 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13591 { } /* end */
13592};
13593
13594static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13595 { 6, alc861vd_6stack_ch6_init },
13596 { 8, alc861vd_6stack_ch8_init },
13597};
13598
13599static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13600 {
13601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13602 .name = "Channel Mode",
13603 .info = alc_ch_mode_info,
13604 .get = alc_ch_mode_get,
13605 .put = alc_ch_mode_put,
13606 },
13607 { } /* end */
13608};
13609
13610static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13611 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13612 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13613
13614 {
13615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13616 /* The multiple "Capture Source" controls confuse alsamixer
13617 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013618 */
13619 /* .name = "Capture Source", */
13620 .name = "Input Source",
13621 .count = 1,
13622 .info = alc861vd_mux_enum_info,
13623 .get = alc861vd_mux_enum_get,
13624 .put = alc861vd_mux_enum_put,
13625 },
13626 { } /* end */
13627};
13628
13629/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13630 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13631 */
13632static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13633 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13634 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13635
13636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13637 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13638
13639 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13640 HDA_OUTPUT),
13641 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13642 HDA_OUTPUT),
13643 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13644 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13645
13646 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13647 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13648
13649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13650
13651 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13654
13655 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13656 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13657 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13658
13659 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13660 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13661
13662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13664
13665 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13666 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13667
13668 { } /* end */
13669};
13670
13671static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13672 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13674
13675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13676
13677 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13680
13681 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13682 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13683 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13684
13685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13687
13688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13690
13691 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13692 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13693
13694 { } /* end */
13695};
13696
Kailang Yangbdd148a2007-05-08 15:19:08 +020013697static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13698 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13699 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13700 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13701
13702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13703
13704 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13707
13708 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13711
13712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13714
13715 { } /* end */
13716};
13717
Tobin Davisb419f342008-03-07 11:57:51 +010013718/* Pin assignment: Speaker=0x14, HP = 0x15,
13719 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013720 */
13721static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013722 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13723 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13725 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013726 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13727 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13728 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13729 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13730 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13731 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13732 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13733 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013734 { } /* end */
13735};
13736
Kailang Yangd1a991a2007-08-15 16:21:59 +020013737/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13738 * Front Mic=0x18, ATAPI Mic = 0x19,
13739 */
13740static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13741 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13742 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13743 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13744 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13747 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13748 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013749
Kailang Yangd1a991a2007-08-15 16:21:59 +020013750 { } /* end */
13751};
13752
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013753/*
13754 * generic initialization of ADC, input mixers and output mixers
13755 */
13756static struct hda_verb alc861vd_volume_init_verbs[] = {
13757 /*
13758 * Unmute ADC0 and set the default input to mic-in
13759 */
13760 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13762
13763 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13764 * the analog-loopback mixer widget
13765 */
13766 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013772
13773 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013778
13779 /*
13780 * Set up output mixers (0x02 - 0x05)
13781 */
13782 /* set vol=0 to output mixers */
13783 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13784 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13785 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13786 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13787
13788 /* set up input amps for analog loopback */
13789 /* Amp Indices: DAC = 0, mixer = 1 */
13790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13798
13799 { }
13800};
13801
13802/*
13803 * 3-stack pin configuration:
13804 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13805 */
13806static struct hda_verb alc861vd_3stack_init_verbs[] = {
13807 /*
13808 * Set pin mode and muting
13809 */
13810 /* set front pin widgets 0x14 for output */
13811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13813 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13814
13815 /* Mic (rear) pin: input vref at 80% */
13816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13818 /* Front Mic pin: input vref at 80% */
13819 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13820 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13821 /* Line In pin: input */
13822 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13824 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13826 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13828 /* CD pin widget for input */
13829 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13830
13831 { }
13832};
13833
13834/*
13835 * 6-stack pin configuration:
13836 */
13837static struct hda_verb alc861vd_6stack_init_verbs[] = {
13838 /*
13839 * Set pin mode and muting
13840 */
13841 /* set front pin widgets 0x14 for output */
13842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13844 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13845
13846 /* Rear Pin: output 1 (0x0d) */
13847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13849 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13850 /* CLFE Pin: output 2 (0x0e) */
13851 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13854 /* Side Pin: output 3 (0x0f) */
13855 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13857 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13858
13859 /* Mic (rear) pin: input vref at 80% */
13860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13862 /* Front Mic pin: input vref at 80% */
13863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13865 /* Line In pin: input */
13866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13868 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13870 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13872 /* CD pin widget for input */
13873 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13874
13875 { }
13876};
13877
Kailang Yangbdd148a2007-05-08 15:19:08 +020013878static struct hda_verb alc861vd_eapd_verbs[] = {
13879 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13880 { }
13881};
13882
Kailang Yangf9423e72008-05-27 12:32:25 +020013883static struct hda_verb alc660vd_eapd_verbs[] = {
13884 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13885 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13886 { }
13887};
13888
Kailang Yangbdd148a2007-05-08 15:19:08 +020013889static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13892 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13893 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013894 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013895 {}
13896};
13897
13898/* toggle speaker-output according to the hp-jack state */
13899static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13900{
13901 unsigned int present;
13902 unsigned char bits;
13903
13904 present = snd_hda_codec_read(codec, 0x1b, 0,
13905 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013906 bits = present ? HDA_AMP_MUTE : 0;
13907 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13908 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013909}
13910
13911static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13912{
13913 unsigned int present;
13914 unsigned char bits;
13915
13916 present = snd_hda_codec_read(codec, 0x18, 0,
13917 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013918 bits = present ? HDA_AMP_MUTE : 0;
13919 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13920 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013921}
13922
13923static void alc861vd_lenovo_automute(struct hda_codec *codec)
13924{
13925 alc861vd_lenovo_hp_automute(codec);
13926 alc861vd_lenovo_mic_automute(codec);
13927}
13928
13929static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13930 unsigned int res)
13931{
13932 switch (res >> 26) {
13933 case ALC880_HP_EVENT:
13934 alc861vd_lenovo_hp_automute(codec);
13935 break;
13936 case ALC880_MIC_EVENT:
13937 alc861vd_lenovo_mic_automute(codec);
13938 break;
13939 }
13940}
13941
Kailang Yang272a5272007-05-14 11:00:38 +020013942static struct hda_verb alc861vd_dallas_verbs[] = {
13943 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13944 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13945 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13946 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13947
13948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13954 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13955 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013956
Kailang Yang272a5272007-05-14 11:00:38 +020013957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13961 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13962 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13963 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13964 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13965
13966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13970 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13971 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13972 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13973 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13974
13975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13979
13980 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013981 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013982 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13983
13984 { } /* end */
13985};
13986
13987/* toggle speaker-output according to the hp-jack state */
13988static void alc861vd_dallas_automute(struct hda_codec *codec)
13989{
13990 unsigned int present;
13991
13992 present = snd_hda_codec_read(codec, 0x15, 0,
13993 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013994 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13995 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013996}
13997
13998static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13999{
14000 if ((res >> 26) == ALC880_HP_EVENT)
14001 alc861vd_dallas_automute(codec);
14002}
14003
Takashi Iwaicb53c622007-08-10 17:21:45 +020014004#ifdef CONFIG_SND_HDA_POWER_SAVE
14005#define alc861vd_loopbacks alc880_loopbacks
14006#endif
14007
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014008/* pcm configuration: identiacal with ALC880 */
14009#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14010#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14011#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14012#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14013
14014/*
14015 * configuration and preset
14016 */
14017static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14018 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014019 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014020 [ALC861VD_3ST] = "3stack",
14021 [ALC861VD_3ST_DIG] = "3stack-digout",
14022 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014023 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014024 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014025 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014026 [ALC861VD_AUTO] = "auto",
14027};
14028
14029static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014030 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14031 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014032 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014033 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020014034 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020014035 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014036 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014037 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014038 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014039 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014040 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014041 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014042 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014043 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14044 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014045 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014046 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014047 {}
14048};
14049
14050static struct alc_config_preset alc861vd_presets[] = {
14051 [ALC660VD_3ST] = {
14052 .mixers = { alc861vd_3st_mixer },
14053 .init_verbs = { alc861vd_volume_init_verbs,
14054 alc861vd_3stack_init_verbs },
14055 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14056 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014057 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14058 .channel_mode = alc861vd_3stack_2ch_modes,
14059 .input_mux = &alc861vd_capture_source,
14060 },
Mike Crash6963f842007-06-25 12:12:51 +020014061 [ALC660VD_3ST_DIG] = {
14062 .mixers = { alc861vd_3st_mixer },
14063 .init_verbs = { alc861vd_volume_init_verbs,
14064 alc861vd_3stack_init_verbs },
14065 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14066 .dac_nids = alc660vd_dac_nids,
14067 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014068 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14069 .channel_mode = alc861vd_3stack_2ch_modes,
14070 .input_mux = &alc861vd_capture_source,
14071 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014072 [ALC861VD_3ST] = {
14073 .mixers = { alc861vd_3st_mixer },
14074 .init_verbs = { alc861vd_volume_init_verbs,
14075 alc861vd_3stack_init_verbs },
14076 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14077 .dac_nids = alc861vd_dac_nids,
14078 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14079 .channel_mode = alc861vd_3stack_2ch_modes,
14080 .input_mux = &alc861vd_capture_source,
14081 },
14082 [ALC861VD_3ST_DIG] = {
14083 .mixers = { alc861vd_3st_mixer },
14084 .init_verbs = { alc861vd_volume_init_verbs,
14085 alc861vd_3stack_init_verbs },
14086 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14087 .dac_nids = alc861vd_dac_nids,
14088 .dig_out_nid = ALC861VD_DIGOUT_NID,
14089 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14090 .channel_mode = alc861vd_3stack_2ch_modes,
14091 .input_mux = &alc861vd_capture_source,
14092 },
14093 [ALC861VD_6ST_DIG] = {
14094 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14095 .init_verbs = { alc861vd_volume_init_verbs,
14096 alc861vd_6stack_init_verbs },
14097 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14098 .dac_nids = alc861vd_dac_nids,
14099 .dig_out_nid = ALC861VD_DIGOUT_NID,
14100 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14101 .channel_mode = alc861vd_6stack_modes,
14102 .input_mux = &alc861vd_capture_source,
14103 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014104 [ALC861VD_LENOVO] = {
14105 .mixers = { alc861vd_lenovo_mixer },
14106 .init_verbs = { alc861vd_volume_init_verbs,
14107 alc861vd_3stack_init_verbs,
14108 alc861vd_eapd_verbs,
14109 alc861vd_lenovo_unsol_verbs },
14110 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14111 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014112 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14113 .channel_mode = alc861vd_3stack_2ch_modes,
14114 .input_mux = &alc861vd_capture_source,
14115 .unsol_event = alc861vd_lenovo_unsol_event,
14116 .init_hook = alc861vd_lenovo_automute,
14117 },
Kailang Yang272a5272007-05-14 11:00:38 +020014118 [ALC861VD_DALLAS] = {
14119 .mixers = { alc861vd_dallas_mixer },
14120 .init_verbs = { alc861vd_dallas_verbs },
14121 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14122 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014123 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14124 .channel_mode = alc861vd_3stack_2ch_modes,
14125 .input_mux = &alc861vd_dallas_capture_source,
14126 .unsol_event = alc861vd_dallas_unsol_event,
14127 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014128 },
14129 [ALC861VD_HP] = {
14130 .mixers = { alc861vd_hp_mixer },
14131 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14132 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14133 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014134 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014135 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14136 .channel_mode = alc861vd_3stack_2ch_modes,
14137 .input_mux = &alc861vd_hp_capture_source,
14138 .unsol_event = alc861vd_dallas_unsol_event,
14139 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014140 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014141};
14142
14143/*
14144 * BIOS auto configuration
14145 */
14146static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14147 hda_nid_t nid, int pin_type, int dac_idx)
14148{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014149 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014150}
14151
14152static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14153{
14154 struct alc_spec *spec = codec->spec;
14155 int i;
14156
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014157 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014158 for (i = 0; i <= HDA_SIDE; i++) {
14159 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014160 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014161 if (nid)
14162 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014163 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014164 }
14165}
14166
14167
14168static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14169{
14170 struct alc_spec *spec = codec->spec;
14171 hda_nid_t pin;
14172
14173 pin = spec->autocfg.hp_pins[0];
14174 if (pin) /* connect to front and use dac 0 */
14175 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014176 pin = spec->autocfg.speaker_pins[0];
14177 if (pin)
14178 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014179}
14180
14181#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14182#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14183
14184static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14185{
14186 struct alc_spec *spec = codec->spec;
14187 int i;
14188
14189 for (i = 0; i < AUTO_PIN_LAST; i++) {
14190 hda_nid_t nid = spec->autocfg.input_pins[i];
14191 if (alc861vd_is_input_pin(nid)) {
14192 snd_hda_codec_write(codec, nid, 0,
14193 AC_VERB_SET_PIN_WIDGET_CONTROL,
14194 i <= AUTO_PIN_FRONT_MIC ?
14195 PIN_VREF80 : PIN_IN);
14196 if (nid != ALC861VD_PIN_CD_NID)
14197 snd_hda_codec_write(codec, nid, 0,
14198 AC_VERB_SET_AMP_GAIN_MUTE,
14199 AMP_OUT_MUTE);
14200 }
14201 }
14202}
14203
Takashi Iwaif511b012008-08-15 16:46:42 +020014204#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14205
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014206#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14207#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14208
14209/* add playback controls from the parsed DAC table */
14210/* Based on ALC880 version. But ALC861VD has separate,
14211 * different NIDs for mute/unmute switch and volume control */
14212static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14213 const struct auto_pin_cfg *cfg)
14214{
14215 char name[32];
14216 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14217 hda_nid_t nid_v, nid_s;
14218 int i, err;
14219
14220 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014221 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014222 continue;
14223 nid_v = alc861vd_idx_to_mixer_vol(
14224 alc880_dac_to_idx(
14225 spec->multiout.dac_nids[i]));
14226 nid_s = alc861vd_idx_to_mixer_switch(
14227 alc880_dac_to_idx(
14228 spec->multiout.dac_nids[i]));
14229
14230 if (i == 2) {
14231 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014232 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14233 "Center Playback Volume",
14234 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14235 HDA_OUTPUT));
14236 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014237 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14239 "LFE Playback Volume",
14240 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14241 HDA_OUTPUT));
14242 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 err = add_control(spec, ALC_CTL_BIND_MUTE,
14245 "Center Playback Switch",
14246 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14247 HDA_INPUT));
14248 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014250 err = add_control(spec, ALC_CTL_BIND_MUTE,
14251 "LFE Playback Switch",
14252 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14253 HDA_INPUT));
14254 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014255 return err;
14256 } else {
14257 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014258 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14259 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14260 HDA_OUTPUT));
14261 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014262 return err;
14263 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014265 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014266 HDA_INPUT));
14267 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014268 return err;
14269 }
14270 }
14271 return 0;
14272}
14273
14274/* add playback controls for speaker and HP outputs */
14275/* Based on ALC880 version. But ALC861VD has separate,
14276 * different NIDs for mute/unmute switch and volume control */
14277static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14278 hda_nid_t pin, const char *pfx)
14279{
14280 hda_nid_t nid_v, nid_s;
14281 int err;
14282 char name[32];
14283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014284 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014285 return 0;
14286
14287 if (alc880_is_fixed_pin(pin)) {
14288 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14289 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014290 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014291 spec->multiout.hp_nid = nid_v;
14292 else
14293 spec->multiout.extra_out_nid[0] = nid_v;
14294 /* control HP volume/switch on the output mixer amp */
14295 nid_v = alc861vd_idx_to_mixer_vol(
14296 alc880_fixed_pin_idx(pin));
14297 nid_s = alc861vd_idx_to_mixer_switch(
14298 alc880_fixed_pin_idx(pin));
14299
14300 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014301 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14302 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14303 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014304 return err;
14305 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014306 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14307 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14308 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014309 return err;
14310 } else if (alc880_is_multi_pin(pin)) {
14311 /* set manual connection */
14312 /* we have only a switch on HP-out PIN */
14313 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014314 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14315 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14316 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014317 return err;
14318 }
14319 return 0;
14320}
14321
14322/* parse the BIOS configuration and set up the alc_spec
14323 * return 1 if successful, 0 if the proper config is not found,
14324 * or a negative error code
14325 * Based on ALC880 version - had to change it to override
14326 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14327static int alc861vd_parse_auto_config(struct hda_codec *codec)
14328{
14329 struct alc_spec *spec = codec->spec;
14330 int err;
14331 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014333 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14334 alc861vd_ignore);
14335 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014336 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014337 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014338 return 0; /* can't find valid BIOS pin config */
14339
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014340 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14341 if (err < 0)
14342 return err;
14343 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14344 if (err < 0)
14345 return err;
14346 err = alc861vd_auto_create_extra_out(spec,
14347 spec->autocfg.speaker_pins[0],
14348 "Speaker");
14349 if (err < 0)
14350 return err;
14351 err = alc861vd_auto_create_extra_out(spec,
14352 spec->autocfg.hp_pins[0],
14353 "Headphone");
14354 if (err < 0)
14355 return err;
14356 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14357 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014358 return err;
14359
14360 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14361
14362 if (spec->autocfg.dig_out_pin)
14363 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14364
Takashi Iwai603c4012008-07-30 15:01:44 +020014365 if (spec->kctls.list)
14366 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014367
14368 spec->init_verbs[spec->num_init_verbs++]
14369 = alc861vd_volume_init_verbs;
14370
14371 spec->num_mux_defs = 1;
14372 spec->input_mux = &spec->private_imux;
14373
Takashi Iwai776e1842007-08-29 15:07:11 +020014374 err = alc_auto_add_mic_boost(codec);
14375 if (err < 0)
14376 return err;
14377
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014378 return 1;
14379}
14380
14381/* additional initialization for auto-configuration model */
14382static void alc861vd_auto_init(struct hda_codec *codec)
14383{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014384 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014385 alc861vd_auto_init_multi_out(codec);
14386 alc861vd_auto_init_hp_out(codec);
14387 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014388 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014389 if (spec->unsol_event)
14390 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014391}
14392
14393static int patch_alc861vd(struct hda_codec *codec)
14394{
14395 struct alc_spec *spec;
14396 int err, board_config;
14397
14398 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14399 if (spec == NULL)
14400 return -ENOMEM;
14401
14402 codec->spec = spec;
14403
14404 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14405 alc861vd_models,
14406 alc861vd_cfg_tbl);
14407
14408 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14409 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14410 "ALC861VD, trying auto-probe from BIOS...\n");
14411 board_config = ALC861VD_AUTO;
14412 }
14413
14414 if (board_config == ALC861VD_AUTO) {
14415 /* automatic parse from the BIOS config */
14416 err = alc861vd_parse_auto_config(codec);
14417 if (err < 0) {
14418 alc_free(codec);
14419 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014420 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014421 printk(KERN_INFO
14422 "hda_codec: Cannot set up configuration "
14423 "from BIOS. Using base mode...\n");
14424 board_config = ALC861VD_3ST;
14425 }
14426 }
14427
14428 if (board_config != ALC861VD_AUTO)
14429 setup_preset(spec, &alc861vd_presets[board_config]);
14430
Kailang Yang2f893282008-05-27 12:14:47 +020014431 if (codec->vendor_id == 0x10ec0660) {
14432 spec->stream_name_analog = "ALC660-VD Analog";
14433 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014434 /* always turn on EAPD */
14435 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020014436 } else {
14437 spec->stream_name_analog = "ALC861VD Analog";
14438 spec->stream_name_digital = "ALC861VD Digital";
14439 }
14440
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014441 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14442 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14443
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014444 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14445 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14446
14447 spec->adc_nids = alc861vd_adc_nids;
14448 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014449 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014450
14451 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
14452 spec->num_mixers++;
14453
Takashi Iwai2134ea42008-01-10 16:53:55 +010014454 spec->vmaster_nid = 0x02;
14455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014456 codec->patch_ops = alc_patch_ops;
14457
14458 if (board_config == ALC861VD_AUTO)
14459 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014460#ifdef CONFIG_SND_HDA_POWER_SAVE
14461 if (!spec->loopback.amplist)
14462 spec->loopback.amplist = alc861vd_loopbacks;
14463#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014464
14465 return 0;
14466}
14467
14468/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014469 * ALC662 support
14470 *
14471 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14472 * configuration. Each pin widget can choose any input DACs and a mixer.
14473 * Each ADC is connected from a mixer of all inputs. This makes possible
14474 * 6-channel independent captures.
14475 *
14476 * In addition, an independent DAC for the multi-playback (not used in this
14477 * driver yet).
14478 */
14479#define ALC662_DIGOUT_NID 0x06
14480#define ALC662_DIGIN_NID 0x0a
14481
14482static hda_nid_t alc662_dac_nids[4] = {
14483 /* front, rear, clfe, rear_surr */
14484 0x02, 0x03, 0x04
14485};
14486
14487static hda_nid_t alc662_adc_nids[1] = {
14488 /* ADC1-2 */
14489 0x09,
14490};
Takashi Iwaie1406342008-02-11 18:32:32 +010014491
Kailang Yang77a261b2008-02-19 11:38:05 +010014492static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014493
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014494/* input MUX */
14495/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014496static struct hda_input_mux alc662_capture_source = {
14497 .num_items = 4,
14498 .items = {
14499 { "Mic", 0x0 },
14500 { "Front Mic", 0x1 },
14501 { "Line", 0x2 },
14502 { "CD", 0x4 },
14503 },
14504};
14505
14506static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14507 .num_items = 2,
14508 .items = {
14509 { "Mic", 0x1 },
14510 { "Line", 0x2 },
14511 },
14512};
Kailang Yang291702f2007-10-16 14:28:03 +020014513
14514static struct hda_input_mux alc662_eeepc_capture_source = {
14515 .num_items = 2,
14516 .items = {
14517 { "i-Mic", 0x1 },
14518 { "e-Mic", 0x0 },
14519 },
14520};
14521
Kailang Yang6dda9f42008-05-27 12:05:31 +020014522static struct hda_input_mux alc663_capture_source = {
14523 .num_items = 3,
14524 .items = {
14525 { "Mic", 0x0 },
14526 { "Front Mic", 0x1 },
14527 { "Line", 0x2 },
14528 },
14529};
14530
14531static struct hda_input_mux alc663_m51va_capture_source = {
14532 .num_items = 2,
14533 .items = {
14534 { "Ext-Mic", 0x0 },
14535 { "D-Mic", 0x9 },
14536 },
14537};
14538
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014539#define alc662_mux_enum_info alc_mux_enum_info
14540#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014541#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014542
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014543/*
14544 * 2ch mode
14545 */
14546static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14547 { 2, NULL }
14548};
14549
14550/*
14551 * 2ch mode
14552 */
14553static struct hda_verb alc662_3ST_ch2_init[] = {
14554 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14555 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14556 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14557 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14558 { } /* end */
14559};
14560
14561/*
14562 * 6ch mode
14563 */
14564static struct hda_verb alc662_3ST_ch6_init[] = {
14565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14567 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14568 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14569 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14570 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14571 { } /* end */
14572};
14573
14574static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14575 { 2, alc662_3ST_ch2_init },
14576 { 6, alc662_3ST_ch6_init },
14577};
14578
14579/*
14580 * 2ch mode
14581 */
14582static struct hda_verb alc662_sixstack_ch6_init[] = {
14583 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14584 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14585 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14586 { } /* end */
14587};
14588
14589/*
14590 * 6ch mode
14591 */
14592static struct hda_verb alc662_sixstack_ch8_init[] = {
14593 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14594 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14595 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14596 { } /* end */
14597};
14598
14599static struct hda_channel_mode alc662_5stack_modes[2] = {
14600 { 2, alc662_sixstack_ch6_init },
14601 { 6, alc662_sixstack_ch8_init },
14602};
14603
14604/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14605 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14606 */
14607
14608static struct snd_kcontrol_new alc662_base_mixer[] = {
14609 /* output mixer control */
14610 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014611 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014613 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014616 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14617 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14619
14620 /*Input mixer control */
14621 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14622 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14623 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14624 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14625 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14626 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14627 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014629 { } /* end */
14630};
14631
14632static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14633 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014634 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14644 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14645 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014646 { } /* end */
14647};
14648
14649static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14650 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014651 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014653 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14655 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014656 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14657 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014658 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14659 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14660 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14661 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14662 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14666 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14667 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14668 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014669 { } /* end */
14670};
14671
14672static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14673 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14674 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14676 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014682 { } /* end */
14683};
14684
Kailang Yang291702f2007-10-16 14:28:03 +020014685static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014686 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014687
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014688 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14689 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014690
14691 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14692 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14693 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14694
14695 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14696 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14697 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14698 { } /* end */
14699};
14700
Kailang Yang8c427222008-01-10 13:03:59 +010014701static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014702 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14703 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014704 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14705 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14706 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14707 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14708 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14709 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014710 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014711 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14712 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14713 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14716 { } /* end */
14717};
14718
Kailang Yangf1d4e282008-08-26 14:03:29 +020014719static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14720 .ops = &snd_hda_bind_vol,
14721 .values = {
14722 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14723 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14724 0
14725 },
14726};
14727
14728static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14729 .ops = &snd_hda_bind_sw,
14730 .values = {
14731 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14732 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14733 0
14734 },
14735};
14736
Kailang Yang6dda9f42008-05-27 12:05:31 +020014737static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014738 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14739 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14741 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14742 { } /* end */
14743};
14744
14745static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14746 .ops = &snd_hda_bind_sw,
14747 .values = {
14748 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14749 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14750 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14751 0
14752 },
14753};
14754
14755static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14756 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14757 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14760 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14761 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14762
14763 { } /* end */
14764};
14765
14766static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14767 .ops = &snd_hda_bind_sw,
14768 .values = {
14769 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14770 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14771 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14772 0
14773 },
14774};
14775
14776static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14777 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14778 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14780 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14781 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14782 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14783 { } /* end */
14784};
14785
14786static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014787 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14788 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14791 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14793 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14794 { } /* end */
14795};
14796
14797static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14798 .ops = &snd_hda_bind_vol,
14799 .values = {
14800 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14801 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14802 0
14803 },
14804};
14805
14806static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14807 .ops = &snd_hda_bind_sw,
14808 .values = {
14809 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14810 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14811 0
14812 },
14813};
14814
14815static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14816 HDA_BIND_VOL("Master Playback Volume",
14817 &alc663_asus_two_bind_master_vol),
14818 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14819 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014823 { } /* end */
14824};
14825
14826static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14827 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14828 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014833 { } /* end */
14834};
14835
14836static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14837 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14838 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14839 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14840 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14842
14843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14845 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14846 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14847 { } /* end */
14848};
14849
14850static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14851 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14852 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14854
14855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14857 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14858 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14859 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14860 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14861 { } /* end */
14862};
14863
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014864static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14865 {
14866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14867 .name = "Channel Mode",
14868 .info = alc_ch_mode_info,
14869 .get = alc_ch_mode_get,
14870 .put = alc_ch_mode_put,
14871 },
14872 { } /* end */
14873};
14874
14875static struct hda_verb alc662_init_verbs[] = {
14876 /* ADC: mute amp left and right */
14877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14878 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14879 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14880
Takashi Iwaicb53c622007-08-10 17:21:45 +020014881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014886
Kailang Yangb60dd392007-09-20 12:50:29 +020014887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014893
14894 /* Front Pin: output 0 (0x0c) */
14895 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14896 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14897
14898 /* Rear Pin: output 1 (0x0d) */
14899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14901
14902 /* CLFE Pin: output 2 (0x0e) */
14903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14904 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14905
14906 /* Mic (rear) pin: input vref at 80% */
14907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14909 /* Front Mic pin: input vref at 80% */
14910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14912 /* Line In pin: input */
14913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14915 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14918 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14919 /* CD pin widget for input */
14920 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14921
14922 /* FIXME: use matrix-type input source selection */
14923 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14924 /* Input mixer */
14925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014929
14930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014934
14935 /* always trun on EAPD */
14936 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14937 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14938
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014939 { }
14940};
14941
14942static struct hda_verb alc662_sue_init_verbs[] = {
14943 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14944 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014945 {}
14946};
14947
14948static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14949 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14950 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14951 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014952};
14953
Kailang Yang8c427222008-01-10 13:03:59 +010014954/* Set Unsolicited Event*/
14955static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14957 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14958 {}
14959};
14960
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014961/*
14962 * generic initialization of ADC, input mixers and output mixers
14963 */
14964static struct hda_verb alc662_auto_init_verbs[] = {
14965 /*
14966 * Unmute ADC and set the default input to mic-in
14967 */
14968 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14970
14971 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14972 * mixer widget
14973 * Note: PASD motherboards uses the Line In 2 as the input for front
14974 * panel mic (mic 2)
14975 */
14976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014982
14983 /*
14984 * Set up output mixers (0x0c - 0x0f)
14985 */
14986 /* set vol=0 to output mixers */
14987 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14988 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14989 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14990
14991 /* set up input amps for analog loopback */
14992 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014999
15000
15001 /* FIXME: use matrix-type input source selection */
15002 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15003 /* Input mixer */
15004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015006 { }
15007};
15008
Takashi Iwai24fb9172008-09-02 14:48:20 +020015009/* additional verbs for ALC663 */
15010static struct hda_verb alc663_auto_init_verbs[] = {
15011 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15013 { }
15014};
15015
Kailang Yang6dda9f42008-05-27 12:05:31 +020015016static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15018 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015019 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15020 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015021 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015024 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15025 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15026 {}
15027};
15028
Kailang Yangf1d4e282008-08-26 14:03:29 +020015029static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15030 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15031 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15032 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15035 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15036 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15037 {}
15038};
15039
15040static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15043 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15044 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15046 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15047 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15048 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15049 {}
15050};
15051
15052static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15053 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15058 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15059 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15060 {}
15061};
15062
15063static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15065 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15066 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15067 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15073 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15074 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15075 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15076 {}
15077};
15078
15079static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15082 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15083 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15084 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15089 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15090 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15092 {}
15093};
15094
Kailang Yang6dda9f42008-05-27 12:05:31 +020015095static struct hda_verb alc663_g71v_init_verbs[] = {
15096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15097 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15098 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15099
15100 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15101 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15102 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15103
15104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15105 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15106 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15107 {}
15108};
15109
15110static struct hda_verb alc663_g50v_init_verbs[] = {
15111 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15112 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15113 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15114
15115 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15116 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15117 {}
15118};
15119
Kailang Yangf1d4e282008-08-26 14:03:29 +020015120static struct hda_verb alc662_ecs_init_verbs[] = {
15121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15123 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15124 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15125 {}
15126};
15127
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015128/* capture mixer elements */
15129static struct snd_kcontrol_new alc662_capture_mixer[] = {
15130 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15131 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15132 {
15133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15134 /* The multiple "Capture Source" controls confuse alsamixer
15135 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015136 */
15137 /* .name = "Capture Source", */
15138 .name = "Input Source",
15139 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010015140 .info = alc662_mux_enum_info,
15141 .get = alc662_mux_enum_get,
15142 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015143 },
15144 { } /* end */
15145};
15146
Kailang Yangf1d4e282008-08-26 14:03:29 +020015147static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15148 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15149 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15150 { } /* end */
15151};
15152
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015153static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15154{
15155 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015156 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015157
15158 present = snd_hda_codec_read(codec, 0x14, 0,
15159 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015160 bits = present ? HDA_AMP_MUTE : 0;
15161 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15162 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015163}
15164
15165static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15166{
15167 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015168 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015169
15170 present = snd_hda_codec_read(codec, 0x1b, 0,
15171 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015172 bits = present ? HDA_AMP_MUTE : 0;
15173 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15174 HDA_AMP_MUTE, bits);
15175 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15176 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015177}
15178
15179static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15180 unsigned int res)
15181{
15182 if ((res >> 26) == ALC880_HP_EVENT)
15183 alc662_lenovo_101e_all_automute(codec);
15184 if ((res >> 26) == ALC880_FRONT_EVENT)
15185 alc662_lenovo_101e_ispeaker_automute(codec);
15186}
15187
Kailang Yang291702f2007-10-16 14:28:03 +020015188static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15189{
15190 unsigned int present;
15191
15192 present = snd_hda_codec_read(codec, 0x18, 0,
15193 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15194 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15195 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15196 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15197 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15198 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15199 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15200 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15201 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15202}
15203
15204/* unsolicited event for HP jack sensing */
15205static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15206 unsigned int res)
15207{
15208 if ((res >> 26) == ALC880_HP_EVENT)
15209 alc262_hippo1_automute( codec );
15210
15211 if ((res >> 26) == ALC880_MIC_EVENT)
15212 alc662_eeepc_mic_automute(codec);
15213}
15214
15215static void alc662_eeepc_inithook(struct hda_codec *codec)
15216{
15217 alc262_hippo1_automute( codec );
15218 alc662_eeepc_mic_automute(codec);
15219}
15220
Kailang Yang8c427222008-01-10 13:03:59 +010015221static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15222{
15223 unsigned int mute;
15224 unsigned int present;
15225
15226 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15227 present = snd_hda_codec_read(codec, 0x14, 0,
15228 AC_VERB_GET_PIN_SENSE, 0);
15229 present = (present & 0x80000000) != 0;
15230 if (present) {
15231 /* mute internal speaker */
15232 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015233 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015234 } else {
15235 /* unmute internal speaker if necessary */
15236 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15237 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015238 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015239 }
15240}
15241
15242/* unsolicited event for HP jack sensing */
15243static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15244 unsigned int res)
15245{
15246 if ((res >> 26) == ALC880_HP_EVENT)
15247 alc662_eeepc_ep20_automute(codec);
15248}
15249
15250static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15251{
15252 alc662_eeepc_ep20_automute(codec);
15253}
15254
Kailang Yang6dda9f42008-05-27 12:05:31 +020015255static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15256{
15257 unsigned int present;
15258 unsigned char bits;
15259
15260 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015261 AC_VERB_GET_PIN_SENSE, 0)
15262 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015263 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015264 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15265 AMP_IN_MUTE(0), bits);
15266 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15267 AMP_IN_MUTE(0), bits);
15268}
15269
15270static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15271{
15272 unsigned int present;
15273 unsigned char bits;
15274
15275 present = snd_hda_codec_read(codec, 0x21, 0,
15276 AC_VERB_GET_PIN_SENSE, 0)
15277 & AC_PINSENSE_PRESENCE;
15278 bits = present ? HDA_AMP_MUTE : 0;
15279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15280 AMP_IN_MUTE(0), bits);
15281 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15282 AMP_IN_MUTE(0), bits);
15283 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15284 AMP_IN_MUTE(0), bits);
15285 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15286 AMP_IN_MUTE(0), bits);
15287}
15288
15289static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15290{
15291 unsigned int present;
15292 unsigned char bits;
15293
15294 present = snd_hda_codec_read(codec, 0x15, 0,
15295 AC_VERB_GET_PIN_SENSE, 0)
15296 & AC_PINSENSE_PRESENCE;
15297 bits = present ? HDA_AMP_MUTE : 0;
15298 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15299 AMP_IN_MUTE(0), bits);
15300 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15301 AMP_IN_MUTE(0), bits);
15302 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15303 AMP_IN_MUTE(0), bits);
15304 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15305 AMP_IN_MUTE(0), bits);
15306}
15307
15308static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15309{
15310 unsigned int present;
15311 unsigned char bits;
15312
15313 present = snd_hda_codec_read(codec, 0x1b, 0,
15314 AC_VERB_GET_PIN_SENSE, 0)
15315 & AC_PINSENSE_PRESENCE;
15316 bits = present ? 0 : PIN_OUT;
15317 snd_hda_codec_write(codec, 0x14, 0,
15318 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15319}
15320
15321static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15322{
15323 unsigned int present1, present2;
15324
15325 present1 = snd_hda_codec_read(codec, 0x21, 0,
15326 AC_VERB_GET_PIN_SENSE, 0)
15327 & AC_PINSENSE_PRESENCE;
15328 present2 = snd_hda_codec_read(codec, 0x15, 0,
15329 AC_VERB_GET_PIN_SENSE, 0)
15330 & AC_PINSENSE_PRESENCE;
15331
15332 if (present1 || present2) {
15333 snd_hda_codec_write_cache(codec, 0x14, 0,
15334 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15335 } else {
15336 snd_hda_codec_write_cache(codec, 0x14, 0,
15337 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15338 }
15339}
15340
15341static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15342{
15343 unsigned int present1, present2;
15344
15345 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15346 AC_VERB_GET_PIN_SENSE, 0)
15347 & AC_PINSENSE_PRESENCE;
15348 present2 = snd_hda_codec_read(codec, 0x15, 0,
15349 AC_VERB_GET_PIN_SENSE, 0)
15350 & AC_PINSENSE_PRESENCE;
15351
15352 if (present1 || present2) {
15353 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15354 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15355 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15356 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15357 } else {
15358 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15359 AMP_IN_MUTE(0), 0);
15360 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15361 AMP_IN_MUTE(0), 0);
15362 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015363}
15364
15365static void alc663_m51va_mic_automute(struct hda_codec *codec)
15366{
15367 unsigned int present;
15368
15369 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015370 AC_VERB_GET_PIN_SENSE, 0)
15371 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015372 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015373 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015374 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015375 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015376 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015377 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015378 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015379 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015380}
15381
15382static void alc663_m51va_unsol_event(struct hda_codec *codec,
15383 unsigned int res)
15384{
15385 switch (res >> 26) {
15386 case ALC880_HP_EVENT:
15387 alc663_m51va_speaker_automute(codec);
15388 break;
15389 case ALC880_MIC_EVENT:
15390 alc663_m51va_mic_automute(codec);
15391 break;
15392 }
15393}
15394
15395static void alc663_m51va_inithook(struct hda_codec *codec)
15396{
15397 alc663_m51va_speaker_automute(codec);
15398 alc663_m51va_mic_automute(codec);
15399}
15400
Kailang Yangf1d4e282008-08-26 14:03:29 +020015401/* ***************** Mode1 ******************************/
15402static void alc663_mode1_unsol_event(struct hda_codec *codec,
15403 unsigned int res)
15404{
15405 switch (res >> 26) {
15406 case ALC880_HP_EVENT:
15407 alc663_m51va_speaker_automute(codec);
15408 break;
15409 case ALC880_MIC_EVENT:
15410 alc662_eeepc_mic_automute(codec);
15411 break;
15412 }
15413}
15414
15415static void alc663_mode1_inithook(struct hda_codec *codec)
15416{
15417 alc663_m51va_speaker_automute(codec);
15418 alc662_eeepc_mic_automute(codec);
15419}
15420/* ***************** Mode2 ******************************/
15421static void alc662_mode2_unsol_event(struct hda_codec *codec,
15422 unsigned int res)
15423{
15424 switch (res >> 26) {
15425 case ALC880_HP_EVENT:
15426 alc662_f5z_speaker_automute(codec);
15427 break;
15428 case ALC880_MIC_EVENT:
15429 alc662_eeepc_mic_automute(codec);
15430 break;
15431 }
15432}
15433
15434static void alc662_mode2_inithook(struct hda_codec *codec)
15435{
15436 alc662_f5z_speaker_automute(codec);
15437 alc662_eeepc_mic_automute(codec);
15438}
15439/* ***************** Mode3 ******************************/
15440static void alc663_mode3_unsol_event(struct hda_codec *codec,
15441 unsigned int res)
15442{
15443 switch (res >> 26) {
15444 case ALC880_HP_EVENT:
15445 alc663_two_hp_m1_speaker_automute(codec);
15446 break;
15447 case ALC880_MIC_EVENT:
15448 alc662_eeepc_mic_automute(codec);
15449 break;
15450 }
15451}
15452
15453static void alc663_mode3_inithook(struct hda_codec *codec)
15454{
15455 alc663_two_hp_m1_speaker_automute(codec);
15456 alc662_eeepc_mic_automute(codec);
15457}
15458/* ***************** Mode4 ******************************/
15459static void alc663_mode4_unsol_event(struct hda_codec *codec,
15460 unsigned int res)
15461{
15462 switch (res >> 26) {
15463 case ALC880_HP_EVENT:
15464 alc663_21jd_two_speaker_automute(codec);
15465 break;
15466 case ALC880_MIC_EVENT:
15467 alc662_eeepc_mic_automute(codec);
15468 break;
15469 }
15470}
15471
15472static void alc663_mode4_inithook(struct hda_codec *codec)
15473{
15474 alc663_21jd_two_speaker_automute(codec);
15475 alc662_eeepc_mic_automute(codec);
15476}
15477/* ***************** Mode5 ******************************/
15478static void alc663_mode5_unsol_event(struct hda_codec *codec,
15479 unsigned int res)
15480{
15481 switch (res >> 26) {
15482 case ALC880_HP_EVENT:
15483 alc663_15jd_two_speaker_automute(codec);
15484 break;
15485 case ALC880_MIC_EVENT:
15486 alc662_eeepc_mic_automute(codec);
15487 break;
15488 }
15489}
15490
15491static void alc663_mode5_inithook(struct hda_codec *codec)
15492{
15493 alc663_15jd_two_speaker_automute(codec);
15494 alc662_eeepc_mic_automute(codec);
15495}
15496/* ***************** Mode6 ******************************/
15497static void alc663_mode6_unsol_event(struct hda_codec *codec,
15498 unsigned int res)
15499{
15500 switch (res >> 26) {
15501 case ALC880_HP_EVENT:
15502 alc663_two_hp_m2_speaker_automute(codec);
15503 break;
15504 case ALC880_MIC_EVENT:
15505 alc662_eeepc_mic_automute(codec);
15506 break;
15507 }
15508}
15509
15510static void alc663_mode6_inithook(struct hda_codec *codec)
15511{
15512 alc663_two_hp_m2_speaker_automute(codec);
15513 alc662_eeepc_mic_automute(codec);
15514}
15515
Kailang Yang6dda9f42008-05-27 12:05:31 +020015516static void alc663_g71v_hp_automute(struct hda_codec *codec)
15517{
15518 unsigned int present;
15519 unsigned char bits;
15520
15521 present = snd_hda_codec_read(codec, 0x21, 0,
15522 AC_VERB_GET_PIN_SENSE, 0)
15523 & AC_PINSENSE_PRESENCE;
15524 bits = present ? HDA_AMP_MUTE : 0;
15525 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15526 HDA_AMP_MUTE, bits);
15527 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15528 HDA_AMP_MUTE, bits);
15529}
15530
15531static void alc663_g71v_front_automute(struct hda_codec *codec)
15532{
15533 unsigned int present;
15534 unsigned char bits;
15535
15536 present = snd_hda_codec_read(codec, 0x15, 0,
15537 AC_VERB_GET_PIN_SENSE, 0)
15538 & AC_PINSENSE_PRESENCE;
15539 bits = present ? HDA_AMP_MUTE : 0;
15540 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15541 HDA_AMP_MUTE, bits);
15542}
15543
15544static void alc663_g71v_unsol_event(struct hda_codec *codec,
15545 unsigned int res)
15546{
15547 switch (res >> 26) {
15548 case ALC880_HP_EVENT:
15549 alc663_g71v_hp_automute(codec);
15550 break;
15551 case ALC880_FRONT_EVENT:
15552 alc663_g71v_front_automute(codec);
15553 break;
15554 case ALC880_MIC_EVENT:
15555 alc662_eeepc_mic_automute(codec);
15556 break;
15557 }
15558}
15559
15560static void alc663_g71v_inithook(struct hda_codec *codec)
15561{
15562 alc663_g71v_front_automute(codec);
15563 alc663_g71v_hp_automute(codec);
15564 alc662_eeepc_mic_automute(codec);
15565}
15566
15567static void alc663_g50v_unsol_event(struct hda_codec *codec,
15568 unsigned int res)
15569{
15570 switch (res >> 26) {
15571 case ALC880_HP_EVENT:
15572 alc663_m51va_speaker_automute(codec);
15573 break;
15574 case ALC880_MIC_EVENT:
15575 alc662_eeepc_mic_automute(codec);
15576 break;
15577 }
15578}
15579
15580static void alc663_g50v_inithook(struct hda_codec *codec)
15581{
15582 alc663_m51va_speaker_automute(codec);
15583 alc662_eeepc_mic_automute(codec);
15584}
15585
Kailang Yangf1d4e282008-08-26 14:03:29 +020015586/* bind hp and internal speaker mute (with plug check) */
15587static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15588 struct snd_ctl_elem_value *ucontrol)
15589{
15590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15591 long *valp = ucontrol->value.integer.value;
15592 int change;
15593
15594 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15595 HDA_AMP_MUTE,
15596 valp[0] ? 0 : HDA_AMP_MUTE);
15597 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15598 HDA_AMP_MUTE,
15599 valp[1] ? 0 : HDA_AMP_MUTE);
15600 if (change)
15601 alc262_hippo1_automute(codec);
15602 return change;
15603}
15604
15605static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15606 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15607 {
15608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15609 .name = "Master Playback Switch",
15610 .info = snd_hda_mixer_amp_switch_info,
15611 .get = snd_hda_mixer_amp_switch_get,
15612 .put = alc662_ecs_master_sw_put,
15613 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15614 },
15615
15616 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15617 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15618 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15619
15620 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15621 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15622 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15623 { } /* end */
15624};
15625
Takashi Iwaicb53c622007-08-10 17:21:45 +020015626#ifdef CONFIG_SND_HDA_POWER_SAVE
15627#define alc662_loopbacks alc880_loopbacks
15628#endif
15629
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015630
15631/* pcm configuration: identiacal with ALC880 */
15632#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15633#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15634#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15635#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15636
15637/*
15638 * configuration and preset
15639 */
15640static const char *alc662_models[ALC662_MODEL_LAST] = {
15641 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15642 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15643 [ALC662_3ST_6ch] = "3stack-6ch",
15644 [ALC662_5ST_DIG] = "6stack-dig",
15645 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015646 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015647 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015648 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015649 [ALC663_ASUS_M51VA] = "m51va",
15650 [ALC663_ASUS_G71V] = "g71v",
15651 [ALC663_ASUS_H13] = "h13",
15652 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015653 [ALC663_ASUS_MODE1] = "asus-mode1",
15654 [ALC662_ASUS_MODE2] = "asus-mode2",
15655 [ALC663_ASUS_MODE3] = "asus-mode3",
15656 [ALC663_ASUS_MODE4] = "asus-mode4",
15657 [ALC663_ASUS_MODE5] = "asus-mode5",
15658 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015659 [ALC662_AUTO] = "auto",
15660};
15661
15662static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015663 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
15664 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015665 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015666 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015667 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015668 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15669 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15670 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15671 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15672 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15673 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15674 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15675 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15676 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15677 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15678 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15679 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15680 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15681 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15682 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15683 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15684 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15685 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15686 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15687 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15688 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15689 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15690 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15691 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15692 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15693 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15694 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15695 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15696 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15697 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15698 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015699 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15700 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015701 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015702 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15703 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015704 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15705 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015706 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015707 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015708 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015709 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15710 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15711 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015712 {}
15713};
15714
15715static struct alc_config_preset alc662_presets[] = {
15716 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015717 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015718 .init_verbs = { alc662_init_verbs },
15719 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15720 .dac_nids = alc662_dac_nids,
15721 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015722 .dig_in_nid = ALC662_DIGIN_NID,
15723 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15724 .channel_mode = alc662_3ST_2ch_modes,
15725 .input_mux = &alc662_capture_source,
15726 },
15727 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015728 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15729 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015730 .init_verbs = { alc662_init_verbs },
15731 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15732 .dac_nids = alc662_dac_nids,
15733 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015734 .dig_in_nid = ALC662_DIGIN_NID,
15735 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15736 .channel_mode = alc662_3ST_6ch_modes,
15737 .need_dac_fix = 1,
15738 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015739 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015740 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015741 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15742 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015743 .init_verbs = { alc662_init_verbs },
15744 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15745 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015746 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15747 .channel_mode = alc662_3ST_6ch_modes,
15748 .need_dac_fix = 1,
15749 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015750 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015751 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015752 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
15753 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015754 .init_verbs = { alc662_init_verbs },
15755 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15756 .dac_nids = alc662_dac_nids,
15757 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015758 .dig_in_nid = ALC662_DIGIN_NID,
15759 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15760 .channel_mode = alc662_5stack_modes,
15761 .input_mux = &alc662_capture_source,
15762 },
15763 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015764 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015765 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15766 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15767 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015768 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15769 .channel_mode = alc662_3ST_2ch_modes,
15770 .input_mux = &alc662_lenovo_101e_capture_source,
15771 .unsol_event = alc662_lenovo_101e_unsol_event,
15772 .init_hook = alc662_lenovo_101e_all_automute,
15773 },
Kailang Yang291702f2007-10-16 14:28:03 +020015774 [ALC662_ASUS_EEEPC_P701] = {
15775 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
15776 .init_verbs = { alc662_init_verbs,
15777 alc662_eeepc_sue_init_verbs },
15778 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15779 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015780 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15781 .channel_mode = alc662_3ST_2ch_modes,
15782 .input_mux = &alc662_eeepc_capture_source,
15783 .unsol_event = alc662_eeepc_unsol_event,
15784 .init_hook = alc662_eeepc_inithook,
15785 },
Kailang Yang8c427222008-01-10 13:03:59 +010015786 [ALC662_ASUS_EEEPC_EP20] = {
15787 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
15788 alc662_chmode_mixer },
15789 .init_verbs = { alc662_init_verbs,
15790 alc662_eeepc_ep20_sue_init_verbs },
15791 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15792 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015793 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15794 .channel_mode = alc662_3ST_6ch_modes,
15795 .input_mux = &alc662_lenovo_101e_capture_source,
15796 .unsol_event = alc662_eeepc_ep20_unsol_event,
15797 .init_hook = alc662_eeepc_ep20_inithook,
15798 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015799 [ALC662_ECS] = {
15800 .mixers = { alc662_ecs_mixer, alc662_capture_mixer },
15801 .init_verbs = { alc662_init_verbs,
15802 alc662_ecs_init_verbs },
15803 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15804 .dac_nids = alc662_dac_nids,
15805 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15806 .channel_mode = alc662_3ST_2ch_modes,
15807 .input_mux = &alc662_eeepc_capture_source,
15808 .unsol_event = alc662_eeepc_unsol_event,
15809 .init_hook = alc662_eeepc_inithook,
15810 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015811 [ALC663_ASUS_M51VA] = {
15812 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15813 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15814 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15815 .dac_nids = alc662_dac_nids,
15816 .dig_out_nid = ALC662_DIGOUT_NID,
15817 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15818 .channel_mode = alc662_3ST_2ch_modes,
15819 .input_mux = &alc663_m51va_capture_source,
15820 .unsol_event = alc663_m51va_unsol_event,
15821 .init_hook = alc663_m51va_inithook,
15822 },
15823 [ALC663_ASUS_G71V] = {
15824 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
15825 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15826 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15827 .dac_nids = alc662_dac_nids,
15828 .dig_out_nid = ALC662_DIGOUT_NID,
15829 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15830 .channel_mode = alc662_3ST_2ch_modes,
15831 .input_mux = &alc662_eeepc_capture_source,
15832 .unsol_event = alc663_g71v_unsol_event,
15833 .init_hook = alc663_g71v_inithook,
15834 },
15835 [ALC663_ASUS_H13] = {
15836 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15837 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15838 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15839 .dac_nids = alc662_dac_nids,
15840 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15841 .channel_mode = alc662_3ST_2ch_modes,
15842 .input_mux = &alc663_m51va_capture_source,
15843 .unsol_event = alc663_m51va_unsol_event,
15844 .init_hook = alc663_m51va_inithook,
15845 },
15846 [ALC663_ASUS_G50V] = {
15847 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
15848 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15849 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15850 .dac_nids = alc662_dac_nids,
15851 .dig_out_nid = ALC662_DIGOUT_NID,
15852 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15853 .channel_mode = alc662_3ST_6ch_modes,
15854 .input_mux = &alc663_capture_source,
15855 .unsol_event = alc663_g50v_unsol_event,
15856 .init_hook = alc663_g50v_inithook,
15857 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015858 [ALC663_ASUS_MODE1] = {
15859 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer },
15860 .init_verbs = { alc662_init_verbs,
15861 alc663_21jd_amic_init_verbs },
15862 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15863 .hp_nid = 0x03,
15864 .dac_nids = alc662_dac_nids,
15865 .dig_out_nid = ALC662_DIGOUT_NID,
15866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15867 .channel_mode = alc662_3ST_2ch_modes,
15868 .input_mux = &alc662_eeepc_capture_source,
15869 .unsol_event = alc663_mode1_unsol_event,
15870 .init_hook = alc663_mode1_inithook,
15871 },
15872 [ALC662_ASUS_MODE2] = {
15873 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer },
15874 .init_verbs = { alc662_init_verbs,
15875 alc662_1bjd_amic_init_verbs },
15876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15877 .dac_nids = alc662_dac_nids,
15878 .dig_out_nid = ALC662_DIGOUT_NID,
15879 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15880 .channel_mode = alc662_3ST_2ch_modes,
15881 .input_mux = &alc662_eeepc_capture_source,
15882 .unsol_event = alc662_mode2_unsol_event,
15883 .init_hook = alc662_mode2_inithook,
15884 },
15885 [ALC663_ASUS_MODE3] = {
15886 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer },
15887 .init_verbs = { alc662_init_verbs,
15888 alc663_two_hp_amic_m1_init_verbs },
15889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15890 .hp_nid = 0x03,
15891 .dac_nids = alc662_dac_nids,
15892 .dig_out_nid = ALC662_DIGOUT_NID,
15893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15894 .channel_mode = alc662_3ST_2ch_modes,
15895 .input_mux = &alc662_eeepc_capture_source,
15896 .unsol_event = alc663_mode3_unsol_event,
15897 .init_hook = alc663_mode3_inithook,
15898 },
15899 [ALC663_ASUS_MODE4] = {
15900 .mixers = { alc663_asus_21jd_clfe_mixer,
15901 alc662_auto_capture_mixer},
15902 .init_verbs = { alc662_init_verbs,
15903 alc663_21jd_amic_init_verbs},
15904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15905 .hp_nid = 0x03,
15906 .dac_nids = alc662_dac_nids,
15907 .dig_out_nid = ALC662_DIGOUT_NID,
15908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15909 .channel_mode = alc662_3ST_2ch_modes,
15910 .input_mux = &alc662_eeepc_capture_source,
15911 .unsol_event = alc663_mode4_unsol_event,
15912 .init_hook = alc663_mode4_inithook,
15913 },
15914 [ALC663_ASUS_MODE5] = {
15915 .mixers = { alc663_asus_15jd_clfe_mixer,
15916 alc662_auto_capture_mixer },
15917 .init_verbs = { alc662_init_verbs,
15918 alc663_15jd_amic_init_verbs },
15919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15920 .hp_nid = 0x03,
15921 .dac_nids = alc662_dac_nids,
15922 .dig_out_nid = ALC662_DIGOUT_NID,
15923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15924 .channel_mode = alc662_3ST_2ch_modes,
15925 .input_mux = &alc662_eeepc_capture_source,
15926 .unsol_event = alc663_mode5_unsol_event,
15927 .init_hook = alc663_mode5_inithook,
15928 },
15929 [ALC663_ASUS_MODE6] = {
15930 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer },
15931 .init_verbs = { alc662_init_verbs,
15932 alc663_two_hp_amic_m2_init_verbs },
15933 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15934 .hp_nid = 0x03,
15935 .dac_nids = alc662_dac_nids,
15936 .dig_out_nid = ALC662_DIGOUT_NID,
15937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15938 .channel_mode = alc662_3ST_2ch_modes,
15939 .input_mux = &alc662_eeepc_capture_source,
15940 .unsol_event = alc663_mode6_unsol_event,
15941 .init_hook = alc663_mode6_inithook,
15942 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015943};
15944
15945
15946/*
15947 * BIOS auto configuration
15948 */
15949
15950/* add playback controls from the parsed DAC table */
15951static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15952 const struct auto_pin_cfg *cfg)
15953{
15954 char name[32];
15955 static const char *chname[4] = {
15956 "Front", "Surround", NULL /*CLFE*/, "Side"
15957 };
15958 hda_nid_t nid;
15959 int i, err;
15960
15961 for (i = 0; i < cfg->line_outs; i++) {
15962 if (!spec->multiout.dac_nids[i])
15963 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015964 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015965 if (i == 2) {
15966 /* Center/LFE */
15967 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15968 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015969 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15970 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015971 if (err < 0)
15972 return err;
15973 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15974 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015975 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15976 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015977 if (err < 0)
15978 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015979 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015980 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015981 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015983 if (err < 0)
15984 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015985 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015986 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015987 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015988 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015989 if (err < 0)
15990 return err;
15991 } else {
15992 sprintf(name, "%s Playback Volume", chname[i]);
15993 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015994 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15995 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015996 if (err < 0)
15997 return err;
15998 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015999 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16000 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16001 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016002 if (err < 0)
16003 return err;
16004 }
16005 }
16006 return 0;
16007}
16008
16009/* add playback controls for speaker and HP outputs */
16010static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16011 const char *pfx)
16012{
16013 hda_nid_t nid;
16014 int err;
16015 char name[32];
16016
16017 if (!pin)
16018 return 0;
16019
Takashi Iwai24fb9172008-09-02 14:48:20 +020016020 if (pin == 0x17) {
16021 /* ALC663 has a mono output pin on 0x17 */
16022 sprintf(name, "%s Playback Switch", pfx);
16023 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16024 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16025 return err;
16026 }
16027
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016028 if (alc880_is_fixed_pin(pin)) {
16029 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16030 /* printk("DAC nid=%x\n",nid); */
16031 /* specify the DAC as the extra output */
16032 if (!spec->multiout.hp_nid)
16033 spec->multiout.hp_nid = nid;
16034 else
16035 spec->multiout.extra_out_nid[0] = nid;
16036 /* control HP volume/switch on the output mixer amp */
16037 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16038 sprintf(name, "%s Playback Volume", pfx);
16039 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16040 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16041 if (err < 0)
16042 return err;
16043 sprintf(name, "%s Playback Switch", pfx);
16044 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16045 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16046 if (err < 0)
16047 return err;
16048 } else if (alc880_is_multi_pin(pin)) {
16049 /* set manual connection */
16050 /* we have only a switch on HP-out PIN */
16051 sprintf(name, "%s Playback Switch", pfx);
16052 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16053 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16054 if (err < 0)
16055 return err;
16056 }
16057 return 0;
16058}
16059
16060/* create playback/capture controls for input pins */
16061static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16062 const struct auto_pin_cfg *cfg)
16063{
16064 struct hda_input_mux *imux = &spec->private_imux;
16065 int i, err, idx;
16066
16067 for (i = 0; i < AUTO_PIN_LAST; i++) {
16068 if (alc880_is_input_pin(cfg->input_pins[i])) {
16069 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16070 err = new_analog_input(spec, cfg->input_pins[i],
16071 auto_pin_cfg_labels[i],
16072 idx, 0x0b);
16073 if (err < 0)
16074 return err;
16075 imux->items[imux->num_items].label =
16076 auto_pin_cfg_labels[i];
16077 imux->items[imux->num_items].index =
16078 alc880_input_pin_idx(cfg->input_pins[i]);
16079 imux->num_items++;
16080 }
16081 }
16082 return 0;
16083}
16084
16085static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16086 hda_nid_t nid, int pin_type,
16087 int dac_idx)
16088{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016089 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016090 /* need the manual connection? */
16091 if (alc880_is_multi_pin(nid)) {
16092 struct alc_spec *spec = codec->spec;
16093 int idx = alc880_multi_pin_idx(nid);
16094 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16095 AC_VERB_SET_CONNECT_SEL,
16096 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16097 }
16098}
16099
16100static void alc662_auto_init_multi_out(struct hda_codec *codec)
16101{
16102 struct alc_spec *spec = codec->spec;
16103 int i;
16104
Kailang Yang8c427222008-01-10 13:03:59 +010016105 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016106 for (i = 0; i <= HDA_SIDE; i++) {
16107 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016108 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016109 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016110 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016111 i);
16112 }
16113}
16114
16115static void alc662_auto_init_hp_out(struct hda_codec *codec)
16116{
16117 struct alc_spec *spec = codec->spec;
16118 hda_nid_t pin;
16119
16120 pin = spec->autocfg.hp_pins[0];
16121 if (pin) /* connect to front */
16122 /* use dac 0 */
16123 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016124 pin = spec->autocfg.speaker_pins[0];
16125 if (pin)
16126 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016127}
16128
16129#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16130#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16131
16132static void alc662_auto_init_analog_input(struct hda_codec *codec)
16133{
16134 struct alc_spec *spec = codec->spec;
16135 int i;
16136
16137 for (i = 0; i < AUTO_PIN_LAST; i++) {
16138 hda_nid_t nid = spec->autocfg.input_pins[i];
16139 if (alc662_is_input_pin(nid)) {
16140 snd_hda_codec_write(codec, nid, 0,
16141 AC_VERB_SET_PIN_WIDGET_CONTROL,
16142 (i <= AUTO_PIN_FRONT_MIC ?
16143 PIN_VREF80 : PIN_IN));
16144 if (nid != ALC662_PIN_CD_NID)
16145 snd_hda_codec_write(codec, nid, 0,
16146 AC_VERB_SET_AMP_GAIN_MUTE,
16147 AMP_OUT_MUTE);
16148 }
16149 }
16150}
16151
Takashi Iwaif511b012008-08-15 16:46:42 +020016152#define alc662_auto_init_input_src alc882_auto_init_input_src
16153
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016154static int alc662_parse_auto_config(struct hda_codec *codec)
16155{
16156 struct alc_spec *spec = codec->spec;
16157 int err;
16158 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16159
16160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16161 alc662_ignore);
16162 if (err < 0)
16163 return err;
16164 if (!spec->autocfg.line_outs)
16165 return 0; /* can't find valid BIOS pin config */
16166
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016167 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16168 if (err < 0)
16169 return err;
16170 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16171 if (err < 0)
16172 return err;
16173 err = alc662_auto_create_extra_out(spec,
16174 spec->autocfg.speaker_pins[0],
16175 "Speaker");
16176 if (err < 0)
16177 return err;
16178 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16179 "Headphone");
16180 if (err < 0)
16181 return err;
16182 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16183 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016184 return err;
16185
16186 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16187
16188 if (spec->autocfg.dig_out_pin)
16189 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16190
Takashi Iwai603c4012008-07-30 15:01:44 +020016191 if (spec->kctls.list)
16192 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016193
16194 spec->num_mux_defs = 1;
16195 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016196
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016197 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020016198 if (codec->vendor_id == 0x10ec0663)
16199 spec->init_verbs[spec->num_init_verbs++] =
16200 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020016201
16202 err = alc_auto_add_mic_boost(codec);
16203 if (err < 0)
16204 return err;
16205
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016206 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16207 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016208 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016209}
16210
16211/* additional initialization for auto-configuration model */
16212static void alc662_auto_init(struct hda_codec *codec)
16213{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016214 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016215 alc662_auto_init_multi_out(codec);
16216 alc662_auto_init_hp_out(codec);
16217 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016218 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016219 if (spec->unsol_event)
16220 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016221}
16222
16223static int patch_alc662(struct hda_codec *codec)
16224{
16225 struct alc_spec *spec;
16226 int err, board_config;
16227
16228 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16229 if (!spec)
16230 return -ENOMEM;
16231
16232 codec->spec = spec;
16233
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016234 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16235
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016236 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16237 alc662_models,
16238 alc662_cfg_tbl);
16239 if (board_config < 0) {
16240 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16241 "trying auto-probe from BIOS...\n");
16242 board_config = ALC662_AUTO;
16243 }
16244
16245 if (board_config == ALC662_AUTO) {
16246 /* automatic parse from the BIOS config */
16247 err = alc662_parse_auto_config(codec);
16248 if (err < 0) {
16249 alc_free(codec);
16250 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016251 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016252 printk(KERN_INFO
16253 "hda_codec: Cannot set up configuration "
16254 "from BIOS. Using base mode...\n");
16255 board_config = ALC662_3ST_2ch_DIG;
16256 }
16257 }
16258
16259 if (board_config != ALC662_AUTO)
16260 setup_preset(spec, &alc662_presets[board_config]);
16261
Kailang Yang6dda9f42008-05-27 12:05:31 +020016262 if (codec->vendor_id == 0x10ec0663) {
16263 spec->stream_name_analog = "ALC663 Analog";
16264 spec->stream_name_digital = "ALC663 Digital";
16265 } else {
16266 spec->stream_name_analog = "ALC662 Analog";
16267 spec->stream_name_digital = "ALC662 Digital";
16268 }
16269
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016270 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16271 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16272
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016273 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16274 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16275
Takashi Iwaie1406342008-02-11 18:32:32 +010016276 spec->adc_nids = alc662_adc_nids;
16277 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16278 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016279
Takashi Iwai2134ea42008-01-10 16:53:55 +010016280 spec->vmaster_nid = 0x02;
16281
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016282 codec->patch_ops = alc_patch_ops;
16283 if (board_config == ALC662_AUTO)
16284 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016285#ifdef CONFIG_SND_HDA_POWER_SAVE
16286 if (!spec->loopback.amplist)
16287 spec->loopback.amplist = alc662_loopbacks;
16288#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289
16290 return 0;
16291}
16292
16293/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016294 * patch entries
16295 */
16296struct hda_codec_preset snd_hda_preset_realtek[] = {
16297 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016298 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016299 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016300 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016301 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016302 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016303 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016304 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16305 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16306 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016307 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16308 .patch = patch_alc883 },
16309 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16310 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016311 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016312 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016313 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016314 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016315 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16316 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016317 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016318 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016319 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016320 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016321 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016322 {} /* terminator */
16323};