blob: d1f5a766c3b224a1fd7a2092f72106b21b534242 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200116 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100117 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100118 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100119#ifdef CONFIG_SND_DEBUG
120 ALC268_TEST,
121#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200122 ALC268_AUTO,
123 ALC268_MODEL_LAST /* last tag */
124};
125
Kailang Yangf6a92242007-12-13 16:52:54 +0100126/* ALC269 models */
127enum {
128 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200129 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200130 ALC269_ASUS_EEEPC_P703,
131 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100132 ALC269_AUTO,
133 ALC269_MODEL_LAST /* last tag */
134};
135
Kailang Yangdf694da2005-12-05 19:42:22 +0100136/* ALC861 models */
137enum {
138 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200139 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100140 ALC861_3ST_DIG,
141 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200142 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200143 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200144 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100145 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_AUTO,
147 ALC861_MODEL_LAST,
148};
149
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100150/* ALC861-VD models */
151enum {
152 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200153 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100154 ALC861VD_3ST,
155 ALC861VD_3ST_DIG,
156 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200157 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200158 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200159 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160 ALC861VD_AUTO,
161 ALC861VD_MODEL_LAST,
162};
163
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200164/* ALC662 models */
165enum {
166 ALC662_3ST_2ch_DIG,
167 ALC662_3ST_6ch_DIG,
168 ALC662_3ST_6ch,
169 ALC662_5ST_DIG,
170 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200171 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100172 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200173 ALC663_ASUS_M51VA,
174 ALC663_ASUS_G71V,
175 ALC663_ASUS_H13,
176 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200177 ALC662_ECS,
178 ALC663_ASUS_MODE1,
179 ALC662_ASUS_MODE2,
180 ALC663_ASUS_MODE3,
181 ALC663_ASUS_MODE4,
182 ALC663_ASUS_MODE5,
183 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200184 ALC662_AUTO,
185 ALC662_MODEL_LAST,
186};
187
Kailang Yangdf694da2005-12-05 19:42:22 +0100188/* ALC882 models */
189enum {
190 ALC882_3ST_DIG,
191 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200192 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200193 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200194 ALC882_TARGA,
195 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200196 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100197 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200198 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200199 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200200 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100201 ALC882_MODEL_LAST,
202};
203
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200204/* ALC883 models */
205enum {
206 ALC883_3ST_2ch_DIG,
207 ALC883_3ST_6ch_DIG,
208 ALC883_3ST_6ch,
209 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200210 ALC883_TARGA_DIG,
211 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200212 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200213 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200214 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200215 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100216 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200217 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200218 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200219 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200220 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200221 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200222 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100223 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100224 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100225 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100226 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200227 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200228 ALC888_ASUS_M90V,
229 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200230 ALC883_AUTO,
231 ALC883_MODEL_LAST,
232};
233
Kailang Yangdf694da2005-12-05 19:42:22 +0100234/* for GPIO Poll */
235#define GPIO_MASK 0x03
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237struct alc_spec {
238 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100239 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 unsigned int num_mixers;
241
Kailang Yangdf694da2005-12-05 19:42:22 +0100242 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200243 * don't forget NULL
244 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200245 */
246 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Takashi Iwai16ded522005-06-10 19:58:24 +0200248 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 struct hda_pcm_stream *stream_analog_playback;
250 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100251 struct hda_pcm_stream *stream_analog_alt_playback;
252 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200254 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 struct hda_pcm_stream *stream_digital_playback;
256 struct hda_pcm_stream *stream_digital_capture;
257
258 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200259 struct hda_multi_out multiout; /* playback set-up
260 * max_channels, dacs must be set
261 * dig_out_nid and hp_nid are optional
262 */
Takashi Iwai63300792008-01-24 15:31:36 +0100263 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265 /* capture */
266 unsigned int num_adc_nids;
267 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100268 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200269 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200272 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 const struct hda_input_mux *input_mux;
274 unsigned int cur_mux[3];
275
276 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100277 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200279 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100282 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200283
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200284 /* dynamic controls, init_verbs and input_mux */
285 struct auto_pin_cfg autocfg;
286 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100287 struct snd_kcontrol_new *kctl_alloc;
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 */
1592static int alc_build_controls(struct hda_codec *codec)
1593{
1594 struct alc_spec *spec = codec->spec;
1595 int err;
1596 int i;
1597
1598 for (i = 0; i < spec->num_mixers; i++) {
1599 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1600 if (err < 0)
1601 return err;
1602 }
1603
1604 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001605 err = snd_hda_create_spdif_out_ctls(codec,
1606 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 if (err < 0)
1608 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001609 err = snd_hda_create_spdif_share_sw(codec,
1610 &spec->multiout);
1611 if (err < 0)
1612 return err;
1613 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614 }
1615 if (spec->dig_in_nid) {
1616 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1617 if (err < 0)
1618 return err;
1619 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001620
1621 /* if we have no master control, let's create it */
1622 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001623 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001624 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001625 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001626 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001627 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001628 if (err < 0)
1629 return err;
1630 }
1631 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1632 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1633 NULL, alc_slave_sws);
1634 if (err < 0)
1635 return err;
1636 }
1637
Linus Torvalds1da177e2005-04-16 15:20:36 -07001638 return 0;
1639}
1640
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001641
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642/*
1643 * initialize the codec volumes, etc
1644 */
1645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646/*
1647 * generic initialization of ADC, input mixers and output mixers
1648 */
1649static struct hda_verb alc880_volume_init_verbs[] = {
1650 /*
1651 * Unmute ADC0-2 and set the default input to mic-in
1652 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001653 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001655 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001657 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001660 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1661 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001662 * Note: PASD motherboards uses the Line In 2 as the input for front
1663 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001665 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001674 /*
1675 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677 /* set vol=0 to output mixers */
1678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1682 /* set up input amps for analog loopback */
1683 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692
1693 { }
1694};
1695
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001696/*
1697 * 3-stack pin configuration:
1698 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1699 */
1700static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1701 /*
1702 * preset connection lists of input pins
1703 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1704 */
1705 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1706 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1707 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1708
1709 /*
1710 * Set pin mode and muting
1711 */
1712 /* set front pin widgets 0x14 for output */
1713 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1715 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1716 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1718 /* Mic2 (as headphone out) for HP output */
1719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1721 /* Line In pin widget for input */
1722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1724 /* Line2 (as front mic) pin widget for input and vref at 80% */
1725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1727 /* CD pin widget for input */
1728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1729
1730 { }
1731};
1732
1733/*
1734 * 5-stack pin configuration:
1735 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1736 * line-in/side = 0x1a, f-mic = 0x1b
1737 */
1738static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1739 /*
1740 * preset connection lists of input pins
1741 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1742 */
1743 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1744 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1745
1746 /*
1747 * Set pin mode and muting
1748 */
1749 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1753 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754 /* unmute pins for output (no gain on this amp) */
1755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1758 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1763 /* Mic2 (as headphone out) for HP output */
1764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766 /* Line In pin widget for input */
1767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1769 /* Line2 (as front mic) pin widget for input and vref at 80% */
1770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1771 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1772 /* CD pin widget for input */
1773 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774
1775 { }
1776};
1777
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001778/*
1779 * W810 pin configuration:
1780 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1781 */
1782static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 /* hphone/speaker input selector: front DAC */
1784 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1785
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1792
1793 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001794 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 { }
1797};
1798
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799/*
1800 * Z71V pin configuration:
1801 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1802 */
1803static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001808
Takashi Iwai16ded522005-06-10 19:58:24 +02001809 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001812 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001813
1814 { }
1815};
1816
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817/*
1818 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001819 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1820 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821 */
1822static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1823 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1824
Takashi Iwai16ded522005-06-10 19:58:24 +02001825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1833
Takashi Iwai16ded522005-06-10 19:58:24 +02001834 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001838 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001841 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001842 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844 { }
1845};
Takashi Iwai16ded522005-06-10 19:58:24 +02001846
Kailang Yangccc656c2006-10-17 12:32:26 +02001847/*
1848 * Uniwill pin configuration:
1849 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1850 * line = 0x1a
1851 */
1852static struct hda_verb alc880_uniwill_init_verbs[] = {
1853 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1854
1855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1857 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1859 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1861 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1869
1870 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1872 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1876 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1877 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1878 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1879
1880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1881 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1882
1883 { }
1884};
1885
1886/*
1887* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001888* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001889 */
1890static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1891 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1892
1893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1894 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1897 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1898 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1905
1906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1907 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1908 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1909 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1912
1913 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1914 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1915
1916 { }
1917};
1918
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001919static struct hda_verb alc880_beep_init_verbs[] = {
1920 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1921 { }
1922};
1923
Kailang Yangccc656c2006-10-17 12:32:26 +02001924/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001925static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001926{
1927 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001928 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001929
1930 present = snd_hda_codec_read(codec, 0x14, 0,
1931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001932 bits = present ? HDA_AMP_MUTE : 0;
1933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1934 HDA_AMP_MUTE, bits);
1935 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1936 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001937}
1938
1939/* auto-toggle front mic */
1940static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1941{
1942 unsigned int present;
1943 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001944
1945 present = snd_hda_codec_read(codec, 0x18, 0,
1946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001947 bits = present ? HDA_AMP_MUTE : 0;
1948 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001949}
1950
1951static void alc880_uniwill_automute(struct hda_codec *codec)
1952{
1953 alc880_uniwill_hp_automute(codec);
1954 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001955}
1956
1957static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1958 unsigned int res)
1959{
1960 /* Looks like the unsol event is incompatible with the standard
1961 * definition. 4bit tag is placed at 28 bit!
1962 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001963 switch (res >> 28) {
1964 case ALC880_HP_EVENT:
1965 alc880_uniwill_hp_automute(codec);
1966 break;
1967 case ALC880_MIC_EVENT:
1968 alc880_uniwill_mic_automute(codec);
1969 break;
1970 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001971}
1972
1973static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1974{
1975 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001976 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001977
1978 present = snd_hda_codec_read(codec, 0x14, 0,
1979 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001980 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001981 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001982}
1983
1984static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1985{
1986 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001987
Kailang Yangccc656c2006-10-17 12:32:26 +02001988 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001989 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1990 present &= HDA_AMP_VOLMASK;
1991 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1992 HDA_AMP_VOLMASK, present);
1993 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1994 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001995}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001996
Kailang Yangccc656c2006-10-17 12:32:26 +02001997static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1998 unsigned int res)
1999{
2000 /* Looks like the unsol event is incompatible with the standard
2001 * definition. 4bit tag is placed at 28 bit!
2002 */
2003 if ((res >> 28) == ALC880_HP_EVENT)
2004 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002005 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002006 alc880_uniwill_p53_dcvol_automute(codec);
2007}
2008
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002009/*
2010 * F1734 pin configuration:
2011 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2012 */
2013static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002014 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002015 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2016 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2017 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2018 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2019
2020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2021 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2023 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024
2025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2031 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002034
Takashi Iwai937b4162008-02-11 14:52:36 +01002035 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2036 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2037
Takashi Iwai16ded522005-06-10 19:58:24 +02002038 { }
2039};
2040
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041/*
2042 * ASUS pin configuration:
2043 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2044 */
2045static struct hda_verb alc880_pin_asus_init_verbs[] = {
2046 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2047 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2048 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2049 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2050
2051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2053 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2059
2060 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2062 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2063 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2064 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2066 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2068 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002069
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070 { }
2071};
2072
2073/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002074#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2075#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002076
Kailang Yangdf694da2005-12-05 19:42:22 +01002077/* Clevo m520g init */
2078static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2079 /* headphone output */
2080 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2081 /* line-out */
2082 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2083 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2084 /* Line-in */
2085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 /* CD */
2088 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2089 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 /* Mic1 (rear panel) */
2091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2092 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 /* Mic2 (front panel) */
2094 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2095 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2096 /* headphone */
2097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2099 /* change to EAPD mode */
2100 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2101 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2102
2103 { }
2104};
2105
2106static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002107 /* change to EAPD mode */
2108 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2109 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2110
Kailang Yangdf694da2005-12-05 19:42:22 +01002111 /* Headphone output */
2112 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2113 /* Front output*/
2114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2115 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2116
2117 /* Line In pin widget for input */
2118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2119 /* CD pin widget for input */
2120 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2121 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2122 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2123
2124 /* change to EAPD mode */
2125 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2126 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2127
2128 { }
2129};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002130
2131/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002132 * LG m1 express dual
2133 *
2134 * Pin assignment:
2135 * Rear Line-In/Out (blue): 0x14
2136 * Build-in Mic-In: 0x15
2137 * Speaker-out: 0x17
2138 * HP-Out (green): 0x1b
2139 * Mic-In/Out (red): 0x19
2140 * SPDIF-Out: 0x1e
2141 */
2142
2143/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2144static hda_nid_t alc880_lg_dac_nids[3] = {
2145 0x05, 0x02, 0x03
2146};
2147
2148/* seems analog CD is not working */
2149static struct hda_input_mux alc880_lg_capture_source = {
2150 .num_items = 3,
2151 .items = {
2152 { "Mic", 0x1 },
2153 { "Line", 0x5 },
2154 { "Internal Mic", 0x6 },
2155 },
2156};
2157
2158/* 2,4,6 channel modes */
2159static struct hda_verb alc880_lg_ch2_init[] = {
2160 /* set line-in and mic-in to input */
2161 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2162 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2163 { }
2164};
2165
2166static struct hda_verb alc880_lg_ch4_init[] = {
2167 /* set line-in to out and mic-in to input */
2168 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2169 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2170 { }
2171};
2172
2173static struct hda_verb alc880_lg_ch6_init[] = {
2174 /* set line-in and mic-in to output */
2175 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2176 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2177 { }
2178};
2179
2180static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2181 { 2, alc880_lg_ch2_init },
2182 { 4, alc880_lg_ch4_init },
2183 { 6, alc880_lg_ch6_init },
2184};
2185
2186static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2188 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2190 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2200 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2201 {
2202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2203 .name = "Channel Mode",
2204 .info = alc_ch_mode_info,
2205 .get = alc_ch_mode_get,
2206 .put = alc_ch_mode_put,
2207 },
2208 { } /* end */
2209};
2210
2211static struct hda_verb alc880_lg_init_verbs[] = {
2212 /* set capture source to mic-in */
2213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2214 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2216 /* mute all amp mixer inputs */
2217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002220 /* line-in to input */
2221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 /* built-in mic */
2224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 /* speaker-out */
2227 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2229 /* mic-in to input */
2230 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2233 /* HP-out */
2234 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2235 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2236 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 /* jack sense */
2238 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2239 { }
2240};
2241
2242/* toggle speaker-output according to the hp-jack state */
2243static void alc880_lg_automute(struct hda_codec *codec)
2244{
2245 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002246 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002247
2248 present = snd_hda_codec_read(codec, 0x1b, 0,
2249 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002250 bits = present ? HDA_AMP_MUTE : 0;
2251 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2252 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002253}
2254
2255static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2256{
2257 /* Looks like the unsol event is incompatible with the standard
2258 * definition. 4bit tag is placed at 28 bit!
2259 */
2260 if ((res >> 28) == 0x01)
2261 alc880_lg_automute(codec);
2262}
2263
2264/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002265 * LG LW20
2266 *
2267 * Pin assignment:
2268 * Speaker-out: 0x14
2269 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002270 * Built-in Mic-In: 0x19
2271 * Line-In: 0x1b
2272 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002273 * SPDIF-Out: 0x1e
2274 */
2275
Takashi Iwaid6815182006-03-23 16:06:23 +01002276static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002277 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002278 .items = {
2279 { "Mic", 0x0 },
2280 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002281 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002282 },
2283};
2284
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002285#define alc880_lg_lw_modes alc880_threestack_modes
2286
Takashi Iwaid6815182006-03-23 16:06:23 +01002287static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002288 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2289 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2290 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2291 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2292 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2294 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2295 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2297 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2300 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2301 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002302 {
2303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2304 .name = "Channel Mode",
2305 .info = alc_ch_mode_info,
2306 .get = alc_ch_mode_get,
2307 .put = alc_ch_mode_put,
2308 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002309 { } /* end */
2310};
2311
2312static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2314 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2315 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2316
Takashi Iwaid6815182006-03-23 16:06:23 +01002317 /* set capture source to mic-in */
2318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002322 /* speaker-out */
2323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2325 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002326 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2327 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2328 /* mic-in to input */
2329 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2331 /* built-in mic */
2332 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2334 /* jack sense */
2335 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2336 { }
2337};
2338
2339/* toggle speaker-output according to the hp-jack state */
2340static void alc880_lg_lw_automute(struct hda_codec *codec)
2341{
2342 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002343 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002344
2345 present = snd_hda_codec_read(codec, 0x1b, 0,
2346 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002347 bits = present ? HDA_AMP_MUTE : 0;
2348 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2349 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002350}
2351
2352static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2353{
2354 /* Looks like the unsol event is incompatible with the standard
2355 * definition. 4bit tag is placed at 28 bit!
2356 */
2357 if ((res >> 28) == 0x01)
2358 alc880_lg_lw_automute(codec);
2359}
2360
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002361static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2362 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2367 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2368 { } /* end */
2369};
2370
2371static struct hda_input_mux alc880_medion_rim_capture_source = {
2372 .num_items = 2,
2373 .items = {
2374 { "Mic", 0x0 },
2375 { "Internal Mic", 0x1 },
2376 },
2377};
2378
2379static struct hda_verb alc880_medion_rim_init_verbs[] = {
2380 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2381
2382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2383 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2384
2385 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2388 /* Mic2 (as headphone out) for HP output */
2389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2391 /* Internal Speaker */
2392 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2394
2395 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2396 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2397
2398 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2399 { }
2400};
2401
2402/* toggle speaker-output according to the hp-jack state */
2403static void alc880_medion_rim_automute(struct hda_codec *codec)
2404{
2405 unsigned int present;
2406 unsigned char bits;
2407
2408 present = snd_hda_codec_read(codec, 0x14, 0,
2409 AC_VERB_GET_PIN_SENSE, 0)
2410 & AC_PINSENSE_PRESENCE;
2411 bits = present ? HDA_AMP_MUTE : 0;
2412 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2413 HDA_AMP_MUTE, bits);
2414 if (present)
2415 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2416 else
2417 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2418}
2419
2420static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2421 unsigned int res)
2422{
2423 /* Looks like the unsol event is incompatible with the standard
2424 * definition. 4bit tag is placed at 28 bit!
2425 */
2426 if ((res >> 28) == ALC880_HP_EVENT)
2427 alc880_medion_rim_automute(codec);
2428}
2429
Takashi Iwaicb53c622007-08-10 17:21:45 +02002430#ifdef CONFIG_SND_HDA_POWER_SAVE
2431static struct hda_amp_list alc880_loopbacks[] = {
2432 { 0x0b, HDA_INPUT, 0 },
2433 { 0x0b, HDA_INPUT, 1 },
2434 { 0x0b, HDA_INPUT, 2 },
2435 { 0x0b, HDA_INPUT, 3 },
2436 { 0x0b, HDA_INPUT, 4 },
2437 { } /* end */
2438};
2439
2440static struct hda_amp_list alc880_lg_loopbacks[] = {
2441 { 0x0b, HDA_INPUT, 1 },
2442 { 0x0b, HDA_INPUT, 6 },
2443 { 0x0b, HDA_INPUT, 7 },
2444 { } /* end */
2445};
2446#endif
2447
Takashi Iwaid6815182006-03-23 16:06:23 +01002448/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002449 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002450 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002451
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452static int alc_init(struct hda_codec *codec)
2453{
2454 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002455 unsigned int i;
2456
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002457 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002458 if (codec->vendor_id == 0x10ec0888)
2459 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002461 for (i = 0; i < spec->num_init_verbs; i++)
2462 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002463
2464 if (spec->init_hook)
2465 spec->init_hook(codec);
2466
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 return 0;
2468}
2469
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002470static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2471{
2472 struct alc_spec *spec = codec->spec;
2473
2474 if (spec->unsol_event)
2475 spec->unsol_event(codec, res);
2476}
2477
Takashi Iwaicb53c622007-08-10 17:21:45 +02002478#ifdef CONFIG_SND_HDA_POWER_SAVE
2479static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2480{
2481 struct alc_spec *spec = codec->spec;
2482 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2483}
2484#endif
2485
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486/*
2487 * Analog playback callbacks
2488 */
2489static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2490 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002491 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492{
2493 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002494 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2495 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496}
2497
2498static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2499 struct hda_codec *codec,
2500 unsigned int stream_tag,
2501 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002502 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503{
2504 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002505 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2506 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507}
2508
2509static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2510 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002511 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512{
2513 struct alc_spec *spec = codec->spec;
2514 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2515}
2516
2517/*
2518 * Digital out
2519 */
2520static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2521 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002522 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523{
2524 struct alc_spec *spec = codec->spec;
2525 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2526}
2527
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002528static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2529 struct hda_codec *codec,
2530 unsigned int stream_tag,
2531 unsigned int format,
2532 struct snd_pcm_substream *substream)
2533{
2534 struct alc_spec *spec = codec->spec;
2535 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2536 stream_tag, format, substream);
2537}
2538
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2540 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002541 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542{
2543 struct alc_spec *spec = codec->spec;
2544 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2545}
2546
2547/*
2548 * Analog capture
2549 */
Takashi Iwai63300792008-01-24 15:31:36 +01002550static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 struct hda_codec *codec,
2552 unsigned int stream_tag,
2553 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002554 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555{
2556 struct alc_spec *spec = codec->spec;
2557
Takashi Iwai63300792008-01-24 15:31:36 +01002558 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 stream_tag, 0, format);
2560 return 0;
2561}
2562
Takashi Iwai63300792008-01-24 15:31:36 +01002563static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002565 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566{
2567 struct alc_spec *spec = codec->spec;
2568
Takashi Iwai888afa12008-03-18 09:57:50 +01002569 snd_hda_codec_cleanup_stream(codec,
2570 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 return 0;
2572}
2573
2574
2575/*
2576 */
2577static struct hda_pcm_stream alc880_pcm_analog_playback = {
2578 .substreams = 1,
2579 .channels_min = 2,
2580 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002581 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 .ops = {
2583 .open = alc880_playback_pcm_open,
2584 .prepare = alc880_playback_pcm_prepare,
2585 .cleanup = alc880_playback_pcm_cleanup
2586 },
2587};
2588
2589static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002590 .substreams = 1,
2591 .channels_min = 2,
2592 .channels_max = 2,
2593 /* NID is set in alc_build_pcms */
2594};
2595
2596static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2597 .substreams = 1,
2598 .channels_min = 2,
2599 .channels_max = 2,
2600 /* NID is set in alc_build_pcms */
2601};
2602
2603static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2604 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 .channels_min = 2,
2606 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002607 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002609 .prepare = alc880_alt_capture_pcm_prepare,
2610 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 },
2612};
2613
2614static struct hda_pcm_stream alc880_pcm_digital_playback = {
2615 .substreams = 1,
2616 .channels_min = 2,
2617 .channels_max = 2,
2618 /* NID is set in alc_build_pcms */
2619 .ops = {
2620 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002621 .close = alc880_dig_playback_pcm_close,
2622 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 },
2624};
2625
2626static struct hda_pcm_stream alc880_pcm_digital_capture = {
2627 .substreams = 1,
2628 .channels_min = 2,
2629 .channels_max = 2,
2630 /* NID is set in alc_build_pcms */
2631};
2632
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002633/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002634static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002635 .substreams = 0,
2636 .channels_min = 0,
2637 .channels_max = 0,
2638};
2639
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640static int alc_build_pcms(struct hda_codec *codec)
2641{
2642 struct alc_spec *spec = codec->spec;
2643 struct hda_pcm *info = spec->pcm_rec;
2644 int i;
2645
2646 codec->num_pcms = 1;
2647 codec->pcm_info = info;
2648
2649 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002650 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002651 if (snd_BUG_ON(!spec->multiout.dac_nids))
2652 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002653 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2654 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2655 }
2656 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002657 if (snd_BUG_ON(!spec->adc_nids))
2658 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002659 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2660 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2661 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662
Takashi Iwai4a471b72005-12-07 13:56:29 +01002663 if (spec->channel_mode) {
2664 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2665 for (i = 0; i < spec->num_channel_mode; i++) {
2666 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2667 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2668 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669 }
2670 }
2671
Takashi Iwaie08a0072006-09-07 17:52:14 +02002672 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002674 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002675 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002677 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002678 if (spec->multiout.dig_out_nid &&
2679 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2681 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2682 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002683 if (spec->dig_in_nid &&
2684 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2686 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2687 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002688 /* FIXME: do we need this for all Realtek codec models? */
2689 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 }
2691
Takashi Iwaie08a0072006-09-07 17:52:14 +02002692 /* If the use of more than one ADC is requested for the current
2693 * model, configure a second analog capture-only PCM.
2694 */
2695 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002696 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2697 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002698 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002699 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002700 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002701 if (spec->alt_dac_nid) {
2702 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2703 *spec->stream_analog_alt_playback;
2704 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2705 spec->alt_dac_nid;
2706 } else {
2707 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2708 alc_pcm_null_stream;
2709 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2710 }
2711 if (spec->num_adc_nids > 1) {
2712 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2713 *spec->stream_analog_alt_capture;
2714 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2715 spec->adc_nids[1];
2716 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2717 spec->num_adc_nids - 1;
2718 } else {
2719 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2720 alc_pcm_null_stream;
2721 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002722 }
2723 }
2724
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725 return 0;
2726}
2727
2728static void alc_free(struct hda_codec *codec)
2729{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 struct alc_spec *spec = codec->spec;
2731 unsigned int i;
2732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002733 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 return;
2735
2736 if (spec->kctl_alloc) {
2737 for (i = 0; i < spec->num_kctl_used; i++)
2738 kfree(spec->kctl_alloc[i].name);
2739 kfree(spec->kctl_alloc);
2740 }
2741 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002742 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743}
2744
2745/*
2746 */
2747static struct hda_codec_ops alc_patch_ops = {
2748 .build_controls = alc_build_controls,
2749 .build_pcms = alc_build_pcms,
2750 .init = alc_init,
2751 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002752 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002753#ifdef CONFIG_SND_HDA_POWER_SAVE
2754 .check_power_status = alc_check_power_status,
2755#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756};
2757
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002758
2759/*
2760 * Test configuration for debugging
2761 *
2762 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2763 * enum controls.
2764 */
2765#ifdef CONFIG_SND_DEBUG
2766static hda_nid_t alc880_test_dac_nids[4] = {
2767 0x02, 0x03, 0x04, 0x05
2768};
2769
2770static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002771 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002772 .items = {
2773 { "In-1", 0x0 },
2774 { "In-2", 0x1 },
2775 { "In-3", 0x2 },
2776 { "In-4", 0x3 },
2777 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002778 { "Front", 0x5 },
2779 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002780 },
2781};
2782
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002783static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002784 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002785 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002786 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002787 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002788};
2789
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002790static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2791 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002792{
2793 static char *texts[] = {
2794 "N/A", "Line Out", "HP Out",
2795 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2796 };
2797 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2798 uinfo->count = 1;
2799 uinfo->value.enumerated.items = 8;
2800 if (uinfo->value.enumerated.item >= 8)
2801 uinfo->value.enumerated.item = 7;
2802 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2803 return 0;
2804}
2805
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002806static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2807 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002808{
2809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2810 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2811 unsigned int pin_ctl, item = 0;
2812
2813 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2814 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2815 if (pin_ctl & AC_PINCTL_OUT_EN) {
2816 if (pin_ctl & AC_PINCTL_HP_EN)
2817 item = 2;
2818 else
2819 item = 1;
2820 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2821 switch (pin_ctl & AC_PINCTL_VREFEN) {
2822 case AC_PINCTL_VREF_HIZ: item = 3; break;
2823 case AC_PINCTL_VREF_50: item = 4; break;
2824 case AC_PINCTL_VREF_GRD: item = 5; break;
2825 case AC_PINCTL_VREF_80: item = 6; break;
2826 case AC_PINCTL_VREF_100: item = 7; break;
2827 }
2828 }
2829 ucontrol->value.enumerated.item[0] = item;
2830 return 0;
2831}
2832
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002833static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2834 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002835{
2836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2837 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2838 static unsigned int ctls[] = {
2839 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2840 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2841 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2842 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2843 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2844 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2845 };
2846 unsigned int old_ctl, new_ctl;
2847
2848 old_ctl = snd_hda_codec_read(codec, nid, 0,
2849 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2850 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2851 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002852 int val;
2853 snd_hda_codec_write_cache(codec, nid, 0,
2854 AC_VERB_SET_PIN_WIDGET_CONTROL,
2855 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002856 val = ucontrol->value.enumerated.item[0] >= 3 ?
2857 HDA_AMP_MUTE : 0;
2858 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2859 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002860 return 1;
2861 }
2862 return 0;
2863}
2864
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002865static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2866 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002867{
2868 static char *texts[] = {
2869 "Front", "Surround", "CLFE", "Side"
2870 };
2871 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2872 uinfo->count = 1;
2873 uinfo->value.enumerated.items = 4;
2874 if (uinfo->value.enumerated.item >= 4)
2875 uinfo->value.enumerated.item = 3;
2876 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2877 return 0;
2878}
2879
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002880static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2881 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002882{
2883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2884 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2885 unsigned int sel;
2886
2887 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2888 ucontrol->value.enumerated.item[0] = sel & 3;
2889 return 0;
2890}
2891
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002892static int alc_test_pin_src_put(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) & 3;
2900 if (ucontrol->value.enumerated.item[0] != sel) {
2901 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002902 snd_hda_codec_write_cache(codec, nid, 0,
2903 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002904 return 1;
2905 }
2906 return 0;
2907}
2908
2909#define PIN_CTL_TEST(xname,nid) { \
2910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2911 .name = xname, \
2912 .info = alc_test_pin_ctl_info, \
2913 .get = alc_test_pin_ctl_get, \
2914 .put = alc_test_pin_ctl_put, \
2915 .private_value = nid \
2916 }
2917
2918#define PIN_SRC_TEST(xname,nid) { \
2919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2920 .name = xname, \
2921 .info = alc_test_pin_src_info, \
2922 .get = alc_test_pin_src_get, \
2923 .put = alc_test_pin_src_put, \
2924 .private_value = nid \
2925 }
2926
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002927static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2930 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2931 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002932 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2934 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2935 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002936 PIN_CTL_TEST("Front Pin Mode", 0x14),
2937 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2938 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2939 PIN_CTL_TEST("Side Pin Mode", 0x17),
2940 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2941 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2942 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2943 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2944 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2945 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2946 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2947 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2948 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2949 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2950 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2951 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2952 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2953 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2954 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2955 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002958 {
2959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2960 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002961 .info = alc_ch_mode_info,
2962 .get = alc_ch_mode_get,
2963 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002964 },
2965 { } /* end */
2966};
2967
2968static struct hda_verb alc880_test_init_verbs[] = {
2969 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002970 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2972 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2973 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2974 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2975 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2976 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2977 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002978 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2981 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2982 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002983 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2986 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2987 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002988 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002989 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2991 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2992 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002993 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2998 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002999 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003004 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003006 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003011 /* Analog input/passthru */
3012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003017 { }
3018};
3019#endif
3020
Linus Torvalds1da177e2005-04-16 15:20:36 -07003021/*
3022 */
3023
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003024static const char *alc880_models[ALC880_MODEL_LAST] = {
3025 [ALC880_3ST] = "3stack",
3026 [ALC880_TCL_S700] = "tcl",
3027 [ALC880_3ST_DIG] = "3stack-digout",
3028 [ALC880_CLEVO] = "clevo",
3029 [ALC880_5ST] = "5stack",
3030 [ALC880_5ST_DIG] = "5stack-digout",
3031 [ALC880_W810] = "w810",
3032 [ALC880_Z71V] = "z71v",
3033 [ALC880_6ST] = "6stack",
3034 [ALC880_6ST_DIG] = "6stack-digout",
3035 [ALC880_ASUS] = "asus",
3036 [ALC880_ASUS_W1V] = "asus-w1v",
3037 [ALC880_ASUS_DIG] = "asus-dig",
3038 [ALC880_ASUS_DIG2] = "asus-dig2",
3039 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003040 [ALC880_UNIWILL_P53] = "uniwill-p53",
3041 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003042 [ALC880_F1734] = "F1734",
3043 [ALC880_LG] = "lg",
3044 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003045 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003046#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003047 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003048#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003049 [ALC880_AUTO] = "auto",
3050};
3051
3052static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003053 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003054 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3055 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3056 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3057 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3058 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3059 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3060 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3061 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003062 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3063 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003064 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3065 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3066 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3067 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3068 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3069 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3070 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3071 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3072 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3073 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003074 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003075 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3076 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3077 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003078 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003079 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003080 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3081 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3083 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003084 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3085 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3086 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3087 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003088 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3089 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003090 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003091 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003092 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003093 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003094 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3095 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003096 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003097 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003098 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003099 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003100 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003101 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003102 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003103 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003104 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003105 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3106 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003107 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003108 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3109 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3110 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3111 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003112 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3113 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003114 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003115 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003116 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3117 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003118 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3119 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3120 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003121 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3122 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3123 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003124 {}
3125};
3126
Takashi Iwai16ded522005-06-10 19:58:24 +02003127/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003128 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003130static struct alc_config_preset alc880_presets[] = {
3131 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003133 .init_verbs = { alc880_volume_init_verbs,
3134 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003137 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3138 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003139 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 .input_mux = &alc880_capture_source,
3141 },
3142 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003143 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003144 .init_verbs = { alc880_volume_init_verbs,
3145 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003146 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003147 .dac_nids = alc880_dac_nids,
3148 .dig_out_nid = ALC880_DIGOUT_NID,
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 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003154 [ALC880_TCL_S700] = {
3155 .mixers = { alc880_tcl_s700_mixer },
3156 .init_verbs = { alc880_volume_init_verbs,
3157 alc880_pin_tcl_S700_init_verbs,
3158 alc880_gpio2_init_verbs },
3159 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3160 .dac_nids = alc880_dac_nids,
3161 .hp_nid = 0x03,
3162 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3163 .channel_mode = alc880_2_jack_modes,
3164 .input_mux = &alc880_capture_source,
3165 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003166 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003167 .mixers = { alc880_three_stack_mixer,
3168 alc880_five_stack_mixer},
3169 .init_verbs = { alc880_volume_init_verbs,
3170 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3172 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003173 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3174 .channel_mode = alc880_fivestack_modes,
3175 .input_mux = &alc880_capture_source,
3176 },
3177 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003178 .mixers = { alc880_three_stack_mixer,
3179 alc880_five_stack_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3183 .dac_nids = alc880_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
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 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003189 [ALC880_6ST] = {
3190 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003191 .init_verbs = { alc880_volume_init_verbs,
3192 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003193 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3194 .dac_nids = alc880_6st_dac_nids,
3195 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3196 .channel_mode = alc880_sixstack_modes,
3197 .input_mux = &alc880_6stack_capture_source,
3198 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003199 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003201 .init_verbs = { alc880_volume_init_verbs,
3202 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003203 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3204 .dac_nids = alc880_6st_dac_nids,
3205 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003206 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3207 .channel_mode = alc880_sixstack_modes,
3208 .input_mux = &alc880_6stack_capture_source,
3209 },
3210 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003212 .init_verbs = { alc880_volume_init_verbs,
3213 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003214 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003215 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3216 .dac_nids = alc880_w810_dac_nids,
3217 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003218 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3219 .channel_mode = alc880_w810_modes,
3220 .input_mux = &alc880_capture_source,
3221 },
3222 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003226 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3227 .dac_nids = alc880_z71v_dac_nids,
3228 .dig_out_nid = ALC880_DIGOUT_NID,
3229 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3231 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003232 .input_mux = &alc880_capture_source,
3233 },
3234 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003236 .init_verbs = { alc880_volume_init_verbs,
3237 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3239 .dac_nids = alc880_f1734_dac_nids,
3240 .hp_nid = 0x02,
3241 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3242 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003243 .input_mux = &alc880_f1734_capture_source,
3244 .unsol_event = alc880_uniwill_p53_unsol_event,
3245 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003246 },
3247 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 .init_verbs = { alc880_volume_init_verbs,
3250 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 alc880_gpio1_init_verbs },
3252 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3253 .dac_nids = alc880_asus_dac_nids,
3254 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3255 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003256 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003257 .input_mux = &alc880_capture_source,
3258 },
3259 [ALC880_ASUS_DIG] = {
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,
Takashi Iwai16ded522005-06-10 19:58:24 +02003266 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3268 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003269 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003270 .input_mux = &alc880_capture_source,
3271 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003272 [ALC880_ASUS_DIG2] = {
3273 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003274 .init_verbs = { alc880_volume_init_verbs,
3275 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003276 alc880_gpio2_init_verbs }, /* use GPIO2 */
3277 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3278 .dac_nids = alc880_asus_dac_nids,
3279 .dig_out_nid = ALC880_DIGOUT_NID,
3280 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3281 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003282 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003283 .input_mux = &alc880_capture_source,
3284 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003285 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003287 .init_verbs = { alc880_volume_init_verbs,
3288 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289 alc880_gpio1_init_verbs },
3290 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3291 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003292 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3294 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003295 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003296 .input_mux = &alc880_capture_source,
3297 },
3298 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003299 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003300 .init_verbs = { alc880_volume_init_verbs,
3301 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 .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 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003310 [ALC880_UNIWILL] = {
3311 .mixers = { alc880_uniwill_mixer },
3312 .init_verbs = { alc880_volume_init_verbs,
3313 alc880_uniwill_init_verbs },
3314 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3315 .dac_nids = alc880_asus_dac_nids,
3316 .dig_out_nid = ALC880_DIGOUT_NID,
3317 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3318 .channel_mode = alc880_threestack_modes,
3319 .need_dac_fix = 1,
3320 .input_mux = &alc880_capture_source,
3321 .unsol_event = alc880_uniwill_unsol_event,
3322 .init_hook = alc880_uniwill_automute,
3323 },
3324 [ALC880_UNIWILL_P53] = {
3325 .mixers = { alc880_uniwill_p53_mixer },
3326 .init_verbs = { alc880_volume_init_verbs,
3327 alc880_uniwill_p53_init_verbs },
3328 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3329 .dac_nids = alc880_asus_dac_nids,
3330 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003331 .channel_mode = alc880_threestack_modes,
3332 .input_mux = &alc880_capture_source,
3333 .unsol_event = alc880_uniwill_p53_unsol_event,
3334 .init_hook = alc880_uniwill_p53_hp_automute,
3335 },
3336 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003337 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003338 alc880_pcbeep_mixer, },
3339 .init_verbs = { alc880_volume_init_verbs,
3340 alc880_uniwill_p53_init_verbs,
3341 alc880_beep_init_verbs },
3342 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3343 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003344 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003345 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3346 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003347 .input_mux = &alc880_capture_source,
3348 .unsol_event = alc880_uniwill_p53_unsol_event,
3349 .init_hook = alc880_uniwill_p53_hp_automute,
3350 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003351 [ALC880_CLEVO] = {
3352 .mixers = { alc880_three_stack_mixer },
3353 .init_verbs = { alc880_volume_init_verbs,
3354 alc880_pin_clevo_init_verbs },
3355 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3356 .dac_nids = alc880_dac_nids,
3357 .hp_nid = 0x03,
3358 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3359 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003360 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003361 .input_mux = &alc880_capture_source,
3362 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003363 [ALC880_LG] = {
3364 .mixers = { alc880_lg_mixer },
3365 .init_verbs = { alc880_volume_init_verbs,
3366 alc880_lg_init_verbs },
3367 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3368 .dac_nids = alc880_lg_dac_nids,
3369 .dig_out_nid = ALC880_DIGOUT_NID,
3370 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3371 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003372 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003373 .input_mux = &alc880_lg_capture_source,
3374 .unsol_event = alc880_lg_unsol_event,
3375 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003376#ifdef CONFIG_SND_HDA_POWER_SAVE
3377 .loopbacks = alc880_lg_loopbacks,
3378#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003379 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003380 [ALC880_LG_LW] = {
3381 .mixers = { alc880_lg_lw_mixer },
3382 .init_verbs = { alc880_volume_init_verbs,
3383 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003384 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003385 .dac_nids = alc880_dac_nids,
3386 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003387 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3388 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003389 .input_mux = &alc880_lg_lw_capture_source,
3390 .unsol_event = alc880_lg_lw_unsol_event,
3391 .init_hook = alc880_lg_lw_automute,
3392 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003393 [ALC880_MEDION_RIM] = {
3394 .mixers = { alc880_medion_rim_mixer },
3395 .init_verbs = { alc880_volume_init_verbs,
3396 alc880_medion_rim_init_verbs,
3397 alc_gpio2_init_verbs },
3398 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3399 .dac_nids = alc880_dac_nids,
3400 .dig_out_nid = ALC880_DIGOUT_NID,
3401 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3402 .channel_mode = alc880_2_jack_modes,
3403 .input_mux = &alc880_medion_rim_capture_source,
3404 .unsol_event = alc880_medion_rim_unsol_event,
3405 .init_hook = alc880_medion_rim_automute,
3406 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003407#ifdef CONFIG_SND_DEBUG
3408 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 .mixers = { alc880_test_mixer },
3410 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003411 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3412 .dac_nids = alc880_test_dac_nids,
3413 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003414 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3415 .channel_mode = alc880_test_modes,
3416 .input_mux = &alc880_test_capture_source,
3417 },
3418#endif
3419};
3420
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003421/*
3422 * Automatic parse of I/O pins from the BIOS configuration
3423 */
3424
3425#define NUM_CONTROL_ALLOC 32
3426#define NUM_VERB_ALLOC 32
3427
3428enum {
3429 ALC_CTL_WIDGET_VOL,
3430 ALC_CTL_WIDGET_MUTE,
3431 ALC_CTL_BIND_MUTE,
3432};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003433static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3435 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003436 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437};
3438
3439/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003440static int add_control(struct alc_spec *spec, int type, const char *name,
3441 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003442{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003443 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003444
3445 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3446 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003448 /* array + terminator */
3449 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3450 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451 return -ENOMEM;
3452 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003453 memcpy(knew, spec->kctl_alloc,
3454 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455 kfree(spec->kctl_alloc);
3456 }
3457 spec->kctl_alloc = knew;
3458 spec->num_kctl_alloc = num;
3459 }
3460
3461 knew = &spec->kctl_alloc[spec->num_kctl_used];
3462 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003463 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003464 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465 return -ENOMEM;
3466 knew->private_value = val;
3467 spec->num_kctl_used++;
3468 return 0;
3469}
3470
3471#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3472#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3473#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3474#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3475#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3476#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3477#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3478#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3479#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3480#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3481#define ALC880_PIN_CD_NID 0x1c
3482
3483/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003484static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3485 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486{
3487 hda_nid_t nid;
3488 int assigned[4];
3489 int i, j;
3490
3491 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003492 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003493
3494 /* check the pins hardwired to audio widget */
3495 for (i = 0; i < cfg->line_outs; i++) {
3496 nid = cfg->line_out_pins[i];
3497 if (alc880_is_fixed_pin(nid)) {
3498 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003499 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500 assigned[idx] = 1;
3501 }
3502 }
3503 /* left pins can be connect to any audio widget */
3504 for (i = 0; i < cfg->line_outs; i++) {
3505 nid = cfg->line_out_pins[i];
3506 if (alc880_is_fixed_pin(nid))
3507 continue;
3508 /* search for an empty channel */
3509 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003510 if (!assigned[j]) {
3511 spec->multiout.dac_nids[i] =
3512 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 assigned[j] = 1;
3514 break;
3515 }
3516 }
3517 }
3518 spec->multiout.num_dacs = cfg->line_outs;
3519 return 0;
3520}
3521
3522/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003523static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3524 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525{
3526 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003527 static const char *chname[4] = {
3528 "Front", "Surround", NULL /*CLFE*/, "Side"
3529 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003530 hda_nid_t nid;
3531 int i, err;
3532
3533 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003534 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003535 continue;
3536 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3537 if (i == 2) {
3538 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003539 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3540 "Center Playback Volume",
3541 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3542 HDA_OUTPUT));
3543 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003544 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003545 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3546 "LFE Playback Volume",
3547 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3548 HDA_OUTPUT));
3549 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003551 err = add_control(spec, ALC_CTL_BIND_MUTE,
3552 "Center Playback Switch",
3553 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3554 HDA_INPUT));
3555 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 err = add_control(spec, ALC_CTL_BIND_MUTE,
3558 "LFE Playback Switch",
3559 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3560 HDA_INPUT));
3561 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003562 return err;
3563 } else {
3564 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003565 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3566 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3567 HDA_OUTPUT));
3568 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 return err;
3570 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003571 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3572 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3573 HDA_INPUT));
3574 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 return err;
3576 }
3577 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578 return 0;
3579}
3580
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003581/* add playback controls for speaker and HP outputs */
3582static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3583 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003584{
3585 hda_nid_t nid;
3586 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003587 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003589 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590 return 0;
3591
3592 if (alc880_is_fixed_pin(pin)) {
3593 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003594 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003595 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003597 else
3598 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 /* control HP volume/switch on the output mixer amp */
3600 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003601 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003602 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3603 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003605 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003606 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003607 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3608 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3609 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003610 return err;
3611 } else if (alc880_is_multi_pin(pin)) {
3612 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003614 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003615 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3616 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3617 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618 return err;
3619 }
3620 return 0;
3621}
3622
3623/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003624static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3625 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003626 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627{
3628 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003629 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630
3631 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003632 err = add_control(spec, ALC_CTL_WIDGET_VOL, 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 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003637 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3638 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3639 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640 return err;
3641 return 0;
3642}
3643
3644/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003645static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3646 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003647{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003648 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003649 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003650
3651 for (i = 0; i < AUTO_PIN_LAST; i++) {
3652 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003653 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003654 err = new_analog_input(spec, cfg->input_pins[i],
3655 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003656 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 if (err < 0)
3658 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003659 imux->items[imux->num_items].label =
3660 auto_pin_cfg_labels[i];
3661 imux->items[imux->num_items].index =
3662 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003663 imux->num_items++;
3664 }
3665 }
3666 return 0;
3667}
3668
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003669static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3670 unsigned int pin_type)
3671{
3672 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3673 pin_type);
3674 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003675 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3676 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003677}
3678
Kailang Yangdf694da2005-12-05 19:42:22 +01003679static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3680 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003681 int dac_idx)
3682{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003683 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003684 /* need the manual connection? */
3685 if (alc880_is_multi_pin(nid)) {
3686 struct alc_spec *spec = codec->spec;
3687 int idx = alc880_multi_pin_idx(nid);
3688 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3689 AC_VERB_SET_CONNECT_SEL,
3690 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3691 }
3692}
3693
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003694static int get_pin_type(int line_out_type)
3695{
3696 if (line_out_type == AUTO_PIN_HP_OUT)
3697 return PIN_HP;
3698 else
3699 return PIN_OUT;
3700}
3701
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702static void alc880_auto_init_multi_out(struct hda_codec *codec)
3703{
3704 struct alc_spec *spec = codec->spec;
3705 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003706
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003707 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708 for (i = 0; i < spec->autocfg.line_outs; i++) {
3709 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003710 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3711 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003712 }
3713}
3714
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003715static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716{
3717 struct alc_spec *spec = codec->spec;
3718 hda_nid_t pin;
3719
Takashi Iwai82bc9552006-03-21 11:24:42 +01003720 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003721 if (pin) /* connect to front */
3722 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003723 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003724 if (pin) /* connect to front */
3725 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3726}
3727
3728static void alc880_auto_init_analog_input(struct hda_codec *codec)
3729{
3730 struct alc_spec *spec = codec->spec;
3731 int i;
3732
3733 for (i = 0; i < AUTO_PIN_LAST; i++) {
3734 hda_nid_t nid = spec->autocfg.input_pins[i];
3735 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003736 snd_hda_codec_write(codec, nid, 0,
3737 AC_VERB_SET_PIN_WIDGET_CONTROL,
3738 i <= AUTO_PIN_FRONT_MIC ?
3739 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003741 snd_hda_codec_write(codec, nid, 0,
3742 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003743 AMP_OUT_MUTE);
3744 }
3745 }
3746}
3747
3748/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003749/* return 1 if successful, 0 if the proper config is not found,
3750 * or a negative error code
3751 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752static int alc880_parse_auto_config(struct hda_codec *codec)
3753{
3754 struct alc_spec *spec = codec->spec;
3755 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003756 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003757
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003758 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3759 alc880_ignore);
3760 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003763 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003764
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003765 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3766 if (err < 0)
3767 return err;
3768 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3769 if (err < 0)
3770 return err;
3771 err = alc880_auto_create_extra_out(spec,
3772 spec->autocfg.speaker_pins[0],
3773 "Speaker");
3774 if (err < 0)
3775 return err;
3776 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3777 "Headphone");
3778 if (err < 0)
3779 return err;
3780 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3781 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003782 return err;
3783
3784 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3785
3786 if (spec->autocfg.dig_out_pin)
3787 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3788 if (spec->autocfg.dig_in_pin)
3789 spec->dig_in_nid = ALC880_DIGIN_NID;
3790
3791 if (spec->kctl_alloc)
3792 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3793
3794 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3795
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003796 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003797 spec->input_mux = &spec->private_imux;
3798
3799 return 1;
3800}
3801
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003802/* additional initialization for auto-configuration model */
3803static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003804{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003805 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003807 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003808 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003809 if (spec->unsol_event)
3810 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811}
3812
3813/*
3814 * OK, here we have finally the patch for ALC880
3815 */
3816
Linus Torvalds1da177e2005-04-16 15:20:36 -07003817static int patch_alc880(struct hda_codec *codec)
3818{
3819 struct alc_spec *spec;
3820 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003821 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003822
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003823 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003824 if (spec == NULL)
3825 return -ENOMEM;
3826
3827 codec->spec = spec;
3828
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003829 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3830 alc880_models,
3831 alc880_cfg_tbl);
3832 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003833 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3834 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003835 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003836 }
3837
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003838 if (board_config == ALC880_AUTO) {
3839 /* automatic parse from the BIOS config */
3840 err = alc880_parse_auto_config(codec);
3841 if (err < 0) {
3842 alc_free(codec);
3843 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003844 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003845 printk(KERN_INFO
3846 "hda_codec: Cannot set up configuration "
3847 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 board_config = ALC880_3ST;
3849 }
3850 }
3851
Kailang Yangdf694da2005-12-05 19:42:22 +01003852 if (board_config != ALC880_AUTO)
3853 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003854
3855 spec->stream_name_analog = "ALC880 Analog";
3856 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3857 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003858 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003859
3860 spec->stream_name_digital = "ALC880 Digital";
3861 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3862 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3863
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003864 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003865 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003866 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003867 /* get type */
3868 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003869 if (wcap != AC_WID_AUD_IN) {
3870 spec->adc_nids = alc880_adc_nids_alt;
3871 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003872 spec->mixers[spec->num_mixers] =
3873 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003874 spec->num_mixers++;
3875 } else {
3876 spec->adc_nids = alc880_adc_nids;
3877 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3878 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3879 spec->num_mixers++;
3880 }
3881 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003882
Takashi Iwai2134ea42008-01-10 16:53:55 +01003883 spec->vmaster_nid = 0x0c;
3884
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003886 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003887 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003888#ifdef CONFIG_SND_HDA_POWER_SAVE
3889 if (!spec->loopback.amplist)
3890 spec->loopback.amplist = alc880_loopbacks;
3891#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892
3893 return 0;
3894}
3895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003896
Linus Torvalds1da177e2005-04-16 15:20:36 -07003897/*
3898 * ALC260 support
3899 */
3900
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003901static hda_nid_t alc260_dac_nids[1] = {
3902 /* front */
3903 0x02,
3904};
3905
3906static hda_nid_t alc260_adc_nids[1] = {
3907 /* ADC0 */
3908 0x04,
3909};
3910
Kailang Yangdf694da2005-12-05 19:42:22 +01003911static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003912 /* ADC1 */
3913 0x05,
3914};
3915
Kailang Yangdf694da2005-12-05 19:42:22 +01003916static hda_nid_t alc260_hp_adc_nids[2] = {
3917 /* ADC1, 0 */
3918 0x05, 0x04
3919};
3920
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003921/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3922 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3923 */
3924static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003925 /* ADC0, ADC1 */
3926 0x04, 0x05
3927};
3928
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929#define ALC260_DIGOUT_NID 0x03
3930#define ALC260_DIGIN_NID 0x06
3931
3932static struct hda_input_mux alc260_capture_source = {
3933 .num_items = 4,
3934 .items = {
3935 { "Mic", 0x0 },
3936 { "Front Mic", 0x1 },
3937 { "Line", 0x2 },
3938 { "CD", 0x4 },
3939 },
3940};
3941
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003942/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003943 * headphone jack and the internal CD lines since these are the only pins at
3944 * which audio can appear. For flexibility, also allow the option of
3945 * recording the mixer output on the second ADC (ADC0 doesn't have a
3946 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003947 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003948static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3949 {
3950 .num_items = 3,
3951 .items = {
3952 { "Mic/Line", 0x0 },
3953 { "CD", 0x4 },
3954 { "Headphone", 0x2 },
3955 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003956 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003957 {
3958 .num_items = 4,
3959 .items = {
3960 { "Mic/Line", 0x0 },
3961 { "CD", 0x4 },
3962 { "Headphone", 0x2 },
3963 { "Mixer", 0x5 },
3964 },
3965 },
3966
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003967};
3968
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003969/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3970 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003971 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003972static struct hda_input_mux alc260_acer_capture_sources[2] = {
3973 {
3974 .num_items = 4,
3975 .items = {
3976 { "Mic", 0x0 },
3977 { "Line", 0x2 },
3978 { "CD", 0x4 },
3979 { "Headphone", 0x5 },
3980 },
3981 },
3982 {
3983 .num_items = 5,
3984 .items = {
3985 { "Mic", 0x0 },
3986 { "Line", 0x2 },
3987 { "CD", 0x4 },
3988 { "Headphone", 0x6 },
3989 { "Mixer", 0x5 },
3990 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003991 },
3992};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993/*
3994 * This is just place-holder, so there's something for alc_build_pcms to look
3995 * at when it calculates the maximum number of channels. ALC260 has no mixer
3996 * element which allows changing the channel mode, so the verb list is
3997 * never used.
3998 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003999static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000 { 2, NULL },
4001};
4002
Kailang Yangdf694da2005-12-05 19:42:22 +01004003
4004/* Mixer combinations
4005 *
4006 * basic: base_output + input + pc_beep + capture
4007 * HP: base_output + input + capture_alt
4008 * HP_3013: hp_3013 + input + capture
4009 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004010 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 */
4012
4013static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004014 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004015 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4017 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4018 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4019 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4020 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004021};
Kailang Yangdf694da2005-12-05 19:42:22 +01004022
4023static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004024 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4025 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4026 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4027 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4029 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004032 { } /* end */
4033};
4034
Kailang Yangdf694da2005-12-05 19:42:22 +01004035static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4036 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4037 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4038 { } /* end */
4039};
4040
Takashi Iwaibec15c32008-01-28 18:16:30 +01004041/* update HP, line and mono out pins according to the master switch */
4042static void alc260_hp_master_update(struct hda_codec *codec,
4043 hda_nid_t hp, hda_nid_t line,
4044 hda_nid_t mono)
4045{
4046 struct alc_spec *spec = codec->spec;
4047 unsigned int val = spec->master_sw ? PIN_HP : 0;
4048 /* change HP and line-out pins */
4049 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4050 val);
4051 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4052 val);
4053 /* mono (speaker) depending on the HP jack sense */
4054 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4055 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4056 val);
4057}
4058
4059static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4060 struct snd_ctl_elem_value *ucontrol)
4061{
4062 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4063 struct alc_spec *spec = codec->spec;
4064 *ucontrol->value.integer.value = spec->master_sw;
4065 return 0;
4066}
4067
4068static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4069 struct snd_ctl_elem_value *ucontrol)
4070{
4071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4072 struct alc_spec *spec = codec->spec;
4073 int val = !!*ucontrol->value.integer.value;
4074 hda_nid_t hp, line, mono;
4075
4076 if (val == spec->master_sw)
4077 return 0;
4078 spec->master_sw = val;
4079 hp = (kcontrol->private_value >> 16) & 0xff;
4080 line = (kcontrol->private_value >> 8) & 0xff;
4081 mono = kcontrol->private_value & 0xff;
4082 alc260_hp_master_update(codec, hp, line, mono);
4083 return 1;
4084}
4085
4086static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4087 {
4088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4089 .name = "Master Playback Switch",
4090 .info = snd_ctl_boolean_mono_info,
4091 .get = alc260_hp_master_sw_get,
4092 .put = alc260_hp_master_sw_put,
4093 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4094 },
4095 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4096 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4098 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4099 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4100 HDA_OUTPUT),
4101 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4102 { } /* end */
4103};
4104
4105static struct hda_verb alc260_hp_unsol_verbs[] = {
4106 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4107 {},
4108};
4109
4110static void alc260_hp_automute(struct hda_codec *codec)
4111{
4112 struct alc_spec *spec = codec->spec;
4113 unsigned int present;
4114
4115 present = snd_hda_codec_read(codec, 0x10, 0,
4116 AC_VERB_GET_PIN_SENSE, 0);
4117 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4118 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4119}
4120
4121static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4122{
4123 if ((res >> 26) == ALC880_HP_EVENT)
4124 alc260_hp_automute(codec);
4125}
4126
Kailang Yangdf694da2005-12-05 19:42:22 +01004127static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004128 {
4129 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4130 .name = "Master Playback Switch",
4131 .info = snd_ctl_boolean_mono_info,
4132 .get = alc260_hp_master_sw_get,
4133 .put = alc260_hp_master_sw_put,
4134 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4135 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004136 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4137 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4138 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4139 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004142 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4143 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 { } /* end */
4145};
4146
Kailang Yang3f878302008-08-26 13:02:23 +02004147static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4148 .ops = &snd_hda_bind_vol,
4149 .values = {
4150 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4151 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4152 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4153 0
4154 },
4155};
4156
4157static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4158 .ops = &snd_hda_bind_sw,
4159 .values = {
4160 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4161 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4162 0
4163 },
4164};
4165
4166static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4167 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4168 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4169 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4171 { } /* end */
4172};
4173
Takashi Iwaibec15c32008-01-28 18:16:30 +01004174static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4175 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4176 {},
4177};
4178
4179static void alc260_hp_3013_automute(struct hda_codec *codec)
4180{
4181 struct alc_spec *spec = codec->spec;
4182 unsigned int present;
4183
4184 present = snd_hda_codec_read(codec, 0x15, 0,
4185 AC_VERB_GET_PIN_SENSE, 0);
4186 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4187 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4188}
4189
4190static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4191 unsigned int res)
4192{
4193 if ((res >> 26) == ALC880_HP_EVENT)
4194 alc260_hp_3013_automute(codec);
4195}
4196
Kailang Yang3f878302008-08-26 13:02:23 +02004197static void alc260_hp_3012_automute(struct hda_codec *codec)
4198{
4199 unsigned int present, bits;
4200
4201 present = snd_hda_codec_read(codec, 0x10, 0,
4202 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4203
4204 bits = present ? 0 : PIN_OUT;
4205 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4206 bits);
4207 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4208 bits);
4209 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4210 bits);
4211}
4212
4213static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4214 unsigned int res)
4215{
4216 if ((res >> 26) == ALC880_HP_EVENT)
4217 alc260_hp_3012_automute(codec);
4218}
4219
4220/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004221 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4222 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004223static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004224 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004225 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004226 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004227 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4228 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4229 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4230 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004231 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004232 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4233 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004234 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4235 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004236 { } /* end */
4237};
4238
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004239/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4240 * versions of the ALC260 don't act on requests to enable mic bias from NID
4241 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4242 * datasheet doesn't mention this restriction. At this stage it's not clear
4243 * whether this behaviour is intentional or is a hardware bug in chip
4244 * revisions available in early 2006. Therefore for now allow the
4245 * "Headphone Jack Mode" control to span all choices, but if it turns out
4246 * that the lack of mic bias for this NID is intentional we could change the
4247 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4248 *
4249 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4250 * don't appear to make the mic bias available from the "line" jack, even
4251 * though the NID used for this jack (0x14) can supply it. The theory is
4252 * that perhaps Acer have included blocking capacitors between the ALC260
4253 * and the output jack. If this turns out to be the case for all such
4254 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4255 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004256 *
4257 * The C20x Tablet series have a mono internal speaker which is controlled
4258 * via the chip's Mono sum widget and pin complex, so include the necessary
4259 * controls for such models. On models without a "mono speaker" the control
4260 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004261 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004262static struct snd_kcontrol_new alc260_acer_mixer[] = {
4263 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4264 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004265 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004266 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004267 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004268 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004269 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004270 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4271 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4273 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4274 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4275 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4276 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4277 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4278 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4279 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4280 { } /* end */
4281};
4282
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004283/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4284 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4285 */
4286static struct snd_kcontrol_new alc260_will_mixer[] = {
4287 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4288 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4290 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4291 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4292 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4293 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4294 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4295 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4296 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4297 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4298 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4299 { } /* end */
4300};
4301
4302/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4303 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4304 */
4305static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4306 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4307 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4309 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4310 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4311 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4312 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4313 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4314 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4315 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4316 { } /* end */
4317};
4318
Kailang Yangdf694da2005-12-05 19:42:22 +01004319/* capture mixer elements */
4320static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004321 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4322 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004323 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4324 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004325 {
4326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004327 /* The multiple "Capture Source" controls confuse alsamixer
4328 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004329 */
4330 /* .name = "Capture Source", */
4331 .name = "Input Source",
4332 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004333 .info = alc_mux_enum_info,
4334 .get = alc_mux_enum_get,
4335 .put = alc_mux_enum_put,
4336 },
4337 { } /* end */
4338};
4339
Kailang Yangdf694da2005-12-05 19:42:22 +01004340static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4341 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4342 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4343 {
4344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4345 /* The multiple "Capture Source" controls confuse alsamixer
4346 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004347 */
4348 /* .name = "Capture Source", */
4349 .name = "Input Source",
4350 .count = 1,
4351 .info = alc_mux_enum_info,
4352 .get = alc_mux_enum_get,
4353 .put = alc_mux_enum_put,
4354 },
4355 { } /* end */
4356};
4357
4358/*
4359 * initialization verbs
4360 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361static struct hda_verb alc260_init_verbs[] = {
4362 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004364 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004367 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004368 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004369 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004370 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004372 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004373 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004374 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004375 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004376 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004377 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004378 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004379 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4380 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004381 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004382 /* set connection select to line in (default select for this ADC) */
4383 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004384 /* mute capture amp left and right */
4385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4386 /* set connection select to line in (default select for this ADC) */
4387 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004388 /* set vol=0 Line-Out mixer amp left and right */
4389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4390 /* unmute pin widget amp left and right (no gain on this amp) */
4391 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4392 /* set vol=0 HP mixer amp left and right */
4393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4394 /* unmute pin widget amp left and right (no gain on this amp) */
4395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4396 /* set vol=0 Mono mixer amp left and right */
4397 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4398 /* unmute pin widget amp left and right (no gain on this amp) */
4399 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4400 /* unmute LINE-2 out pin */
4401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004402 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4403 * Line In 2 = 0x03
4404 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004405 /* mute analog inputs */
4406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004411 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004412 /* mute Front out path */
4413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4415 /* mute Headphone out path */
4416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4418 /* mute Mono out path */
4419 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004421 { }
4422};
4423
Takashi Iwai474167d2006-05-17 17:17:43 +02004424#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004425static struct hda_verb alc260_hp_init_verbs[] = {
4426 /* Headphone and output */
4427 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4428 /* mono output */
4429 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4430 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4431 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4432 /* Mic2 (front panel) pin widget for input and vref at 80% */
4433 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4434 /* Line In pin widget for input */
4435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4436 /* Line-2 pin widget for output */
4437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4438 /* CD pin widget for input */
4439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4440 /* unmute amp left and right */
4441 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4442 /* set connection select to line in (default select for this ADC) */
4443 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4444 /* unmute Line-Out mixer amp left and right (volume = 0) */
4445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4446 /* mute pin widget amp left and right (no gain on this amp) */
4447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4448 /* unmute HP mixer amp left and right (volume = 0) */
4449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4450 /* mute pin widget amp left and right (no gain on this amp) */
4451 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4453 * Line In 2 = 0x03
4454 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004455 /* mute analog inputs */
4456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004461 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4462 /* Unmute Front out path */
4463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4465 /* Unmute Headphone out path */
4466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4468 /* Unmute Mono out path */
4469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4471 { }
4472};
Takashi Iwai474167d2006-05-17 17:17:43 +02004473#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004474
4475static struct hda_verb alc260_hp_3013_init_verbs[] = {
4476 /* Line out and output */
4477 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4478 /* mono output */
4479 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4480 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4481 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4482 /* Mic2 (front panel) pin widget for input and vref at 80% */
4483 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4484 /* Line In pin widget for input */
4485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4486 /* Headphone pin widget for output */
4487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4488 /* CD pin widget for input */
4489 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4490 /* unmute amp left and right */
4491 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4492 /* set connection select to line in (default select for this ADC) */
4493 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4494 /* unmute Line-Out mixer amp left and right (volume = 0) */
4495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4496 /* mute pin widget amp left and right (no gain on this amp) */
4497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4498 /* unmute HP mixer amp left and right (volume = 0) */
4499 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4500 /* mute pin widget amp left and right (no gain on this amp) */
4501 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004502 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4503 * Line In 2 = 0x03
4504 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004505 /* mute analog inputs */
4506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004511 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4512 /* Unmute Front out path */
4513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4515 /* Unmute Headphone out path */
4516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4518 /* Unmute Mono out path */
4519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4521 { }
4522};
4523
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004524/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4526 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004527 */
4528static struct hda_verb alc260_fujitsu_init_verbs[] = {
4529 /* Disable all GPIOs */
4530 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4531 /* Internal speaker is connected to headphone pin */
4532 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4533 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004535 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4536 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4537 /* Ensure all other unused pins are disabled and muted. */
4538 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004540 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004541 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004542 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004543 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4545 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004546
Jonathan Woithef7ace402006-02-28 11:46:14 +01004547 /* Disable digital (SPDIF) pins */
4548 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4549 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004550
Kailang Yangea1fb292008-08-26 12:58:38 +02004551 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004552 * when acting as an output.
4553 */
4554 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4555
4556 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4563 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4564 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4565 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004566
Jonathan Woithef7ace402006-02-28 11:46:14 +01004567 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4568 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4569 /* Unmute Line1 pin widget output buffer since it starts as an output.
4570 * If the pin mode is changed by the user the pin mode control will
4571 * take care of enabling the pin's input/output buffers as needed.
4572 * Therefore there's no need to enable the input buffer at this
4573 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004574 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004576 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004577 * mixer ctrl)
4578 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004579 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004580
Jonathan Woithef7ace402006-02-28 11:46:14 +01004581 /* Mute capture amp left and right */
4582 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004583 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004584 * in (on mic1 pin)
4585 */
4586 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004587
Jonathan Woithef7ace402006-02-28 11:46:14 +01004588 /* Do the same for the second ADC: mute capture input amp and
4589 * set ADC connection to line in (on mic1 pin)
4590 */
4591 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4592 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004593
Jonathan Woithef7ace402006-02-28 11:46:14 +01004594 /* Mute all inputs to mixer widget (even unconnected ones) */
4595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004603
4604 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004605};
4606
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004607/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4608 * similar laptops (adapted from Fujitsu init verbs).
4609 */
4610static struct hda_verb alc260_acer_init_verbs[] = {
4611 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4612 * the headphone jack. Turn this on and rely on the standard mute
4613 * methods whenever the user wants to turn these outputs off.
4614 */
4615 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4616 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4617 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4618 /* Internal speaker/Headphone jack is connected to Line-out pin */
4619 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4620 /* Internal microphone/Mic jack is connected to Mic1 pin */
4621 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4622 /* Line In jack is connected to Line1 pin */
4623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004624 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4625 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004626 /* Ensure all other unused pins are disabled and muted. */
4627 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4628 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004629 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4630 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4633 /* Disable digital (SPDIF) pins */
4634 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4635 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4636
Kailang Yangea1fb292008-08-26 12:58:38 +02004637 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004638 * bus when acting as outputs.
4639 */
4640 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4641 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4642
4643 /* Start with output sum widgets muted and their output gains at min */
4644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4647 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4650 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4651 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 /* Unmute Line-out pin widget amp left and right
4655 * (no equiv mixer ctrl)
4656 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004658 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4659 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004660 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4661 * inputs. If the pin mode is changed by the user the pin mode control
4662 * will take care of enabling the pin's input/output buffers as needed.
4663 * Therefore there's no need to enable the input buffer at this
4664 * stage.
4665 */
4666 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4668
4669 /* Mute capture amp left and right */
4670 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4671 /* Set ADC connection select to match default mixer setting - mic
4672 * (on mic1 pin)
4673 */
4674 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4675
4676 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004677 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004678 */
4679 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004680 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004681
4682 /* Mute all inputs to mixer widget (even unconnected ones) */
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4691
4692 { }
4693};
4694
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004695static struct hda_verb alc260_will_verbs[] = {
4696 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4697 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4698 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4699 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4700 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4701 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4702 {}
4703};
4704
4705static struct hda_verb alc260_replacer_672v_verbs[] = {
4706 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4707 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4708 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4709
4710 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4711 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4712 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4713
4714 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4715 {}
4716};
4717
4718/* toggle speaker-output according to the hp-jack state */
4719static void alc260_replacer_672v_automute(struct hda_codec *codec)
4720{
4721 unsigned int present;
4722
4723 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4724 present = snd_hda_codec_read(codec, 0x0f, 0,
4725 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4726 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004727 snd_hda_codec_write_cache(codec, 0x01, 0,
4728 AC_VERB_SET_GPIO_DATA, 1);
4729 snd_hda_codec_write_cache(codec, 0x0f, 0,
4730 AC_VERB_SET_PIN_WIDGET_CONTROL,
4731 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004732 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004733 snd_hda_codec_write_cache(codec, 0x01, 0,
4734 AC_VERB_SET_GPIO_DATA, 0);
4735 snd_hda_codec_write_cache(codec, 0x0f, 0,
4736 AC_VERB_SET_PIN_WIDGET_CONTROL,
4737 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004738 }
4739}
4740
4741static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4742 unsigned int res)
4743{
4744 if ((res >> 26) == ALC880_HP_EVENT)
4745 alc260_replacer_672v_automute(codec);
4746}
4747
Kailang Yang3f878302008-08-26 13:02:23 +02004748static struct hda_verb alc260_hp_dc7600_verbs[] = {
4749 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4751 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4752 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4753 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4755 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4756 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4757 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4758 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4759 {}
4760};
4761
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004762/* Test configuration for debugging, modelled after the ALC880 test
4763 * configuration.
4764 */
4765#ifdef CONFIG_SND_DEBUG
4766static hda_nid_t alc260_test_dac_nids[1] = {
4767 0x02,
4768};
4769static hda_nid_t alc260_test_adc_nids[2] = {
4770 0x04, 0x05,
4771};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004772/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004773 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004774 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004775 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004776static struct hda_input_mux alc260_test_capture_sources[2] = {
4777 {
4778 .num_items = 7,
4779 .items = {
4780 { "MIC1 pin", 0x0 },
4781 { "MIC2 pin", 0x1 },
4782 { "LINE1 pin", 0x2 },
4783 { "LINE2 pin", 0x3 },
4784 { "CD pin", 0x4 },
4785 { "LINE-OUT pin", 0x5 },
4786 { "HP-OUT pin", 0x6 },
4787 },
4788 },
4789 {
4790 .num_items = 8,
4791 .items = {
4792 { "MIC1 pin", 0x0 },
4793 { "MIC2 pin", 0x1 },
4794 { "LINE1 pin", 0x2 },
4795 { "LINE2 pin", 0x3 },
4796 { "CD pin", 0x4 },
4797 { "Mixer", 0x5 },
4798 { "LINE-OUT pin", 0x6 },
4799 { "HP-OUT pin", 0x7 },
4800 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004801 },
4802};
4803static struct snd_kcontrol_new alc260_test_mixer[] = {
4804 /* Output driver widgets */
4805 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4806 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4807 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4808 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4809 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4810 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4811
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004812 /* Modes for retasking pin widgets
4813 * Note: the ALC260 doesn't seem to act on requests to enable mic
4814 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4815 * mention this restriction. At this stage it's not clear whether
4816 * this behaviour is intentional or is a hardware bug in chip
4817 * revisions available at least up until early 2006. Therefore for
4818 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4819 * choices, but if it turns out that the lack of mic bias for these
4820 * NIDs is intentional we could change their modes from
4821 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4822 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004823 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4824 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4825 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4826 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4827 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4828 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4829
4830 /* Loopback mixer controls */
4831 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4832 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4833 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4834 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4835 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4836 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4837 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4838 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4839 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4840 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4841 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4842 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4843 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4844 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4845 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4846 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004847
4848 /* Controls for GPIO pins, assuming they are configured as outputs */
4849 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4850 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4851 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4852 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4853
Jonathan Woithe92621f12006-02-28 11:47:47 +01004854 /* Switches to allow the digital IO pins to be enabled. The datasheet
4855 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004856 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004857 */
4858 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4859 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4860
Jonathan Woithef8225f62008-01-08 12:16:54 +01004861 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4862 * this output to turn on an external amplifier.
4863 */
4864 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4865 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4866
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004867 { } /* end */
4868};
4869static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004870 /* Enable all GPIOs as outputs with an initial value of 0 */
4871 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4872 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4873 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4874
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004875 /* Enable retasking pins as output, initially without power amp */
4876 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4877 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4880 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4882
Jonathan Woithe92621f12006-02-28 11:47:47 +01004883 /* Disable digital (SPDIF) pins initially, but users can enable
4884 * them via a mixer switch. In the case of SPDIF-out, this initverb
4885 * payload also sets the generation to 0, output to be in "consumer"
4886 * PCM format, copyright asserted, no pre-emphasis and no validity
4887 * control.
4888 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004889 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4890 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4891
Kailang Yangea1fb292008-08-26 12:58:38 +02004892 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004893 * OUT1 sum bus when acting as an output.
4894 */
4895 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4896 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4897 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4898 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4899
4900 /* Start with output sum widgets muted and their output gains at min */
4901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4910
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004911 /* Unmute retasking pin widget output buffers since the default
4912 * state appears to be output. As the pin mode is changed by the
4913 * user the pin mode control will take care of enabling the pin's
4914 * input/output buffers as needed.
4915 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004916 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4920 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 /* Also unmute the mono-out pin widget */
4923 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4924
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004925 /* Mute capture amp left and right */
4926 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004927 /* Set ADC connection select to match default mixer setting (mic1
4928 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004929 */
4930 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4931
4932 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004933 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004934 */
4935 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4936 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4937
4938 /* Mute all inputs to mixer widget (even unconnected ones) */
4939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4947
4948 { }
4949};
4950#endif
4951
Takashi Iwai63300792008-01-24 15:31:36 +01004952#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4953#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004954
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004955#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4956#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4957
Kailang Yangdf694da2005-12-05 19:42:22 +01004958/*
4959 * for BIOS auto-configuration
4960 */
4961
4962static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4963 const char *pfx)
4964{
4965 hda_nid_t nid_vol;
4966 unsigned long vol_val, sw_val;
4967 char name[32];
4968 int err;
4969
4970 if (nid >= 0x0f && nid < 0x11) {
4971 nid_vol = nid - 0x7;
4972 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4973 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4974 } else if (nid == 0x11) {
4975 nid_vol = nid - 0x7;
4976 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4977 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4978 } else if (nid >= 0x12 && nid <= 0x15) {
4979 nid_vol = 0x08;
4980 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4981 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4982 } else
4983 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004984
Kailang Yangdf694da2005-12-05 19:42:22 +01004985 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004986 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4987 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004988 return err;
4989 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004990 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4991 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004992 return err;
4993 return 1;
4994}
4995
4996/* add playback controls from the parsed DAC table */
4997static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4998 const struct auto_pin_cfg *cfg)
4999{
5000 hda_nid_t nid;
5001 int err;
5002
5003 spec->multiout.num_dacs = 1;
5004 spec->multiout.dac_nids = spec->private_dac_nids;
5005 spec->multiout.dac_nids[0] = 0x02;
5006
5007 nid = cfg->line_out_pins[0];
5008 if (nid) {
5009 err = alc260_add_playback_controls(spec, nid, "Front");
5010 if (err < 0)
5011 return err;
5012 }
5013
Takashi Iwai82bc9552006-03-21 11:24:42 +01005014 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005015 if (nid) {
5016 err = alc260_add_playback_controls(spec, nid, "Speaker");
5017 if (err < 0)
5018 return err;
5019 }
5020
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005021 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005022 if (nid) {
5023 err = alc260_add_playback_controls(spec, nid, "Headphone");
5024 if (err < 0)
5025 return err;
5026 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005027 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005028}
5029
5030/* create playback/capture controls for input pins */
5031static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5032 const struct auto_pin_cfg *cfg)
5033{
Kailang Yangdf694da2005-12-05 19:42:22 +01005034 struct hda_input_mux *imux = &spec->private_imux;
5035 int i, err, idx;
5036
5037 for (i = 0; i < AUTO_PIN_LAST; i++) {
5038 if (cfg->input_pins[i] >= 0x12) {
5039 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005040 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005041 auto_pin_cfg_labels[i], idx,
5042 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005043 if (err < 0)
5044 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045 imux->items[imux->num_items].label =
5046 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005047 imux->items[imux->num_items].index = idx;
5048 imux->num_items++;
5049 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005050 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005051 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005052 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005053 auto_pin_cfg_labels[i], idx,
5054 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005055 if (err < 0)
5056 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005057 imux->items[imux->num_items].label =
5058 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005059 imux->items[imux->num_items].index = idx;
5060 imux->num_items++;
5061 }
5062 }
5063 return 0;
5064}
5065
5066static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5067 hda_nid_t nid, int pin_type,
5068 int sel_idx)
5069{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005070 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005071 /* need the manual connection? */
5072 if (nid >= 0x12) {
5073 int idx = nid - 0x12;
5074 snd_hda_codec_write(codec, idx + 0x0b, 0,
5075 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005076 }
5077}
5078
5079static void alc260_auto_init_multi_out(struct hda_codec *codec)
5080{
5081 struct alc_spec *spec = codec->spec;
5082 hda_nid_t nid;
5083
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005084 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005085 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005086 if (nid) {
5087 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5088 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5089 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005090
Takashi Iwai82bc9552006-03-21 11:24:42 +01005091 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005092 if (nid)
5093 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5094
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005095 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005096 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005097 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005098}
Kailang Yangdf694da2005-12-05 19:42:22 +01005099
5100#define ALC260_PIN_CD_NID 0x16
5101static void alc260_auto_init_analog_input(struct hda_codec *codec)
5102{
5103 struct alc_spec *spec = codec->spec;
5104 int i;
5105
5106 for (i = 0; i < AUTO_PIN_LAST; i++) {
5107 hda_nid_t nid = spec->autocfg.input_pins[i];
5108 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005109 snd_hda_codec_write(codec, nid, 0,
5110 AC_VERB_SET_PIN_WIDGET_CONTROL,
5111 i <= AUTO_PIN_FRONT_MIC ?
5112 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005113 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005114 snd_hda_codec_write(codec, nid, 0,
5115 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005116 AMP_OUT_MUTE);
5117 }
5118 }
5119}
5120
5121/*
5122 * generic initialization of ADC, input mixers and output mixers
5123 */
5124static struct hda_verb alc260_volume_init_verbs[] = {
5125 /*
5126 * Unmute ADC0-1 and set the default input to mic-in
5127 */
5128 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5129 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5130 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5131 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005132
Kailang Yangdf694da2005-12-05 19:42:22 +01005133 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5134 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005135 * Note: PASD motherboards uses the Line In 2 as the input for
5136 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005137 */
5138 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005139 /* mute analog inputs */
5140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005145
5146 /*
5147 * Set up output mixers (0x08 - 0x0a)
5148 */
5149 /* set vol=0 to output mixers */
5150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5153 /* set up input amps for analog loopback */
5154 /* Amp Indices: DAC = 0, mixer = 1 */
5155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5159 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5160 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005161
Kailang Yangdf694da2005-12-05 19:42:22 +01005162 { }
5163};
5164
5165static int alc260_parse_auto_config(struct hda_codec *codec)
5166{
5167 struct alc_spec *spec = codec->spec;
5168 unsigned int wcap;
5169 int err;
5170 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5171
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005172 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5173 alc260_ignore);
5174 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005175 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005176 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5177 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005178 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005179 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005180 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005181 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5182 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005183 return err;
5184
5185 spec->multiout.max_channels = 2;
5186
5187 if (spec->autocfg.dig_out_pin)
5188 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5189 if (spec->kctl_alloc)
5190 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5191
5192 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5193
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005194 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005195 spec->input_mux = &spec->private_imux;
5196
5197 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005198 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005200 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005201 spec->adc_nids = alc260_adc_nids_alt;
5202 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5203 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005204 } else {
5205 spec->adc_nids = alc260_adc_nids;
5206 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5207 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005208 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005209 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005210
5211 return 1;
5212}
5213
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005214/* additional initialization for auto-configuration model */
5215static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005216{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005217 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005218 alc260_auto_init_multi_out(codec);
5219 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005220 if (spec->unsol_event)
5221 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005222}
5223
Takashi Iwaicb53c622007-08-10 17:21:45 +02005224#ifdef CONFIG_SND_HDA_POWER_SAVE
5225static struct hda_amp_list alc260_loopbacks[] = {
5226 { 0x07, HDA_INPUT, 0 },
5227 { 0x07, HDA_INPUT, 1 },
5228 { 0x07, HDA_INPUT, 2 },
5229 { 0x07, HDA_INPUT, 3 },
5230 { 0x07, HDA_INPUT, 4 },
5231 { } /* end */
5232};
5233#endif
5234
Kailang Yangdf694da2005-12-05 19:42:22 +01005235/*
5236 * ALC260 configurations
5237 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005238static const char *alc260_models[ALC260_MODEL_LAST] = {
5239 [ALC260_BASIC] = "basic",
5240 [ALC260_HP] = "hp",
5241 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005242 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005243 [ALC260_FUJITSU_S702X] = "fujitsu",
5244 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005245 [ALC260_WILL] = "will",
5246 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005247#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005248 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005249#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005250 [ALC260_AUTO] = "auto",
5251};
5252
5253static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005254 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005255 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005256 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005257 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005258 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005259 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005260 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005261 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5262 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5263 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5264 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5265 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5266 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5267 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5268 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5269 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005270 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005271 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005272 {}
5273};
5274
Kailang Yangdf694da2005-12-05 19:42:22 +01005275static struct alc_config_preset alc260_presets[] = {
5276 [ALC260_BASIC] = {
5277 .mixers = { alc260_base_output_mixer,
5278 alc260_input_mixer,
5279 alc260_pc_beep_mixer,
5280 alc260_capture_mixer },
5281 .init_verbs = { alc260_init_verbs },
5282 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5283 .dac_nids = alc260_dac_nids,
5284 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5285 .adc_nids = alc260_adc_nids,
5286 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5287 .channel_mode = alc260_modes,
5288 .input_mux = &alc260_capture_source,
5289 },
5290 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005291 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005292 alc260_input_mixer,
5293 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005294 .init_verbs = { alc260_init_verbs,
5295 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005296 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5297 .dac_nids = alc260_dac_nids,
5298 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5299 .adc_nids = alc260_hp_adc_nids,
5300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5301 .channel_mode = alc260_modes,
5302 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005303 .unsol_event = alc260_hp_unsol_event,
5304 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005305 },
Kailang Yang3f878302008-08-26 13:02:23 +02005306 [ALC260_HP_DC7600] = {
5307 .mixers = { alc260_hp_dc7600_mixer,
5308 alc260_input_mixer,
5309 alc260_capture_alt_mixer },
5310 .init_verbs = { alc260_init_verbs,
5311 alc260_hp_dc7600_verbs },
5312 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5313 .dac_nids = alc260_dac_nids,
5314 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5315 .adc_nids = alc260_hp_adc_nids,
5316 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5317 .channel_mode = alc260_modes,
5318 .input_mux = &alc260_capture_source,
5319 .unsol_event = alc260_hp_3012_unsol_event,
5320 .init_hook = alc260_hp_3012_automute,
5321 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005322 [ALC260_HP_3013] = {
5323 .mixers = { alc260_hp_3013_mixer,
5324 alc260_input_mixer,
5325 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005326 .init_verbs = { alc260_hp_3013_init_verbs,
5327 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005328 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5329 .dac_nids = alc260_dac_nids,
5330 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5331 .adc_nids = alc260_hp_adc_nids,
5332 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5333 .channel_mode = alc260_modes,
5334 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005335 .unsol_event = alc260_hp_3013_unsol_event,
5336 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005337 },
5338 [ALC260_FUJITSU_S702X] = {
5339 .mixers = { alc260_fujitsu_mixer,
5340 alc260_capture_mixer },
5341 .init_verbs = { alc260_fujitsu_init_verbs },
5342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5343 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005344 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5345 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5347 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005348 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5349 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005350 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005351 [ALC260_ACER] = {
5352 .mixers = { alc260_acer_mixer,
5353 alc260_capture_mixer },
5354 .init_verbs = { alc260_acer_init_verbs },
5355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5356 .dac_nids = alc260_dac_nids,
5357 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5358 .adc_nids = alc260_dual_adc_nids,
5359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5360 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005361 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5362 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005363 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005364 [ALC260_WILL] = {
5365 .mixers = { alc260_will_mixer,
5366 alc260_capture_mixer },
5367 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5368 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5369 .dac_nids = alc260_dac_nids,
5370 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5371 .adc_nids = alc260_adc_nids,
5372 .dig_out_nid = ALC260_DIGOUT_NID,
5373 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5374 .channel_mode = alc260_modes,
5375 .input_mux = &alc260_capture_source,
5376 },
5377 [ALC260_REPLACER_672V] = {
5378 .mixers = { alc260_replacer_672v_mixer,
5379 alc260_capture_mixer },
5380 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5381 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5382 .dac_nids = alc260_dac_nids,
5383 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5384 .adc_nids = alc260_adc_nids,
5385 .dig_out_nid = ALC260_DIGOUT_NID,
5386 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5387 .channel_mode = alc260_modes,
5388 .input_mux = &alc260_capture_source,
5389 .unsol_event = alc260_replacer_672v_unsol_event,
5390 .init_hook = alc260_replacer_672v_automute,
5391 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005392#ifdef CONFIG_SND_DEBUG
5393 [ALC260_TEST] = {
5394 .mixers = { alc260_test_mixer,
5395 alc260_capture_mixer },
5396 .init_verbs = { alc260_test_init_verbs },
5397 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5398 .dac_nids = alc260_test_dac_nids,
5399 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5400 .adc_nids = alc260_test_adc_nids,
5401 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5402 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005403 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5404 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005405 },
5406#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005407};
5408
Linus Torvalds1da177e2005-04-16 15:20:36 -07005409static int patch_alc260(struct hda_codec *codec)
5410{
5411 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005412 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005413
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005414 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005415 if (spec == NULL)
5416 return -ENOMEM;
5417
5418 codec->spec = spec;
5419
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005420 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5421 alc260_models,
5422 alc260_cfg_tbl);
5423 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005424 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5425 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005426 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005427 }
5428
Kailang Yangdf694da2005-12-05 19:42:22 +01005429 if (board_config == ALC260_AUTO) {
5430 /* automatic parse from the BIOS config */
5431 err = alc260_parse_auto_config(codec);
5432 if (err < 0) {
5433 alc_free(codec);
5434 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005435 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005436 printk(KERN_INFO
5437 "hda_codec: Cannot set up configuration "
5438 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005439 board_config = ALC260_BASIC;
5440 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005441 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005442
Kailang Yangdf694da2005-12-05 19:42:22 +01005443 if (board_config != ALC260_AUTO)
5444 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005445
5446 spec->stream_name_analog = "ALC260 Analog";
5447 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5448 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5449
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005450 spec->stream_name_digital = "ALC260 Digital";
5451 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5452 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5453
Takashi Iwai2134ea42008-01-10 16:53:55 +01005454 spec->vmaster_nid = 0x08;
5455
Linus Torvalds1da177e2005-04-16 15:20:36 -07005456 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005457 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005458 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005459#ifdef CONFIG_SND_HDA_POWER_SAVE
5460 if (!spec->loopback.amplist)
5461 spec->loopback.amplist = alc260_loopbacks;
5462#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005463
5464 return 0;
5465}
5466
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005467
Linus Torvalds1da177e2005-04-16 15:20:36 -07005468/*
5469 * ALC882 support
5470 *
5471 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5472 * configuration. Each pin widget can choose any input DACs and a mixer.
5473 * Each ADC is connected from a mixer of all inputs. This makes possible
5474 * 6-channel independent captures.
5475 *
5476 * In addition, an independent DAC for the multi-playback (not used in this
5477 * driver yet).
5478 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005479#define ALC882_DIGOUT_NID 0x06
5480#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005481
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005482static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005483 { 8, NULL }
5484};
5485
5486static hda_nid_t alc882_dac_nids[4] = {
5487 /* front, rear, clfe, rear_surr */
5488 0x02, 0x03, 0x04, 0x05
5489};
5490
Kailang Yangdf694da2005-12-05 19:42:22 +01005491/* identical with ALC880 */
5492#define alc882_adc_nids alc880_adc_nids
5493#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005494
Takashi Iwaie1406342008-02-11 18:32:32 +01005495static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5496static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5497
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498/* input MUX */
5499/* FIXME: should be a matrix-type input source selection */
5500
5501static struct hda_input_mux alc882_capture_source = {
5502 .num_items = 4,
5503 .items = {
5504 { "Mic", 0x0 },
5505 { "Front Mic", 0x1 },
5506 { "Line", 0x2 },
5507 { "CD", 0x4 },
5508 },
5509};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510#define alc882_mux_enum_info alc_mux_enum_info
5511#define alc882_mux_enum_get alc_mux_enum_get
5512
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005513static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5514 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515{
5516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5517 struct alc_spec *spec = codec->spec;
5518 const struct hda_input_mux *imux = spec->input_mux;
5519 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005520 hda_nid_t nid = spec->capsrc_nids ?
5521 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5523 unsigned int i, idx;
5524
5525 idx = ucontrol->value.enumerated.item[0];
5526 if (idx >= imux->num_items)
5527 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005528 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005529 return 0;
5530 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005531 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5532 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005533 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005534 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005535 }
5536 *cur_val = idx;
5537 return 1;
5538}
5539
Kailang Yangdf694da2005-12-05 19:42:22 +01005540/*
Kailang Yang272a5272007-05-14 11:00:38 +02005541 * 2ch mode
5542 */
5543static struct hda_verb alc882_3ST_ch2_init[] = {
5544 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5545 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5546 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5547 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5548 { } /* end */
5549};
5550
5551/*
5552 * 6ch mode
5553 */
5554static struct hda_verb alc882_3ST_ch6_init[] = {
5555 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5556 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5557 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5558 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5559 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5560 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5561 { } /* end */
5562};
5563
5564static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5565 { 2, alc882_3ST_ch2_init },
5566 { 6, alc882_3ST_ch6_init },
5567};
5568
5569/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005570 * 6ch mode
5571 */
5572static struct hda_verb alc882_sixstack_ch6_init[] = {
5573 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5574 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5575 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5576 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5577 { } /* end */
5578};
5579
5580/*
5581 * 8ch mode
5582 */
5583static struct hda_verb alc882_sixstack_ch8_init[] = {
5584 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5585 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5586 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5587 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5588 { } /* end */
5589};
5590
5591static struct hda_channel_mode alc882_sixstack_modes[2] = {
5592 { 6, alc882_sixstack_ch6_init },
5593 { 8, alc882_sixstack_ch8_init },
5594};
5595
Takashi Iwai87350ad2007-08-16 18:19:38 +02005596/*
5597 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5598 */
5599
5600/*
5601 * 2ch mode
5602 */
5603static struct hda_verb alc885_mbp_ch2_init[] = {
5604 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5605 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5607 { } /* end */
5608};
5609
5610/*
5611 * 6ch mode
5612 */
5613static struct hda_verb alc885_mbp_ch6_init[] = {
5614 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5615 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5616 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5617 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5618 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5619 { } /* end */
5620};
5621
5622static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5623 { 2, alc885_mbp_ch2_init },
5624 { 6, alc885_mbp_ch6_init },
5625};
5626
5627
Linus Torvalds1da177e2005-04-16 15:20:36 -07005628/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5629 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5630 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005631static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005634 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005635 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5637 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005638 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5639 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005640 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005641 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005648 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5650 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005651 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5653 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5654 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005655 { } /* end */
5656};
5657
Takashi Iwai87350ad2007-08-16 18:19:38 +02005658static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005659 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5660 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5661 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5662 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5664 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5666 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005667 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5669 { } /* end */
5670};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005671static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5674 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5675 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5676 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5677 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5681 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5682 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5683 { } /* end */
5684};
5685
Kailang Yang272a5272007-05-14 11:00:38 +02005686static struct snd_kcontrol_new alc882_targa_mixer[] = {
5687 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5688 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5690 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5691 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005697 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005699 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005700 { } /* end */
5701};
5702
5703/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5704 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5705 */
5706static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5707 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5708 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5709 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5710 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5711 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5712 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5713 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5714 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5715 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5716 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005720 { } /* end */
5721};
5722
Takashi Iwai914759b2007-09-06 14:52:04 +02005723static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5724 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5725 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5727 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5728 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5732 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5734 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5735 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5736 { } /* end */
5737};
5738
Kailang Yangdf694da2005-12-05 19:42:22 +01005739static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5740 {
5741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5742 .name = "Channel Mode",
5743 .info = alc_ch_mode_info,
5744 .get = alc_ch_mode_get,
5745 .put = alc_ch_mode_put,
5746 },
5747 { } /* end */
5748};
5749
Linus Torvalds1da177e2005-04-16 15:20:36 -07005750static struct hda_verb alc882_init_verbs[] = {
5751 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005755 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005759 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005763 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5766 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005767
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005768 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005772 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005776 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005777 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005778 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005779 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005780 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005781 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005782 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005783 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005784 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005786 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5787 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5790 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5793 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5795 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5796 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005797 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005799
5800 /* FIXME: use matrix-type input source selection */
5801 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5802 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005807 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005812 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5817 /* ADC1: mute amp left and right */
5818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005819 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005820 /* ADC2: mute amp left and right */
5821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005822 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005823 /* ADC3: mute amp left and right */
5824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005825 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005826
5827 { }
5828};
5829
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005830static struct hda_verb alc882_eapd_verbs[] = {
5831 /* change to EAPD mode */
5832 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005833 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005834 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005835};
5836
Tobin Davis9102cd12006-12-15 10:02:12 +01005837/* Mac Pro test */
5838static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5839 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5840 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5844 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5845 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5846 { } /* end */
5847};
5848
5849static struct hda_verb alc882_macpro_init_verbs[] = {
5850 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5854 /* Front Pin: output 0 (0x0c) */
5855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5857 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5858 /* Front Mic pin: input vref at 80% */
5859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5860 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5861 /* Speaker: output */
5862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5864 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5865 /* Headphone output (output 0 - 0x0c) */
5866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5868 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5869
5870 /* FIXME: use matrix-type input source selection */
5871 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5872 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5875 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5876 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5877 /* Input mixer2 */
5878 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5880 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5882 /* Input mixer3 */
5883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5887 /* ADC1: mute amp left and right */
5888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5889 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5890 /* ADC2: mute amp left and right */
5891 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5893 /* ADC3: mute amp left and right */
5894 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5895 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5896
5897 { }
5898};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005899
Takashi Iwai87350ad2007-08-16 18:19:38 +02005900/* Macbook Pro rev3 */
5901static struct hda_verb alc885_mbp3_init_verbs[] = {
5902 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5906 /* Rear mixer */
5907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5910 /* Front Pin: output 0 (0x0c) */
5911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5913 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5914 /* HP Pin: output 0 (0x0d) */
5915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5918 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5919 /* Mic (rear) pin: input vref at 80% */
5920 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5922 /* Front Mic pin: input vref at 80% */
5923 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5925 /* Line In pin: use output 1 when in LineOut mode */
5926 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5928 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5929
5930 /* FIXME: use matrix-type input source selection */
5931 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5932 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5937 /* Input mixer2 */
5938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5942 /* Input mixer3 */
5943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5947 /* ADC1: mute amp left and right */
5948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5949 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5950 /* ADC2: mute amp left and right */
5951 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5952 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5953 /* ADC3: mute amp left and right */
5954 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5955 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5956
5957 { }
5958};
5959
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005960/* iMac 24 mixer. */
5961static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5962 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5963 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5964 { } /* end */
5965};
5966
5967/* iMac 24 init verbs. */
5968static struct hda_verb alc885_imac24_init_verbs[] = {
5969 /* Internal speakers: output 0 (0x0c) */
5970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5971 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5972 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5973 /* Internal speakers: output 0 (0x0c) */
5974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5976 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5977 /* Headphone: output 0 (0x0c) */
5978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5980 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5981 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5982 /* Front Mic: input vref at 80% */
5983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5984 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5985 { }
5986};
5987
5988/* Toggle speaker-output according to the hp-jack state */
5989static void alc885_imac24_automute(struct hda_codec *codec)
5990{
5991 unsigned int present;
5992
5993 present = snd_hda_codec_read(codec, 0x14, 0,
5994 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005995 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5996 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5997 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5998 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005999}
6000
6001/* Processes unsolicited events. */
6002static void alc885_imac24_unsol_event(struct hda_codec *codec,
6003 unsigned int res)
6004{
6005 /* Headphone insertion or removal. */
6006 if ((res >> 26) == ALC880_HP_EVENT)
6007 alc885_imac24_automute(codec);
6008}
6009
Takashi Iwai87350ad2007-08-16 18:19:38 +02006010static void alc885_mbp3_automute(struct hda_codec *codec)
6011{
6012 unsigned int present;
6013
6014 present = snd_hda_codec_read(codec, 0x15, 0,
6015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6016 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6017 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6018 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6019 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6020
6021}
6022static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6023 unsigned int res)
6024{
6025 /* Headphone insertion or removal. */
6026 if ((res >> 26) == ALC880_HP_EVENT)
6027 alc885_mbp3_automute(codec);
6028}
6029
6030
Kailang Yang272a5272007-05-14 11:00:38 +02006031static struct hda_verb alc882_targa_verbs[] = {
6032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6034
6035 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006037
Kailang Yang272a5272007-05-14 11:00:38 +02006038 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6039 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6040 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6041
6042 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6043 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6045 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6046 { } /* end */
6047};
6048
6049/* toggle speaker-output according to the hp-jack state */
6050static void alc882_targa_automute(struct hda_codec *codec)
6051{
6052 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006053
Kailang Yang272a5272007-05-14 11:00:38 +02006054 present = snd_hda_codec_read(codec, 0x14, 0,
6055 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006056 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6057 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006058 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6059 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006060}
6061
6062static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6063{
6064 /* Looks like the unsol event is incompatible with the standard
6065 * definition. 4bit tag is placed at 26 bit!
6066 */
6067 if (((res >> 26) == ALC880_HP_EVENT)) {
6068 alc882_targa_automute(codec);
6069 }
6070}
6071
6072static struct hda_verb alc882_asus_a7j_verbs[] = {
6073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6075
6076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6078 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006079
Kailang Yang272a5272007-05-14 11:00:38 +02006080 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6082 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6083
6084 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6085 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6086 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6087 { } /* end */
6088};
6089
Takashi Iwai914759b2007-09-06 14:52:04 +02006090static struct hda_verb alc882_asus_a7m_verbs[] = {
6091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6093
6094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006097
Takashi Iwai914759b2007-09-06 14:52:04 +02006098 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6100 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6101
6102 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6103 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6105 { } /* end */
6106};
6107
Tobin Davis9102cd12006-12-15 10:02:12 +01006108static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6109{
6110 unsigned int gpiostate, gpiomask, gpiodir;
6111
6112 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6113 AC_VERB_GET_GPIO_DATA, 0);
6114
6115 if (!muted)
6116 gpiostate |= (1 << pin);
6117 else
6118 gpiostate &= ~(1 << pin);
6119
6120 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6121 AC_VERB_GET_GPIO_MASK, 0);
6122 gpiomask |= (1 << pin);
6123
6124 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6125 AC_VERB_GET_GPIO_DIRECTION, 0);
6126 gpiodir |= (1 << pin);
6127
6128
6129 snd_hda_codec_write(codec, codec->afg, 0,
6130 AC_VERB_SET_GPIO_MASK, gpiomask);
6131 snd_hda_codec_write(codec, codec->afg, 0,
6132 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6133
6134 msleep(1);
6135
6136 snd_hda_codec_write(codec, codec->afg, 0,
6137 AC_VERB_SET_GPIO_DATA, gpiostate);
6138}
6139
Takashi Iwai7debbe52007-08-16 15:01:03 +02006140/* set up GPIO at initialization */
6141static void alc885_macpro_init_hook(struct hda_codec *codec)
6142{
6143 alc882_gpio_mute(codec, 0, 0);
6144 alc882_gpio_mute(codec, 1, 0);
6145}
6146
6147/* set up GPIO and update auto-muting at initialization */
6148static void alc885_imac24_init_hook(struct hda_codec *codec)
6149{
6150 alc885_macpro_init_hook(codec);
6151 alc885_imac24_automute(codec);
6152}
6153
Kailang Yangdf694da2005-12-05 19:42:22 +01006154/*
6155 * generic initialization of ADC, input mixers and output mixers
6156 */
6157static struct hda_verb alc882_auto_init_verbs[] = {
6158 /*
6159 * Unmute ADC0-2 and set the default input to mic-in
6160 */
6161 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6165 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6166 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6167
Takashi Iwaicb53c622007-08-10 17:21:45 +02006168 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006170 * Note: PASD motherboards uses the Line In 2 as the input for
6171 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006172 */
6173 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006179
6180 /*
6181 * Set up output mixers (0x0c - 0x0f)
6182 */
6183 /* set vol=0 to output mixers */
6184 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6185 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6186 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6187 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6188 /* set up input amps for analog loopback */
6189 /* Amp Indices: DAC = 0, mixer = 1 */
6190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6192 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6196 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6198 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6199 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6200
6201 /* FIXME: use matrix-type input source selection */
6202 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6203 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6208 /* Input mixer2 */
6209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6213 /* Input mixer3 */
6214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6218
6219 { }
6220};
6221
6222/* capture mixer elements */
6223static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6224 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6225 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6226 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6227 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6228 {
6229 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6230 /* The multiple "Capture Source" controls confuse alsamixer
6231 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006232 */
6233 /* .name = "Capture Source", */
6234 .name = "Input Source",
6235 .count = 2,
6236 .info = alc882_mux_enum_info,
6237 .get = alc882_mux_enum_get,
6238 .put = alc882_mux_enum_put,
6239 },
6240 { } /* end */
6241};
6242
6243static struct snd_kcontrol_new alc882_capture_mixer[] = {
6244 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6245 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6246 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6247 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6248 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6249 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6250 {
6251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6252 /* The multiple "Capture Source" controls confuse alsamixer
6253 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006254 */
6255 /* .name = "Capture Source", */
6256 .name = "Input Source",
6257 .count = 3,
6258 .info = alc882_mux_enum_info,
6259 .get = alc882_mux_enum_get,
6260 .put = alc882_mux_enum_put,
6261 },
6262 { } /* end */
6263};
6264
Takashi Iwaicb53c622007-08-10 17:21:45 +02006265#ifdef CONFIG_SND_HDA_POWER_SAVE
6266#define alc882_loopbacks alc880_loopbacks
6267#endif
6268
Kailang Yangdf694da2005-12-05 19:42:22 +01006269/* pcm configuration: identiacal with ALC880 */
6270#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6271#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6272#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6273#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6274
6275/*
6276 * configuration and preset
6277 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006278static const char *alc882_models[ALC882_MODEL_LAST] = {
6279 [ALC882_3ST_DIG] = "3stack-dig",
6280 [ALC882_6ST_DIG] = "6stack-dig",
6281 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006282 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006283 [ALC882_TARGA] = "targa",
6284 [ALC882_ASUS_A7J] = "asus-a7j",
6285 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006286 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006287 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006288 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006289 [ALC882_AUTO] = "auto",
6290};
6291
6292static struct snd_pci_quirk alc882_cfg_tbl[] = {
6293 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006294 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006295 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006296 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006297 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006298 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006299 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006300 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006301 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006302 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6303 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6304 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 {}
6306};
6307
6308static struct alc_config_preset alc882_presets[] = {
6309 [ALC882_3ST_DIG] = {
6310 .mixers = { alc882_base_mixer },
6311 .init_verbs = { alc882_init_verbs },
6312 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6313 .dac_nids = alc882_dac_nids,
6314 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006315 .dig_in_nid = ALC882_DIGIN_NID,
6316 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6317 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006318 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006319 .input_mux = &alc882_capture_source,
6320 },
6321 [ALC882_6ST_DIG] = {
6322 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6323 .init_verbs = { alc882_init_verbs },
6324 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6325 .dac_nids = alc882_dac_nids,
6326 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 .dig_in_nid = ALC882_DIGIN_NID,
6328 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6329 .channel_mode = alc882_sixstack_modes,
6330 .input_mux = &alc882_capture_source,
6331 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006332 [ALC882_ARIMA] = {
6333 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6334 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6335 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6336 .dac_nids = alc882_dac_nids,
6337 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6338 .channel_mode = alc882_sixstack_modes,
6339 .input_mux = &alc882_capture_source,
6340 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006341 [ALC882_W2JC] = {
6342 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6343 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6344 alc880_gpio1_init_verbs },
6345 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6346 .dac_nids = alc882_dac_nids,
6347 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6348 .channel_mode = alc880_threestack_modes,
6349 .need_dac_fix = 1,
6350 .input_mux = &alc882_capture_source,
6351 .dig_out_nid = ALC882_DIGOUT_NID,
6352 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006353 [ALC885_MBP3] = {
6354 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6355 .init_verbs = { alc885_mbp3_init_verbs,
6356 alc880_gpio1_init_verbs },
6357 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6358 .dac_nids = alc882_dac_nids,
6359 .channel_mode = alc885_mbp_6ch_modes,
6360 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6361 .input_mux = &alc882_capture_source,
6362 .dig_out_nid = ALC882_DIGOUT_NID,
6363 .dig_in_nid = ALC882_DIGIN_NID,
6364 .unsol_event = alc885_mbp3_unsol_event,
6365 .init_hook = alc885_mbp3_automute,
6366 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006367 [ALC885_MACPRO] = {
6368 .mixers = { alc882_macpro_mixer },
6369 .init_verbs = { alc882_macpro_init_verbs },
6370 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6371 .dac_nids = alc882_dac_nids,
6372 .dig_out_nid = ALC882_DIGOUT_NID,
6373 .dig_in_nid = ALC882_DIGIN_NID,
6374 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6375 .channel_mode = alc882_ch_modes,
6376 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006377 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006378 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006379 [ALC885_IMAC24] = {
6380 .mixers = { alc885_imac24_mixer },
6381 .init_verbs = { alc885_imac24_init_verbs },
6382 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6383 .dac_nids = alc882_dac_nids,
6384 .dig_out_nid = ALC882_DIGOUT_NID,
6385 .dig_in_nid = ALC882_DIGIN_NID,
6386 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6387 .channel_mode = alc882_ch_modes,
6388 .input_mux = &alc882_capture_source,
6389 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006390 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006391 },
Kailang Yang272a5272007-05-14 11:00:38 +02006392 [ALC882_TARGA] = {
6393 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6394 alc882_capture_mixer },
6395 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6396 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6397 .dac_nids = alc882_dac_nids,
6398 .dig_out_nid = ALC882_DIGOUT_NID,
6399 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6400 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006401 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006402 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6403 .channel_mode = alc882_3ST_6ch_modes,
6404 .need_dac_fix = 1,
6405 .input_mux = &alc882_capture_source,
6406 .unsol_event = alc882_targa_unsol_event,
6407 .init_hook = alc882_targa_automute,
6408 },
6409 [ALC882_ASUS_A7J] = {
6410 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6411 alc882_capture_mixer },
6412 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6413 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6414 .dac_nids = alc882_dac_nids,
6415 .dig_out_nid = ALC882_DIGOUT_NID,
6416 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6417 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006418 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006419 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6420 .channel_mode = alc882_3ST_6ch_modes,
6421 .need_dac_fix = 1,
6422 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006423 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006424 [ALC882_ASUS_A7M] = {
6425 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6426 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6427 alc880_gpio1_init_verbs,
6428 alc882_asus_a7m_verbs },
6429 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6430 .dac_nids = alc882_dac_nids,
6431 .dig_out_nid = ALC882_DIGOUT_NID,
6432 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6433 .channel_mode = alc880_threestack_modes,
6434 .need_dac_fix = 1,
6435 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006436 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006437};
6438
6439
6440/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006441 * Pin config fixes
6442 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006443enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006444 PINFIX_ABIT_AW9D_MAX
6445};
6446
6447static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6448 { 0x15, 0x01080104 }, /* side */
6449 { 0x16, 0x01011012 }, /* rear */
6450 { 0x17, 0x01016011 }, /* clfe */
6451 { }
6452};
6453
6454static const struct alc_pincfg *alc882_pin_fixes[] = {
6455 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6456};
6457
6458static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6459 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6460 {}
6461};
6462
6463/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006464 * BIOS auto configuration
6465 */
6466static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6467 hda_nid_t nid, int pin_type,
6468 int dac_idx)
6469{
6470 /* set as output */
6471 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006472 int idx;
6473
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006474 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006475 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6476 idx = 4;
6477 else
6478 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006479 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6480
6481}
6482
6483static void alc882_auto_init_multi_out(struct hda_codec *codec)
6484{
6485 struct alc_spec *spec = codec->spec;
6486 int i;
6487
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006488 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006489 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006490 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006491 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006492 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006493 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006494 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006495 }
6496}
6497
6498static void alc882_auto_init_hp_out(struct hda_codec *codec)
6499{
6500 struct alc_spec *spec = codec->spec;
6501 hda_nid_t pin;
6502
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006503 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006504 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505 /* use dac 0 */
6506 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006507 pin = spec->autocfg.speaker_pins[0];
6508 if (pin)
6509 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006510}
6511
6512#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6513#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6514
6515static void alc882_auto_init_analog_input(struct hda_codec *codec)
6516{
6517 struct alc_spec *spec = codec->spec;
6518 int i;
6519
6520 for (i = 0; i < AUTO_PIN_LAST; i++) {
6521 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006522 unsigned int vref;
6523 if (!nid)
6524 continue;
6525 vref = PIN_IN;
6526 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006527 unsigned int pincap;
6528 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6529 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006530 AC_PINCAP_VREF_80)
6531 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006532 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006533 snd_hda_codec_write(codec, nid, 0,
6534 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6535 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6536 snd_hda_codec_write(codec, nid, 0,
6537 AC_VERB_SET_AMP_GAIN_MUTE,
6538 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006539 }
6540}
6541
Takashi Iwaif511b012008-08-15 16:46:42 +02006542static void alc882_auto_init_input_src(struct hda_codec *codec)
6543{
6544 struct alc_spec *spec = codec->spec;
6545 const struct hda_input_mux *imux = spec->input_mux;
6546 int c;
6547
6548 for (c = 0; c < spec->num_adc_nids; c++) {
6549 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6550 hda_nid_t nid = spec->capsrc_nids[c];
6551 int conns, mute, idx, item;
6552
6553 conns = snd_hda_get_connections(codec, nid, conn_list,
6554 ARRAY_SIZE(conn_list));
6555 if (conns < 0)
6556 continue;
6557 for (idx = 0; idx < conns; idx++) {
6558 /* if the current connection is the selected one,
6559 * unmute it as default - otherwise mute it
6560 */
6561 mute = AMP_IN_MUTE(idx);
6562 for (item = 0; item < imux->num_items; item++) {
6563 if (imux->items[item].index == idx) {
6564 if (spec->cur_mux[c] == item)
6565 mute = AMP_IN_UNMUTE(idx);
6566 break;
6567 }
6568 }
6569 snd_hda_codec_write(codec, nid, 0,
6570 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6571 }
6572 }
6573}
6574
Takashi Iwai776e1842007-08-29 15:07:11 +02006575/* add mic boosts if needed */
6576static int alc_auto_add_mic_boost(struct hda_codec *codec)
6577{
6578 struct alc_spec *spec = codec->spec;
6579 int err;
6580 hda_nid_t nid;
6581
6582 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006583 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006584 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6585 "Mic Boost",
6586 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6587 if (err < 0)
6588 return err;
6589 }
6590 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006591 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006592 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6593 "Front Mic Boost",
6594 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6595 if (err < 0)
6596 return err;
6597 }
6598 return 0;
6599}
6600
Kailang Yangdf694da2005-12-05 19:42:22 +01006601/* almost identical with ALC880 parser... */
6602static int alc882_parse_auto_config(struct hda_codec *codec)
6603{
6604 struct alc_spec *spec = codec->spec;
6605 int err = alc880_parse_auto_config(codec);
6606
6607 if (err < 0)
6608 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006609 else if (!err)
6610 return 0; /* no config found */
6611
6612 err = alc_auto_add_mic_boost(codec);
6613 if (err < 0)
6614 return err;
6615
6616 /* hack - override the init verbs */
6617 spec->init_verbs[0] = alc882_auto_init_verbs;
6618
6619 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006620}
6621
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006622/* additional initialization for auto-configuration model */
6623static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006624{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006625 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 alc882_auto_init_multi_out(codec);
6627 alc882_auto_init_hp_out(codec);
6628 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006629 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006630 if (spec->unsol_event)
6631 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006632}
6633
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006634static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6635
Linus Torvalds1da177e2005-04-16 15:20:36 -07006636static int patch_alc882(struct hda_codec *codec)
6637{
6638 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006639 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006640
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006641 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006642 if (spec == NULL)
6643 return -ENOMEM;
6644
Linus Torvalds1da177e2005-04-16 15:20:36 -07006645 codec->spec = spec;
6646
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006647 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6648 alc882_models,
6649 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006650
Kailang Yangdf694da2005-12-05 19:42:22 +01006651 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006652 /* Pick up systems that don't supply PCI SSID */
6653 switch (codec->subsystem_id) {
6654 case 0x106b0c00: /* Mac Pro */
6655 board_config = ALC885_MACPRO;
6656 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006657 case 0x106b1000: /* iMac 24 */
6658 board_config = ALC885_IMAC24;
6659 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006660 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006661 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006662 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006663 board_config = ALC885_MBP3;
6664 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006665 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006666 /* ALC889A is handled better as ALC888-compatible */
6667 if (codec->revision_id == 0x100103) {
6668 alc_free(codec);
6669 return patch_alc883(codec);
6670 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006671 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6672 "trying auto-probe from BIOS...\n");
6673 board_config = ALC882_AUTO;
6674 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006675 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006676
Takashi Iwaif95474e2007-07-10 00:47:43 +02006677 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6678
Kailang Yangdf694da2005-12-05 19:42:22 +01006679 if (board_config == ALC882_AUTO) {
6680 /* automatic parse from the BIOS config */
6681 err = alc882_parse_auto_config(codec);
6682 if (err < 0) {
6683 alc_free(codec);
6684 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006685 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006686 printk(KERN_INFO
6687 "hda_codec: Cannot set up configuration "
6688 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 board_config = ALC882_3ST_DIG;
6690 }
6691 }
6692
6693 if (board_config != ALC882_AUTO)
6694 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006695
Kailang Yang2f893282008-05-27 12:14:47 +02006696 if (codec->vendor_id == 0x10ec0885) {
6697 spec->stream_name_analog = "ALC885 Analog";
6698 spec->stream_name_digital = "ALC885 Digital";
6699 } else {
6700 spec->stream_name_analog = "ALC882 Analog";
6701 spec->stream_name_digital = "ALC882 Digital";
6702 }
6703
Kailang Yangdf694da2005-12-05 19:42:22 +01006704 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6705 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006706 /* FIXME: setup DAC5 */
6707 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6708 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006709
Kailang Yangdf694da2005-12-05 19:42:22 +01006710 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6711 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006712
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006713 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006714 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006715 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006716 /* get type */
6717 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006718 if (wcap != AC_WID_AUD_IN) {
6719 spec->adc_nids = alc882_adc_nids_alt;
6720 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006721 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006722 spec->mixers[spec->num_mixers] =
6723 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 spec->num_mixers++;
6725 } else {
6726 spec->adc_nids = alc882_adc_nids;
6727 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006728 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006729 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6730 spec->num_mixers++;
6731 }
6732 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006733
Takashi Iwai2134ea42008-01-10 16:53:55 +01006734 spec->vmaster_nid = 0x0c;
6735
Linus Torvalds1da177e2005-04-16 15:20:36 -07006736 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006738 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006739#ifdef CONFIG_SND_HDA_POWER_SAVE
6740 if (!spec->loopback.amplist)
6741 spec->loopback.amplist = alc882_loopbacks;
6742#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006743
6744 return 0;
6745}
6746
6747/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006748 * ALC883 support
6749 *
6750 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6751 * configuration. Each pin widget can choose any input DACs and a mixer.
6752 * Each ADC is connected from a mixer of all inputs. This makes possible
6753 * 6-channel independent captures.
6754 *
6755 * In addition, an independent DAC for the multi-playback (not used in this
6756 * driver yet).
6757 */
6758#define ALC883_DIGOUT_NID 0x06
6759#define ALC883_DIGIN_NID 0x0a
6760
6761static hda_nid_t alc883_dac_nids[4] = {
6762 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006763 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006764};
6765
6766static hda_nid_t alc883_adc_nids[2] = {
6767 /* ADC1-2 */
6768 0x08, 0x09,
6769};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006770
Takashi Iwaie1406342008-02-11 18:32:32 +01006771static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6772
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006773/* input MUX */
6774/* FIXME: should be a matrix-type input source selection */
6775
6776static struct hda_input_mux alc883_capture_source = {
6777 .num_items = 4,
6778 .items = {
6779 { "Mic", 0x0 },
6780 { "Front Mic", 0x1 },
6781 { "Line", 0x2 },
6782 { "CD", 0x4 },
6783 },
6784};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006785
Jiang zhe17bba1b2008-06-04 12:11:07 +02006786static struct hda_input_mux alc883_3stack_6ch_intel = {
6787 .num_items = 4,
6788 .items = {
6789 { "Mic", 0x1 },
6790 { "Front Mic", 0x0 },
6791 { "Line", 0x2 },
6792 { "CD", 0x4 },
6793 },
6794};
6795
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006796static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6797 .num_items = 2,
6798 .items = {
6799 { "Mic", 0x1 },
6800 { "Line", 0x2 },
6801 },
6802};
6803
Kailang Yang272a5272007-05-14 11:00:38 +02006804static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6805 .num_items = 4,
6806 .items = {
6807 { "Mic", 0x0 },
6808 { "iMic", 0x1 },
6809 { "Line", 0x2 },
6810 { "CD", 0x4 },
6811 },
6812};
6813
Jiang zhefb97dc62008-03-06 11:07:11 +01006814static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6815 .num_items = 2,
6816 .items = {
6817 { "Mic", 0x0 },
6818 { "Int Mic", 0x1 },
6819 },
6820};
6821
Kailang Yange2757d52008-08-26 13:17:46 +02006822static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6823 .num_items = 3,
6824 .items = {
6825 { "Mic", 0x0 },
6826 { "Front Mic", 0x1 },
6827 { "Line", 0x4 },
6828 },
6829};
6830
6831static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6832 .num_items = 2,
6833 .items = {
6834 { "Mic", 0x0 },
6835 { "Line", 0x2 },
6836 },
6837};
6838
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006839#define alc883_mux_enum_info alc_mux_enum_info
6840#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006841/* ALC883 has the ALC882-type input selection */
6842#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006843
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006844/*
6845 * 2ch mode
6846 */
6847static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6848 { 2, NULL }
6849};
6850
6851/*
6852 * 2ch mode
6853 */
6854static struct hda_verb alc883_3ST_ch2_init[] = {
6855 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6856 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6857 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6858 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6859 { } /* end */
6860};
6861
6862/*
Tobin Davisb2011312007-09-17 12:45:11 +02006863 * 4ch mode
6864 */
6865static struct hda_verb alc883_3ST_ch4_init[] = {
6866 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6867 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6870 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6871 { } /* end */
6872};
6873
6874/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006875 * 6ch mode
6876 */
6877static struct hda_verb alc883_3ST_ch6_init[] = {
6878 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6879 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6880 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6881 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6882 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6883 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6884 { } /* end */
6885};
6886
Tobin Davisb2011312007-09-17 12:45:11 +02006887static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006888 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006889 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006890 { 6, alc883_3ST_ch6_init },
6891};
6892
6893/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006894 * 2ch mode
6895 */
6896static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6897 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6898 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6899 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6900 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6901 { } /* end */
6902};
6903
6904/*
6905 * 4ch mode
6906 */
6907static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6908 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6909 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6912 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6913 { } /* end */
6914};
6915
6916/*
6917 * 6ch mode
6918 */
6919static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6920 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6922 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6925 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6926 { } /* end */
6927};
6928
6929static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6930 { 2, alc883_3ST_ch2_intel_init },
6931 { 4, alc883_3ST_ch4_intel_init },
6932 { 6, alc883_3ST_ch6_intel_init },
6933};
6934
6935/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006936 * 6ch mode
6937 */
6938static struct hda_verb alc883_sixstack_ch6_init[] = {
6939 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6940 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6941 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6942 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { } /* end */
6944};
6945
6946/*
6947 * 8ch mode
6948 */
6949static struct hda_verb alc883_sixstack_ch8_init[] = {
6950 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6951 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6952 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6953 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { } /* end */
6955};
6956
6957static struct hda_channel_mode alc883_sixstack_modes[2] = {
6958 { 6, alc883_sixstack_ch6_init },
6959 { 8, alc883_sixstack_ch8_init },
6960};
6961
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006962static struct hda_verb alc883_medion_eapd_verbs[] = {
6963 /* eanable EAPD on medion laptop */
6964 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6965 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6966 { }
6967};
6968
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006969/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6970 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6971 */
6972
6973static struct snd_kcontrol_new alc883_base_mixer[] = {
6974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6995 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6996 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6999 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7000 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7001 {
7002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7003 /* .name = "Capture Source", */
7004 .name = "Input Source",
7005 .count = 2,
7006 .info = alc883_mux_enum_info,
7007 .get = alc883_mux_enum_get,
7008 .put = alc883_mux_enum_put,
7009 },
7010 { } /* end */
7011};
7012
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007013static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7015 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7017 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7028 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7029 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7030 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7031 {
7032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7033 /* .name = "Capture Source", */
7034 .name = "Input Source",
7035 .count = 2,
7036 .info = alc883_mux_enum_info,
7037 .get = alc883_mux_enum_get,
7038 .put = alc883_mux_enum_put,
7039 },
7040 { } /* end */
7041};
7042
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007043static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7047 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7051 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7053 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7054 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7055 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7057 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7058 {
7059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7060 /* .name = "Capture Source", */
7061 .name = "Input Source",
7062 .count = 2,
7063 .info = alc883_mux_enum_info,
7064 .get = alc883_mux_enum_get,
7065 .put = alc883_mux_enum_put,
7066 },
7067 { } /* end */
7068};
7069
Jiang zhefb97dc62008-03-06 11:07:11 +01007070static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7071 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7072 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7074 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7080 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7081 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7082 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7083 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7084 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7085 {
7086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7087 /* .name = "Capture Source", */
7088 .name = "Input Source",
7089 .count = 2,
7090 .info = alc883_mux_enum_info,
7091 .get = alc883_mux_enum_get,
7092 .put = alc883_mux_enum_put,
7093 },
7094 { } /* end */
7095};
7096
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007097static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007106 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007109 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007110 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7111 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7112 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7114 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7115 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7116 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7117 {
7118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7119 /* .name = "Capture Source", */
7120 .name = "Input Source",
7121 .count = 2,
7122 .info = alc883_mux_enum_info,
7123 .get = alc883_mux_enum_get,
7124 .put = alc883_mux_enum_put,
7125 },
7126 { } /* end */
7127};
7128
7129static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7139 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7140 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007147 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7149 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7150 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7151 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7152 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007153 {
7154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7155 /* .name = "Capture Source", */
7156 .name = "Input Source",
Kailang Yange2757d52008-08-26 13:17:46 +02007157 .count = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007158 .info = alc883_mux_enum_info,
7159 .get = alc883_mux_enum_get,
7160 .put = alc883_mux_enum_put,
7161 },
7162 { } /* end */
7163};
7164
Jiang zhe17bba1b2008-06-04 12:11:07 +02007165static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7166 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7167 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7168 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7169 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7170 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7171 HDA_OUTPUT),
7172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7173 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7174 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7184 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7186 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7187 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7189 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7190 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7191 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7192 {
7193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7194 /* .name = "Capture Source", */
7195 .name = "Input Source",
7196 .count = 2,
7197 .info = alc883_mux_enum_info,
7198 .get = alc883_mux_enum_get,
7199 .put = alc883_mux_enum_put,
7200 },
7201 { } /* end */
7202};
7203
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007204static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007205 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007206 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007207 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007208 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007209 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7210 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007211 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7212 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007222 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007223 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7224 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7225 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7226 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7227 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7228
7229 {
7230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7231 /* .name = "Capture Source", */
7232 .name = "Input Source",
7233 .count = 1,
7234 .info = alc883_mux_enum_info,
7235 .get = alc883_mux_enum_get,
7236 .put = alc883_mux_enum_put,
7237 },
7238 { } /* end */
7239};
7240
Kailang Yangccc656c2006-10-17 12:32:26 +02007241static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7243 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7244 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7246 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7249 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7250 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007256 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7258 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7259 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7260 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7261 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7262 {
7263 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7264 /* .name = "Capture Source", */
7265 .name = "Input Source",
7266 .count = 2,
7267 .info = alc883_mux_enum_info,
7268 .get = alc883_mux_enum_get,
7269 .put = alc883_mux_enum_put,
7270 },
7271 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007272};
Kailang Yangccc656c2006-10-17 12:32:26 +02007273
7274static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7275 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7276 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7277 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7278 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7279 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007283 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7285 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007286 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7287 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7288 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7289 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7290 {
7291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7292 /* .name = "Capture Source", */
7293 .name = "Input Source",
7294 .count = 2,
7295 .info = alc883_mux_enum_info,
7296 .get = alc883_mux_enum_get,
7297 .put = alc883_mux_enum_put,
7298 },
7299 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007300};
Kailang Yangccc656c2006-10-17 12:32:26 +02007301
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007302static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007305 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7306 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7311 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7312 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7313 {
7314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7315 /* .name = "Capture Source", */
7316 .name = "Input Source",
7317 .count = 1,
7318 .info = alc883_mux_enum_info,
7319 .get = alc883_mux_enum_get,
7320 .put = alc883_mux_enum_put,
7321 },
7322 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007323};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007324
Kailang Yang272a5272007-05-14 11:00:38 +02007325static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7326 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7327 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7333 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7334 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7335 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7336 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7337 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7338 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7339 {
7340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7341 /* .name = "Capture Source", */
7342 .name = "Input Source",
7343 .count = 2,
7344 .info = alc883_mux_enum_info,
7345 .get = alc883_mux_enum_get,
7346 .put = alc883_mux_enum_put,
7347 },
7348 { } /* end */
7349};
7350
7351static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7354 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7355 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7356 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7359 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7360 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7361 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7362 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7363 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7364 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7365 {
7366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7367 /* .name = "Capture Source", */
7368 .name = "Input Source",
7369 .count = 2,
7370 .info = alc883_mux_enum_info,
7371 .get = alc883_mux_enum_get,
7372 .put = alc883_mux_enum_put,
7373 },
7374 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007375};
Kailang Yang272a5272007-05-14 11:00:38 +02007376
Tobin Davis2880a862007-08-07 11:50:26 +02007377static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007380 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7384 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007386 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7387 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7390 {
7391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7392 /* .name = "Capture Source", */
7393 .name = "Input Source",
7394 .count = 2,
7395 .info = alc883_mux_enum_info,
7396 .get = alc883_mux_enum_get,
7397 .put = alc883_mux_enum_put,
7398 },
7399 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007400};
Tobin Davis2880a862007-08-07 11:50:26 +02007401
Kailang Yange2757d52008-08-26 13:17:46 +02007402static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7403 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7404 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7405 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7406 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7407 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7408 0x0d, 1, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7410 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7411 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7412 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7413 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7415 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7416 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7417 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7422 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7423 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7427 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7428 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7429 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7430 {
7431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7432 /* .name = "Capture Source", */
7433 .name = "Input Source",
7434 .count = 2,
7435 .info = alc883_mux_enum_info,
7436 .get = alc883_mux_enum_get,
7437 .put = alc883_mux_enum_put,
7438 },
7439 { } /* end */
7440};
7441
7442static struct hda_bind_ctls alc883_bind_cap_vol = {
7443 .ops = &snd_hda_bind_vol,
7444 .values = {
7445 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7446 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7447 0
7448 },
7449};
7450
7451static struct hda_bind_ctls alc883_bind_cap_switch = {
7452 .ops = &snd_hda_bind_sw,
7453 .values = {
7454 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7455 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7456 0
7457 },
7458};
7459
7460static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7461 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7462 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7464 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7465 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7469 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7470 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7471 {
7472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7473 /* .name = "Capture Source", */
7474 .name = "Input Source",
7475 .count = 1,
7476 .info = alc883_mux_enum_info,
7477 .get = alc883_mux_enum_get,
7478 .put = alc883_mux_enum_put,
7479 },
7480 { } /* end */
7481};
7482
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007483static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7484 {
7485 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7486 .name = "Channel Mode",
7487 .info = alc_ch_mode_info,
7488 .get = alc_ch_mode_get,
7489 .put = alc_ch_mode_put,
7490 },
7491 { } /* end */
7492};
7493
7494static struct hda_verb alc883_init_verbs[] = {
7495 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007496 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007497 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7498 /* ADC2: mute amp left and right */
7499 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7500 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7501 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7505 /* Rear mixer */
7506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7509 /* CLFE mixer */
7510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7513 /* Side mixer */
7514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7517
Takashi Iwaicb53c622007-08-10 17:21:45 +02007518 /* mute analog input loopbacks */
7519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007524
7525 /* Front Pin: output 0 (0x0c) */
7526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7529 /* Rear Pin: output 1 (0x0d) */
7530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7533 /* CLFE Pin: output 2 (0x0e) */
7534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7536 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7537 /* Side Pin: output 3 (0x0f) */
7538 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7540 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7541 /* Mic (rear) pin: input vref at 80% */
7542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7544 /* Front Mic pin: input vref at 80% */
7545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7547 /* Line In pin: input */
7548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7550 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7554 /* CD pin widget for input */
7555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7556
7557 /* FIXME: use matrix-type input source selection */
7558 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7559 /* Input mixer2 */
7560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007564 /* Input mixer3 */
7565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007569 { }
7570};
7571
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007572/* toggle speaker-output according to the hp-jack state */
7573static void alc883_mitac_hp_automute(struct hda_codec *codec)
7574{
7575 unsigned int present;
7576
7577 present = snd_hda_codec_read(codec, 0x15, 0,
7578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7580 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7581 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7582 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7583}
7584
7585/* auto-toggle front mic */
7586/*
7587static void alc883_mitac_mic_automute(struct hda_codec *codec)
7588{
7589 unsigned int present;
7590 unsigned char bits;
7591
7592 present = snd_hda_codec_read(codec, 0x18, 0,
7593 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7594 bits = present ? HDA_AMP_MUTE : 0;
7595 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7596}
7597*/
7598
7599static void alc883_mitac_automute(struct hda_codec *codec)
7600{
7601 alc883_mitac_hp_automute(codec);
7602 /* alc883_mitac_mic_automute(codec); */
7603}
7604
7605static void alc883_mitac_unsol_event(struct hda_codec *codec,
7606 unsigned int res)
7607{
7608 switch (res >> 26) {
7609 case ALC880_HP_EVENT:
7610 alc883_mitac_hp_automute(codec);
7611 break;
7612 case ALC880_MIC_EVENT:
7613 /* alc883_mitac_mic_automute(codec); */
7614 break;
7615 }
7616}
7617
7618static struct hda_verb alc883_mitac_verbs[] = {
7619 /* HP */
7620 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7622 /* Subwoofer */
7623 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7624 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7625
7626 /* enable unsolicited event */
7627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7628 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7629
7630 { } /* end */
7631};
7632
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007633static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007634 /* HP */
7635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7637 /* Int speaker */
7638 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7640
7641 /* enable unsolicited event */
7642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007643 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007644
7645 { } /* end */
7646};
7647
Jiang zhefb97dc62008-03-06 11:07:11 +01007648static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7649 /* HP */
7650 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7652 /* Subwoofer */
7653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7655
7656 /* enable unsolicited event */
7657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7658
7659 { } /* end */
7660};
7661
Kailang Yangccc656c2006-10-17 12:32:26 +02007662static struct hda_verb alc883_tagra_verbs[] = {
7663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7665
7666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7667 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007668
Kailang Yangccc656c2006-10-17 12:32:26 +02007669 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7670 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7671 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7672
7673 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007674 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7675 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7676 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007677
7678 { } /* end */
7679};
7680
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007681static struct hda_verb alc883_lenovo_101e_verbs[] = {
7682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7684 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7685 { } /* end */
7686};
7687
Kailang Yang272a5272007-05-14 11:00:38 +02007688static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7689 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7691 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7693 { } /* end */
7694};
7695
7696static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7699 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7700 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7701 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7702 { } /* end */
7703};
7704
Kailang Yang189609a2007-08-20 11:31:23 +02007705static struct hda_verb alc883_haier_w66_verbs[] = {
7706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7708
7709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7710
7711 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7713 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7714 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7715 { } /* end */
7716};
7717
Kailang Yange2757d52008-08-26 13:17:46 +02007718static struct hda_verb alc888_lenovo_sky_verbs[] = {
7719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7722 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7723 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7725 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7726 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7727 { } /* end */
7728};
7729
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007730static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007731 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007732 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7733 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007734 { }
7735};
7736
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007737static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007738 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7739 { }
7740};
7741
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007742static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7746 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7747 { }
7748};
7749
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007750static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7753 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7754 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7755 { }
7756};
7757
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007758static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7759 { 2, alc888_3st_hp_2ch_init },
7760 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007761};
7762
Kailang Yang272a5272007-05-14 11:00:38 +02007763/* toggle front-jack and RCA according to the hp-jack state */
7764static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7765{
7766 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007767
Kailang Yang272a5272007-05-14 11:00:38 +02007768 present = snd_hda_codec_read(codec, 0x1b, 0,
7769 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007770 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7772 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7773 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007774}
7775
7776/* toggle RCA according to the front-jack state */
7777static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7778{
7779 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007780
Kailang Yang272a5272007-05-14 11:00:38 +02007781 present = snd_hda_codec_read(codec, 0x14, 0,
7782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007783 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7784 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007785}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007786
Kailang Yang272a5272007-05-14 11:00:38 +02007787static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7788 unsigned int res)
7789{
7790 if ((res >> 26) == ALC880_HP_EVENT)
7791 alc888_lenovo_ms7195_front_automute(codec);
7792 if ((res >> 26) == ALC880_FRONT_EVENT)
7793 alc888_lenovo_ms7195_rca_automute(codec);
7794}
7795
7796static struct hda_verb alc883_medion_md2_verbs[] = {
7797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7799
7800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7801
7802 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7803 { } /* end */
7804};
7805
7806/* toggle speaker-output according to the hp-jack state */
7807static void alc883_medion_md2_automute(struct hda_codec *codec)
7808{
7809 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007810
Kailang Yang272a5272007-05-14 11:00:38 +02007811 present = snd_hda_codec_read(codec, 0x14, 0,
7812 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007813 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7814 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007815}
7816
7817static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7818 unsigned int res)
7819{
7820 if ((res >> 26) == ALC880_HP_EVENT)
7821 alc883_medion_md2_automute(codec);
7822}
7823
Kailang Yangccc656c2006-10-17 12:32:26 +02007824/* toggle speaker-output according to the hp-jack state */
7825static void alc883_tagra_automute(struct hda_codec *codec)
7826{
7827 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007828 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007829
7830 present = snd_hda_codec_read(codec, 0x14, 0,
7831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007832 bits = present ? HDA_AMP_MUTE : 0;
7833 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7834 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007835 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7836 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007837}
7838
7839static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7840{
7841 if ((res >> 26) == ALC880_HP_EVENT)
7842 alc883_tagra_automute(codec);
7843}
7844
Jiang zhe368c7a92008-03-04 11:20:33 +01007845/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007846static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007847{
7848 unsigned int present;
7849 unsigned char bits;
7850
7851 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7852 & AC_PINSENSE_PRESENCE;
7853 bits = present ? HDA_AMP_MUTE : 0;
7854 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7855 HDA_AMP_MUTE, bits);
7856}
7857
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007858static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7859{
7860 unsigned int present;
7861
7862 present = snd_hda_codec_read(codec, 0x18, 0,
7863 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7864 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7865 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7866}
7867
7868static void alc883_clevo_m720_automute(struct hda_codec *codec)
7869{
7870 alc883_clevo_m720_hp_automute(codec);
7871 alc883_clevo_m720_mic_automute(codec);
7872}
7873
7874static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007875 unsigned int res)
7876{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007877 switch (res >> 26) {
7878 case ALC880_HP_EVENT:
7879 alc883_clevo_m720_hp_automute(codec);
7880 break;
7881 case ALC880_MIC_EVENT:
7882 alc883_clevo_m720_mic_automute(codec);
7883 break;
7884 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007885}
7886
Jiang zhefb97dc62008-03-06 11:07:11 +01007887/* toggle speaker-output according to the hp-jack state */
7888static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7889{
7890 unsigned int present;
7891 unsigned char bits;
7892
7893 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7894 & AC_PINSENSE_PRESENCE;
7895 bits = present ? HDA_AMP_MUTE : 0;
7896 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7897 HDA_AMP_MUTE, bits);
7898}
7899
7900static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7901 unsigned int res)
7902{
7903 if ((res >> 26) == ALC880_HP_EVENT)
7904 alc883_2ch_fujitsu_pi2515_automute(codec);
7905}
7906
Kailang Yang189609a2007-08-20 11:31:23 +02007907static void alc883_haier_w66_automute(struct hda_codec *codec)
7908{
7909 unsigned int present;
7910 unsigned char bits;
7911
7912 present = snd_hda_codec_read(codec, 0x1b, 0,
7913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7914 bits = present ? 0x80 : 0;
7915 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7916 0x80, bits);
7917}
7918
7919static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7920 unsigned int res)
7921{
7922 if ((res >> 26) == ALC880_HP_EVENT)
7923 alc883_haier_w66_automute(codec);
7924}
7925
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007926static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7927{
7928 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007929 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007930
7931 present = snd_hda_codec_read(codec, 0x14, 0,
7932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007933 bits = present ? HDA_AMP_MUTE : 0;
7934 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7935 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007936}
7937
7938static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7939{
7940 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007941 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007942
7943 present = snd_hda_codec_read(codec, 0x1b, 0,
7944 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007945 bits = present ? HDA_AMP_MUTE : 0;
7946 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7947 HDA_AMP_MUTE, bits);
7948 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7949 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007950}
7951
7952static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7953 unsigned int res)
7954{
7955 if ((res >> 26) == ALC880_HP_EVENT)
7956 alc883_lenovo_101e_all_automute(codec);
7957 if ((res >> 26) == ALC880_FRONT_EVENT)
7958 alc883_lenovo_101e_ispeaker_automute(codec);
7959}
7960
Takashi Iwai676a9b52007-08-16 15:23:35 +02007961/* toggle speaker-output according to the hp-jack state */
7962static void alc883_acer_aspire_automute(struct hda_codec *codec)
7963{
7964 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007965
Takashi Iwai676a9b52007-08-16 15:23:35 +02007966 present = snd_hda_codec_read(codec, 0x14, 0,
7967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7968 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7970 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7971 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7972}
7973
7974static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7975 unsigned int res)
7976{
7977 if ((res >> 26) == ALC880_HP_EVENT)
7978 alc883_acer_aspire_automute(codec);
7979}
7980
Kailang Yangd1a991a2007-08-15 16:21:59 +02007981static struct hda_verb alc883_acer_eapd_verbs[] = {
7982 /* HP Pin: output 0 (0x0c) */
7983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7985 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7986 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007987 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7988 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007989 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007990 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7991 /* eanable EAPD on medion laptop */
7992 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7993 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007994 /* enable unsolicited event */
7995 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007996 { }
7997};
7998
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007999static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8000{
8001 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008002
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008003 present = snd_hda_codec_read(codec, 0x1b, 0,
8004 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8005 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8006 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8007 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8008 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8009 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8010 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8011 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8012 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8013}
8014
8015static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8016 unsigned int res)
8017{
8018 switch (res >> 26) {
8019 case ALC880_HP_EVENT:
8020 printk("hp_event\n");
8021 alc888_6st_dell_front_automute(codec);
8022 break;
8023 }
8024}
8025
Kailang Yange2757d52008-08-26 13:17:46 +02008026static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8027{
8028 unsigned int mute;
8029 unsigned int present;
8030
8031 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8032 present = snd_hda_codec_read(codec, 0x1b, 0,
8033 AC_VERB_GET_PIN_SENSE, 0);
8034 present = (present & 0x80000000) != 0;
8035 if (present) {
8036 /* mute internal speaker */
8037 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8038 HDA_AMP_MUTE, HDA_AMP_MUTE);
8039 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8040 HDA_AMP_MUTE, HDA_AMP_MUTE);
8041 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8042 HDA_AMP_MUTE, HDA_AMP_MUTE);
8043 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8044 HDA_AMP_MUTE, HDA_AMP_MUTE);
8045 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8046 HDA_AMP_MUTE, HDA_AMP_MUTE);
8047 } else {
8048 /* unmute internal speaker if necessary */
8049 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8050 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8051 HDA_AMP_MUTE, mute);
8052 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8053 HDA_AMP_MUTE, mute);
8054 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8055 HDA_AMP_MUTE, mute);
8056 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8057 HDA_AMP_MUTE, mute);
8058 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8059 HDA_AMP_MUTE, mute);
8060 }
8061}
8062
8063static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8064 unsigned int res)
8065{
8066 if ((res >> 26) == ALC880_HP_EVENT)
8067 alc888_lenovo_sky_front_automute(codec);
8068}
8069
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008070/*
8071 * generic initialization of ADC, input mixers and output mixers
8072 */
8073static struct hda_verb alc883_auto_init_verbs[] = {
8074 /*
8075 * Unmute ADC0-2 and set the default input to mic-in
8076 */
8077 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8079 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8080 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8081
Takashi Iwaicb53c622007-08-10 17:21:45 +02008082 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008083 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008084 * Note: PASD motherboards uses the Line In 2 as the input for
8085 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008086 */
8087 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008093
8094 /*
8095 * Set up output mixers (0x0c - 0x0f)
8096 */
8097 /* set vol=0 to output mixers */
8098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8100 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8101 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8102 /* set up input amps for analog loopback */
8103 /* Amp Indices: DAC = 0, mixer = 1 */
8104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8112 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8113 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8114
8115 /* FIXME: use matrix-type input source selection */
8116 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8117 /* Input mixer1 */
8118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008121 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8123 /* Input mixer2 */
8124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008127 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008129
8130 { }
8131};
8132
8133/* capture mixer elements */
8134static struct snd_kcontrol_new alc883_capture_mixer[] = {
8135 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8136 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8137 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
8138 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
8139 {
8140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8141 /* The multiple "Capture Source" controls confuse alsamixer
8142 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008143 */
8144 /* .name = "Capture Source", */
8145 .name = "Input Source",
8146 .count = 2,
8147 .info = alc882_mux_enum_info,
8148 .get = alc882_mux_enum_get,
8149 .put = alc882_mux_enum_put,
8150 },
8151 { } /* end */
8152};
8153
Kailang Yange2757d52008-08-26 13:17:46 +02008154static struct hda_verb alc888_asus_m90v_verbs[] = {
8155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8158 /* enable unsolicited event */
8159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8160 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8161 { } /* end */
8162};
8163
8164static void alc883_nb_mic_automute(struct hda_codec *codec)
8165{
8166 unsigned int present;
8167
8168 present = snd_hda_codec_read(codec, 0x18, 0,
8169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8170 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8171 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8172 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8173 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8174}
8175
8176static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8177{
8178 unsigned int present;
8179 unsigned char bits;
8180
8181 present = snd_hda_codec_read(codec, 0x1b, 0,
8182 AC_VERB_GET_PIN_SENSE, 0)
8183 & AC_PINSENSE_PRESENCE;
8184 bits = present ? 0 : PIN_OUT;
8185 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8186 bits);
8187 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8188 bits);
8189 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8190 bits);
8191}
8192
8193static void alc883_mode2_unsol_event(struct hda_codec *codec,
8194 unsigned int res)
8195{
8196 switch (res >> 26) {
8197 case ALC880_HP_EVENT:
8198 alc883_M90V_speaker_automute(codec);
8199 break;
8200 case ALC880_MIC_EVENT:
8201 alc883_nb_mic_automute(codec);
8202 break;
8203 }
8204}
8205
8206static void alc883_mode2_inithook(struct hda_codec *codec)
8207{
8208 alc883_M90V_speaker_automute(codec);
8209 alc883_nb_mic_automute(codec);
8210}
8211
8212static struct hda_verb alc888_asus_eee1601_verbs[] = {
8213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8218 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8219 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8220 /* enable unsolicited event */
8221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 { } /* end */
8223};
8224
8225static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8226{
8227 unsigned int present;
8228 unsigned char bits;
8229
8230 present = snd_hda_codec_read(codec, 0x14, 0,
8231 AC_VERB_GET_PIN_SENSE, 0)
8232 & AC_PINSENSE_PRESENCE;
8233 bits = present ? 0 : PIN_OUT;
8234 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8235 bits);
8236}
8237
8238static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8239 unsigned int res)
8240{
8241 switch (res >> 26) {
8242 case ALC880_HP_EVENT:
8243 alc883_eee1601_speaker_automute(codec);
8244 break;
8245 }
8246}
8247
8248static void alc883_eee1601_inithook(struct hda_codec *codec)
8249{
8250 alc883_eee1601_speaker_automute(codec);
8251}
8252
Takashi Iwaicb53c622007-08-10 17:21:45 +02008253#ifdef CONFIG_SND_HDA_POWER_SAVE
8254#define alc883_loopbacks alc880_loopbacks
8255#endif
8256
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008257/* pcm configuration: identiacal with ALC880 */
8258#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8259#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008260#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008261#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8262#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8263
8264/*
8265 * configuration and preset
8266 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008267static const char *alc883_models[ALC883_MODEL_LAST] = {
8268 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8269 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8270 [ALC883_3ST_6ch] = "3stack-6ch",
8271 [ALC883_6ST_DIG] = "6stack-dig",
8272 [ALC883_TARGA_DIG] = "targa-dig",
8273 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008274 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008275 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008276 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008277 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008278 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008279 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008280 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8281 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008282 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008283 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008284 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008285 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008286 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008287 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008288 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008289 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008290 [ALC883_AUTO] = "auto",
8291};
8292
8293static struct snd_pci_quirk alc883_cfg_tbl[] = {
8294 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008295 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8296 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8297 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008298 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008299 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008300 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008301 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008302 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8303 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008304 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008305 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008306 SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V),
8307 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008308 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008309 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008310 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8311 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008312 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008313 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008314 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008315 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8316 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8317 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008318 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008319 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008320 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008321 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8322 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8323 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8324 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8325 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8326 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8327 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8328 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8329 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008330 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8331 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008332 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008333 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008334 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008335 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008336 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008337 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008338 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8339 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008340 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008341 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008342 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008343 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008344 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008345 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008346 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8347 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008348 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008349 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008350 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008351 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008352 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8353 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008354 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008355 {}
8356};
8357
8358static struct alc_config_preset alc883_presets[] = {
8359 [ALC883_3ST_2ch_DIG] = {
8360 .mixers = { alc883_3ST_2ch_mixer },
8361 .init_verbs = { alc883_init_verbs },
8362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8363 .dac_nids = alc883_dac_nids,
8364 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008365 .dig_in_nid = ALC883_DIGIN_NID,
8366 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8367 .channel_mode = alc883_3ST_2ch_modes,
8368 .input_mux = &alc883_capture_source,
8369 },
8370 [ALC883_3ST_6ch_DIG] = {
8371 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8372 .init_verbs = { alc883_init_verbs },
8373 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8374 .dac_nids = alc883_dac_nids,
8375 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008376 .dig_in_nid = ALC883_DIGIN_NID,
8377 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8378 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008379 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008381 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382 [ALC883_3ST_6ch] = {
8383 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8384 .init_verbs = { alc883_init_verbs },
8385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8386 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008387 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8388 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008389 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008390 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008391 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008392 [ALC883_3ST_6ch_INTEL] = {
8393 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8394 .init_verbs = { alc883_init_verbs },
8395 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8396 .dac_nids = alc883_dac_nids,
8397 .dig_out_nid = ALC883_DIGOUT_NID,
8398 .dig_in_nid = ALC883_DIGIN_NID,
8399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8400 .channel_mode = alc883_3ST_6ch_intel_modes,
8401 .need_dac_fix = 1,
8402 .input_mux = &alc883_3stack_6ch_intel,
8403 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008404 [ALC883_6ST_DIG] = {
8405 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8406 .init_verbs = { alc883_init_verbs },
8407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8408 .dac_nids = alc883_dac_nids,
8409 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008410 .dig_in_nid = ALC883_DIGIN_NID,
8411 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8412 .channel_mode = alc883_sixstack_modes,
8413 .input_mux = &alc883_capture_source,
8414 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008415 [ALC883_TARGA_DIG] = {
8416 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8417 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8419 .dac_nids = alc883_dac_nids,
8420 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8422 .channel_mode = alc883_3ST_6ch_modes,
8423 .need_dac_fix = 1,
8424 .input_mux = &alc883_capture_source,
8425 .unsol_event = alc883_tagra_unsol_event,
8426 .init_hook = alc883_tagra_automute,
8427 },
8428 [ALC883_TARGA_2ch_DIG] = {
8429 .mixers = { alc883_tagra_2ch_mixer},
8430 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8432 .dac_nids = alc883_dac_nids,
8433 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8435 .channel_mode = alc883_3ST_2ch_modes,
8436 .input_mux = &alc883_capture_source,
8437 .unsol_event = alc883_tagra_unsol_event,
8438 .init_hook = alc883_tagra_automute,
8439 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008440 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008441 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008442 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8443 * and the headphone jack. Turn this on and rely on the
8444 * standard mute methods whenever the user wants to turn
8445 * these outputs off.
8446 */
8447 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8448 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8449 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008450 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8451 .channel_mode = alc883_3ST_2ch_modes,
8452 .input_mux = &alc883_capture_source,
8453 },
Tobin Davis2880a862007-08-07 11:50:26 +02008454 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008455 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008456 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8458 .dac_nids = alc883_dac_nids,
8459 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008460 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8461 .channel_mode = alc883_3ST_2ch_modes,
8462 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008463 .unsol_event = alc883_acer_aspire_unsol_event,
8464 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008465 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008466 [ALC883_MEDION] = {
8467 .mixers = { alc883_fivestack_mixer,
8468 alc883_chmode_mixer },
8469 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008470 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8472 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008473 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8474 .channel_mode = alc883_sixstack_modes,
8475 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008476 },
Kailang Yang272a5272007-05-14 11:00:38 +02008477 [ALC883_MEDION_MD2] = {
8478 .mixers = { alc883_medion_md2_mixer},
8479 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8481 .dac_nids = alc883_dac_nids,
8482 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008483 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8484 .channel_mode = alc883_3ST_2ch_modes,
8485 .input_mux = &alc883_capture_source,
8486 .unsol_event = alc883_medion_md2_unsol_event,
8487 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008488 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008489 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008490 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008491 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8493 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008494 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8495 .channel_mode = alc883_3ST_2ch_modes,
8496 .input_mux = &alc883_capture_source,
8497 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008498 [ALC883_CLEVO_M720] = {
8499 .mixers = { alc883_clevo_m720_mixer },
8500 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8502 .dac_nids = alc883_dac_nids,
8503 .dig_out_nid = ALC883_DIGOUT_NID,
8504 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8505 .channel_mode = alc883_3ST_2ch_modes,
8506 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008507 .unsol_event = alc883_clevo_m720_unsol_event,
8508 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008509 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008510 [ALC883_LENOVO_101E_2ch] = {
8511 .mixers = { alc883_lenovo_101e_2ch_mixer},
8512 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8513 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8514 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008515 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8516 .channel_mode = alc883_3ST_2ch_modes,
8517 .input_mux = &alc883_lenovo_101e_capture_source,
8518 .unsol_event = alc883_lenovo_101e_unsol_event,
8519 .init_hook = alc883_lenovo_101e_all_automute,
8520 },
Kailang Yang272a5272007-05-14 11:00:38 +02008521 [ALC883_LENOVO_NB0763] = {
8522 .mixers = { alc883_lenovo_nb0763_mixer },
8523 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8525 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8527 .channel_mode = alc883_3ST_2ch_modes,
8528 .need_dac_fix = 1,
8529 .input_mux = &alc883_lenovo_nb0763_capture_source,
8530 .unsol_event = alc883_medion_md2_unsol_event,
8531 .init_hook = alc883_medion_md2_automute,
8532 },
8533 [ALC888_LENOVO_MS7195_DIG] = {
8534 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8535 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8536 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8537 .dac_nids = alc883_dac_nids,
8538 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008539 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8540 .channel_mode = alc883_3ST_6ch_modes,
8541 .need_dac_fix = 1,
8542 .input_mux = &alc883_capture_source,
8543 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8544 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008545 },
8546 [ALC883_HAIER_W66] = {
8547 .mixers = { alc883_tagra_2ch_mixer},
8548 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8549 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8550 .dac_nids = alc883_dac_nids,
8551 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8553 .channel_mode = alc883_3ST_2ch_modes,
8554 .input_mux = &alc883_capture_source,
8555 .unsol_event = alc883_haier_w66_unsol_event,
8556 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008557 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008558 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008559 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008560 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8562 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008563 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8564 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008565 .need_dac_fix = 1,
8566 .input_mux = &alc883_capture_source,
8567 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008568 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008569 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008570 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8571 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8572 .dac_nids = alc883_dac_nids,
8573 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008574 .dig_in_nid = ALC883_DIGIN_NID,
8575 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8576 .channel_mode = alc883_sixstack_modes,
8577 .input_mux = &alc883_capture_source,
8578 .unsol_event = alc888_6st_dell_unsol_event,
8579 .init_hook = alc888_6st_dell_front_automute,
8580 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008581 [ALC883_MITAC] = {
8582 .mixers = { alc883_mitac_mixer },
8583 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8584 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8585 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008586 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8587 .channel_mode = alc883_3ST_2ch_modes,
8588 .input_mux = &alc883_capture_source,
8589 .unsol_event = alc883_mitac_unsol_event,
8590 .init_hook = alc883_mitac_automute,
8591 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008592 [ALC883_FUJITSU_PI2515] = {
8593 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8594 .init_verbs = { alc883_init_verbs,
8595 alc883_2ch_fujitsu_pi2515_verbs},
8596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8597 .dac_nids = alc883_dac_nids,
8598 .dig_out_nid = ALC883_DIGOUT_NID,
8599 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8600 .channel_mode = alc883_3ST_2ch_modes,
8601 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8602 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8603 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8604 },
Kailang Yange2757d52008-08-26 13:17:46 +02008605 [ALC888_LENOVO_SKY] = {
8606 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8607 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8608 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8609 .dac_nids = alc883_dac_nids,
8610 .dig_out_nid = ALC883_DIGOUT_NID,
8611 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
8612 .adc_nids = alc883_adc_nids,
8613 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8614 .channel_mode = alc883_sixstack_modes,
8615 .need_dac_fix = 1,
8616 .input_mux = &alc883_lenovo_sky_capture_source,
8617 .unsol_event = alc883_lenovo_sky_unsol_event,
8618 .init_hook = alc888_lenovo_sky_front_automute,
8619 },
8620 [ALC888_ASUS_M90V] = {
8621 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8622 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8623 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8624 .dac_nids = alc883_dac_nids,
8625 .dig_out_nid = ALC883_DIGOUT_NID,
8626 .dig_in_nid = ALC883_DIGIN_NID,
8627 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8628 .channel_mode = alc883_3ST_6ch_modes,
8629 .need_dac_fix = 1,
8630 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8631 .unsol_event = alc883_mode2_unsol_event,
8632 .init_hook = alc883_mode2_inithook,
8633 },
8634 [ALC888_ASUS_EEE1601] = {
8635 .mixers = { alc883_asus_eee1601_mixer },
8636 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8637 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8638 .dac_nids = alc883_dac_nids,
8639 .dig_out_nid = ALC883_DIGOUT_NID,
8640 .dig_in_nid = ALC883_DIGIN_NID,
8641 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8642 .channel_mode = alc883_3ST_2ch_modes,
8643 .need_dac_fix = 1,
8644 .input_mux = &alc883_asus_eee1601_capture_source,
8645 .unsol_event = alc883_eee1601_unsol_event,
8646 .init_hook = alc883_eee1601_inithook,
8647 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008648};
8649
8650
8651/*
8652 * BIOS auto configuration
8653 */
8654static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8655 hda_nid_t nid, int pin_type,
8656 int dac_idx)
8657{
8658 /* set as output */
8659 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008660 int idx;
8661
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008662 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008663 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8664 idx = 4;
8665 else
8666 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008667 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8668
8669}
8670
8671static void alc883_auto_init_multi_out(struct hda_codec *codec)
8672{
8673 struct alc_spec *spec = codec->spec;
8674 int i;
8675
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008676 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008677 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008678 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008679 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008680 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008681 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008682 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008683 }
8684}
8685
8686static void alc883_auto_init_hp_out(struct hda_codec *codec)
8687{
8688 struct alc_spec *spec = codec->spec;
8689 hda_nid_t pin;
8690
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008691 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008692 if (pin) /* connect to front */
8693 /* use dac 0 */
8694 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008695 pin = spec->autocfg.speaker_pins[0];
8696 if (pin)
8697 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008698}
8699
8700#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8701#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8702
8703static void alc883_auto_init_analog_input(struct hda_codec *codec)
8704{
8705 struct alc_spec *spec = codec->spec;
8706 int i;
8707
8708 for (i = 0; i < AUTO_PIN_LAST; i++) {
8709 hda_nid_t nid = spec->autocfg.input_pins[i];
8710 if (alc883_is_input_pin(nid)) {
8711 snd_hda_codec_write(codec, nid, 0,
8712 AC_VERB_SET_PIN_WIDGET_CONTROL,
8713 (i <= AUTO_PIN_FRONT_MIC ?
8714 PIN_VREF80 : PIN_IN));
8715 if (nid != ALC883_PIN_CD_NID)
8716 snd_hda_codec_write(codec, nid, 0,
8717 AC_VERB_SET_AMP_GAIN_MUTE,
8718 AMP_OUT_MUTE);
8719 }
8720 }
8721}
8722
Takashi Iwaif511b012008-08-15 16:46:42 +02008723#define alc883_auto_init_input_src alc882_auto_init_input_src
8724
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725/* almost identical with ALC880 parser... */
8726static int alc883_parse_auto_config(struct hda_codec *codec)
8727{
8728 struct alc_spec *spec = codec->spec;
8729 int err = alc880_parse_auto_config(codec);
8730
8731 if (err < 0)
8732 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008733 else if (!err)
8734 return 0; /* no config found */
8735
8736 err = alc_auto_add_mic_boost(codec);
8737 if (err < 0)
8738 return err;
8739
8740 /* hack - override the init verbs */
8741 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008742 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8743 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008744
8745 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008746}
8747
8748/* additional initialization for auto-configuration model */
8749static void alc883_auto_init(struct hda_codec *codec)
8750{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008751 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008752 alc883_auto_init_multi_out(codec);
8753 alc883_auto_init_hp_out(codec);
8754 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008755 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008756 if (spec->unsol_event)
8757 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008758}
8759
8760static int patch_alc883(struct hda_codec *codec)
8761{
8762 struct alc_spec *spec;
8763 int err, board_config;
8764
8765 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8766 if (spec == NULL)
8767 return -ENOMEM;
8768
8769 codec->spec = spec;
8770
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008771 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8772
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008773 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8774 alc883_models,
8775 alc883_cfg_tbl);
8776 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008777 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8778 "trying auto-probe from BIOS...\n");
8779 board_config = ALC883_AUTO;
8780 }
8781
8782 if (board_config == ALC883_AUTO) {
8783 /* automatic parse from the BIOS config */
8784 err = alc883_parse_auto_config(codec);
8785 if (err < 0) {
8786 alc_free(codec);
8787 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008788 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008789 printk(KERN_INFO
8790 "hda_codec: Cannot set up configuration "
8791 "from BIOS. Using base mode...\n");
8792 board_config = ALC883_3ST_2ch_DIG;
8793 }
8794 }
8795
8796 if (board_config != ALC883_AUTO)
8797 setup_preset(spec, &alc883_presets[board_config]);
8798
Kailang Yang2f893282008-05-27 12:14:47 +02008799 switch (codec->vendor_id) {
8800 case 0x10ec0888:
8801 spec->stream_name_analog = "ALC888 Analog";
8802 spec->stream_name_digital = "ALC888 Digital";
8803 break;
8804 case 0x10ec0889:
8805 spec->stream_name_analog = "ALC889 Analog";
8806 spec->stream_name_digital = "ALC889 Digital";
8807 break;
8808 default:
8809 spec->stream_name_analog = "ALC883 Analog";
8810 spec->stream_name_digital = "ALC883 Digital";
8811 break;
8812 }
8813
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008814 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8815 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008816 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008817
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008818 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8819 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8820
Takashi Iwaie1406342008-02-11 18:32:32 +01008821 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8822 spec->adc_nids = alc883_adc_nids;
8823 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008824
Takashi Iwai2134ea42008-01-10 16:53:55 +01008825 spec->vmaster_nid = 0x0c;
8826
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008827 codec->patch_ops = alc_patch_ops;
8828 if (board_config == ALC883_AUTO)
8829 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008830
Takashi Iwaicb53c622007-08-10 17:21:45 +02008831#ifdef CONFIG_SND_HDA_POWER_SAVE
8832 if (!spec->loopback.amplist)
8833 spec->loopback.amplist = alc883_loopbacks;
8834#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008835
8836 return 0;
8837}
8838
8839/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008840 * ALC262 support
8841 */
8842
8843#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8844#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8845
8846#define alc262_dac_nids alc260_dac_nids
8847#define alc262_adc_nids alc882_adc_nids
8848#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008849#define alc262_capsrc_nids alc882_capsrc_nids
8850#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008851
8852#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008853#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008854
Kailang Yang4e555fe2008-08-26 13:05:55 +02008855static hda_nid_t alc262_dmic_adc_nids[1] = {
8856 /* ADC0 */
8857 0x09
8858};
8859
8860static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8861
Kailang Yangdf694da2005-12-05 19:42:22 +01008862static struct snd_kcontrol_new alc262_base_mixer[] = {
8863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8864 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008872 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8873 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008875 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008876 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008877 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8879 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8880 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008881 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008882};
8883
Kailang Yangccc656c2006-10-17 12:32:26 +02008884static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8885 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8886 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008896 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008897 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008898 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008899 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8901 { } /* end */
8902};
8903
Takashi Iwaice875f02008-01-28 18:17:43 +01008904/* update HP, line and mono-out pins according to the master switch */
8905static void alc262_hp_master_update(struct hda_codec *codec)
8906{
8907 struct alc_spec *spec = codec->spec;
8908 int val = spec->master_sw;
8909
8910 /* HP & line-out */
8911 snd_hda_codec_write_cache(codec, 0x1b, 0,
8912 AC_VERB_SET_PIN_WIDGET_CONTROL,
8913 val ? PIN_HP : 0);
8914 snd_hda_codec_write_cache(codec, 0x15, 0,
8915 AC_VERB_SET_PIN_WIDGET_CONTROL,
8916 val ? PIN_HP : 0);
8917 /* mono (speaker) depending on the HP jack sense */
8918 val = val && !spec->jack_present;
8919 snd_hda_codec_write_cache(codec, 0x16, 0,
8920 AC_VERB_SET_PIN_WIDGET_CONTROL,
8921 val ? PIN_OUT : 0);
8922}
8923
8924static void alc262_hp_bpc_automute(struct hda_codec *codec)
8925{
8926 struct alc_spec *spec = codec->spec;
8927 unsigned int presence;
8928 presence = snd_hda_codec_read(codec, 0x1b, 0,
8929 AC_VERB_GET_PIN_SENSE, 0);
8930 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8931 alc262_hp_master_update(codec);
8932}
8933
8934static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8935{
8936 if ((res >> 26) != ALC880_HP_EVENT)
8937 return;
8938 alc262_hp_bpc_automute(codec);
8939}
8940
8941static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8942{
8943 struct alc_spec *spec = codec->spec;
8944 unsigned int presence;
8945 presence = snd_hda_codec_read(codec, 0x15, 0,
8946 AC_VERB_GET_PIN_SENSE, 0);
8947 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8948 alc262_hp_master_update(codec);
8949}
8950
8951static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8952 unsigned int res)
8953{
8954 if ((res >> 26) != ALC880_HP_EVENT)
8955 return;
8956 alc262_hp_wildwest_automute(codec);
8957}
8958
8959static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8960 struct snd_ctl_elem_value *ucontrol)
8961{
8962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8963 struct alc_spec *spec = codec->spec;
8964 *ucontrol->value.integer.value = spec->master_sw;
8965 return 0;
8966}
8967
8968static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8969 struct snd_ctl_elem_value *ucontrol)
8970{
8971 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8972 struct alc_spec *spec = codec->spec;
8973 int val = !!*ucontrol->value.integer.value;
8974
8975 if (val == spec->master_sw)
8976 return 0;
8977 spec->master_sw = val;
8978 alc262_hp_master_update(codec);
8979 return 1;
8980}
8981
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008982static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008983 {
8984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8985 .name = "Master Playback Switch",
8986 .info = snd_ctl_boolean_mono_info,
8987 .get = alc262_hp_master_sw_get,
8988 .put = alc262_hp_master_sw_put,
8989 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8991 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008993 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8994 HDA_OUTPUT),
8995 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8996 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008999 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009002 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9007 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9008 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9009 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9010 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9011 { } /* end */
9012};
9013
Kailang Yangcd7509a2007-01-26 18:33:17 +01009014static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009015 {
9016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9017 .name = "Master Playback Switch",
9018 .info = snd_ctl_boolean_mono_info,
9019 .get = alc262_hp_master_sw_get,
9020 .put = alc262_hp_master_sw_put,
9021 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9023 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009026 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9027 HDA_OUTPUT),
9028 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9029 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009032 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9035 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9036 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9037 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9038 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9039 { } /* end */
9040};
9041
9042static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9043 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9044 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009045 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009046 { } /* end */
9047};
9048
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009049/* mute/unmute internal speaker according to the hp jack and mute state */
9050static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9051{
9052 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009053
9054 if (force || !spec->sense_updated) {
9055 unsigned int present;
9056 present = snd_hda_codec_read(codec, 0x15, 0,
9057 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009058 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009059 spec->sense_updated = 1;
9060 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009061 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9062 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009063}
9064
9065static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9066 unsigned int res)
9067{
9068 if ((res >> 26) != ALC880_HP_EVENT)
9069 return;
9070 alc262_hp_t5735_automute(codec, 1);
9071}
9072
9073static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9074{
9075 alc262_hp_t5735_automute(codec, 1);
9076}
9077
9078static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009079 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9080 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009081 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9085 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9086 { } /* end */
9087};
9088
9089static struct hda_verb alc262_hp_t5735_verbs[] = {
9090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9092
9093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9094 { }
9095};
9096
Kailang Yang8c427222008-01-10 13:03:59 +01009097static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9101 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9104 { } /* end */
9105};
9106
9107static struct hda_verb alc262_hp_rp5700_verbs[] = {
9108 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9109 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9110 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9113 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9118 {}
9119};
9120
9121static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9122 .num_items = 1,
9123 .items = {
9124 { "Line", 0x1 },
9125 },
9126};
9127
Takashi Iwai0724ea22007-08-23 00:31:43 +02009128/* bind hp and internal speaker mute (with plug check) */
9129static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9130 struct snd_ctl_elem_value *ucontrol)
9131{
9132 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9133 long *valp = ucontrol->value.integer.value;
9134 int change;
9135
9136 /* change hp mute */
9137 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9138 HDA_AMP_MUTE,
9139 valp[0] ? 0 : HDA_AMP_MUTE);
9140 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9141 HDA_AMP_MUTE,
9142 valp[1] ? 0 : HDA_AMP_MUTE);
9143 if (change) {
9144 /* change speaker according to HP jack state */
9145 struct alc_spec *spec = codec->spec;
9146 unsigned int mute;
9147 if (spec->jack_present)
9148 mute = HDA_AMP_MUTE;
9149 else
9150 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9151 HDA_OUTPUT, 0);
9152 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9153 HDA_AMP_MUTE, mute);
9154 }
9155 return change;
9156}
Takashi Iwai5b319542007-07-26 11:49:22 +02009157
Kailang Yang272a5272007-05-14 11:00:38 +02009158static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009159 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9160 {
9161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9162 .name = "Master Playback Switch",
9163 .info = snd_hda_mixer_amp_switch_info,
9164 .get = snd_hda_mixer_amp_switch_get,
9165 .put = alc262_sony_master_sw_put,
9166 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9167 },
Kailang Yang272a5272007-05-14 11:00:38 +02009168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9170 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9171 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9172 { } /* end */
9173};
9174
Kailang Yang83c34212007-07-05 11:43:05 +02009175static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9177 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9181 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9182 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9183 { } /* end */
9184};
Kailang Yang272a5272007-05-14 11:00:38 +02009185
Kailang Yangdf694da2005-12-05 19:42:22 +01009186#define alc262_capture_mixer alc882_capture_mixer
9187#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9188
9189/*
9190 * generic initialization of ADC, input mixers and output mixers
9191 */
9192static struct hda_verb alc262_init_verbs[] = {
9193 /*
9194 * Unmute ADC0-2 and set the default input to mic-in
9195 */
9196 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9200 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9202
Takashi Iwaicb53c622007-08-10 17:21:45 +02009203 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009204 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009205 * Note: PASD motherboards uses the Line In 2 as the input for
9206 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009207 */
9208 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009214
9215 /*
9216 * Set up output mixers (0x0c - 0x0e)
9217 */
9218 /* set vol=0 to output mixers */
9219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9222 /* set up input amps for analog loopback */
9223 /* Amp Indices: DAC = 0, mixer = 1 */
9224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9230
9231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9234 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9237
9238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9241 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9242 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009243
Kailang Yangdf694da2005-12-05 19:42:22 +01009244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009246
Kailang Yangdf694da2005-12-05 19:42:22 +01009247 /* FIXME: use matrix-type input source selection */
9248 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9249 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9254 /* Input mixer2 */
9255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9259 /* Input mixer3 */
9260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009264
9265 { }
9266};
9267
Kailang Yang4e555fe2008-08-26 13:05:55 +02009268static struct hda_verb alc262_eapd_verbs[] = {
9269 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9270 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9271 { }
9272};
9273
Kailang Yangccc656c2006-10-17 12:32:26 +02009274static struct hda_verb alc262_hippo_unsol_verbs[] = {
9275 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9277 {}
9278};
9279
9280static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9281 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9284
9285 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9286 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9287 {}
9288};
9289
Kailang Yang272a5272007-05-14 11:00:38 +02009290static struct hda_verb alc262_sony_unsol_verbs[] = {
9291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9293 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9294
9295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009297 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009298};
9299
Kailang Yang4e555fe2008-08-26 13:05:55 +02009300static struct hda_input_mux alc262_dmic_capture_source = {
9301 .num_items = 2,
9302 .items = {
9303 { "Int DMic", 0x9 },
9304 { "Mic", 0x0 },
9305 },
9306};
9307
9308static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9310 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9314 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9315 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9316 {
9317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9318 /* The multiple "Capture Source" controls confuse alsamixer
9319 * So call somewhat different..
9320 */
9321 /* .name = "Capture Source", */
9322 .name = "Input Source",
9323 .count = 1,
9324 .info = alc_mux_enum_info,
9325 .get = alc_mux_enum_get,
9326 .put = alc_mux_enum_put,
9327 },
9328 { } /* end */
9329};
9330
9331static struct hda_verb alc262_toshiba_s06_verbs[] = {
9332 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9335 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9336 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9338 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9339 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9340 {}
9341};
9342
9343static void alc262_dmic_automute(struct hda_codec *codec)
9344{
9345 unsigned int present;
9346
9347 present = snd_hda_codec_read(codec, 0x18, 0,
9348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9349 snd_hda_codec_write(codec, 0x22, 0,
9350 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9351}
9352
9353/* toggle speaker-output according to the hp-jack state */
9354static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9355{
9356 unsigned int present;
9357 unsigned char bits;
9358
9359 present = snd_hda_codec_read(codec, 0x15, 0,
9360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9361 bits = present ? 0 : PIN_OUT;
9362 snd_hda_codec_write(codec, 0x14, 0,
9363 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9364}
9365
9366
9367
9368/* unsolicited event for HP jack sensing */
9369static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9370 unsigned int res)
9371{
9372 if ((res >> 26) == ALC880_HP_EVENT)
9373 alc262_toshiba_s06_speaker_automute(codec);
9374 if ((res >> 26) == ALC880_MIC_EVENT)
9375 alc262_dmic_automute(codec);
9376
9377}
9378
9379static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9380{
9381 alc262_toshiba_s06_speaker_automute(codec);
9382 alc262_dmic_automute(codec);
9383}
9384
Kailang Yangccc656c2006-10-17 12:32:26 +02009385/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009386static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009387{
9388 struct alc_spec *spec = codec->spec;
9389 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009390 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009391
Takashi Iwai5b319542007-07-26 11:49:22 +02009392 /* need to execute and sync at first */
9393 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9394 present = snd_hda_codec_read(codec, 0x15, 0,
9395 AC_VERB_GET_PIN_SENSE, 0);
9396 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009397 if (spec->jack_present) {
9398 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009399 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9400 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009401 } else {
9402 /* unmute internal speaker if necessary */
9403 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009404 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9405 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009406 }
9407}
9408
9409/* unsolicited event for HP jack sensing */
9410static void alc262_hippo_unsol_event(struct hda_codec *codec,
9411 unsigned int res)
9412{
9413 if ((res >> 26) != ALC880_HP_EVENT)
9414 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009415 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009416}
9417
Takashi Iwai5b319542007-07-26 11:49:22 +02009418static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009419{
Kailang Yangccc656c2006-10-17 12:32:26 +02009420 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009421 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009422
Takashi Iwai5b319542007-07-26 11:49:22 +02009423 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9424 present = snd_hda_codec_read(codec, 0x1b, 0,
9425 AC_VERB_GET_PIN_SENSE, 0);
9426 present = (present & 0x80000000) != 0;
9427 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009428 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009429 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9430 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009431 } else {
9432 /* unmute internal speaker if necessary */
9433 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009434 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9435 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009436 }
9437}
9438
9439/* unsolicited event for HP jack sensing */
9440static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9441 unsigned int res)
9442{
9443 if ((res >> 26) != ALC880_HP_EVENT)
9444 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009445 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009446}
9447
Takashi Iwai834be882006-03-01 14:16:17 +01009448/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009449 * nec model
9450 * 0x15 = headphone
9451 * 0x16 = internal speaker
9452 * 0x18 = external mic
9453 */
9454
9455static struct snd_kcontrol_new alc262_nec_mixer[] = {
9456 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9457 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9458
9459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9462
9463 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9465 { } /* end */
9466};
9467
9468static struct hda_verb alc262_nec_verbs[] = {
9469 /* Unmute Speaker */
9470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9471
9472 /* Headphone */
9473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9475
9476 /* External mic to headphone */
9477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9478 /* External mic to speaker */
9479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9480 {}
9481};
9482
9483/*
Takashi Iwai834be882006-03-01 14:16:17 +01009484 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009485 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9486 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009487 */
9488
9489#define ALC_HP_EVENT 0x37
9490
9491static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9492 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009496 {}
9497};
9498
Jiang zhe0e31daf2008-03-20 12:12:39 +01009499static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9500 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9502 {}
9503};
9504
Takashi Iwai834be882006-03-01 14:16:17 +01009505static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009506 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009507 .items = {
9508 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009509 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009510 { "CD", 0x4 },
9511 },
9512};
9513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009514static struct hda_input_mux alc262_HP_capture_source = {
9515 .num_items = 5,
9516 .items = {
9517 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009518 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009519 { "Line", 0x2 },
9520 { "CD", 0x4 },
9521 { "AUX IN", 0x6 },
9522 },
9523};
9524
zhejiangaccbe492007-08-31 12:36:05 +02009525static struct hda_input_mux alc262_HP_D7000_capture_source = {
9526 .num_items = 4,
9527 .items = {
9528 { "Mic", 0x0 },
9529 { "Front Mic", 0x2 },
9530 { "Line", 0x1 },
9531 { "CD", 0x4 },
9532 },
9533};
9534
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009535/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009536static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9537{
9538 struct alc_spec *spec = codec->spec;
9539 unsigned int mute;
9540
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009541 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009542 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009543 /* need to execute and sync at first */
9544 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009545 /* check laptop HP jack */
9546 present = snd_hda_codec_read(codec, 0x14, 0,
9547 AC_VERB_GET_PIN_SENSE, 0);
9548 /* need to execute and sync at first */
9549 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9550 /* check docking HP jack */
9551 present |= snd_hda_codec_read(codec, 0x1b, 0,
9552 AC_VERB_GET_PIN_SENSE, 0);
9553 if (present & AC_PINSENSE_PRESENCE)
9554 spec->jack_present = 1;
9555 else
9556 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009557 spec->sense_updated = 1;
9558 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009559 /* unmute internal speaker only if both HPs are unplugged and
9560 * master switch is on
9561 */
9562 if (spec->jack_present)
9563 mute = HDA_AMP_MUTE;
9564 else
Takashi Iwai834be882006-03-01 14:16:17 +01009565 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009566 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9567 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009568}
9569
9570/* unsolicited event for HP jack sensing */
9571static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9572 unsigned int res)
9573{
9574 if ((res >> 26) != ALC_HP_EVENT)
9575 return;
9576 alc262_fujitsu_automute(codec, 1);
9577}
9578
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009579static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9580{
9581 alc262_fujitsu_automute(codec, 1);
9582}
9583
Takashi Iwai834be882006-03-01 14:16:17 +01009584/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009585static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9586 .ops = &snd_hda_bind_vol,
9587 .values = {
9588 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9589 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9590 0
9591 },
9592};
Takashi Iwai834be882006-03-01 14:16:17 +01009593
Jiang zhe0e31daf2008-03-20 12:12:39 +01009594/* mute/unmute internal speaker according to the hp jack and mute state */
9595static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9596{
9597 struct alc_spec *spec = codec->spec;
9598 unsigned int mute;
9599
9600 if (force || !spec->sense_updated) {
9601 unsigned int present_int_hp;
9602 /* need to execute and sync at first */
9603 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9604 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9605 AC_VERB_GET_PIN_SENSE, 0);
9606 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9607 spec->sense_updated = 1;
9608 }
9609 if (spec->jack_present) {
9610 /* mute internal speaker */
9611 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9612 HDA_AMP_MUTE, HDA_AMP_MUTE);
9613 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9614 HDA_AMP_MUTE, HDA_AMP_MUTE);
9615 } else {
9616 /* unmute internal speaker if necessary */
9617 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9618 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9619 HDA_AMP_MUTE, mute);
9620 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9621 HDA_AMP_MUTE, mute);
9622 }
9623}
9624
9625/* unsolicited event for HP jack sensing */
9626static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9627 unsigned int res)
9628{
9629 if ((res >> 26) != ALC_HP_EVENT)
9630 return;
9631 alc262_lenovo_3000_automute(codec, 1);
9632}
9633
Takashi Iwai834be882006-03-01 14:16:17 +01009634/* bind hp and internal speaker mute (with plug check) */
9635static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9636 struct snd_ctl_elem_value *ucontrol)
9637{
9638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9639 long *valp = ucontrol->value.integer.value;
9640 int change;
9641
Tony Vroon5d9fab22008-03-14 17:09:18 +01009642 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9643 HDA_AMP_MUTE,
9644 valp ? 0 : HDA_AMP_MUTE);
9645 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9646 HDA_AMP_MUTE,
9647 valp ? 0 : HDA_AMP_MUTE);
9648
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009649 if (change)
9650 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009651 return change;
9652}
9653
9654static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009655 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009656 {
9657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9658 .name = "Master Playback Switch",
9659 .info = snd_hda_mixer_amp_switch_info,
9660 .get = snd_hda_mixer_amp_switch_get,
9661 .put = alc262_fujitsu_master_sw_put,
9662 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9663 },
9664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009666 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9667 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009671 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9672 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9673 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009674 { } /* end */
9675};
9676
Jiang zhe0e31daf2008-03-20 12:12:39 +01009677/* bind hp and internal speaker mute (with plug check) */
9678static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9679 struct snd_ctl_elem_value *ucontrol)
9680{
9681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9682 long *valp = ucontrol->value.integer.value;
9683 int change;
9684
9685 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9686 HDA_AMP_MUTE,
9687 valp ? 0 : HDA_AMP_MUTE);
9688
9689 if (change)
9690 alc262_lenovo_3000_automute(codec, 0);
9691 return change;
9692}
9693
9694static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9695 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9696 {
9697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9698 .name = "Master Playback Switch",
9699 .info = snd_hda_mixer_amp_switch_info,
9700 .get = snd_hda_mixer_amp_switch_get,
9701 .put = alc262_lenovo_3000_master_sw_put,
9702 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9703 },
9704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9711 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9712 { } /* end */
9713};
9714
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009715/* additional init verbs for Benq laptops */
9716static struct hda_verb alc262_EAPD_verbs[] = {
9717 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9718 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9719 {}
9720};
9721
Kailang Yang83c34212007-07-05 11:43:05 +02009722static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9725
9726 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9727 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9728 {}
9729};
9730
Tobin Davisf651b502007-10-26 12:40:47 +02009731/* Samsung Q1 Ultra Vista model setup */
9732static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009733 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9734 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9737 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009738 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009739 { } /* end */
9740};
9741
9742static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009743 /* output mixer */
9744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9747 /* speaker */
9748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9752 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009753 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009754 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9758 /* internal mic */
9759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9761 /* ADC, choose mic */
9762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9763 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9765 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009772 {}
9773};
9774
Tobin Davisf651b502007-10-26 12:40:47 +02009775/* mute/unmute internal speaker according to the hp jack and mute state */
9776static void alc262_ultra_automute(struct hda_codec *codec)
9777{
9778 struct alc_spec *spec = codec->spec;
9779 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009780
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009781 mute = 0;
9782 /* auto-mute only when HP is used as HP */
9783 if (!spec->cur_mux[0]) {
9784 unsigned int present;
9785 /* need to execute and sync at first */
9786 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9787 present = snd_hda_codec_read(codec, 0x15, 0,
9788 AC_VERB_GET_PIN_SENSE, 0);
9789 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9790 if (spec->jack_present)
9791 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009792 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009793 /* mute/unmute internal speaker */
9794 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9795 HDA_AMP_MUTE, mute);
9796 /* mute/unmute HP */
9797 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9798 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009799}
9800
9801/* unsolicited event for HP jack sensing */
9802static void alc262_ultra_unsol_event(struct hda_codec *codec,
9803 unsigned int res)
9804{
9805 if ((res >> 26) != ALC880_HP_EVENT)
9806 return;
9807 alc262_ultra_automute(codec);
9808}
9809
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009810static struct hda_input_mux alc262_ultra_capture_source = {
9811 .num_items = 2,
9812 .items = {
9813 { "Mic", 0x1 },
9814 { "Headphone", 0x7 },
9815 },
9816};
9817
9818static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9819 struct snd_ctl_elem_value *ucontrol)
9820{
9821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9822 struct alc_spec *spec = codec->spec;
9823 int ret;
9824
9825 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9826 if (!ret)
9827 return 0;
9828 /* reprogram the HP pin as mic or HP according to the input source */
9829 snd_hda_codec_write_cache(codec, 0x15, 0,
9830 AC_VERB_SET_PIN_WIDGET_CONTROL,
9831 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9832 alc262_ultra_automute(codec); /* mute/unmute HP */
9833 return ret;
9834}
9835
9836static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9837 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9838 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9839 {
9840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9841 .name = "Capture Source",
9842 .info = alc882_mux_enum_info,
9843 .get = alc882_mux_enum_get,
9844 .put = alc262_ultra_mux_enum_put,
9845 },
9846 { } /* end */
9847};
9848
Kailang Yangdf694da2005-12-05 19:42:22 +01009849/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009850static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9851 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009852{
9853 hda_nid_t nid;
9854 int err;
9855
9856 spec->multiout.num_dacs = 1; /* only use one dac */
9857 spec->multiout.dac_nids = spec->private_dac_nids;
9858 spec->multiout.dac_nids[0] = 2;
9859
9860 nid = cfg->line_out_pins[0];
9861 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009862 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9863 "Front Playback Volume",
9864 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009866 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009867 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9868 "Front Playback Switch",
9869 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009871 return err;
9872 }
9873
Takashi Iwai82bc9552006-03-21 11:24:42 +01009874 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009875 if (nid) {
9876 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009877 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9878 "Speaker Playback Volume",
9879 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9880 HDA_OUTPUT));
9881 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009882 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009883 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9884 "Speaker Playback Switch",
9885 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9886 HDA_OUTPUT));
9887 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009888 return err;
9889 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009890 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9891 "Speaker Playback Switch",
9892 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9893 HDA_OUTPUT));
9894 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009895 return err;
9896 }
9897 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009898 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009899 if (nid) {
9900 /* spec->multiout.hp_nid = 2; */
9901 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009902 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9903 "Headphone Playback Volume",
9904 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9905 HDA_OUTPUT));
9906 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009907 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009908 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9909 "Headphone Playback Switch",
9910 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9911 HDA_OUTPUT));
9912 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009913 return err;
9914 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009915 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9916 "Headphone Playback Switch",
9917 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9918 HDA_OUTPUT));
9919 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009920 return err;
9921 }
9922 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009923 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009924}
9925
9926/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009927#define alc262_auto_create_analog_input_ctls \
9928 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009929
9930/*
9931 * generic initialization of ADC, input mixers and output mixers
9932 */
9933static struct hda_verb alc262_volume_init_verbs[] = {
9934 /*
9935 * Unmute ADC0-2 and set the default input to mic-in
9936 */
9937 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9939 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9940 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9941 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9943
Takashi Iwaicb53c622007-08-10 17:21:45 +02009944 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009945 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009946 * Note: PASD motherboards uses the Line In 2 as the input for
9947 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009948 */
9949 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009955
9956 /*
9957 * Set up output mixers (0x0c - 0x0f)
9958 */
9959 /* set vol=0 to output mixers */
9960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009963
Kailang Yangdf694da2005-12-05 19:42:22 +01009964 /* set up input amps for analog loopback */
9965 /* Amp Indices: DAC = 0, mixer = 1 */
9966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9972
9973 /* FIXME: use matrix-type input source selection */
9974 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9975 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9980 /* Input mixer2 */
9981 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9982 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9983 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9984 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9985 /* Input mixer3 */
9986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9989 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9990
9991 { }
9992};
9993
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009994static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9995 /*
9996 * Unmute ADC0-2 and set the default input to mic-in
9997 */
9998 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10000 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10001 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10002 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10003 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10004
Takashi Iwaicb53c622007-08-10 17:21:45 +020010005 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010006 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010007 * Note: PASD motherboards uses the Line In 2 as the input for
10008 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010009 */
10010 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010018
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010019 /*
10020 * Set up output mixers (0x0c - 0x0e)
10021 */
10022 /* set vol=0 to output mixers */
10023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10026
10027 /* set up input amps for analog loopback */
10028 /* Amp Indices: DAC = 0, mixer = 1 */
10029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10035
Takashi Iwaice875f02008-01-28 18:17:43 +010010036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010037 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10039
10040 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10042
10043 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10045
10046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10051
10052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10056 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10057 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10058
10059
10060 /* FIXME: use matrix-type input source selection */
10061 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10062 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10067 /* Input mixer2 */
10068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10072 /* Input mixer3 */
10073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10077
Takashi Iwaice875f02008-01-28 18:17:43 +010010078 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10079
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010080 { }
10081};
10082
Kailang Yangcd7509a2007-01-26 18:33:17 +010010083static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10084 /*
10085 * Unmute ADC0-2 and set the default input to mic-in
10086 */
10087 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10088 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10089 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10091 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10093
Takashi Iwaicb53c622007-08-10 17:21:45 +020010094 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010095 * mixer widget
10096 * Note: PASD motherboards uses the Line In 2 as the input for front
10097 * panel mic (mic 2)
10098 */
10099 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010108 /*
10109 * Set up output mixers (0x0c - 0x0e)
10110 */
10111 /* set vol=0 to output mixers */
10112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10114 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10115
10116 /* set up input amps for analog loopback */
10117 /* Amp Indices: DAC = 0, mixer = 1 */
10118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10119 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10121 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10124
10125
10126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10132 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10133
10134 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10136
10137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10139
10140 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10141 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10142 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10143 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10144 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10145 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10146
10147 /* FIXME: use matrix-type input source selection */
10148 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10149 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10155 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10157 /* Input mixer2 */
10158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10163 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10165 /* Input mixer3 */
10166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10167 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10171 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10173
Takashi Iwaice875f02008-01-28 18:17:43 +010010174 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10175
Kailang Yangcd7509a2007-01-26 18:33:17 +010010176 { }
10177};
10178
Takashi Iwaicb53c622007-08-10 17:21:45 +020010179#ifdef CONFIG_SND_HDA_POWER_SAVE
10180#define alc262_loopbacks alc880_loopbacks
10181#endif
10182
Kailang Yangdf694da2005-12-05 19:42:22 +010010183/* pcm configuration: identiacal with ALC880 */
10184#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10185#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10186#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10187#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10188
10189/*
10190 * BIOS auto configuration
10191 */
10192static int alc262_parse_auto_config(struct hda_codec *codec)
10193{
10194 struct alc_spec *spec = codec->spec;
10195 int err;
10196 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010198 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10199 alc262_ignore);
10200 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010202 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010203 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010204 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10205 if (err < 0)
10206 return err;
10207 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10208 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010209 return err;
10210
10211 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10212
10213 if (spec->autocfg.dig_out_pin)
10214 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10215 if (spec->autocfg.dig_in_pin)
10216 spec->dig_in_nid = ALC262_DIGIN_NID;
10217
10218 if (spec->kctl_alloc)
10219 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10220
10221 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010222 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010223 spec->input_mux = &spec->private_imux;
10224
Takashi Iwai776e1842007-08-29 15:07:11 +020010225 err = alc_auto_add_mic_boost(codec);
10226 if (err < 0)
10227 return err;
10228
Kailang Yangdf694da2005-12-05 19:42:22 +010010229 return 1;
10230}
10231
10232#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10233#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10234#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010235#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010236
10237
10238/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010239static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010240{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010241 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010242 alc262_auto_init_multi_out(codec);
10243 alc262_auto_init_hp_out(codec);
10244 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010245 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010246 if (spec->unsol_event)
10247 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010248}
10249
10250/*
10251 * configuration and preset
10252 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010253static const char *alc262_models[ALC262_MODEL_LAST] = {
10254 [ALC262_BASIC] = "basic",
10255 [ALC262_HIPPO] = "hippo",
10256 [ALC262_HIPPO_1] = "hippo_1",
10257 [ALC262_FUJITSU] = "fujitsu",
10258 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010259 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010260 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010261 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010262 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010263 [ALC262_BENQ_T31] = "benq-t31",
10264 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010265 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Tobin Davisf651b502007-10-26 12:40:47 +020010266 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010267 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010268 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010269 [ALC262_AUTO] = "auto",
10270};
10271
10272static struct snd_pci_quirk alc262_cfg_tbl[] = {
10273 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010274 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010275 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010276 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010277 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10278 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010279 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010280 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010281 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010282 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010283 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010284 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010285 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010286 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010287 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010288 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010289 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010290 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010291 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10292 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10293 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010294 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10295 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010296 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010297 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010298 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010299 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10300 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10301 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010302 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10303 ALC262_SONY_ASSAMD),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010304 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010305 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010306 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010307 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010308 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010309 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010310 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010311 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010312 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010313 {}
10314};
10315
10316static struct alc_config_preset alc262_presets[] = {
10317 [ALC262_BASIC] = {
10318 .mixers = { alc262_base_mixer },
10319 .init_verbs = { alc262_init_verbs },
10320 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10321 .dac_nids = alc262_dac_nids,
10322 .hp_nid = 0x03,
10323 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10324 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010325 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010326 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010327 [ALC262_HIPPO] = {
10328 .mixers = { alc262_base_mixer },
10329 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10330 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10331 .dac_nids = alc262_dac_nids,
10332 .hp_nid = 0x03,
10333 .dig_out_nid = ALC262_DIGOUT_NID,
10334 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10335 .channel_mode = alc262_modes,
10336 .input_mux = &alc262_capture_source,
10337 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010338 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010339 },
10340 [ALC262_HIPPO_1] = {
10341 .mixers = { alc262_hippo1_mixer },
10342 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10343 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10344 .dac_nids = alc262_dac_nids,
10345 .hp_nid = 0x02,
10346 .dig_out_nid = ALC262_DIGOUT_NID,
10347 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10348 .channel_mode = alc262_modes,
10349 .input_mux = &alc262_capture_source,
10350 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010351 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010352 },
Takashi Iwai834be882006-03-01 14:16:17 +010010353 [ALC262_FUJITSU] = {
10354 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010355 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10356 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010357 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10358 .dac_nids = alc262_dac_nids,
10359 .hp_nid = 0x03,
10360 .dig_out_nid = ALC262_DIGOUT_NID,
10361 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10362 .channel_mode = alc262_modes,
10363 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010364 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010365 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010366 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010367 [ALC262_HP_BPC] = {
10368 .mixers = { alc262_HP_BPC_mixer },
10369 .init_verbs = { alc262_HP_BPC_init_verbs },
10370 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10371 .dac_nids = alc262_dac_nids,
10372 .hp_nid = 0x03,
10373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10374 .channel_mode = alc262_modes,
10375 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010376 .unsol_event = alc262_hp_bpc_unsol_event,
10377 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010378 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010379 [ALC262_HP_BPC_D7000_WF] = {
10380 .mixers = { alc262_HP_BPC_WildWest_mixer },
10381 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10382 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10383 .dac_nids = alc262_dac_nids,
10384 .hp_nid = 0x03,
10385 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10386 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010387 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010388 .unsol_event = alc262_hp_wildwest_unsol_event,
10389 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010390 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010391 [ALC262_HP_BPC_D7000_WL] = {
10392 .mixers = { alc262_HP_BPC_WildWest_mixer,
10393 alc262_HP_BPC_WildWest_option_mixer },
10394 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10395 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10396 .dac_nids = alc262_dac_nids,
10397 .hp_nid = 0x03,
10398 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10399 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010400 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010401 .unsol_event = alc262_hp_wildwest_unsol_event,
10402 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010403 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010404 [ALC262_HP_TC_T5735] = {
10405 .mixers = { alc262_hp_t5735_mixer },
10406 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10407 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10408 .dac_nids = alc262_dac_nids,
10409 .hp_nid = 0x03,
10410 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10411 .channel_mode = alc262_modes,
10412 .input_mux = &alc262_capture_source,
10413 .unsol_event = alc262_hp_t5735_unsol_event,
10414 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010415 },
10416 [ALC262_HP_RP5700] = {
10417 .mixers = { alc262_hp_rp5700_mixer },
10418 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10420 .dac_nids = alc262_dac_nids,
10421 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10422 .channel_mode = alc262_modes,
10423 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010424 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010425 [ALC262_BENQ_ED8] = {
10426 .mixers = { alc262_base_mixer },
10427 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10428 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10429 .dac_nids = alc262_dac_nids,
10430 .hp_nid = 0x03,
10431 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10432 .channel_mode = alc262_modes,
10433 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010434 },
Kailang Yang272a5272007-05-14 11:00:38 +020010435 [ALC262_SONY_ASSAMD] = {
10436 .mixers = { alc262_sony_mixer },
10437 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10438 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10439 .dac_nids = alc262_dac_nids,
10440 .hp_nid = 0x02,
10441 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10442 .channel_mode = alc262_modes,
10443 .input_mux = &alc262_capture_source,
10444 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010445 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010446 },
10447 [ALC262_BENQ_T31] = {
10448 .mixers = { alc262_benq_t31_mixer },
10449 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10450 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10451 .dac_nids = alc262_dac_nids,
10452 .hp_nid = 0x03,
10453 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10454 .channel_mode = alc262_modes,
10455 .input_mux = &alc262_capture_source,
10456 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010457 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010458 },
Tobin Davisf651b502007-10-26 12:40:47 +020010459 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010460 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10461 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010462 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10463 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010464 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10465 .channel_mode = alc262_modes,
10466 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010467 .adc_nids = alc262_adc_nids, /* ADC0 */
10468 .capsrc_nids = alc262_capsrc_nids,
10469 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010470 .unsol_event = alc262_ultra_unsol_event,
10471 .init_hook = alc262_ultra_automute,
10472 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010473 [ALC262_LENOVO_3000] = {
10474 .mixers = { alc262_lenovo_3000_mixer },
10475 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10476 alc262_lenovo_3000_unsol_verbs },
10477 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10478 .dac_nids = alc262_dac_nids,
10479 .hp_nid = 0x03,
10480 .dig_out_nid = ALC262_DIGOUT_NID,
10481 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10482 .channel_mode = alc262_modes,
10483 .input_mux = &alc262_fujitsu_capture_source,
10484 .unsol_event = alc262_lenovo_3000_unsol_event,
10485 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010486 [ALC262_NEC] = {
10487 .mixers = { alc262_nec_mixer },
10488 .init_verbs = { alc262_nec_verbs },
10489 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10490 .dac_nids = alc262_dac_nids,
10491 .hp_nid = 0x03,
10492 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10493 .channel_mode = alc262_modes,
10494 .input_mux = &alc262_capture_source,
10495 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010496 [ALC262_TOSHIBA_S06] = {
10497 .mixers = { alc262_toshiba_s06_mixer },
10498 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10499 alc262_eapd_verbs },
10500 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10501 .capsrc_nids = alc262_dmic_capsrc_nids,
10502 .dac_nids = alc262_dac_nids,
10503 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10504 .dig_out_nid = ALC262_DIGOUT_NID,
10505 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10506 .channel_mode = alc262_modes,
10507 .input_mux = &alc262_dmic_capture_source,
10508 .unsol_event = alc262_toshiba_s06_unsol_event,
10509 .init_hook = alc262_toshiba_s06_init_hook,
10510 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010511};
10512
10513static int patch_alc262(struct hda_codec *codec)
10514{
10515 struct alc_spec *spec;
10516 int board_config;
10517 int err;
10518
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010519 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010520 if (spec == NULL)
10521 return -ENOMEM;
10522
10523 codec->spec = spec;
10524#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010525 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10526 * under-run
10527 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010528 {
10529 int tmp;
10530 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10531 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10532 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10533 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10534 }
10535#endif
10536
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010537 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10538
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010539 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10540 alc262_models,
10541 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010542
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010543 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010544 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10545 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010546 board_config = ALC262_AUTO;
10547 }
10548
10549 if (board_config == ALC262_AUTO) {
10550 /* automatic parse from the BIOS config */
10551 err = alc262_parse_auto_config(codec);
10552 if (err < 0) {
10553 alc_free(codec);
10554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010555 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010556 printk(KERN_INFO
10557 "hda_codec: Cannot set up configuration "
10558 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010559 board_config = ALC262_BASIC;
10560 }
10561 }
10562
10563 if (board_config != ALC262_AUTO)
10564 setup_preset(spec, &alc262_presets[board_config]);
10565
10566 spec->stream_name_analog = "ALC262 Analog";
10567 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10568 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010569
Kailang Yangdf694da2005-12-05 19:42:22 +010010570 spec->stream_name_digital = "ALC262 Digital";
10571 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10572 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10573
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010574 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010575 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010576 unsigned int wcap = get_wcaps(codec, 0x07);
10577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010578 /* get type */
10579 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010580 if (wcap != AC_WID_AUD_IN) {
10581 spec->adc_nids = alc262_adc_nids_alt;
10582 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010583 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010584 spec->mixers[spec->num_mixers] =
10585 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010586 spec->num_mixers++;
10587 } else {
10588 spec->adc_nids = alc262_adc_nids;
10589 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010590 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010591 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10592 spec->num_mixers++;
10593 }
10594 }
10595
Takashi Iwai2134ea42008-01-10 16:53:55 +010010596 spec->vmaster_nid = 0x0c;
10597
Kailang Yangdf694da2005-12-05 19:42:22 +010010598 codec->patch_ops = alc_patch_ops;
10599 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010600 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010601#ifdef CONFIG_SND_HDA_POWER_SAVE
10602 if (!spec->loopback.amplist)
10603 spec->loopback.amplist = alc262_loopbacks;
10604#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010605
Kailang Yangdf694da2005-12-05 19:42:22 +010010606 return 0;
10607}
10608
Kailang Yangdf694da2005-12-05 19:42:22 +010010609/*
Kailang Yanga361d842007-06-05 12:30:55 +020010610 * ALC268 channel source setting (2 channel)
10611 */
10612#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10613#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010614
Kailang Yanga361d842007-06-05 12:30:55 +020010615static hda_nid_t alc268_dac_nids[2] = {
10616 /* front, hp */
10617 0x02, 0x03
10618};
10619
10620static hda_nid_t alc268_adc_nids[2] = {
10621 /* ADC0-1 */
10622 0x08, 0x07
10623};
10624
10625static hda_nid_t alc268_adc_nids_alt[1] = {
10626 /* ADC0 */
10627 0x08
10628};
10629
Takashi Iwaie1406342008-02-11 18:32:32 +010010630static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10631
Kailang Yanga361d842007-06-05 12:30:55 +020010632static struct snd_kcontrol_new alc268_base_mixer[] = {
10633 /* output mixer control */
10634 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10635 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10636 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010638 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10639 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10640 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010641 { }
10642};
10643
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010644/* bind Beep switches of both NID 0x0f and 0x10 */
10645static struct hda_bind_ctls alc268_bind_beep_sw = {
10646 .ops = &snd_hda_bind_sw,
10647 .values = {
10648 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10649 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10650 0
10651 },
10652};
10653
10654static struct snd_kcontrol_new alc268_beep_mixer[] = {
10655 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10656 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10657 { }
10658};
10659
Kailang Yangd1a991a2007-08-15 16:21:59 +020010660static struct hda_verb alc268_eapd_verbs[] = {
10661 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10662 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10663 { }
10664};
10665
Takashi Iwaid2738092007-08-16 14:59:45 +020010666/* Toshiba specific */
10667#define alc268_toshiba_automute alc262_hippo_automute
10668
10669static struct hda_verb alc268_toshiba_verbs[] = {
10670 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10671 { } /* end */
10672};
10673
Kailang Yang8ef355d2008-08-26 13:10:22 +020010674static struct hda_input_mux alc268_acer_lc_capture_source = {
10675 .num_items = 2,
10676 .items = {
10677 { "i-Mic", 0x6 },
10678 { "E-Mic", 0x0 },
10679 },
10680};
10681
Takashi Iwaid2738092007-08-16 14:59:45 +020010682/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010683/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010684static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10685 .ops = &snd_hda_bind_vol,
10686 .values = {
10687 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10688 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10689 0
10690 },
10691};
10692
Takashi Iwai889c4392007-08-23 18:56:52 +020010693/* mute/unmute internal speaker according to the hp jack and mute state */
10694static void alc268_acer_automute(struct hda_codec *codec, int force)
10695{
10696 struct alc_spec *spec = codec->spec;
10697 unsigned int mute;
10698
10699 if (force || !spec->sense_updated) {
10700 unsigned int present;
10701 present = snd_hda_codec_read(codec, 0x14, 0,
10702 AC_VERB_GET_PIN_SENSE, 0);
10703 spec->jack_present = (present & 0x80000000) != 0;
10704 spec->sense_updated = 1;
10705 }
10706 if (spec->jack_present)
10707 mute = HDA_AMP_MUTE; /* mute internal speaker */
10708 else /* unmute internal speaker if necessary */
10709 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10710 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10711 HDA_AMP_MUTE, mute);
10712}
10713
10714
10715/* bind hp and internal speaker mute (with plug check) */
10716static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10717 struct snd_ctl_elem_value *ucontrol)
10718{
10719 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10720 long *valp = ucontrol->value.integer.value;
10721 int change;
10722
10723 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10724 HDA_AMP_MUTE,
10725 valp[0] ? 0 : HDA_AMP_MUTE);
10726 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10727 HDA_AMP_MUTE,
10728 valp[1] ? 0 : HDA_AMP_MUTE);
10729 if (change)
10730 alc268_acer_automute(codec, 0);
10731 return change;
10732}
Takashi Iwaid2738092007-08-16 14:59:45 +020010733
Kailang Yang8ef355d2008-08-26 13:10:22 +020010734static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10735 /* output mixer control */
10736 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10737 {
10738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10739 .name = "Master Playback Switch",
10740 .info = snd_hda_mixer_amp_switch_info,
10741 .get = snd_hda_mixer_amp_switch_get,
10742 .put = alc268_acer_master_sw_put,
10743 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10744 },
10745 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10746 { }
10747};
10748
Takashi Iwaid2738092007-08-16 14:59:45 +020010749static struct snd_kcontrol_new alc268_acer_mixer[] = {
10750 /* output mixer control */
10751 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10752 {
10753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10754 .name = "Master Playback Switch",
10755 .info = snd_hda_mixer_amp_switch_info,
10756 .get = snd_hda_mixer_amp_switch_get,
10757 .put = alc268_acer_master_sw_put,
10758 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10759 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10761 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010763 { }
10764};
10765
Kailang Yang8ef355d2008-08-26 13:10:22 +020010766static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10767 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10769 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10770 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10771 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10773 { }
10774};
10775
Takashi Iwaid2738092007-08-16 14:59:45 +020010776static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10778 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010783 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10784 { }
10785};
10786
10787/* unsolicited event for HP jack sensing */
10788static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10789 unsigned int res)
10790{
Takashi Iwai889c4392007-08-23 18:56:52 +020010791 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010792 return;
10793 alc268_toshiba_automute(codec);
10794}
10795
10796static void alc268_acer_unsol_event(struct hda_codec *codec,
10797 unsigned int res)
10798{
Takashi Iwai889c4392007-08-23 18:56:52 +020010799 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010800 return;
10801 alc268_acer_automute(codec, 1);
10802}
10803
Takashi Iwai889c4392007-08-23 18:56:52 +020010804static void alc268_acer_init_hook(struct hda_codec *codec)
10805{
10806 alc268_acer_automute(codec, 1);
10807}
10808
Kailang Yang8ef355d2008-08-26 13:10:22 +020010809/* toggle speaker-output according to the hp-jack state */
10810static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10811{
10812 unsigned int present;
10813 unsigned char bits;
10814
10815 present = snd_hda_codec_read(codec, 0x15, 0,
10816 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10817 bits = present ? AMP_IN_MUTE(0) : 0;
10818 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10819 AMP_IN_MUTE(0), bits);
10820 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10821 AMP_IN_MUTE(0), bits);
10822}
10823
10824
10825static void alc268_acer_mic_automute(struct hda_codec *codec)
10826{
10827 unsigned int present;
10828
10829 present = snd_hda_codec_read(codec, 0x18, 0,
10830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10831 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10832 present ? 0x0 : 0x6);
10833}
10834
10835static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10836 unsigned int res)
10837{
10838 if ((res >> 26) == ALC880_HP_EVENT)
10839 alc268_aspire_one_speaker_automute(codec);
10840 if ((res >> 26) == ALC880_MIC_EVENT)
10841 alc268_acer_mic_automute(codec);
10842}
10843
10844static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10845{
10846 alc268_aspire_one_speaker_automute(codec);
10847 alc268_acer_mic_automute(codec);
10848}
10849
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010850static struct snd_kcontrol_new alc268_dell_mixer[] = {
10851 /* output mixer control */
10852 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10853 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10856 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10857 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10858 { }
10859};
10860
10861static struct hda_verb alc268_dell_verbs[] = {
10862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10864 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10865 { }
10866};
10867
10868/* mute/unmute internal speaker according to the hp jack and mute state */
10869static void alc268_dell_automute(struct hda_codec *codec)
10870{
10871 unsigned int present;
10872 unsigned int mute;
10873
10874 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10875 if (present & 0x80000000)
10876 mute = HDA_AMP_MUTE;
10877 else
10878 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10879 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10880 HDA_AMP_MUTE, mute);
10881}
10882
10883static void alc268_dell_unsol_event(struct hda_codec *codec,
10884 unsigned int res)
10885{
10886 if ((res >> 26) != ALC880_HP_EVENT)
10887 return;
10888 alc268_dell_automute(codec);
10889}
10890
10891#define alc268_dell_init_hook alc268_dell_automute
10892
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010893static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10894 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10895 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10898 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10899 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10900 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10901 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10902 { }
10903};
10904
10905static struct hda_verb alc267_quanta_il1_verbs[] = {
10906 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10907 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10908 { }
10909};
10910
10911static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10912{
10913 unsigned int present;
10914
10915 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10916 & AC_PINSENSE_PRESENCE;
10917 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10918 present ? 0 : PIN_OUT);
10919}
10920
10921static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10922{
10923 unsigned int present;
10924
10925 present = snd_hda_codec_read(codec, 0x18, 0,
10926 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10927 snd_hda_codec_write(codec, 0x23, 0,
10928 AC_VERB_SET_CONNECT_SEL,
10929 present ? 0x00 : 0x01);
10930}
10931
10932static void alc267_quanta_il1_automute(struct hda_codec *codec)
10933{
10934 alc267_quanta_il1_hp_automute(codec);
10935 alc267_quanta_il1_mic_automute(codec);
10936}
10937
10938static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10939 unsigned int res)
10940{
10941 switch (res >> 26) {
10942 case ALC880_HP_EVENT:
10943 alc267_quanta_il1_hp_automute(codec);
10944 break;
10945 case ALC880_MIC_EVENT:
10946 alc267_quanta_il1_mic_automute(codec);
10947 break;
10948 }
10949}
10950
Kailang Yanga361d842007-06-05 12:30:55 +020010951/*
10952 * generic initialization of ADC, input mixers and output mixers
10953 */
10954static struct hda_verb alc268_base_init_verbs[] = {
10955 /* Unmute DAC0-1 and set vol = 0 */
10956 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10957 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10958 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10959 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10960 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10961 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10962
10963 /*
10964 * Set up output mixers (0x0c - 0x0e)
10965 */
10966 /* set vol=0 to output mixers */
10967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10970 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10971
10972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10973 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10974
10975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10978 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10979 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10980 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10981 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10982 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10983
10984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10986 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10990 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010991
10992 /* set PCBEEP vol = 0, mute connections */
10993 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10995 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010996
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010997 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010998
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010999 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11001 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011003
Kailang Yanga361d842007-06-05 12:30:55 +020011004 { }
11005};
11006
11007/*
11008 * generic initialization of ADC, input mixers and output mixers
11009 */
11010static struct hda_verb alc268_volume_init_verbs[] = {
11011 /* set output DAC */
11012 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11013 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11014 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11015 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11016
11017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11021 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11022
11023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11026 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028
11029 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11030 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11032 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11033
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011034 /* set PCBEEP vol = 0, mute connections */
11035 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11036 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11037 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011038
11039 { }
11040};
11041
11042#define alc268_mux_enum_info alc_mux_enum_info
11043#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011044#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020011045
11046static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11047 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11048 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11049 {
11050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11051 /* The multiple "Capture Source" controls confuse alsamixer
11052 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011053 */
11054 /* .name = "Capture Source", */
11055 .name = "Input Source",
11056 .count = 1,
11057 .info = alc268_mux_enum_info,
11058 .get = alc268_mux_enum_get,
11059 .put = alc268_mux_enum_put,
11060 },
11061 { } /* end */
11062};
11063
11064static struct snd_kcontrol_new alc268_capture_mixer[] = {
11065 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11066 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11067 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11068 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11069 {
11070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11071 /* The multiple "Capture Source" controls confuse alsamixer
11072 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011073 */
11074 /* .name = "Capture Source", */
11075 .name = "Input Source",
11076 .count = 2,
11077 .info = alc268_mux_enum_info,
11078 .get = alc268_mux_enum_get,
11079 .put = alc268_mux_enum_put,
11080 },
11081 { } /* end */
11082};
11083
11084static struct hda_input_mux alc268_capture_source = {
11085 .num_items = 4,
11086 .items = {
11087 { "Mic", 0x0 },
11088 { "Front Mic", 0x1 },
11089 { "Line", 0x2 },
11090 { "CD", 0x3 },
11091 },
11092};
11093
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011094static struct hda_input_mux alc268_acer_capture_source = {
11095 .num_items = 3,
11096 .items = {
11097 { "Mic", 0x0 },
11098 { "Internal Mic", 0x6 },
11099 { "Line", 0x2 },
11100 },
11101};
11102
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011103#ifdef CONFIG_SND_DEBUG
11104static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011105 /* Volume widgets */
11106 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11107 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11108 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11109 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11110 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11111 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11112 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11113 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11114 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11115 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11116 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11117 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11118 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011119 /* The below appears problematic on some hardwares */
11120 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011121 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11122 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11123 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11124 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11125
11126 /* Modes for retasking pin widgets */
11127 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11128 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11129 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11130 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11131
11132 /* Controls for GPIO pins, assuming they are configured as outputs */
11133 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11134 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11135 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11136 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11137
11138 /* Switches to allow the digital SPDIF output pin to be enabled.
11139 * The ALC268 does not have an SPDIF input.
11140 */
11141 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11142
11143 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11144 * this output to turn on an external amplifier.
11145 */
11146 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11147 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11148
11149 { } /* end */
11150};
11151#endif
11152
Kailang Yanga361d842007-06-05 12:30:55 +020011153/* create input playback/capture controls for the given pin */
11154static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11155 const char *ctlname, int idx)
11156{
11157 char name[32];
11158 int err;
11159
11160 sprintf(name, "%s Playback Volume", ctlname);
11161 if (nid == 0x14) {
11162 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11163 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11164 HDA_OUTPUT));
11165 if (err < 0)
11166 return err;
11167 } else if (nid == 0x15) {
11168 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11169 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11170 HDA_OUTPUT));
11171 if (err < 0)
11172 return err;
11173 } else
11174 return -1;
11175 sprintf(name, "%s Playback Switch", ctlname);
11176 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11177 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11178 if (err < 0)
11179 return err;
11180 return 0;
11181}
11182
11183/* add playback controls from the parsed DAC table */
11184static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11185 const struct auto_pin_cfg *cfg)
11186{
11187 hda_nid_t nid;
11188 int err;
11189
11190 spec->multiout.num_dacs = 2; /* only use one dac */
11191 spec->multiout.dac_nids = spec->private_dac_nids;
11192 spec->multiout.dac_nids[0] = 2;
11193 spec->multiout.dac_nids[1] = 3;
11194
11195 nid = cfg->line_out_pins[0];
11196 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011197 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011198
11199 nid = cfg->speaker_pins[0];
11200 if (nid == 0x1d) {
11201 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11202 "Speaker Playback Volume",
11203 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11204 if (err < 0)
11205 return err;
11206 }
11207 nid = cfg->hp_pins[0];
11208 if (nid)
11209 alc268_new_analog_output(spec, nid, "Headphone", 0);
11210
11211 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11212 if (nid == 0x16) {
11213 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11214 "Mono Playback Switch",
11215 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11216 if (err < 0)
11217 return err;
11218 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011219 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011220}
11221
11222/* create playback/capture controls for input pins */
11223static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11224 const struct auto_pin_cfg *cfg)
11225{
11226 struct hda_input_mux *imux = &spec->private_imux;
11227 int i, idx1;
11228
11229 for (i = 0; i < AUTO_PIN_LAST; i++) {
11230 switch(cfg->input_pins[i]) {
11231 case 0x18:
11232 idx1 = 0; /* Mic 1 */
11233 break;
11234 case 0x19:
11235 idx1 = 1; /* Mic 2 */
11236 break;
11237 case 0x1a:
11238 idx1 = 2; /* Line In */
11239 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011240 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011241 idx1 = 3; /* CD */
11242 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011243 case 0x12:
11244 case 0x13:
11245 idx1 = 6; /* digital mics */
11246 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011247 default:
11248 continue;
11249 }
11250 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11251 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011252 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011253 }
11254 return 0;
11255}
11256
11257static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11258{
11259 struct alc_spec *spec = codec->spec;
11260 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11261 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11262 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11263 unsigned int dac_vol1, dac_vol2;
11264
11265 if (speaker_nid) {
11266 snd_hda_codec_write(codec, speaker_nid, 0,
11267 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11268 snd_hda_codec_write(codec, 0x0f, 0,
11269 AC_VERB_SET_AMP_GAIN_MUTE,
11270 AMP_IN_UNMUTE(1));
11271 snd_hda_codec_write(codec, 0x10, 0,
11272 AC_VERB_SET_AMP_GAIN_MUTE,
11273 AMP_IN_UNMUTE(1));
11274 } else {
11275 snd_hda_codec_write(codec, 0x0f, 0,
11276 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11277 snd_hda_codec_write(codec, 0x10, 0,
11278 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11279 }
11280
11281 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011282 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011283 dac_vol2 = AMP_OUT_ZERO;
11284 else if (line_nid == 0x15)
11285 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011286 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011287 dac_vol2 = AMP_OUT_ZERO;
11288 else if (hp_nid == 0x15)
11289 dac_vol1 = AMP_OUT_ZERO;
11290 if (line_nid != 0x16 || hp_nid != 0x16 ||
11291 spec->autocfg.line_out_pins[1] != 0x16 ||
11292 spec->autocfg.line_out_pins[2] != 0x16)
11293 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11294
11295 snd_hda_codec_write(codec, 0x02, 0,
11296 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11297 snd_hda_codec_write(codec, 0x03, 0,
11298 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11299}
11300
11301/* pcm configuration: identiacal with ALC880 */
11302#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11303#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011304#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011305#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11306
11307/*
11308 * BIOS auto configuration
11309 */
11310static int alc268_parse_auto_config(struct hda_codec *codec)
11311{
11312 struct alc_spec *spec = codec->spec;
11313 int err;
11314 static hda_nid_t alc268_ignore[] = { 0 };
11315
11316 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11317 alc268_ignore);
11318 if (err < 0)
11319 return err;
11320 if (!spec->autocfg.line_outs)
11321 return 0; /* can't find valid BIOS pin config */
11322
11323 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11324 if (err < 0)
11325 return err;
11326 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11327 if (err < 0)
11328 return err;
11329
11330 spec->multiout.max_channels = 2;
11331
11332 /* digital only support output */
11333 if (spec->autocfg.dig_out_pin)
11334 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11335
11336 if (spec->kctl_alloc)
11337 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11338
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011339 if (spec->autocfg.speaker_pins[0] != 0x1d)
11340 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11341
Kailang Yanga361d842007-06-05 12:30:55 +020011342 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11343 spec->num_mux_defs = 1;
11344 spec->input_mux = &spec->private_imux;
11345
Takashi Iwai776e1842007-08-29 15:07:11 +020011346 err = alc_auto_add_mic_boost(codec);
11347 if (err < 0)
11348 return err;
11349
Kailang Yanga361d842007-06-05 12:30:55 +020011350 return 1;
11351}
11352
11353#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11354#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11355#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11356
11357/* init callback for auto-configuration model -- overriding the default init */
11358static void alc268_auto_init(struct hda_codec *codec)
11359{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011360 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011361 alc268_auto_init_multi_out(codec);
11362 alc268_auto_init_hp_out(codec);
11363 alc268_auto_init_mono_speaker_out(codec);
11364 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011365 if (spec->unsol_event)
11366 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011367}
11368
11369/*
11370 * configuration and preset
11371 */
11372static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011373 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011374 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011375 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011376 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011377 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011378 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011379 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011380#ifdef CONFIG_SND_DEBUG
11381 [ALC268_TEST] = "test",
11382#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011383 [ALC268_AUTO] = "auto",
11384};
11385
11386static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011387 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011388 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011389 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011390 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011391 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011392 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11393 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011394 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011395 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011396 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011397 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011398 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011399 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011400 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011401 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011402 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011403 {}
11404};
11405
11406static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011407 [ALC267_QUANTA_IL1] = {
11408 .mixers = { alc267_quanta_il1_mixer },
11409 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11410 alc267_quanta_il1_verbs },
11411 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11412 .dac_nids = alc268_dac_nids,
11413 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11414 .adc_nids = alc268_adc_nids_alt,
11415 .hp_nid = 0x03,
11416 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11417 .channel_mode = alc268_modes,
11418 .input_mux = &alc268_capture_source,
11419 .unsol_event = alc267_quanta_il1_unsol_event,
11420 .init_hook = alc267_quanta_il1_automute,
11421 },
Kailang Yanga361d842007-06-05 12:30:55 +020011422 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011423 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11424 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011425 .init_verbs = { alc268_base_init_verbs },
11426 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11427 .dac_nids = alc268_dac_nids,
11428 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11429 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011430 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011431 .hp_nid = 0x03,
11432 .dig_out_nid = ALC268_DIGOUT_NID,
11433 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11434 .channel_mode = alc268_modes,
11435 .input_mux = &alc268_capture_source,
11436 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011437 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011438 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11439 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011440 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11441 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011442 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11443 .dac_nids = alc268_dac_nids,
11444 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11445 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011446 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011447 .hp_nid = 0x03,
11448 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11449 .channel_mode = alc268_modes,
11450 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011451 .unsol_event = alc268_toshiba_unsol_event,
11452 .init_hook = alc268_toshiba_automute,
11453 },
11454 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011455 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11456 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011457 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11458 alc268_acer_verbs },
11459 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11460 .dac_nids = alc268_dac_nids,
11461 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11462 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011463 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011464 .hp_nid = 0x02,
11465 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11466 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011467 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011468 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011469 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011470 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011471 [ALC268_ACER_ASPIRE_ONE] = {
11472 .mixers = { alc268_acer_aspire_one_mixer,
11473 alc268_capture_alt_mixer },
11474 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11475 alc268_acer_aspire_one_verbs },
11476 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11477 .dac_nids = alc268_dac_nids,
11478 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11479 .adc_nids = alc268_adc_nids_alt,
11480 .capsrc_nids = alc268_capsrc_nids,
11481 .hp_nid = 0x03,
11482 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11483 .channel_mode = alc268_modes,
11484 .input_mux = &alc268_acer_lc_capture_source,
11485 .unsol_event = alc268_acer_lc_unsol_event,
11486 .init_hook = alc268_acer_lc_init_hook,
11487 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011488 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011489 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011490 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11491 alc268_dell_verbs },
11492 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11493 .dac_nids = alc268_dac_nids,
11494 .hp_nid = 0x02,
11495 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11496 .channel_mode = alc268_modes,
11497 .unsol_event = alc268_dell_unsol_event,
11498 .init_hook = alc268_dell_init_hook,
11499 .input_mux = &alc268_capture_source,
11500 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011501 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011502 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11503 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011504 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11505 alc268_toshiba_verbs },
11506 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11507 .dac_nids = alc268_dac_nids,
11508 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11509 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011510 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011511 .hp_nid = 0x03,
11512 .dig_out_nid = ALC268_DIGOUT_NID,
11513 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11514 .channel_mode = alc268_modes,
11515 .input_mux = &alc268_capture_source,
11516 .unsol_event = alc268_toshiba_unsol_event,
11517 .init_hook = alc268_toshiba_automute
11518 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011519#ifdef CONFIG_SND_DEBUG
11520 [ALC268_TEST] = {
11521 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11522 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11523 alc268_volume_init_verbs },
11524 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11525 .dac_nids = alc268_dac_nids,
11526 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11527 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011528 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011529 .hp_nid = 0x03,
11530 .dig_out_nid = ALC268_DIGOUT_NID,
11531 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11532 .channel_mode = alc268_modes,
11533 .input_mux = &alc268_capture_source,
11534 },
11535#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011536};
11537
11538static int patch_alc268(struct hda_codec *codec)
11539{
11540 struct alc_spec *spec;
11541 int board_config;
11542 int err;
11543
11544 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11545 if (spec == NULL)
11546 return -ENOMEM;
11547
11548 codec->spec = spec;
11549
11550 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11551 alc268_models,
11552 alc268_cfg_tbl);
11553
11554 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11555 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11556 "trying auto-probe from BIOS...\n");
11557 board_config = ALC268_AUTO;
11558 }
11559
11560 if (board_config == ALC268_AUTO) {
11561 /* automatic parse from the BIOS config */
11562 err = alc268_parse_auto_config(codec);
11563 if (err < 0) {
11564 alc_free(codec);
11565 return err;
11566 } else if (!err) {
11567 printk(KERN_INFO
11568 "hda_codec: Cannot set up configuration "
11569 "from BIOS. Using base mode...\n");
11570 board_config = ALC268_3ST;
11571 }
11572 }
11573
11574 if (board_config != ALC268_AUTO)
11575 setup_preset(spec, &alc268_presets[board_config]);
11576
Kailang Yang2f893282008-05-27 12:14:47 +020011577 if (codec->vendor_id == 0x10ec0267) {
11578 spec->stream_name_analog = "ALC267 Analog";
11579 spec->stream_name_digital = "ALC267 Digital";
11580 } else {
11581 spec->stream_name_analog = "ALC268 Analog";
11582 spec->stream_name_digital = "ALC268 Digital";
11583 }
11584
Kailang Yanga361d842007-06-05 12:30:55 +020011585 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11586 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011587 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011588
Kailang Yanga361d842007-06-05 12:30:55 +020011589 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11590
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011591 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11592 /* override the amp caps for beep generator */
11593 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11594 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11595 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11596 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11597 (0 << AC_AMPCAP_MUTE_SHIFT));
11598
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011599 if (!spec->adc_nids && spec->input_mux) {
11600 /* check whether NID 0x07 is valid */
11601 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011602 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011603
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011604 /* get type */
11605 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011606 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011607 spec->adc_nids = alc268_adc_nids_alt;
11608 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11609 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011610 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011611 spec->num_mixers++;
11612 } else {
11613 spec->adc_nids = alc268_adc_nids;
11614 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11615 spec->mixers[spec->num_mixers] =
11616 alc268_capture_mixer;
11617 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011618 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011619 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011620 /* set default input source */
11621 for (i = 0; i < spec->num_adc_nids; i++)
11622 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11623 0, AC_VERB_SET_CONNECT_SEL,
11624 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011625 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011626
11627 spec->vmaster_nid = 0x02;
11628
Kailang Yanga361d842007-06-05 12:30:55 +020011629 codec->patch_ops = alc_patch_ops;
11630 if (board_config == ALC268_AUTO)
11631 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011632
Kailang Yanga361d842007-06-05 12:30:55 +020011633 return 0;
11634}
11635
11636/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011637 * ALC269 channel source setting (2 channel)
11638 */
11639#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11640
11641#define alc269_dac_nids alc260_dac_nids
11642
11643static hda_nid_t alc269_adc_nids[1] = {
11644 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011645 0x08,
11646};
11647
Takashi Iwaie01bf502008-08-21 16:25:07 +020011648static hda_nid_t alc269_capsrc_nids[1] = {
11649 0x23,
11650};
11651
11652/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11653 * not a mux!
11654 */
11655
Kailang Yangf53281e2008-07-18 12:36:43 +020011656static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11657 .num_items = 2,
11658 .items = {
11659 { "i-Mic", 0x5 },
11660 { "e-Mic", 0x0 },
11661 },
11662};
11663
11664static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11665 .num_items = 2,
11666 .items = {
11667 { "i-Mic", 0x1 },
11668 { "e-Mic", 0x0 },
11669 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011670};
11671
11672#define alc269_modes alc260_modes
11673#define alc269_capture_source alc880_lg_lw_capture_source
11674
11675static struct snd_kcontrol_new alc269_base_mixer[] = {
11676 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11677 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011682 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11683 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11685 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11686 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11687 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11689 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11690 { } /* end */
11691};
11692
Kailang Yang60db6b52008-08-26 13:13:00 +020011693static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11694 /* output mixer control */
11695 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11696 {
11697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11698 .name = "Master Playback Switch",
11699 .info = snd_hda_mixer_amp_switch_info,
11700 .get = snd_hda_mixer_amp_switch_get,
11701 .put = alc268_acer_master_sw_put,
11702 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11703 },
11704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11707 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11708 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11709 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11710 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11711 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11712 { }
11713};
11714
Kailang Yangf53281e2008-07-18 12:36:43 +020011715/* bind volumes of both NID 0x0c and 0x0d */
11716static struct hda_bind_ctls alc269_epc_bind_vol = {
11717 .ops = &snd_hda_bind_vol,
11718 .values = {
11719 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11720 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11721 0
11722 },
11723};
11724
11725static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11726 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11727 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11728 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11729 { } /* end */
11730};
11731
Kailang Yangf6a92242007-12-13 16:52:54 +010011732/* capture mixer elements */
11733static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011734 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11735 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011736 {
11737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11738 /* The multiple "Capture Source" controls confuse alsamixer
11739 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011740 */
11741 /* .name = "Capture Source", */
11742 .name = "Input Source",
11743 .count = 1,
11744 .info = alc_mux_enum_info,
11745 .get = alc_mux_enum_get,
11746 .put = alc_mux_enum_put,
11747 },
11748 { } /* end */
11749};
11750
Kailang Yangf53281e2008-07-18 12:36:43 +020011751/* capture mixer elements */
11752static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11753 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11754 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11755 { } /* end */
11756};
11757
Takashi Iwai2005af22008-08-20 18:38:26 +020011758/* beep control */
11759static struct snd_kcontrol_new alc269_beep_mixer[] = {
11760 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11761 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11762 { } /* end */
11763};
11764
Kailang Yang60db6b52008-08-26 13:13:00 +020011765static struct hda_verb alc269_quanta_fl1_verbs[] = {
11766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11767 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11769 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11770 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11771 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11772 { }
11773};
11774
11775/* toggle speaker-output according to the hp-jack state */
11776static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11777{
11778 unsigned int present;
11779 unsigned char bits;
11780
11781 present = snd_hda_codec_read(codec, 0x15, 0,
11782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11783 bits = present ? AMP_IN_MUTE(0) : 0;
11784 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11785 AMP_IN_MUTE(0), bits);
11786 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11787 AMP_IN_MUTE(0), bits);
11788
11789 snd_hda_codec_write(codec, 0x20, 0,
11790 AC_VERB_SET_COEF_INDEX, 0x0c);
11791 snd_hda_codec_write(codec, 0x20, 0,
11792 AC_VERB_SET_PROC_COEF, 0x680);
11793
11794 snd_hda_codec_write(codec, 0x20, 0,
11795 AC_VERB_SET_COEF_INDEX, 0x0c);
11796 snd_hda_codec_write(codec, 0x20, 0,
11797 AC_VERB_SET_PROC_COEF, 0x480);
11798}
11799
11800static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11801{
11802 unsigned int present;
11803
11804 present = snd_hda_codec_read(codec, 0x18, 0,
11805 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11806 snd_hda_codec_write(codec, 0x23, 0,
11807 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11808}
11809
11810static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11811 unsigned int res)
11812{
11813 if ((res >> 26) == ALC880_HP_EVENT)
11814 alc269_quanta_fl1_speaker_automute(codec);
11815 if ((res >> 26) == ALC880_MIC_EVENT)
11816 alc269_quanta_fl1_mic_automute(codec);
11817}
11818
11819static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11820{
11821 alc269_quanta_fl1_speaker_automute(codec);
11822 alc269_quanta_fl1_mic_automute(codec);
11823}
11824
11825static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11827 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11828 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11829 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11830 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11831 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11832 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11833 {}
11834};
11835
11836static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11838 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11839 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11841 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11842 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11843 {}
11844};
11845
11846/* toggle speaker-output according to the hp-jack state */
11847static void alc269_speaker_automute(struct hda_codec *codec)
11848{
11849 unsigned int present;
11850 unsigned char bits;
11851
11852 present = snd_hda_codec_read(codec, 0x15, 0,
11853 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11854 bits = present ? AMP_IN_MUTE(0) : 0;
11855 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11856 AMP_IN_MUTE(0), bits);
11857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11858 AMP_IN_MUTE(0), bits);
11859}
11860
11861static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11862{
11863 unsigned int present;
11864
11865 present = snd_hda_codec_read(codec, 0x18, 0,
11866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11867 snd_hda_codec_write(codec, 0x23, 0,
11868 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11869}
11870
11871static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11872{
11873 unsigned int present;
11874
11875 present = snd_hda_codec_read(codec, 0x18, 0,
11876 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11877 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11878 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11879 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11880 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11881}
11882
11883/* unsolicited event for HP jack sensing */
11884static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11885 unsigned int res)
11886{
11887 if ((res >> 26) == ALC880_HP_EVENT)
11888 alc269_speaker_automute(codec);
11889
11890 if ((res >> 26) == ALC880_MIC_EVENT)
11891 alc269_eeepc_dmic_automute(codec);
11892}
11893
11894static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11895{
11896 alc269_speaker_automute(codec);
11897 alc269_eeepc_dmic_automute(codec);
11898}
11899
11900/* unsolicited event for HP jack sensing */
11901static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11902 unsigned int res)
11903{
11904 if ((res >> 26) == ALC880_HP_EVENT)
11905 alc269_speaker_automute(codec);
11906
11907 if ((res >> 26) == ALC880_MIC_EVENT)
11908 alc269_eeepc_amic_automute(codec);
11909}
11910
11911static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11912{
11913 alc269_speaker_automute(codec);
11914 alc269_eeepc_amic_automute(codec);
11915}
11916
Kailang Yangf6a92242007-12-13 16:52:54 +010011917/*
11918 * generic initialization of ADC, input mixers and output mixers
11919 */
11920static struct hda_verb alc269_init_verbs[] = {
11921 /*
11922 * Unmute ADC0 and set the default input to mic-in
11923 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011924 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011925
11926 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11927 * analog-loopback mixer widget
11928 * Note: PASD motherboards uses the Line In 2 as the input for
11929 * front panel mic (mic 2)
11930 */
11931 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11937
11938 /*
11939 * Set up output mixers (0x0c - 0x0e)
11940 */
11941 /* set vol=0 to output mixers */
11942 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11943 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11944
11945 /* set up input amps for analog loopback */
11946 /* Amp Indices: DAC = 0, mixer = 1 */
11947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11953
11954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11959 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11961
11962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11965 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11966 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11967 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11968 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11969
11970 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11972
11973 /* FIXME: use matrix-type input source selection */
11974 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11975 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020011976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11980
11981 /* set EAPD */
11982 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11983 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11984 { }
11985};
11986
11987/* add playback controls from the parsed DAC table */
11988static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11989 const struct auto_pin_cfg *cfg)
11990{
11991 hda_nid_t nid;
11992 int err;
11993
11994 spec->multiout.num_dacs = 1; /* only use one dac */
11995 spec->multiout.dac_nids = spec->private_dac_nids;
11996 spec->multiout.dac_nids[0] = 2;
11997
11998 nid = cfg->line_out_pins[0];
11999 if (nid) {
12000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12001 "Front Playback Volume",
12002 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12003 if (err < 0)
12004 return err;
12005 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12006 "Front Playback Switch",
12007 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12008 if (err < 0)
12009 return err;
12010 }
12011
12012 nid = cfg->speaker_pins[0];
12013 if (nid) {
12014 if (!cfg->line_out_pins[0]) {
12015 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12016 "Speaker Playback Volume",
12017 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12018 HDA_OUTPUT));
12019 if (err < 0)
12020 return err;
12021 }
12022 if (nid == 0x16) {
12023 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12024 "Speaker Playback Switch",
12025 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12026 HDA_OUTPUT));
12027 if (err < 0)
12028 return err;
12029 } else {
12030 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12031 "Speaker Playback Switch",
12032 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12033 HDA_OUTPUT));
12034 if (err < 0)
12035 return err;
12036 }
12037 }
12038 nid = cfg->hp_pins[0];
12039 if (nid) {
12040 /* spec->multiout.hp_nid = 2; */
12041 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12042 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12043 "Headphone Playback Volume",
12044 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12045 HDA_OUTPUT));
12046 if (err < 0)
12047 return err;
12048 }
12049 if (nid == 0x16) {
12050 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12051 "Headphone Playback Switch",
12052 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12053 HDA_OUTPUT));
12054 if (err < 0)
12055 return err;
12056 } else {
12057 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12058 "Headphone Playback Switch",
12059 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12060 HDA_OUTPUT));
12061 if (err < 0)
12062 return err;
12063 }
12064 }
12065 return 0;
12066}
12067
12068#define alc269_auto_create_analog_input_ctls \
12069 alc880_auto_create_analog_input_ctls
12070
12071#ifdef CONFIG_SND_HDA_POWER_SAVE
12072#define alc269_loopbacks alc880_loopbacks
12073#endif
12074
12075/* pcm configuration: identiacal with ALC880 */
12076#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12077#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12078#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12079#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12080
12081/*
12082 * BIOS auto configuration
12083 */
12084static int alc269_parse_auto_config(struct hda_codec *codec)
12085{
12086 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012087 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012088 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12089
12090 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12091 alc269_ignore);
12092 if (err < 0)
12093 return err;
12094
12095 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12096 if (err < 0)
12097 return err;
12098 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12099 if (err < 0)
12100 return err;
12101
12102 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12103
12104 if (spec->autocfg.dig_out_pin)
12105 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12106
12107 if (spec->kctl_alloc)
12108 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12109
Takashi Iwai2005af22008-08-20 18:38:26 +020012110 /* create a beep mixer control if the pin 0x1d isn't assigned */
12111 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12112 if (spec->autocfg.input_pins[i] == 0x1d)
12113 break;
12114 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12115 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
12116
Kailang Yangf6a92242007-12-13 16:52:54 +010012117 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
12118 spec->num_mux_defs = 1;
12119 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012120 /* set default input source */
12121 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12122 0, AC_VERB_SET_CONNECT_SEL,
12123 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012124
12125 err = alc_auto_add_mic_boost(codec);
12126 if (err < 0)
12127 return err;
12128
Kailang Yangf53281e2008-07-18 12:36:43 +020012129 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
12130 spec->num_mixers++;
12131
Kailang Yangf6a92242007-12-13 16:52:54 +010012132 return 1;
12133}
12134
12135#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12136#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12137#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12138
12139
12140/* init callback for auto-configuration model -- overriding the default init */
12141static void alc269_auto_init(struct hda_codec *codec)
12142{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012143 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012144 alc269_auto_init_multi_out(codec);
12145 alc269_auto_init_hp_out(codec);
12146 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012147 if (spec->unsol_event)
12148 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012149}
12150
12151/*
12152 * configuration and preset
12153 */
12154static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012155 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012156 [ALC269_QUANTA_FL1] = "quanta",
12157 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12158 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901"
Kailang Yangf6a92242007-12-13 16:52:54 +010012159};
12160
12161static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012162 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012163 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12164 ALC269_ASUS_EEEPC_P703),
12165 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12166 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012167 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12168 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010012169 {}
12170};
12171
12172static struct alc_config_preset alc269_presets[] = {
12173 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020012174 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012175 .init_verbs = { alc269_init_verbs },
12176 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12177 .dac_nids = alc269_dac_nids,
12178 .hp_nid = 0x03,
12179 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12180 .channel_mode = alc269_modes,
12181 .input_mux = &alc269_capture_source,
12182 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012183 [ALC269_QUANTA_FL1] = {
12184 .mixers = { alc269_quanta_fl1_mixer },
12185 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12186 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12187 .dac_nids = alc269_dac_nids,
12188 .hp_nid = 0x03,
12189 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12190 .channel_mode = alc269_modes,
12191 .input_mux = &alc269_capture_source,
12192 .unsol_event = alc269_quanta_fl1_unsol_event,
12193 .init_hook = alc269_quanta_fl1_init_hook,
12194 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012195 [ALC269_ASUS_EEEPC_P703] = {
12196 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
12197 .init_verbs = { alc269_init_verbs,
12198 alc269_eeepc_amic_init_verbs },
12199 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12200 .dac_nids = alc269_dac_nids,
12201 .hp_nid = 0x03,
12202 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12203 .channel_mode = alc269_modes,
12204 .input_mux = &alc269_eeepc_amic_capture_source,
12205 .unsol_event = alc269_eeepc_amic_unsol_event,
12206 .init_hook = alc269_eeepc_amic_inithook,
12207 },
12208 [ALC269_ASUS_EEEPC_P901] = {
12209 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
12210 .init_verbs = { alc269_init_verbs,
12211 alc269_eeepc_dmic_init_verbs },
12212 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12213 .dac_nids = alc269_dac_nids,
12214 .hp_nid = 0x03,
12215 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12216 .channel_mode = alc269_modes,
12217 .input_mux = &alc269_eeepc_dmic_capture_source,
12218 .unsol_event = alc269_eeepc_dmic_unsol_event,
12219 .init_hook = alc269_eeepc_dmic_inithook,
12220 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012221};
12222
12223static int patch_alc269(struct hda_codec *codec)
12224{
12225 struct alc_spec *spec;
12226 int board_config;
12227 int err;
12228
12229 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12230 if (spec == NULL)
12231 return -ENOMEM;
12232
12233 codec->spec = spec;
12234
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012235 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12236
Kailang Yangf6a92242007-12-13 16:52:54 +010012237 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12238 alc269_models,
12239 alc269_cfg_tbl);
12240
12241 if (board_config < 0) {
12242 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12243 "trying auto-probe from BIOS...\n");
12244 board_config = ALC269_AUTO;
12245 }
12246
12247 if (board_config == ALC269_AUTO) {
12248 /* automatic parse from the BIOS config */
12249 err = alc269_parse_auto_config(codec);
12250 if (err < 0) {
12251 alc_free(codec);
12252 return err;
12253 } else if (!err) {
12254 printk(KERN_INFO
12255 "hda_codec: Cannot set up configuration "
12256 "from BIOS. Using base mode...\n");
12257 board_config = ALC269_BASIC;
12258 }
12259 }
12260
12261 if (board_config != ALC269_AUTO)
12262 setup_preset(spec, &alc269_presets[board_config]);
12263
12264 spec->stream_name_analog = "ALC269 Analog";
12265 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12266 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12267
12268 spec->stream_name_digital = "ALC269 Digital";
12269 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12270 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12271
12272 spec->adc_nids = alc269_adc_nids;
12273 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012274 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010012275
12276 codec->patch_ops = alc_patch_ops;
12277 if (board_config == ALC269_AUTO)
12278 spec->init_hook = alc269_auto_init;
12279#ifdef CONFIG_SND_HDA_POWER_SAVE
12280 if (!spec->loopback.amplist)
12281 spec->loopback.amplist = alc269_loopbacks;
12282#endif
12283
12284 return 0;
12285}
12286
12287/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012288 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12289 */
12290
12291/*
12292 * set the path ways for 2 channel output
12293 * need to set the codec line out and mic 1 pin widgets to inputs
12294 */
12295static struct hda_verb alc861_threestack_ch2_init[] = {
12296 /* set pin widget 1Ah (line in) for input */
12297 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012298 /* set pin widget 18h (mic1/2) for input, for mic also enable
12299 * the vref
12300 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012301 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12302
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12304#if 0
12305 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12307#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012308 { } /* end */
12309};
12310/*
12311 * 6ch mode
12312 * need to set the codec line out and mic 1 pin widgets to outputs
12313 */
12314static struct hda_verb alc861_threestack_ch6_init[] = {
12315 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12316 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12317 /* set pin widget 18h (mic1) for output (CLFE)*/
12318 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12319
12320 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012321 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012322
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012323 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12324#if 0
12325 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12326 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12327#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012328 { } /* end */
12329};
12330
12331static struct hda_channel_mode alc861_threestack_modes[2] = {
12332 { 2, alc861_threestack_ch2_init },
12333 { 6, alc861_threestack_ch6_init },
12334};
Takashi Iwai22309c32006-08-09 16:57:28 +020012335/* Set mic1 as input and unmute the mixer */
12336static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12337 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12338 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12339 { } /* end */
12340};
12341/* Set mic1 as output and mute mixer */
12342static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12343 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12344 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12345 { } /* end */
12346};
12347
12348static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12349 { 2, alc861_uniwill_m31_ch2_init },
12350 { 4, alc861_uniwill_m31_ch4_init },
12351};
Kailang Yangdf694da2005-12-05 19:42:22 +010012352
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012353/* Set mic1 and line-in as input and unmute the mixer */
12354static struct hda_verb alc861_asus_ch2_init[] = {
12355 /* set pin widget 1Ah (line in) for input */
12356 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012357 /* set pin widget 18h (mic1/2) for input, for mic also enable
12358 * the vref
12359 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12361
12362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12363#if 0
12364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12366#endif
12367 { } /* end */
12368};
12369/* Set mic1 nad line-in as output and mute mixer */
12370static struct hda_verb alc861_asus_ch6_init[] = {
12371 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12372 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12373 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12374 /* set pin widget 18h (mic1) for output (CLFE)*/
12375 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12376 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12377 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12378 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12379
12380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12381#if 0
12382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12383 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12384#endif
12385 { } /* end */
12386};
12387
12388static struct hda_channel_mode alc861_asus_modes[2] = {
12389 { 2, alc861_asus_ch2_init },
12390 { 6, alc861_asus_ch6_init },
12391};
12392
Kailang Yangdf694da2005-12-05 19:42:22 +010012393/* patch-ALC861 */
12394
12395static struct snd_kcontrol_new alc861_base_mixer[] = {
12396 /* output mixer control */
12397 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12398 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12399 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12400 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12401 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12402
12403 /*Input mixer control */
12404 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12405 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12406 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12407 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12408 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12409 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12411 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12412 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012414
Kailang Yangdf694da2005-12-05 19:42:22 +010012415 /* Capture mixer control */
12416 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12417 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12418 {
12419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12420 .name = "Capture Source",
12421 .count = 1,
12422 .info = alc_mux_enum_info,
12423 .get = alc_mux_enum_get,
12424 .put = alc_mux_enum_put,
12425 },
12426 { } /* end */
12427};
12428
12429static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12430 /* output mixer control */
12431 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12432 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12433 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12434 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12435 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12436
12437 /* Input mixer control */
12438 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12439 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12440 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12441 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12442 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12443 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12445 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12446 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12447 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012448
Kailang Yangdf694da2005-12-05 19:42:22 +010012449 /* Capture mixer control */
12450 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12451 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12452 {
12453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12454 .name = "Capture Source",
12455 .count = 1,
12456 .info = alc_mux_enum_info,
12457 .get = alc_mux_enum_get,
12458 .put = alc_mux_enum_put,
12459 },
12460 {
12461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12462 .name = "Channel Mode",
12463 .info = alc_ch_mode_info,
12464 .get = alc_ch_mode_get,
12465 .put = alc_ch_mode_put,
12466 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12467 },
12468 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012469};
12470
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012471static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012472 /* output mixer control */
12473 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12475 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012476
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012477 /*Capture mixer control */
12478 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12479 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12480 {
12481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12482 .name = "Capture Source",
12483 .count = 1,
12484 .info = alc_mux_enum_info,
12485 .get = alc_mux_enum_get,
12486 .put = alc_mux_enum_put,
12487 },
12488
12489 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012490};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012491
Takashi Iwai22309c32006-08-09 16:57:28 +020012492static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12493 /* output mixer control */
12494 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12495 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12496 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12498 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12499
12500 /* Input mixer control */
12501 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12502 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12503 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12504 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12505 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12506 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12508 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012511
Takashi Iwai22309c32006-08-09 16:57:28 +020012512 /* Capture mixer control */
12513 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12514 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12515 {
12516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12517 .name = "Capture Source",
12518 .count = 1,
12519 .info = alc_mux_enum_info,
12520 .get = alc_mux_enum_get,
12521 .put = alc_mux_enum_put,
12522 },
12523 {
12524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12525 .name = "Channel Mode",
12526 .info = alc_ch_mode_info,
12527 .get = alc_ch_mode_get,
12528 .put = alc_ch_mode_put,
12529 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12530 },
12531 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012532};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012533
12534static struct snd_kcontrol_new alc861_asus_mixer[] = {
12535 /* output mixer control */
12536 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12537 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12538 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12539 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12540 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12541
12542 /* Input mixer control */
12543 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12544 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12545 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12546 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12547 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12548 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12550 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12553
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012554 /* Capture mixer control */
12555 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12556 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12557 {
12558 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12559 .name = "Capture Source",
12560 .count = 1,
12561 .info = alc_mux_enum_info,
12562 .get = alc_mux_enum_get,
12563 .put = alc_mux_enum_put,
12564 },
12565 {
12566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12567 .name = "Channel Mode",
12568 .info = alc_ch_mode_info,
12569 .get = alc_ch_mode_get,
12570 .put = alc_ch_mode_put,
12571 .private_value = ARRAY_SIZE(alc861_asus_modes),
12572 },
12573 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012574};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012575
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012576/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012577static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012578 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12579 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12580 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12581 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12582 { }
12583};
12584
Kailang Yangdf694da2005-12-05 19:42:22 +010012585/*
12586 * generic initialization of ADC, input mixers and output mixers
12587 */
12588static struct hda_verb alc861_base_init_verbs[] = {
12589 /*
12590 * Unmute ADC0 and set the default input to mic-in
12591 */
12592 /* port-A for surround (rear panel) */
12593 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12594 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12595 /* port-B for mic-in (rear panel) with vref */
12596 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12597 /* port-C for line-in (rear panel) */
12598 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12599 /* port-D for Front */
12600 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12601 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12602 /* port-E for HP out (front panel) */
12603 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12604 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012605 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012606 /* port-F for mic-in (front panel) with vref */
12607 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12608 /* port-G for CLFE (rear panel) */
12609 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12610 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12611 /* port-H for side (rear panel) */
12612 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12613 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12614 /* CD-in */
12615 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12616 /* route front mic to ADC1*/
12617 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12618 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012619
Kailang Yangdf694da2005-12-05 19:42:22 +010012620 /* Unmute DAC0~3 & spdif out*/
12621 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12622 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12623 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12624 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012626
Kailang Yangdf694da2005-12-05 19:42:22 +010012627 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12628 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12629 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12630 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12631 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012632
Kailang Yangdf694da2005-12-05 19:42:22 +010012633 /* Unmute Stereo Mixer 15 */
12634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012638
12639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12640 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12641 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12642 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012647 /* hp used DAC 3 (Front) */
12648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12650
12651 { }
12652};
12653
12654static struct hda_verb alc861_threestack_init_verbs[] = {
12655 /*
12656 * Unmute ADC0 and set the default input to mic-in
12657 */
12658 /* port-A for surround (rear panel) */
12659 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12660 /* port-B for mic-in (rear panel) with vref */
12661 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12662 /* port-C for line-in (rear panel) */
12663 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12664 /* port-D for Front */
12665 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12666 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12667 /* port-E for HP out (front panel) */
12668 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12669 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012670 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012671 /* port-F for mic-in (front panel) with vref */
12672 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12673 /* port-G for CLFE (rear panel) */
12674 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12675 /* port-H for side (rear panel) */
12676 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12677 /* CD-in */
12678 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12679 /* route front mic to ADC1*/
12680 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12682 /* Unmute DAC0~3 & spdif out*/
12683 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12684 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12685 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12686 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012688
Kailang Yangdf694da2005-12-05 19:42:22 +010012689 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12690 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12691 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12692 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12693 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012694
Kailang Yangdf694da2005-12-05 19:42:22 +010012695 /* Unmute Stereo Mixer 15 */
12696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012700
12701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12705 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012709 /* hp used DAC 3 (Front) */
12710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12712 { }
12713};
Takashi Iwai22309c32006-08-09 16:57:28 +020012714
12715static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12716 /*
12717 * Unmute ADC0 and set the default input to mic-in
12718 */
12719 /* port-A for surround (rear panel) */
12720 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12721 /* port-B for mic-in (rear panel) with vref */
12722 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12723 /* port-C for line-in (rear panel) */
12724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12725 /* port-D for Front */
12726 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12727 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12728 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012729 /* this has to be set to VREF80 */
12730 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012731 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012732 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012733 /* port-F for mic-in (front panel) with vref */
12734 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12735 /* port-G for CLFE (rear panel) */
12736 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12737 /* port-H for side (rear panel) */
12738 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12739 /* CD-in */
12740 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12741 /* route front mic to ADC1*/
12742 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12744 /* Unmute DAC0~3 & spdif out*/
12745 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12746 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12748 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012750
Takashi Iwai22309c32006-08-09 16:57:28 +020012751 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12752 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12754 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12755 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012756
Takashi Iwai22309c32006-08-09 16:57:28 +020012757 /* Unmute Stereo Mixer 15 */
12758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012762
12763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12765 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012771 /* hp used DAC 3 (Front) */
12772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12774 { }
12775};
12776
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012777static struct hda_verb alc861_asus_init_verbs[] = {
12778 /*
12779 * Unmute ADC0 and set the default input to mic-in
12780 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012781 /* port-A for surround (rear panel)
12782 * according to codec#0 this is the HP jack
12783 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012784 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12785 /* route front PCM to HP */
12786 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12787 /* port-B for mic-in (rear panel) with vref */
12788 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12789 /* port-C for line-in (rear panel) */
12790 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12791 /* port-D for Front */
12792 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12793 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12794 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012795 /* this has to be set to VREF80 */
12796 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012797 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012799 /* port-F for mic-in (front panel) with vref */
12800 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12801 /* port-G for CLFE (rear panel) */
12802 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12803 /* port-H for side (rear panel) */
12804 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12805 /* CD-in */
12806 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12807 /* route front mic to ADC1*/
12808 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12810 /* Unmute DAC0~3 & spdif out*/
12811 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12812 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12813 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12814 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12816 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12817 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12818 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12819 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12820 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012821
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012822 /* Unmute Stereo Mixer 15 */
12823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012827
12828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12831 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12832 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012836 /* hp used DAC 3 (Front) */
12837 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12839 { }
12840};
12841
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012842/* additional init verbs for ASUS laptops */
12843static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12844 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12845 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12846 { }
12847};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012848
Kailang Yangdf694da2005-12-05 19:42:22 +010012849/*
12850 * generic initialization of ADC, input mixers and output mixers
12851 */
12852static struct hda_verb alc861_auto_init_verbs[] = {
12853 /*
12854 * Unmute ADC0 and set the default input to mic-in
12855 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012856 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012858
Kailang Yangdf694da2005-12-05 19:42:22 +010012859 /* Unmute DAC0~3 & spdif out*/
12860 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12862 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12863 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012865
Kailang Yangdf694da2005-12-05 19:42:22 +010012866 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12867 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12868 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12869 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12870 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012871
Kailang Yangdf694da2005-12-05 19:42:22 +010012872 /* Unmute Stereo Mixer 15 */
12873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12877
12878 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12879 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12882 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12886
12887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12888 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012889 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012891 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12892 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012895
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012896 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012897
12898 { }
12899};
12900
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012901static struct hda_verb alc861_toshiba_init_verbs[] = {
12902 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012903
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012904 { }
12905};
12906
12907/* toggle speaker-output according to the hp-jack state */
12908static void alc861_toshiba_automute(struct hda_codec *codec)
12909{
12910 unsigned int present;
12911
12912 present = snd_hda_codec_read(codec, 0x0f, 0,
12913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012914 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12915 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12916 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12917 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012918}
12919
12920static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12921 unsigned int res)
12922{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012923 if ((res >> 26) == ALC880_HP_EVENT)
12924 alc861_toshiba_automute(codec);
12925}
12926
Kailang Yangdf694da2005-12-05 19:42:22 +010012927/* pcm configuration: identiacal with ALC880 */
12928#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12929#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12930#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12931#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12932
12933
12934#define ALC861_DIGOUT_NID 0x07
12935
12936static struct hda_channel_mode alc861_8ch_modes[1] = {
12937 { 8, NULL }
12938};
12939
12940static hda_nid_t alc861_dac_nids[4] = {
12941 /* front, surround, clfe, side */
12942 0x03, 0x06, 0x05, 0x04
12943};
12944
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012945static hda_nid_t alc660_dac_nids[3] = {
12946 /* front, clfe, surround */
12947 0x03, 0x05, 0x06
12948};
12949
Kailang Yangdf694da2005-12-05 19:42:22 +010012950static hda_nid_t alc861_adc_nids[1] = {
12951 /* ADC0-2 */
12952 0x08,
12953};
12954
12955static struct hda_input_mux alc861_capture_source = {
12956 .num_items = 5,
12957 .items = {
12958 { "Mic", 0x0 },
12959 { "Front Mic", 0x3 },
12960 { "Line", 0x1 },
12961 { "CD", 0x4 },
12962 { "Mixer", 0x5 },
12963 },
12964};
12965
12966/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012967static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12968 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012969{
12970 int i;
12971 hda_nid_t nid;
12972
12973 spec->multiout.dac_nids = spec->private_dac_nids;
12974 for (i = 0; i < cfg->line_outs; i++) {
12975 nid = cfg->line_out_pins[i];
12976 if (nid) {
12977 if (i >= ARRAY_SIZE(alc861_dac_nids))
12978 continue;
12979 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12980 }
12981 }
12982 spec->multiout.num_dacs = cfg->line_outs;
12983 return 0;
12984}
12985
12986/* add playback controls from the parsed DAC table */
12987static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12988 const struct auto_pin_cfg *cfg)
12989{
12990 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012991 static const char *chname[4] = {
12992 "Front", "Surround", NULL /*CLFE*/, "Side"
12993 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012994 hda_nid_t nid;
12995 int i, idx, err;
12996
12997 for (i = 0; i < cfg->line_outs; i++) {
12998 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012999 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013000 continue;
13001 if (nid == 0x05) {
13002 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013003 err = add_control(spec, ALC_CTL_BIND_MUTE,
13004 "Center Playback Switch",
13005 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13006 HDA_OUTPUT));
13007 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013009 err = add_control(spec, ALC_CTL_BIND_MUTE,
13010 "LFE Playback Switch",
13011 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13012 HDA_OUTPUT));
13013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013014 return err;
13015 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013016 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13017 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013018 if (nid == alc861_dac_nids[idx])
13019 break;
13020 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013021 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13022 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13023 HDA_OUTPUT));
13024 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013025 return err;
13026 }
13027 }
13028 return 0;
13029}
13030
13031static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13032{
13033 int err;
13034 hda_nid_t nid;
13035
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013036 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013037 return 0;
13038
13039 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13040 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013041 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13042 "Headphone Playback Switch",
13043 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13044 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013045 return err;
13046 spec->multiout.hp_nid = nid;
13047 }
13048 return 0;
13049}
13050
13051/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013052static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13053 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013054{
Kailang Yangdf694da2005-12-05 19:42:22 +010013055 struct hda_input_mux *imux = &spec->private_imux;
13056 int i, err, idx, idx1;
13057
13058 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013059 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013060 case 0x0c:
13061 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013062 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013063 break;
13064 case 0x0f:
13065 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013066 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013067 break;
13068 case 0x0d:
13069 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013070 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013071 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013072 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013073 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013074 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013075 break;
13076 case 0x11:
13077 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013078 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013079 break;
13080 default:
13081 continue;
13082 }
13083
Takashi Iwai4a471b72005-12-07 13:56:29 +010013084 err = new_analog_input(spec, cfg->input_pins[i],
13085 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013086 if (err < 0)
13087 return err;
13088
Takashi Iwai4a471b72005-12-07 13:56:29 +010013089 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013090 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013091 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013092 }
13093 return 0;
13094}
13095
13096static struct snd_kcontrol_new alc861_capture_mixer[] = {
13097 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13098 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13099
13100 {
13101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13102 /* The multiple "Capture Source" controls confuse alsamixer
13103 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010013104 */
13105 /* .name = "Capture Source", */
13106 .name = "Input Source",
13107 .count = 1,
13108 .info = alc_mux_enum_info,
13109 .get = alc_mux_enum_get,
13110 .put = alc_mux_enum_put,
13111 },
13112 { } /* end */
13113};
13114
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013115static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13116 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 int pin_type, int dac_idx)
13118{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013119 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13120 pin_type);
13121 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13122 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013123}
13124
13125static void alc861_auto_init_multi_out(struct hda_codec *codec)
13126{
13127 struct alc_spec *spec = codec->spec;
13128 int i;
13129
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013130 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013131 for (i = 0; i < spec->autocfg.line_outs; i++) {
13132 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013133 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013134 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013135 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013136 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013137 }
13138}
13139
13140static void alc861_auto_init_hp_out(struct hda_codec *codec)
13141{
13142 struct alc_spec *spec = codec->spec;
13143 hda_nid_t pin;
13144
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013145 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013146 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013147 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13148 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013149 pin = spec->autocfg.speaker_pins[0];
13150 if (pin)
13151 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013152}
13153
13154static void alc861_auto_init_analog_input(struct hda_codec *codec)
13155{
13156 struct alc_spec *spec = codec->spec;
13157 int i;
13158
13159 for (i = 0; i < AUTO_PIN_LAST; i++) {
13160 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013161 if (nid >= 0x0c && nid <= 0x11) {
13162 snd_hda_codec_write(codec, nid, 0,
13163 AC_VERB_SET_PIN_WIDGET_CONTROL,
13164 i <= AUTO_PIN_FRONT_MIC ?
13165 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013166 }
13167 }
13168}
13169
13170/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013171/* return 1 if successful, 0 if the proper config is not found,
13172 * or a negative error code
13173 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013174static int alc861_parse_auto_config(struct hda_codec *codec)
13175{
13176 struct alc_spec *spec = codec->spec;
13177 int err;
13178 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13179
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013180 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13181 alc861_ignore);
13182 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013183 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013184 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013185 return 0; /* can't find valid BIOS pin config */
13186
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013187 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13188 if (err < 0)
13189 return err;
13190 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13191 if (err < 0)
13192 return err;
13193 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13194 if (err < 0)
13195 return err;
13196 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13197 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013198 return err;
13199
13200 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13201
13202 if (spec->autocfg.dig_out_pin)
13203 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13204
13205 if (spec->kctl_alloc)
13206 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13207
13208 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
13209
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013210 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013211 spec->input_mux = &spec->private_imux;
13212
13213 spec->adc_nids = alc861_adc_nids;
13214 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13215 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
13216 spec->num_mixers++;
13217
13218 return 1;
13219}
13220
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013221/* additional initialization for auto-configuration model */
13222static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013223{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013224 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013225 alc861_auto_init_multi_out(codec);
13226 alc861_auto_init_hp_out(codec);
13227 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013228 if (spec->unsol_event)
13229 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013230}
13231
Takashi Iwaicb53c622007-08-10 17:21:45 +020013232#ifdef CONFIG_SND_HDA_POWER_SAVE
13233static struct hda_amp_list alc861_loopbacks[] = {
13234 { 0x15, HDA_INPUT, 0 },
13235 { 0x15, HDA_INPUT, 1 },
13236 { 0x15, HDA_INPUT, 2 },
13237 { 0x15, HDA_INPUT, 3 },
13238 { } /* end */
13239};
13240#endif
13241
Kailang Yangdf694da2005-12-05 19:42:22 +010013242
13243/*
13244 * configuration and preset
13245 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013246static const char *alc861_models[ALC861_MODEL_LAST] = {
13247 [ALC861_3ST] = "3stack",
13248 [ALC660_3ST] = "3stack-660",
13249 [ALC861_3ST_DIG] = "3stack-dig",
13250 [ALC861_6ST_DIG] = "6stack-dig",
13251 [ALC861_UNIWILL_M31] = "uniwill-m31",
13252 [ALC861_TOSHIBA] = "toshiba",
13253 [ALC861_ASUS] = "asus",
13254 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13255 [ALC861_AUTO] = "auto",
13256};
13257
13258static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013259 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013260 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13261 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13262 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013263 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013264 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013265 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013266 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13267 * Any other models that need this preset?
13268 */
13269 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013270 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13271 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013272 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13273 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13274 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13275 /* FIXME: the below seems conflict */
13276 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13277 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13278 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013279 {}
13280};
13281
13282static struct alc_config_preset alc861_presets[] = {
13283 [ALC861_3ST] = {
13284 .mixers = { alc861_3ST_mixer },
13285 .init_verbs = { alc861_threestack_init_verbs },
13286 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13287 .dac_nids = alc861_dac_nids,
13288 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13289 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013290 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013291 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13292 .adc_nids = alc861_adc_nids,
13293 .input_mux = &alc861_capture_source,
13294 },
13295 [ALC861_3ST_DIG] = {
13296 .mixers = { alc861_base_mixer },
13297 .init_verbs = { alc861_threestack_init_verbs },
13298 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13299 .dac_nids = alc861_dac_nids,
13300 .dig_out_nid = ALC861_DIGOUT_NID,
13301 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13302 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013303 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013304 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13305 .adc_nids = alc861_adc_nids,
13306 .input_mux = &alc861_capture_source,
13307 },
13308 [ALC861_6ST_DIG] = {
13309 .mixers = { alc861_base_mixer },
13310 .init_verbs = { alc861_base_init_verbs },
13311 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13312 .dac_nids = alc861_dac_nids,
13313 .dig_out_nid = ALC861_DIGOUT_NID,
13314 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13315 .channel_mode = alc861_8ch_modes,
13316 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13317 .adc_nids = alc861_adc_nids,
13318 .input_mux = &alc861_capture_source,
13319 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013320 [ALC660_3ST] = {
13321 .mixers = { alc861_3ST_mixer },
13322 .init_verbs = { alc861_threestack_init_verbs },
13323 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13324 .dac_nids = alc660_dac_nids,
13325 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13326 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013327 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013328 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13329 .adc_nids = alc861_adc_nids,
13330 .input_mux = &alc861_capture_source,
13331 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013332 [ALC861_UNIWILL_M31] = {
13333 .mixers = { alc861_uniwill_m31_mixer },
13334 .init_verbs = { alc861_uniwill_m31_init_verbs },
13335 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13336 .dac_nids = alc861_dac_nids,
13337 .dig_out_nid = ALC861_DIGOUT_NID,
13338 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13339 .channel_mode = alc861_uniwill_m31_modes,
13340 .need_dac_fix = 1,
13341 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13342 .adc_nids = alc861_adc_nids,
13343 .input_mux = &alc861_capture_source,
13344 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013345 [ALC861_TOSHIBA] = {
13346 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013347 .init_verbs = { alc861_base_init_verbs,
13348 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013349 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13350 .dac_nids = alc861_dac_nids,
13351 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13352 .channel_mode = alc883_3ST_2ch_modes,
13353 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13354 .adc_nids = alc861_adc_nids,
13355 .input_mux = &alc861_capture_source,
13356 .unsol_event = alc861_toshiba_unsol_event,
13357 .init_hook = alc861_toshiba_automute,
13358 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013359 [ALC861_ASUS] = {
13360 .mixers = { alc861_asus_mixer },
13361 .init_verbs = { alc861_asus_init_verbs },
13362 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13363 .dac_nids = alc861_dac_nids,
13364 .dig_out_nid = ALC861_DIGOUT_NID,
13365 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13366 .channel_mode = alc861_asus_modes,
13367 .need_dac_fix = 1,
13368 .hp_nid = 0x06,
13369 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13370 .adc_nids = alc861_adc_nids,
13371 .input_mux = &alc861_capture_source,
13372 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013373 [ALC861_ASUS_LAPTOP] = {
13374 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13375 .init_verbs = { alc861_asus_init_verbs,
13376 alc861_asus_laptop_init_verbs },
13377 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13378 .dac_nids = alc861_dac_nids,
13379 .dig_out_nid = ALC861_DIGOUT_NID,
13380 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13381 .channel_mode = alc883_3ST_2ch_modes,
13382 .need_dac_fix = 1,
13383 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13384 .adc_nids = alc861_adc_nids,
13385 .input_mux = &alc861_capture_source,
13386 },
13387};
Kailang Yangdf694da2005-12-05 19:42:22 +010013388
13389
13390static int patch_alc861(struct hda_codec *codec)
13391{
13392 struct alc_spec *spec;
13393 int board_config;
13394 int err;
13395
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013396 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013397 if (spec == NULL)
13398 return -ENOMEM;
13399
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013400 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013401
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013402 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13403 alc861_models,
13404 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013405
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013406 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013407 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13408 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013409 board_config = ALC861_AUTO;
13410 }
13411
13412 if (board_config == ALC861_AUTO) {
13413 /* automatic parse from the BIOS config */
13414 err = alc861_parse_auto_config(codec);
13415 if (err < 0) {
13416 alc_free(codec);
13417 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013418 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013419 printk(KERN_INFO
13420 "hda_codec: Cannot set up configuration "
13421 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013422 board_config = ALC861_3ST_DIG;
13423 }
13424 }
13425
13426 if (board_config != ALC861_AUTO)
13427 setup_preset(spec, &alc861_presets[board_config]);
13428
13429 spec->stream_name_analog = "ALC861 Analog";
13430 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13431 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13432
13433 spec->stream_name_digital = "ALC861 Digital";
13434 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13435 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13436
Takashi Iwai2134ea42008-01-10 16:53:55 +010013437 spec->vmaster_nid = 0x03;
13438
Kailang Yangdf694da2005-12-05 19:42:22 +010013439 codec->patch_ops = alc_patch_ops;
13440 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013441 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013442#ifdef CONFIG_SND_HDA_POWER_SAVE
13443 if (!spec->loopback.amplist)
13444 spec->loopback.amplist = alc861_loopbacks;
13445#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013446
Kailang Yangdf694da2005-12-05 19:42:22 +010013447 return 0;
13448}
13449
13450/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013451 * ALC861-VD support
13452 *
13453 * Based on ALC882
13454 *
13455 * In addition, an independent DAC
13456 */
13457#define ALC861VD_DIGOUT_NID 0x06
13458
13459static hda_nid_t alc861vd_dac_nids[4] = {
13460 /* front, surr, clfe, side surr */
13461 0x02, 0x03, 0x04, 0x05
13462};
13463
13464/* dac_nids for ALC660vd are in a different order - according to
13465 * Realtek's driver.
13466 * This should probably tesult in a different mixer for 6stack models
13467 * of ALC660vd codecs, but for now there is only 3stack mixer
13468 * - and it is the same as in 861vd.
13469 * adc_nids in ALC660vd are (is) the same as in 861vd
13470 */
13471static hda_nid_t alc660vd_dac_nids[3] = {
13472 /* front, rear, clfe, rear_surr */
13473 0x02, 0x04, 0x03
13474};
13475
13476static hda_nid_t alc861vd_adc_nids[1] = {
13477 /* ADC0 */
13478 0x09,
13479};
13480
Takashi Iwaie1406342008-02-11 18:32:32 +010013481static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13482
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013483/* input MUX */
13484/* FIXME: should be a matrix-type input source selection */
13485static struct hda_input_mux alc861vd_capture_source = {
13486 .num_items = 4,
13487 .items = {
13488 { "Mic", 0x0 },
13489 { "Front Mic", 0x1 },
13490 { "Line", 0x2 },
13491 { "CD", 0x4 },
13492 },
13493};
13494
Kailang Yang272a5272007-05-14 11:00:38 +020013495static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013496 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013497 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013498 { "Ext Mic", 0x0 },
13499 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013500 },
13501};
13502
Kailang Yangd1a991a2007-08-15 16:21:59 +020013503static struct hda_input_mux alc861vd_hp_capture_source = {
13504 .num_items = 2,
13505 .items = {
13506 { "Front Mic", 0x0 },
13507 { "ATAPI Mic", 0x1 },
13508 },
13509};
13510
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013511#define alc861vd_mux_enum_info alc_mux_enum_info
13512#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013513/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13514#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013515
13516/*
13517 * 2ch mode
13518 */
13519static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13520 { 2, NULL }
13521};
13522
13523/*
13524 * 6ch mode
13525 */
13526static struct hda_verb alc861vd_6stack_ch6_init[] = {
13527 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13528 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13529 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13530 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13531 { } /* end */
13532};
13533
13534/*
13535 * 8ch mode
13536 */
13537static struct hda_verb alc861vd_6stack_ch8_init[] = {
13538 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13539 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13540 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13541 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13542 { } /* end */
13543};
13544
13545static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13546 { 6, alc861vd_6stack_ch6_init },
13547 { 8, alc861vd_6stack_ch8_init },
13548};
13549
13550static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13551 {
13552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13553 .name = "Channel Mode",
13554 .info = alc_ch_mode_info,
13555 .get = alc_ch_mode_get,
13556 .put = alc_ch_mode_put,
13557 },
13558 { } /* end */
13559};
13560
13561static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13562 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13563 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13564
13565 {
13566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13567 /* The multiple "Capture Source" controls confuse alsamixer
13568 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013569 */
13570 /* .name = "Capture Source", */
13571 .name = "Input Source",
13572 .count = 1,
13573 .info = alc861vd_mux_enum_info,
13574 .get = alc861vd_mux_enum_get,
13575 .put = alc861vd_mux_enum_put,
13576 },
13577 { } /* end */
13578};
13579
13580/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13581 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13582 */
13583static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13584 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13585 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13586
13587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13588 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13589
13590 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13591 HDA_OUTPUT),
13592 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13593 HDA_OUTPUT),
13594 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13595 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13596
13597 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13598 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13599
13600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13601
13602 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13605
13606 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13607 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13608 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13609
13610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13612
13613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13615
13616 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13617 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13618
13619 { } /* end */
13620};
13621
13622static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13623 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13624 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13625
13626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13627
13628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13631
13632 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13633 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13634 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13635
13636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13638
13639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13641
13642 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13643 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13644
13645 { } /* end */
13646};
13647
Kailang Yangbdd148a2007-05-08 15:19:08 +020013648static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13649 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13650 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13651 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13652
13653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13654
13655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13658
13659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13662
13663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13665
13666 { } /* end */
13667};
13668
Tobin Davisb419f342008-03-07 11:57:51 +010013669/* Pin assignment: Speaker=0x14, HP = 0x15,
13670 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013671 */
13672static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013673 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13674 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013675 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13676 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013677 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13679 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13680 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13681 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13682 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13683 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13684 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013685 { } /* end */
13686};
13687
Kailang Yangd1a991a2007-08-15 16:21:59 +020013688/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13689 * Front Mic=0x18, ATAPI Mic = 0x19,
13690 */
13691static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13692 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13693 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13695 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13697 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13698 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13699 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013700
Kailang Yangd1a991a2007-08-15 16:21:59 +020013701 { } /* end */
13702};
13703
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013704/*
13705 * generic initialization of ADC, input mixers and output mixers
13706 */
13707static struct hda_verb alc861vd_volume_init_verbs[] = {
13708 /*
13709 * Unmute ADC0 and set the default input to mic-in
13710 */
13711 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13713
13714 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13715 * the analog-loopback mixer widget
13716 */
13717 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013723
13724 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013729
13730 /*
13731 * Set up output mixers (0x02 - 0x05)
13732 */
13733 /* set vol=0 to output mixers */
13734 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13735 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13736 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13737 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13738
13739 /* set up input amps for analog loopback */
13740 /* Amp Indices: DAC = 0, mixer = 1 */
13741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13747 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13749
13750 { }
13751};
13752
13753/*
13754 * 3-stack pin configuration:
13755 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13756 */
13757static struct hda_verb alc861vd_3stack_init_verbs[] = {
13758 /*
13759 * Set pin mode and muting
13760 */
13761 /* set front pin widgets 0x14 for output */
13762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13764 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13765
13766 /* Mic (rear) pin: input vref at 80% */
13767 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13769 /* Front Mic pin: input vref at 80% */
13770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13771 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13772 /* Line In pin: input */
13773 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13775 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13778 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13779 /* CD pin widget for input */
13780 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13781
13782 { }
13783};
13784
13785/*
13786 * 6-stack pin configuration:
13787 */
13788static struct hda_verb alc861vd_6stack_init_verbs[] = {
13789 /*
13790 * Set pin mode and muting
13791 */
13792 /* set front pin widgets 0x14 for output */
13793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13795 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13796
13797 /* Rear Pin: output 1 (0x0d) */
13798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13801 /* CLFE Pin: output 2 (0x0e) */
13802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13804 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13805 /* Side Pin: output 3 (0x0f) */
13806 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13808 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13809
13810 /* Mic (rear) pin: input vref at 80% */
13811 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13813 /* Front Mic pin: input vref at 80% */
13814 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13815 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13816 /* Line In pin: input */
13817 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13818 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13819 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13820 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13821 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13822 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13823 /* CD pin widget for input */
13824 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13825
13826 { }
13827};
13828
Kailang Yangbdd148a2007-05-08 15:19:08 +020013829static struct hda_verb alc861vd_eapd_verbs[] = {
13830 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13831 { }
13832};
13833
Kailang Yangf9423e72008-05-27 12:32:25 +020013834static struct hda_verb alc660vd_eapd_verbs[] = {
13835 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13836 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13837 { }
13838};
13839
Kailang Yangbdd148a2007-05-08 15:19:08 +020013840static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13844 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013845 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013846 {}
13847};
13848
13849/* toggle speaker-output according to the hp-jack state */
13850static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13851{
13852 unsigned int present;
13853 unsigned char bits;
13854
13855 present = snd_hda_codec_read(codec, 0x1b, 0,
13856 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013857 bits = present ? HDA_AMP_MUTE : 0;
13858 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13859 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013860}
13861
13862static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13863{
13864 unsigned int present;
13865 unsigned char bits;
13866
13867 present = snd_hda_codec_read(codec, 0x18, 0,
13868 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013869 bits = present ? HDA_AMP_MUTE : 0;
13870 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13871 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013872}
13873
13874static void alc861vd_lenovo_automute(struct hda_codec *codec)
13875{
13876 alc861vd_lenovo_hp_automute(codec);
13877 alc861vd_lenovo_mic_automute(codec);
13878}
13879
13880static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13881 unsigned int res)
13882{
13883 switch (res >> 26) {
13884 case ALC880_HP_EVENT:
13885 alc861vd_lenovo_hp_automute(codec);
13886 break;
13887 case ALC880_MIC_EVENT:
13888 alc861vd_lenovo_mic_automute(codec);
13889 break;
13890 }
13891}
13892
Kailang Yang272a5272007-05-14 11:00:38 +020013893static struct hda_verb alc861vd_dallas_verbs[] = {
13894 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13898
13899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13905 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013907
Kailang Yang272a5272007-05-14 11:00:38 +020013908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13914 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13916
13917 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13919 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13923 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13924 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13925
13926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13930
13931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013932 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13934
13935 { } /* end */
13936};
13937
13938/* toggle speaker-output according to the hp-jack state */
13939static void alc861vd_dallas_automute(struct hda_codec *codec)
13940{
13941 unsigned int present;
13942
13943 present = snd_hda_codec_read(codec, 0x15, 0,
13944 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013945 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13946 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013947}
13948
13949static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13950{
13951 if ((res >> 26) == ALC880_HP_EVENT)
13952 alc861vd_dallas_automute(codec);
13953}
13954
Takashi Iwaicb53c622007-08-10 17:21:45 +020013955#ifdef CONFIG_SND_HDA_POWER_SAVE
13956#define alc861vd_loopbacks alc880_loopbacks
13957#endif
13958
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013959/* pcm configuration: identiacal with ALC880 */
13960#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13961#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13962#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13963#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13964
13965/*
13966 * configuration and preset
13967 */
13968static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13969 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013970 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013971 [ALC861VD_3ST] = "3stack",
13972 [ALC861VD_3ST_DIG] = "3stack-digout",
13973 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013974 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013975 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013976 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013977 [ALC861VD_AUTO] = "auto",
13978};
13979
13980static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013981 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13982 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013983 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013984 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013985 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013986 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013987 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013988 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013989 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013990 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013991 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013992 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013993 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013994 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13995 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013996 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013997 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013998 {}
13999};
14000
14001static struct alc_config_preset alc861vd_presets[] = {
14002 [ALC660VD_3ST] = {
14003 .mixers = { alc861vd_3st_mixer },
14004 .init_verbs = { alc861vd_volume_init_verbs,
14005 alc861vd_3stack_init_verbs },
14006 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14007 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014008 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14009 .channel_mode = alc861vd_3stack_2ch_modes,
14010 .input_mux = &alc861vd_capture_source,
14011 },
Mike Crash6963f842007-06-25 12:12:51 +020014012 [ALC660VD_3ST_DIG] = {
14013 .mixers = { alc861vd_3st_mixer },
14014 .init_verbs = { alc861vd_volume_init_verbs,
14015 alc861vd_3stack_init_verbs },
14016 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14017 .dac_nids = alc660vd_dac_nids,
14018 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014019 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14020 .channel_mode = alc861vd_3stack_2ch_modes,
14021 .input_mux = &alc861vd_capture_source,
14022 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014023 [ALC861VD_3ST] = {
14024 .mixers = { alc861vd_3st_mixer },
14025 .init_verbs = { alc861vd_volume_init_verbs,
14026 alc861vd_3stack_init_verbs },
14027 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14028 .dac_nids = alc861vd_dac_nids,
14029 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14030 .channel_mode = alc861vd_3stack_2ch_modes,
14031 .input_mux = &alc861vd_capture_source,
14032 },
14033 [ALC861VD_3ST_DIG] = {
14034 .mixers = { alc861vd_3st_mixer },
14035 .init_verbs = { alc861vd_volume_init_verbs,
14036 alc861vd_3stack_init_verbs },
14037 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14038 .dac_nids = alc861vd_dac_nids,
14039 .dig_out_nid = ALC861VD_DIGOUT_NID,
14040 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14041 .channel_mode = alc861vd_3stack_2ch_modes,
14042 .input_mux = &alc861vd_capture_source,
14043 },
14044 [ALC861VD_6ST_DIG] = {
14045 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14046 .init_verbs = { alc861vd_volume_init_verbs,
14047 alc861vd_6stack_init_verbs },
14048 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14049 .dac_nids = alc861vd_dac_nids,
14050 .dig_out_nid = ALC861VD_DIGOUT_NID,
14051 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14052 .channel_mode = alc861vd_6stack_modes,
14053 .input_mux = &alc861vd_capture_source,
14054 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014055 [ALC861VD_LENOVO] = {
14056 .mixers = { alc861vd_lenovo_mixer },
14057 .init_verbs = { alc861vd_volume_init_verbs,
14058 alc861vd_3stack_init_verbs,
14059 alc861vd_eapd_verbs,
14060 alc861vd_lenovo_unsol_verbs },
14061 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14062 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014063 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14064 .channel_mode = alc861vd_3stack_2ch_modes,
14065 .input_mux = &alc861vd_capture_source,
14066 .unsol_event = alc861vd_lenovo_unsol_event,
14067 .init_hook = alc861vd_lenovo_automute,
14068 },
Kailang Yang272a5272007-05-14 11:00:38 +020014069 [ALC861VD_DALLAS] = {
14070 .mixers = { alc861vd_dallas_mixer },
14071 .init_verbs = { alc861vd_dallas_verbs },
14072 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14073 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014074 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14075 .channel_mode = alc861vd_3stack_2ch_modes,
14076 .input_mux = &alc861vd_dallas_capture_source,
14077 .unsol_event = alc861vd_dallas_unsol_event,
14078 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014079 },
14080 [ALC861VD_HP] = {
14081 .mixers = { alc861vd_hp_mixer },
14082 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14083 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14084 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014085 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014086 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14087 .channel_mode = alc861vd_3stack_2ch_modes,
14088 .input_mux = &alc861vd_hp_capture_source,
14089 .unsol_event = alc861vd_dallas_unsol_event,
14090 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014091 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014092};
14093
14094/*
14095 * BIOS auto configuration
14096 */
14097static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14098 hda_nid_t nid, int pin_type, int dac_idx)
14099{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014100 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014101}
14102
14103static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14104{
14105 struct alc_spec *spec = codec->spec;
14106 int i;
14107
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014108 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014109 for (i = 0; i <= HDA_SIDE; i++) {
14110 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014111 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014112 if (nid)
14113 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014114 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014115 }
14116}
14117
14118
14119static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14120{
14121 struct alc_spec *spec = codec->spec;
14122 hda_nid_t pin;
14123
14124 pin = spec->autocfg.hp_pins[0];
14125 if (pin) /* connect to front and use dac 0 */
14126 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014127 pin = spec->autocfg.speaker_pins[0];
14128 if (pin)
14129 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014130}
14131
14132#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14133#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14134
14135static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14136{
14137 struct alc_spec *spec = codec->spec;
14138 int i;
14139
14140 for (i = 0; i < AUTO_PIN_LAST; i++) {
14141 hda_nid_t nid = spec->autocfg.input_pins[i];
14142 if (alc861vd_is_input_pin(nid)) {
14143 snd_hda_codec_write(codec, nid, 0,
14144 AC_VERB_SET_PIN_WIDGET_CONTROL,
14145 i <= AUTO_PIN_FRONT_MIC ?
14146 PIN_VREF80 : PIN_IN);
14147 if (nid != ALC861VD_PIN_CD_NID)
14148 snd_hda_codec_write(codec, nid, 0,
14149 AC_VERB_SET_AMP_GAIN_MUTE,
14150 AMP_OUT_MUTE);
14151 }
14152 }
14153}
14154
Takashi Iwaif511b012008-08-15 16:46:42 +020014155#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14156
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014157#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14158#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14159
14160/* add playback controls from the parsed DAC table */
14161/* Based on ALC880 version. But ALC861VD has separate,
14162 * different NIDs for mute/unmute switch and volume control */
14163static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14164 const struct auto_pin_cfg *cfg)
14165{
14166 char name[32];
14167 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14168 hda_nid_t nid_v, nid_s;
14169 int i, err;
14170
14171 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014172 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014173 continue;
14174 nid_v = alc861vd_idx_to_mixer_vol(
14175 alc880_dac_to_idx(
14176 spec->multiout.dac_nids[i]));
14177 nid_s = alc861vd_idx_to_mixer_switch(
14178 alc880_dac_to_idx(
14179 spec->multiout.dac_nids[i]));
14180
14181 if (i == 2) {
14182 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014183 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14184 "Center Playback Volume",
14185 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14186 HDA_OUTPUT));
14187 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014188 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014189 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14190 "LFE Playback Volume",
14191 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14192 HDA_OUTPUT));
14193 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014194 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014195 err = add_control(spec, ALC_CTL_BIND_MUTE,
14196 "Center Playback Switch",
14197 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14198 HDA_INPUT));
14199 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014200 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014201 err = add_control(spec, ALC_CTL_BIND_MUTE,
14202 "LFE Playback Switch",
14203 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14204 HDA_INPUT));
14205 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014206 return err;
14207 } else {
14208 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014209 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14210 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14211 HDA_OUTPUT));
14212 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014213 return err;
14214 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014215 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014216 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014217 HDA_INPUT));
14218 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014219 return err;
14220 }
14221 }
14222 return 0;
14223}
14224
14225/* add playback controls for speaker and HP outputs */
14226/* Based on ALC880 version. But ALC861VD has separate,
14227 * different NIDs for mute/unmute switch and volume control */
14228static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14229 hda_nid_t pin, const char *pfx)
14230{
14231 hda_nid_t nid_v, nid_s;
14232 int err;
14233 char name[32];
14234
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014235 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014236 return 0;
14237
14238 if (alc880_is_fixed_pin(pin)) {
14239 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14240 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014241 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014242 spec->multiout.hp_nid = nid_v;
14243 else
14244 spec->multiout.extra_out_nid[0] = nid_v;
14245 /* control HP volume/switch on the output mixer amp */
14246 nid_v = alc861vd_idx_to_mixer_vol(
14247 alc880_fixed_pin_idx(pin));
14248 nid_s = alc861vd_idx_to_mixer_switch(
14249 alc880_fixed_pin_idx(pin));
14250
14251 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014252 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14253 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14254 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014255 return err;
14256 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014257 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14258 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14259 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014260 return err;
14261 } else if (alc880_is_multi_pin(pin)) {
14262 /* set manual connection */
14263 /* we have only a switch on HP-out PIN */
14264 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014265 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14266 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14267 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014268 return err;
14269 }
14270 return 0;
14271}
14272
14273/* parse the BIOS configuration and set up the alc_spec
14274 * return 1 if successful, 0 if the proper config is not found,
14275 * or a negative error code
14276 * Based on ALC880 version - had to change it to override
14277 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14278static int alc861vd_parse_auto_config(struct hda_codec *codec)
14279{
14280 struct alc_spec *spec = codec->spec;
14281 int err;
14282 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014284 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14285 alc861vd_ignore);
14286 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014287 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014288 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014289 return 0; /* can't find valid BIOS pin config */
14290
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014291 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14292 if (err < 0)
14293 return err;
14294 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14295 if (err < 0)
14296 return err;
14297 err = alc861vd_auto_create_extra_out(spec,
14298 spec->autocfg.speaker_pins[0],
14299 "Speaker");
14300 if (err < 0)
14301 return err;
14302 err = alc861vd_auto_create_extra_out(spec,
14303 spec->autocfg.hp_pins[0],
14304 "Headphone");
14305 if (err < 0)
14306 return err;
14307 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14308 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014309 return err;
14310
14311 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14312
14313 if (spec->autocfg.dig_out_pin)
14314 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14315
14316 if (spec->kctl_alloc)
14317 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14318
14319 spec->init_verbs[spec->num_init_verbs++]
14320 = alc861vd_volume_init_verbs;
14321
14322 spec->num_mux_defs = 1;
14323 spec->input_mux = &spec->private_imux;
14324
Takashi Iwai776e1842007-08-29 15:07:11 +020014325 err = alc_auto_add_mic_boost(codec);
14326 if (err < 0)
14327 return err;
14328
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014329 return 1;
14330}
14331
14332/* additional initialization for auto-configuration model */
14333static void alc861vd_auto_init(struct hda_codec *codec)
14334{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014335 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014336 alc861vd_auto_init_multi_out(codec);
14337 alc861vd_auto_init_hp_out(codec);
14338 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014339 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014340 if (spec->unsol_event)
14341 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014342}
14343
14344static int patch_alc861vd(struct hda_codec *codec)
14345{
14346 struct alc_spec *spec;
14347 int err, board_config;
14348
14349 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14350 if (spec == NULL)
14351 return -ENOMEM;
14352
14353 codec->spec = spec;
14354
14355 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14356 alc861vd_models,
14357 alc861vd_cfg_tbl);
14358
14359 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14360 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14361 "ALC861VD, trying auto-probe from BIOS...\n");
14362 board_config = ALC861VD_AUTO;
14363 }
14364
14365 if (board_config == ALC861VD_AUTO) {
14366 /* automatic parse from the BIOS config */
14367 err = alc861vd_parse_auto_config(codec);
14368 if (err < 0) {
14369 alc_free(codec);
14370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014371 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014372 printk(KERN_INFO
14373 "hda_codec: Cannot set up configuration "
14374 "from BIOS. Using base mode...\n");
14375 board_config = ALC861VD_3ST;
14376 }
14377 }
14378
14379 if (board_config != ALC861VD_AUTO)
14380 setup_preset(spec, &alc861vd_presets[board_config]);
14381
Kailang Yang2f893282008-05-27 12:14:47 +020014382 if (codec->vendor_id == 0x10ec0660) {
14383 spec->stream_name_analog = "ALC660-VD Analog";
14384 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014385 /* always turn on EAPD */
14386 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020014387 } else {
14388 spec->stream_name_analog = "ALC861VD Analog";
14389 spec->stream_name_digital = "ALC861VD Digital";
14390 }
14391
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014392 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14393 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14394
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014395 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14396 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14397
14398 spec->adc_nids = alc861vd_adc_nids;
14399 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014400 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014401
14402 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
14403 spec->num_mixers++;
14404
Takashi Iwai2134ea42008-01-10 16:53:55 +010014405 spec->vmaster_nid = 0x02;
14406
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014407 codec->patch_ops = alc_patch_ops;
14408
14409 if (board_config == ALC861VD_AUTO)
14410 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014411#ifdef CONFIG_SND_HDA_POWER_SAVE
14412 if (!spec->loopback.amplist)
14413 spec->loopback.amplist = alc861vd_loopbacks;
14414#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014415
14416 return 0;
14417}
14418
14419/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014420 * ALC662 support
14421 *
14422 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14423 * configuration. Each pin widget can choose any input DACs and a mixer.
14424 * Each ADC is connected from a mixer of all inputs. This makes possible
14425 * 6-channel independent captures.
14426 *
14427 * In addition, an independent DAC for the multi-playback (not used in this
14428 * driver yet).
14429 */
14430#define ALC662_DIGOUT_NID 0x06
14431#define ALC662_DIGIN_NID 0x0a
14432
14433static hda_nid_t alc662_dac_nids[4] = {
14434 /* front, rear, clfe, rear_surr */
14435 0x02, 0x03, 0x04
14436};
14437
14438static hda_nid_t alc662_adc_nids[1] = {
14439 /* ADC1-2 */
14440 0x09,
14441};
Takashi Iwaie1406342008-02-11 18:32:32 +010014442
Kailang Yang77a261b2008-02-19 11:38:05 +010014443static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014444
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014445/* input MUX */
14446/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014447static struct hda_input_mux alc662_capture_source = {
14448 .num_items = 4,
14449 .items = {
14450 { "Mic", 0x0 },
14451 { "Front Mic", 0x1 },
14452 { "Line", 0x2 },
14453 { "CD", 0x4 },
14454 },
14455};
14456
14457static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14458 .num_items = 2,
14459 .items = {
14460 { "Mic", 0x1 },
14461 { "Line", 0x2 },
14462 },
14463};
Kailang Yang291702f2007-10-16 14:28:03 +020014464
14465static struct hda_input_mux alc662_eeepc_capture_source = {
14466 .num_items = 2,
14467 .items = {
14468 { "i-Mic", 0x1 },
14469 { "e-Mic", 0x0 },
14470 },
14471};
14472
Kailang Yang6dda9f42008-05-27 12:05:31 +020014473static struct hda_input_mux alc663_capture_source = {
14474 .num_items = 3,
14475 .items = {
14476 { "Mic", 0x0 },
14477 { "Front Mic", 0x1 },
14478 { "Line", 0x2 },
14479 },
14480};
14481
14482static struct hda_input_mux alc663_m51va_capture_source = {
14483 .num_items = 2,
14484 .items = {
14485 { "Ext-Mic", 0x0 },
14486 { "D-Mic", 0x9 },
14487 },
14488};
14489
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014490#define alc662_mux_enum_info alc_mux_enum_info
14491#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014492#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014493
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014494/*
14495 * 2ch mode
14496 */
14497static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14498 { 2, NULL }
14499};
14500
14501/*
14502 * 2ch mode
14503 */
14504static struct hda_verb alc662_3ST_ch2_init[] = {
14505 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14506 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14507 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14508 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14509 { } /* end */
14510};
14511
14512/*
14513 * 6ch mode
14514 */
14515static struct hda_verb alc662_3ST_ch6_init[] = {
14516 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14517 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14518 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14519 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14520 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14521 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14522 { } /* end */
14523};
14524
14525static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14526 { 2, alc662_3ST_ch2_init },
14527 { 6, alc662_3ST_ch6_init },
14528};
14529
14530/*
14531 * 2ch mode
14532 */
14533static struct hda_verb alc662_sixstack_ch6_init[] = {
14534 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14535 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14536 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14537 { } /* end */
14538};
14539
14540/*
14541 * 6ch mode
14542 */
14543static struct hda_verb alc662_sixstack_ch8_init[] = {
14544 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14545 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14546 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14547 { } /* end */
14548};
14549
14550static struct hda_channel_mode alc662_5stack_modes[2] = {
14551 { 2, alc662_sixstack_ch6_init },
14552 { 6, alc662_sixstack_ch8_init },
14553};
14554
14555/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14556 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14557 */
14558
14559static struct snd_kcontrol_new alc662_base_mixer[] = {
14560 /* output mixer control */
14561 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014562 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014563 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014564 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014565 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14566 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014567 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14568 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14570
14571 /*Input mixer control */
14572 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14573 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14574 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14575 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14576 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14577 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14578 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014580 { } /* end */
14581};
14582
14583static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14584 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014585 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14593 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14595 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14596 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014597 { } /* end */
14598};
14599
14600static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014602 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014604 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014607 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14608 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014609 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14616 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14617 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14618 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14619 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014620 { } /* end */
14621};
14622
14623static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14624 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14625 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014626 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14627 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014633 { } /* end */
14634};
14635
Kailang Yang291702f2007-10-16 14:28:03 +020014636static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014637 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014638
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014639 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14640 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014641
14642 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14643 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14644 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14645
14646 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14647 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14648 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14649 { } /* end */
14650};
14651
Kailang Yang8c427222008-01-10 13:03:59 +010014652static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014653 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14654 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014655 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14656 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14657 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14658 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14659 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14660 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014661 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014662 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14667 { } /* end */
14668};
14669
Kailang Yangf1d4e282008-08-26 14:03:29 +020014670static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14671 .ops = &snd_hda_bind_vol,
14672 .values = {
14673 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14674 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14675 0
14676 },
14677};
14678
14679static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14680 .ops = &snd_hda_bind_sw,
14681 .values = {
14682 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14683 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14684 0
14685 },
14686};
14687
Kailang Yang6dda9f42008-05-27 12:05:31 +020014688static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014689 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14690 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14693 { } /* end */
14694};
14695
14696static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14697 .ops = &snd_hda_bind_sw,
14698 .values = {
14699 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14700 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14701 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14702 0
14703 },
14704};
14705
14706static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14707 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14708 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14711 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14712 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14713
14714 { } /* end */
14715};
14716
14717static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14718 .ops = &snd_hda_bind_sw,
14719 .values = {
14720 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14721 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14722 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14723 0
14724 },
14725};
14726
14727static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14728 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14729 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14732 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14733 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14734 { } /* end */
14735};
14736
14737static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014738 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14739 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14743 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14744 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14745 { } /* end */
14746};
14747
14748static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14749 .ops = &snd_hda_bind_vol,
14750 .values = {
14751 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14752 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14753 0
14754 },
14755};
14756
14757static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14758 .ops = &snd_hda_bind_sw,
14759 .values = {
14760 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14761 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14762 0
14763 },
14764};
14765
14766static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14767 HDA_BIND_VOL("Master Playback Volume",
14768 &alc663_asus_two_bind_master_vol),
14769 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14770 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014774 { } /* end */
14775};
14776
14777static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14778 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14779 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14780 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014784 { } /* end */
14785};
14786
14787static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14788 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14789 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14790 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14791 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14793
14794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14796 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14797 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14798 { } /* end */
14799};
14800
14801static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14802 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14803 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14805
14806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14808 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14809 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14812 { } /* end */
14813};
14814
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014815static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14816 {
14817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14818 .name = "Channel Mode",
14819 .info = alc_ch_mode_info,
14820 .get = alc_ch_mode_get,
14821 .put = alc_ch_mode_put,
14822 },
14823 { } /* end */
14824};
14825
14826static struct hda_verb alc662_init_verbs[] = {
14827 /* ADC: mute amp left and right */
14828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14830 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14831
Takashi Iwaicb53c622007-08-10 17:21:45 +020014832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014837
Kailang Yangb60dd392007-09-20 12:50:29 +020014838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014844
14845 /* Front Pin: output 0 (0x0c) */
14846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14848
14849 /* Rear Pin: output 1 (0x0d) */
14850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14852
14853 /* CLFE Pin: output 2 (0x0e) */
14854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14856
14857 /* Mic (rear) pin: input vref at 80% */
14858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14860 /* Front Mic pin: input vref at 80% */
14861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14862 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14863 /* Line In pin: input */
14864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14866 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14869 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14870 /* CD pin widget for input */
14871 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14872
14873 /* FIXME: use matrix-type input source selection */
14874 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14875 /* Input mixer */
14876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014880
14881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14884 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014885
14886 /* always trun on EAPD */
14887 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14888 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14889
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014890 { }
14891};
14892
14893static struct hda_verb alc662_sue_init_verbs[] = {
14894 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014896 {}
14897};
14898
14899static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14900 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14901 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14902 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014903};
14904
Kailang Yang8c427222008-01-10 13:03:59 +010014905/* Set Unsolicited Event*/
14906static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14908 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14909 {}
14910};
14911
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014912/*
14913 * generic initialization of ADC, input mixers and output mixers
14914 */
14915static struct hda_verb alc662_auto_init_verbs[] = {
14916 /*
14917 * Unmute ADC and set the default input to mic-in
14918 */
14919 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14921
14922 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14923 * mixer widget
14924 * Note: PASD motherboards uses the Line In 2 as the input for front
14925 * panel mic (mic 2)
14926 */
14927 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014933
14934 /*
14935 * Set up output mixers (0x0c - 0x0f)
14936 */
14937 /* set vol=0 to output mixers */
14938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14939 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14941
14942 /* set up input amps for analog loopback */
14943 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14945 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14947 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014950
14951
14952 /* FIXME: use matrix-type input source selection */
14953 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14954 /* Input mixer */
14955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014957 { }
14958};
14959
Takashi Iwai24fb9172008-09-02 14:48:20 +020014960/* additional verbs for ALC663 */
14961static struct hda_verb alc663_auto_init_verbs[] = {
14962 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14963 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14964 { }
14965};
14966
Kailang Yang6dda9f42008-05-27 12:05:31 +020014967static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014970 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14971 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020014972 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14974 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014975 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14976 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14977 {}
14978};
14979
Kailang Yangf1d4e282008-08-26 14:03:29 +020014980static struct hda_verb alc663_21jd_amic_init_verbs[] = {
14981 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14982 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14983 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14986 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14987 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14988 {}
14989};
14990
14991static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
14992 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14994 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14995 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14998 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14999 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15000 {}
15001};
15002
15003static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15011 {}
15012};
15013
15014static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15016 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15017 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15018 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15024 {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 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15027 {}
15028};
15029
15030static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15031 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15040 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15041 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15042 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15043 {}
15044};
15045
Kailang Yang6dda9f42008-05-27 12:05:31 +020015046static struct hda_verb alc663_g71v_init_verbs[] = {
15047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15048 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15049 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15050
15051 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15052 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15053 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15054
15055 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15056 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15057 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15058 {}
15059};
15060
15061static struct hda_verb alc663_g50v_init_verbs[] = {
15062 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15063 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15064 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15065
15066 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15067 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15068 {}
15069};
15070
Kailang Yangf1d4e282008-08-26 14:03:29 +020015071static struct hda_verb alc662_ecs_init_verbs[] = {
15072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15074 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15075 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15076 {}
15077};
15078
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015079/* capture mixer elements */
15080static struct snd_kcontrol_new alc662_capture_mixer[] = {
15081 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15082 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15083 {
15084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15085 /* The multiple "Capture Source" controls confuse alsamixer
15086 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015087 */
15088 /* .name = "Capture Source", */
15089 .name = "Input Source",
15090 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010015091 .info = alc662_mux_enum_info,
15092 .get = alc662_mux_enum_get,
15093 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015094 },
15095 { } /* end */
15096};
15097
Kailang Yangf1d4e282008-08-26 14:03:29 +020015098static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15099 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15100 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15101 { } /* end */
15102};
15103
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015104static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15105{
15106 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015107 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015108
15109 present = snd_hda_codec_read(codec, 0x14, 0,
15110 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015111 bits = present ? HDA_AMP_MUTE : 0;
15112 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15113 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015114}
15115
15116static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15117{
15118 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015119 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015120
15121 present = snd_hda_codec_read(codec, 0x1b, 0,
15122 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015123 bits = present ? HDA_AMP_MUTE : 0;
15124 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15125 HDA_AMP_MUTE, bits);
15126 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15127 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015128}
15129
15130static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15131 unsigned int res)
15132{
15133 if ((res >> 26) == ALC880_HP_EVENT)
15134 alc662_lenovo_101e_all_automute(codec);
15135 if ((res >> 26) == ALC880_FRONT_EVENT)
15136 alc662_lenovo_101e_ispeaker_automute(codec);
15137}
15138
Kailang Yang291702f2007-10-16 14:28:03 +020015139static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15140{
15141 unsigned int present;
15142
15143 present = snd_hda_codec_read(codec, 0x18, 0,
15144 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15145 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15146 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15147 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15148 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15149 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15150 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15151 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15152 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15153}
15154
15155/* unsolicited event for HP jack sensing */
15156static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15157 unsigned int res)
15158{
15159 if ((res >> 26) == ALC880_HP_EVENT)
15160 alc262_hippo1_automute( codec );
15161
15162 if ((res >> 26) == ALC880_MIC_EVENT)
15163 alc662_eeepc_mic_automute(codec);
15164}
15165
15166static void alc662_eeepc_inithook(struct hda_codec *codec)
15167{
15168 alc262_hippo1_automute( codec );
15169 alc662_eeepc_mic_automute(codec);
15170}
15171
Kailang Yang8c427222008-01-10 13:03:59 +010015172static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15173{
15174 unsigned int mute;
15175 unsigned int present;
15176
15177 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15178 present = snd_hda_codec_read(codec, 0x14, 0,
15179 AC_VERB_GET_PIN_SENSE, 0);
15180 present = (present & 0x80000000) != 0;
15181 if (present) {
15182 /* mute internal speaker */
15183 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015184 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015185 } else {
15186 /* unmute internal speaker if necessary */
15187 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15188 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015189 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015190 }
15191}
15192
15193/* unsolicited event for HP jack sensing */
15194static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15195 unsigned int res)
15196{
15197 if ((res >> 26) == ALC880_HP_EVENT)
15198 alc662_eeepc_ep20_automute(codec);
15199}
15200
15201static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15202{
15203 alc662_eeepc_ep20_automute(codec);
15204}
15205
Kailang Yang6dda9f42008-05-27 12:05:31 +020015206static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15207{
15208 unsigned int present;
15209 unsigned char bits;
15210
15211 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015212 AC_VERB_GET_PIN_SENSE, 0)
15213 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015214 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15216 AMP_IN_MUTE(0), bits);
15217 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15218 AMP_IN_MUTE(0), bits);
15219}
15220
15221static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15222{
15223 unsigned int present;
15224 unsigned char bits;
15225
15226 present = snd_hda_codec_read(codec, 0x21, 0,
15227 AC_VERB_GET_PIN_SENSE, 0)
15228 & AC_PINSENSE_PRESENCE;
15229 bits = present ? HDA_AMP_MUTE : 0;
15230 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15231 AMP_IN_MUTE(0), bits);
15232 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15233 AMP_IN_MUTE(0), bits);
15234 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15235 AMP_IN_MUTE(0), bits);
15236 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15237 AMP_IN_MUTE(0), bits);
15238}
15239
15240static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15241{
15242 unsigned int present;
15243 unsigned char bits;
15244
15245 present = snd_hda_codec_read(codec, 0x15, 0,
15246 AC_VERB_GET_PIN_SENSE, 0)
15247 & AC_PINSENSE_PRESENCE;
15248 bits = present ? HDA_AMP_MUTE : 0;
15249 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15250 AMP_IN_MUTE(0), bits);
15251 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15252 AMP_IN_MUTE(0), bits);
15253 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15254 AMP_IN_MUTE(0), bits);
15255 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15256 AMP_IN_MUTE(0), bits);
15257}
15258
15259static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15260{
15261 unsigned int present;
15262 unsigned char bits;
15263
15264 present = snd_hda_codec_read(codec, 0x1b, 0,
15265 AC_VERB_GET_PIN_SENSE, 0)
15266 & AC_PINSENSE_PRESENCE;
15267 bits = present ? 0 : PIN_OUT;
15268 snd_hda_codec_write(codec, 0x14, 0,
15269 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15270}
15271
15272static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15273{
15274 unsigned int present1, present2;
15275
15276 present1 = snd_hda_codec_read(codec, 0x21, 0,
15277 AC_VERB_GET_PIN_SENSE, 0)
15278 & AC_PINSENSE_PRESENCE;
15279 present2 = snd_hda_codec_read(codec, 0x15, 0,
15280 AC_VERB_GET_PIN_SENSE, 0)
15281 & AC_PINSENSE_PRESENCE;
15282
15283 if (present1 || present2) {
15284 snd_hda_codec_write_cache(codec, 0x14, 0,
15285 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15286 } else {
15287 snd_hda_codec_write_cache(codec, 0x14, 0,
15288 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15289 }
15290}
15291
15292static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15293{
15294 unsigned int present1, present2;
15295
15296 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15297 AC_VERB_GET_PIN_SENSE, 0)
15298 & AC_PINSENSE_PRESENCE;
15299 present2 = snd_hda_codec_read(codec, 0x15, 0,
15300 AC_VERB_GET_PIN_SENSE, 0)
15301 & AC_PINSENSE_PRESENCE;
15302
15303 if (present1 || present2) {
15304 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15305 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15306 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15307 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15308 } else {
15309 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15310 AMP_IN_MUTE(0), 0);
15311 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15312 AMP_IN_MUTE(0), 0);
15313 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015314}
15315
15316static void alc663_m51va_mic_automute(struct hda_codec *codec)
15317{
15318 unsigned int present;
15319
15320 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015321 AC_VERB_GET_PIN_SENSE, 0)
15322 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015323 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015324 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015325 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015326 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015327 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015328 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015329 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015330 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015331}
15332
15333static void alc663_m51va_unsol_event(struct hda_codec *codec,
15334 unsigned int res)
15335{
15336 switch (res >> 26) {
15337 case ALC880_HP_EVENT:
15338 alc663_m51va_speaker_automute(codec);
15339 break;
15340 case ALC880_MIC_EVENT:
15341 alc663_m51va_mic_automute(codec);
15342 break;
15343 }
15344}
15345
15346static void alc663_m51va_inithook(struct hda_codec *codec)
15347{
15348 alc663_m51va_speaker_automute(codec);
15349 alc663_m51va_mic_automute(codec);
15350}
15351
Kailang Yangf1d4e282008-08-26 14:03:29 +020015352/* ***************** Mode1 ******************************/
15353static void alc663_mode1_unsol_event(struct hda_codec *codec,
15354 unsigned int res)
15355{
15356 switch (res >> 26) {
15357 case ALC880_HP_EVENT:
15358 alc663_m51va_speaker_automute(codec);
15359 break;
15360 case ALC880_MIC_EVENT:
15361 alc662_eeepc_mic_automute(codec);
15362 break;
15363 }
15364}
15365
15366static void alc663_mode1_inithook(struct hda_codec *codec)
15367{
15368 alc663_m51va_speaker_automute(codec);
15369 alc662_eeepc_mic_automute(codec);
15370}
15371/* ***************** Mode2 ******************************/
15372static void alc662_mode2_unsol_event(struct hda_codec *codec,
15373 unsigned int res)
15374{
15375 switch (res >> 26) {
15376 case ALC880_HP_EVENT:
15377 alc662_f5z_speaker_automute(codec);
15378 break;
15379 case ALC880_MIC_EVENT:
15380 alc662_eeepc_mic_automute(codec);
15381 break;
15382 }
15383}
15384
15385static void alc662_mode2_inithook(struct hda_codec *codec)
15386{
15387 alc662_f5z_speaker_automute(codec);
15388 alc662_eeepc_mic_automute(codec);
15389}
15390/* ***************** Mode3 ******************************/
15391static void alc663_mode3_unsol_event(struct hda_codec *codec,
15392 unsigned int res)
15393{
15394 switch (res >> 26) {
15395 case ALC880_HP_EVENT:
15396 alc663_two_hp_m1_speaker_automute(codec);
15397 break;
15398 case ALC880_MIC_EVENT:
15399 alc662_eeepc_mic_automute(codec);
15400 break;
15401 }
15402}
15403
15404static void alc663_mode3_inithook(struct hda_codec *codec)
15405{
15406 alc663_two_hp_m1_speaker_automute(codec);
15407 alc662_eeepc_mic_automute(codec);
15408}
15409/* ***************** Mode4 ******************************/
15410static void alc663_mode4_unsol_event(struct hda_codec *codec,
15411 unsigned int res)
15412{
15413 switch (res >> 26) {
15414 case ALC880_HP_EVENT:
15415 alc663_21jd_two_speaker_automute(codec);
15416 break;
15417 case ALC880_MIC_EVENT:
15418 alc662_eeepc_mic_automute(codec);
15419 break;
15420 }
15421}
15422
15423static void alc663_mode4_inithook(struct hda_codec *codec)
15424{
15425 alc663_21jd_two_speaker_automute(codec);
15426 alc662_eeepc_mic_automute(codec);
15427}
15428/* ***************** Mode5 ******************************/
15429static void alc663_mode5_unsol_event(struct hda_codec *codec,
15430 unsigned int res)
15431{
15432 switch (res >> 26) {
15433 case ALC880_HP_EVENT:
15434 alc663_15jd_two_speaker_automute(codec);
15435 break;
15436 case ALC880_MIC_EVENT:
15437 alc662_eeepc_mic_automute(codec);
15438 break;
15439 }
15440}
15441
15442static void alc663_mode5_inithook(struct hda_codec *codec)
15443{
15444 alc663_15jd_two_speaker_automute(codec);
15445 alc662_eeepc_mic_automute(codec);
15446}
15447/* ***************** Mode6 ******************************/
15448static void alc663_mode6_unsol_event(struct hda_codec *codec,
15449 unsigned int res)
15450{
15451 switch (res >> 26) {
15452 case ALC880_HP_EVENT:
15453 alc663_two_hp_m2_speaker_automute(codec);
15454 break;
15455 case ALC880_MIC_EVENT:
15456 alc662_eeepc_mic_automute(codec);
15457 break;
15458 }
15459}
15460
15461static void alc663_mode6_inithook(struct hda_codec *codec)
15462{
15463 alc663_two_hp_m2_speaker_automute(codec);
15464 alc662_eeepc_mic_automute(codec);
15465}
15466
Kailang Yang6dda9f42008-05-27 12:05:31 +020015467static void alc663_g71v_hp_automute(struct hda_codec *codec)
15468{
15469 unsigned int present;
15470 unsigned char bits;
15471
15472 present = snd_hda_codec_read(codec, 0x21, 0,
15473 AC_VERB_GET_PIN_SENSE, 0)
15474 & AC_PINSENSE_PRESENCE;
15475 bits = present ? HDA_AMP_MUTE : 0;
15476 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15477 HDA_AMP_MUTE, bits);
15478 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15479 HDA_AMP_MUTE, bits);
15480}
15481
15482static void alc663_g71v_front_automute(struct hda_codec *codec)
15483{
15484 unsigned int present;
15485 unsigned char bits;
15486
15487 present = snd_hda_codec_read(codec, 0x15, 0,
15488 AC_VERB_GET_PIN_SENSE, 0)
15489 & AC_PINSENSE_PRESENCE;
15490 bits = present ? HDA_AMP_MUTE : 0;
15491 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15492 HDA_AMP_MUTE, bits);
15493}
15494
15495static void alc663_g71v_unsol_event(struct hda_codec *codec,
15496 unsigned int res)
15497{
15498 switch (res >> 26) {
15499 case ALC880_HP_EVENT:
15500 alc663_g71v_hp_automute(codec);
15501 break;
15502 case ALC880_FRONT_EVENT:
15503 alc663_g71v_front_automute(codec);
15504 break;
15505 case ALC880_MIC_EVENT:
15506 alc662_eeepc_mic_automute(codec);
15507 break;
15508 }
15509}
15510
15511static void alc663_g71v_inithook(struct hda_codec *codec)
15512{
15513 alc663_g71v_front_automute(codec);
15514 alc663_g71v_hp_automute(codec);
15515 alc662_eeepc_mic_automute(codec);
15516}
15517
15518static void alc663_g50v_unsol_event(struct hda_codec *codec,
15519 unsigned int res)
15520{
15521 switch (res >> 26) {
15522 case ALC880_HP_EVENT:
15523 alc663_m51va_speaker_automute(codec);
15524 break;
15525 case ALC880_MIC_EVENT:
15526 alc662_eeepc_mic_automute(codec);
15527 break;
15528 }
15529}
15530
15531static void alc663_g50v_inithook(struct hda_codec *codec)
15532{
15533 alc663_m51va_speaker_automute(codec);
15534 alc662_eeepc_mic_automute(codec);
15535}
15536
Kailang Yangf1d4e282008-08-26 14:03:29 +020015537/* bind hp and internal speaker mute (with plug check) */
15538static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15539 struct snd_ctl_elem_value *ucontrol)
15540{
15541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15542 long *valp = ucontrol->value.integer.value;
15543 int change;
15544
15545 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15546 HDA_AMP_MUTE,
15547 valp[0] ? 0 : HDA_AMP_MUTE);
15548 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15549 HDA_AMP_MUTE,
15550 valp[1] ? 0 : HDA_AMP_MUTE);
15551 if (change)
15552 alc262_hippo1_automute(codec);
15553 return change;
15554}
15555
15556static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15557 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15558 {
15559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15560 .name = "Master Playback Switch",
15561 .info = snd_hda_mixer_amp_switch_info,
15562 .get = snd_hda_mixer_amp_switch_get,
15563 .put = alc662_ecs_master_sw_put,
15564 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15565 },
15566
15567 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15568 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15569 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15570
15571 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15572 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15573 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15574 { } /* end */
15575};
15576
Takashi Iwaicb53c622007-08-10 17:21:45 +020015577#ifdef CONFIG_SND_HDA_POWER_SAVE
15578#define alc662_loopbacks alc880_loopbacks
15579#endif
15580
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015581
15582/* pcm configuration: identiacal with ALC880 */
15583#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15584#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15585#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15586#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15587
15588/*
15589 * configuration and preset
15590 */
15591static const char *alc662_models[ALC662_MODEL_LAST] = {
15592 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15593 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15594 [ALC662_3ST_6ch] = "3stack-6ch",
15595 [ALC662_5ST_DIG] = "6stack-dig",
15596 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015597 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015598 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015599 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015600 [ALC663_ASUS_M51VA] = "m51va",
15601 [ALC663_ASUS_G71V] = "g71v",
15602 [ALC663_ASUS_H13] = "h13",
15603 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015604 [ALC663_ASUS_MODE1] = "asus-mode1",
15605 [ALC662_ASUS_MODE2] = "asus-mode2",
15606 [ALC663_ASUS_MODE3] = "asus-mode3",
15607 [ALC663_ASUS_MODE4] = "asus-mode4",
15608 [ALC663_ASUS_MODE5] = "asus-mode5",
15609 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015610 [ALC662_AUTO] = "auto",
15611};
15612
15613static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015614 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
15615 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015616 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015617 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015618 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015619 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15620 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15621 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15622 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15623 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15624 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15625 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15626 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15627 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15628 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15629 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15630 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15631 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15632 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15633 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15634 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15635 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15636 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15637 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15638 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15639 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15640 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15641 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15642 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15643 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15644 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15645 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15646 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15647 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15648 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15649 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015650 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015651 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15652 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015653 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15654 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15655 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015656 {}
15657};
15658
15659static struct alc_config_preset alc662_presets[] = {
15660 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015661 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015662 .init_verbs = { alc662_init_verbs },
15663 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15664 .dac_nids = alc662_dac_nids,
15665 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015666 .dig_in_nid = ALC662_DIGIN_NID,
15667 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15668 .channel_mode = alc662_3ST_2ch_modes,
15669 .input_mux = &alc662_capture_source,
15670 },
15671 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015672 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15673 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015674 .init_verbs = { alc662_init_verbs },
15675 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15676 .dac_nids = alc662_dac_nids,
15677 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015678 .dig_in_nid = ALC662_DIGIN_NID,
15679 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15680 .channel_mode = alc662_3ST_6ch_modes,
15681 .need_dac_fix = 1,
15682 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015683 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015684 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015685 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15686 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015687 .init_verbs = { alc662_init_verbs },
15688 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15689 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015690 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15691 .channel_mode = alc662_3ST_6ch_modes,
15692 .need_dac_fix = 1,
15693 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015694 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015695 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015696 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
15697 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015698 .init_verbs = { alc662_init_verbs },
15699 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15700 .dac_nids = alc662_dac_nids,
15701 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015702 .dig_in_nid = ALC662_DIGIN_NID,
15703 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15704 .channel_mode = alc662_5stack_modes,
15705 .input_mux = &alc662_capture_source,
15706 },
15707 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015708 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015709 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15710 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15711 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015712 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15713 .channel_mode = alc662_3ST_2ch_modes,
15714 .input_mux = &alc662_lenovo_101e_capture_source,
15715 .unsol_event = alc662_lenovo_101e_unsol_event,
15716 .init_hook = alc662_lenovo_101e_all_automute,
15717 },
Kailang Yang291702f2007-10-16 14:28:03 +020015718 [ALC662_ASUS_EEEPC_P701] = {
15719 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
15720 .init_verbs = { alc662_init_verbs,
15721 alc662_eeepc_sue_init_verbs },
15722 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15723 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015724 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15725 .channel_mode = alc662_3ST_2ch_modes,
15726 .input_mux = &alc662_eeepc_capture_source,
15727 .unsol_event = alc662_eeepc_unsol_event,
15728 .init_hook = alc662_eeepc_inithook,
15729 },
Kailang Yang8c427222008-01-10 13:03:59 +010015730 [ALC662_ASUS_EEEPC_EP20] = {
15731 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
15732 alc662_chmode_mixer },
15733 .init_verbs = { alc662_init_verbs,
15734 alc662_eeepc_ep20_sue_init_verbs },
15735 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15736 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015737 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15738 .channel_mode = alc662_3ST_6ch_modes,
15739 .input_mux = &alc662_lenovo_101e_capture_source,
15740 .unsol_event = alc662_eeepc_ep20_unsol_event,
15741 .init_hook = alc662_eeepc_ep20_inithook,
15742 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015743 [ALC662_ECS] = {
15744 .mixers = { alc662_ecs_mixer, alc662_capture_mixer },
15745 .init_verbs = { alc662_init_verbs,
15746 alc662_ecs_init_verbs },
15747 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15748 .dac_nids = alc662_dac_nids,
15749 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15750 .channel_mode = alc662_3ST_2ch_modes,
15751 .input_mux = &alc662_eeepc_capture_source,
15752 .unsol_event = alc662_eeepc_unsol_event,
15753 .init_hook = alc662_eeepc_inithook,
15754 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015755 [ALC663_ASUS_M51VA] = {
15756 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15757 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15758 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15759 .dac_nids = alc662_dac_nids,
15760 .dig_out_nid = ALC662_DIGOUT_NID,
15761 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15762 .channel_mode = alc662_3ST_2ch_modes,
15763 .input_mux = &alc663_m51va_capture_source,
15764 .unsol_event = alc663_m51va_unsol_event,
15765 .init_hook = alc663_m51va_inithook,
15766 },
15767 [ALC663_ASUS_G71V] = {
15768 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
15769 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15770 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15771 .dac_nids = alc662_dac_nids,
15772 .dig_out_nid = ALC662_DIGOUT_NID,
15773 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15774 .channel_mode = alc662_3ST_2ch_modes,
15775 .input_mux = &alc662_eeepc_capture_source,
15776 .unsol_event = alc663_g71v_unsol_event,
15777 .init_hook = alc663_g71v_inithook,
15778 },
15779 [ALC663_ASUS_H13] = {
15780 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15781 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15782 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15783 .dac_nids = alc662_dac_nids,
15784 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15785 .channel_mode = alc662_3ST_2ch_modes,
15786 .input_mux = &alc663_m51va_capture_source,
15787 .unsol_event = alc663_m51va_unsol_event,
15788 .init_hook = alc663_m51va_inithook,
15789 },
15790 [ALC663_ASUS_G50V] = {
15791 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
15792 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15794 .dac_nids = alc662_dac_nids,
15795 .dig_out_nid = ALC662_DIGOUT_NID,
15796 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15797 .channel_mode = alc662_3ST_6ch_modes,
15798 .input_mux = &alc663_capture_source,
15799 .unsol_event = alc663_g50v_unsol_event,
15800 .init_hook = alc663_g50v_inithook,
15801 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015802 [ALC663_ASUS_MODE1] = {
15803 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer },
15804 .init_verbs = { alc662_init_verbs,
15805 alc663_21jd_amic_init_verbs },
15806 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15807 .hp_nid = 0x03,
15808 .dac_nids = alc662_dac_nids,
15809 .dig_out_nid = ALC662_DIGOUT_NID,
15810 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15811 .channel_mode = alc662_3ST_2ch_modes,
15812 .input_mux = &alc662_eeepc_capture_source,
15813 .unsol_event = alc663_mode1_unsol_event,
15814 .init_hook = alc663_mode1_inithook,
15815 },
15816 [ALC662_ASUS_MODE2] = {
15817 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer },
15818 .init_verbs = { alc662_init_verbs,
15819 alc662_1bjd_amic_init_verbs },
15820 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15821 .dac_nids = alc662_dac_nids,
15822 .dig_out_nid = ALC662_DIGOUT_NID,
15823 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15824 .channel_mode = alc662_3ST_2ch_modes,
15825 .input_mux = &alc662_eeepc_capture_source,
15826 .unsol_event = alc662_mode2_unsol_event,
15827 .init_hook = alc662_mode2_inithook,
15828 },
15829 [ALC663_ASUS_MODE3] = {
15830 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer },
15831 .init_verbs = { alc662_init_verbs,
15832 alc663_two_hp_amic_m1_init_verbs },
15833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15834 .hp_nid = 0x03,
15835 .dac_nids = alc662_dac_nids,
15836 .dig_out_nid = ALC662_DIGOUT_NID,
15837 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15838 .channel_mode = alc662_3ST_2ch_modes,
15839 .input_mux = &alc662_eeepc_capture_source,
15840 .unsol_event = alc663_mode3_unsol_event,
15841 .init_hook = alc663_mode3_inithook,
15842 },
15843 [ALC663_ASUS_MODE4] = {
15844 .mixers = { alc663_asus_21jd_clfe_mixer,
15845 alc662_auto_capture_mixer},
15846 .init_verbs = { alc662_init_verbs,
15847 alc663_21jd_amic_init_verbs},
15848 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15849 .hp_nid = 0x03,
15850 .dac_nids = alc662_dac_nids,
15851 .dig_out_nid = ALC662_DIGOUT_NID,
15852 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15853 .channel_mode = alc662_3ST_2ch_modes,
15854 .input_mux = &alc662_eeepc_capture_source,
15855 .unsol_event = alc663_mode4_unsol_event,
15856 .init_hook = alc663_mode4_inithook,
15857 },
15858 [ALC663_ASUS_MODE5] = {
15859 .mixers = { alc663_asus_15jd_clfe_mixer,
15860 alc662_auto_capture_mixer },
15861 .init_verbs = { alc662_init_verbs,
15862 alc663_15jd_amic_init_verbs },
15863 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15864 .hp_nid = 0x03,
15865 .dac_nids = alc662_dac_nids,
15866 .dig_out_nid = ALC662_DIGOUT_NID,
15867 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15868 .channel_mode = alc662_3ST_2ch_modes,
15869 .input_mux = &alc662_eeepc_capture_source,
15870 .unsol_event = alc663_mode5_unsol_event,
15871 .init_hook = alc663_mode5_inithook,
15872 },
15873 [ALC663_ASUS_MODE6] = {
15874 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer },
15875 .init_verbs = { alc662_init_verbs,
15876 alc663_two_hp_amic_m2_init_verbs },
15877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15878 .hp_nid = 0x03,
15879 .dac_nids = alc662_dac_nids,
15880 .dig_out_nid = ALC662_DIGOUT_NID,
15881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15882 .channel_mode = alc662_3ST_2ch_modes,
15883 .input_mux = &alc662_eeepc_capture_source,
15884 .unsol_event = alc663_mode6_unsol_event,
15885 .init_hook = alc663_mode6_inithook,
15886 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015887};
15888
15889
15890/*
15891 * BIOS auto configuration
15892 */
15893
15894/* add playback controls from the parsed DAC table */
15895static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15896 const struct auto_pin_cfg *cfg)
15897{
15898 char name[32];
15899 static const char *chname[4] = {
15900 "Front", "Surround", NULL /*CLFE*/, "Side"
15901 };
15902 hda_nid_t nid;
15903 int i, err;
15904
15905 for (i = 0; i < cfg->line_outs; i++) {
15906 if (!spec->multiout.dac_nids[i])
15907 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015908 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015909 if (i == 2) {
15910 /* Center/LFE */
15911 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15912 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015913 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15914 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015915 if (err < 0)
15916 return err;
15917 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15918 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015919 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15920 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015921 if (err < 0)
15922 return err;
15923 err = add_control(spec, ALC_CTL_BIND_MUTE,
15924 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015925 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
15926 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015927 if (err < 0)
15928 return err;
15929 err = add_control(spec, ALC_CTL_BIND_MUTE,
15930 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015931 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
15932 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015933 if (err < 0)
15934 return err;
15935 } else {
15936 sprintf(name, "%s Playback Volume", chname[i]);
15937 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015938 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15939 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015940 if (err < 0)
15941 return err;
15942 sprintf(name, "%s Playback Switch", chname[i]);
15943 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015944 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
15945 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015946 if (err < 0)
15947 return err;
15948 }
15949 }
15950 return 0;
15951}
15952
15953/* add playback controls for speaker and HP outputs */
15954static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
15955 const char *pfx)
15956{
15957 hda_nid_t nid;
15958 int err;
15959 char name[32];
15960
15961 if (!pin)
15962 return 0;
15963
Takashi Iwai24fb9172008-09-02 14:48:20 +020015964 if (pin == 0x17) {
15965 /* ALC663 has a mono output pin on 0x17 */
15966 sprintf(name, "%s Playback Switch", pfx);
15967 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15968 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
15969 return err;
15970 }
15971
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015972 if (alc880_is_fixed_pin(pin)) {
15973 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15974 /* printk("DAC nid=%x\n",nid); */
15975 /* specify the DAC as the extra output */
15976 if (!spec->multiout.hp_nid)
15977 spec->multiout.hp_nid = nid;
15978 else
15979 spec->multiout.extra_out_nid[0] = nid;
15980 /* control HP volume/switch on the output mixer amp */
15981 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15982 sprintf(name, "%s Playback Volume", pfx);
15983 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15984 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
15985 if (err < 0)
15986 return err;
15987 sprintf(name, "%s Playback Switch", pfx);
15988 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15989 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
15990 if (err < 0)
15991 return err;
15992 } else if (alc880_is_multi_pin(pin)) {
15993 /* set manual connection */
15994 /* we have only a switch on HP-out PIN */
15995 sprintf(name, "%s Playback Switch", pfx);
15996 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15997 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15998 if (err < 0)
15999 return err;
16000 }
16001 return 0;
16002}
16003
16004/* create playback/capture controls for input pins */
16005static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16006 const struct auto_pin_cfg *cfg)
16007{
16008 struct hda_input_mux *imux = &spec->private_imux;
16009 int i, err, idx;
16010
16011 for (i = 0; i < AUTO_PIN_LAST; i++) {
16012 if (alc880_is_input_pin(cfg->input_pins[i])) {
16013 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16014 err = new_analog_input(spec, cfg->input_pins[i],
16015 auto_pin_cfg_labels[i],
16016 idx, 0x0b);
16017 if (err < 0)
16018 return err;
16019 imux->items[imux->num_items].label =
16020 auto_pin_cfg_labels[i];
16021 imux->items[imux->num_items].index =
16022 alc880_input_pin_idx(cfg->input_pins[i]);
16023 imux->num_items++;
16024 }
16025 }
16026 return 0;
16027}
16028
16029static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16030 hda_nid_t nid, int pin_type,
16031 int dac_idx)
16032{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016033 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016034 /* need the manual connection? */
16035 if (alc880_is_multi_pin(nid)) {
16036 struct alc_spec *spec = codec->spec;
16037 int idx = alc880_multi_pin_idx(nid);
16038 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16039 AC_VERB_SET_CONNECT_SEL,
16040 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16041 }
16042}
16043
16044static void alc662_auto_init_multi_out(struct hda_codec *codec)
16045{
16046 struct alc_spec *spec = codec->spec;
16047 int i;
16048
Kailang Yang8c427222008-01-10 13:03:59 +010016049 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016050 for (i = 0; i <= HDA_SIDE; i++) {
16051 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016052 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016053 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016054 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016055 i);
16056 }
16057}
16058
16059static void alc662_auto_init_hp_out(struct hda_codec *codec)
16060{
16061 struct alc_spec *spec = codec->spec;
16062 hda_nid_t pin;
16063
16064 pin = spec->autocfg.hp_pins[0];
16065 if (pin) /* connect to front */
16066 /* use dac 0 */
16067 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016068 pin = spec->autocfg.speaker_pins[0];
16069 if (pin)
16070 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071}
16072
16073#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16074#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16075
16076static void alc662_auto_init_analog_input(struct hda_codec *codec)
16077{
16078 struct alc_spec *spec = codec->spec;
16079 int i;
16080
16081 for (i = 0; i < AUTO_PIN_LAST; i++) {
16082 hda_nid_t nid = spec->autocfg.input_pins[i];
16083 if (alc662_is_input_pin(nid)) {
16084 snd_hda_codec_write(codec, nid, 0,
16085 AC_VERB_SET_PIN_WIDGET_CONTROL,
16086 (i <= AUTO_PIN_FRONT_MIC ?
16087 PIN_VREF80 : PIN_IN));
16088 if (nid != ALC662_PIN_CD_NID)
16089 snd_hda_codec_write(codec, nid, 0,
16090 AC_VERB_SET_AMP_GAIN_MUTE,
16091 AMP_OUT_MUTE);
16092 }
16093 }
16094}
16095
Takashi Iwaif511b012008-08-15 16:46:42 +020016096#define alc662_auto_init_input_src alc882_auto_init_input_src
16097
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016098static int alc662_parse_auto_config(struct hda_codec *codec)
16099{
16100 struct alc_spec *spec = codec->spec;
16101 int err;
16102 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16103
16104 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16105 alc662_ignore);
16106 if (err < 0)
16107 return err;
16108 if (!spec->autocfg.line_outs)
16109 return 0; /* can't find valid BIOS pin config */
16110
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016111 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16112 if (err < 0)
16113 return err;
16114 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16115 if (err < 0)
16116 return err;
16117 err = alc662_auto_create_extra_out(spec,
16118 spec->autocfg.speaker_pins[0],
16119 "Speaker");
16120 if (err < 0)
16121 return err;
16122 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16123 "Headphone");
16124 if (err < 0)
16125 return err;
16126 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16127 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016128 return err;
16129
16130 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16131
16132 if (spec->autocfg.dig_out_pin)
16133 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16134
16135 if (spec->kctl_alloc)
16136 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
16137
16138 spec->num_mux_defs = 1;
16139 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016140
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016141 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020016142 if (codec->vendor_id == 0x10ec0663)
16143 spec->init_verbs[spec->num_init_verbs++] =
16144 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020016145
16146 err = alc_auto_add_mic_boost(codec);
16147 if (err < 0)
16148 return err;
16149
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016150 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16151 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016152 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016153}
16154
16155/* additional initialization for auto-configuration model */
16156static void alc662_auto_init(struct hda_codec *codec)
16157{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016158 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016159 alc662_auto_init_multi_out(codec);
16160 alc662_auto_init_hp_out(codec);
16161 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016162 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016163 if (spec->unsol_event)
16164 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016165}
16166
16167static int patch_alc662(struct hda_codec *codec)
16168{
16169 struct alc_spec *spec;
16170 int err, board_config;
16171
16172 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16173 if (!spec)
16174 return -ENOMEM;
16175
16176 codec->spec = spec;
16177
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016178 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16179
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016180 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16181 alc662_models,
16182 alc662_cfg_tbl);
16183 if (board_config < 0) {
16184 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16185 "trying auto-probe from BIOS...\n");
16186 board_config = ALC662_AUTO;
16187 }
16188
16189 if (board_config == ALC662_AUTO) {
16190 /* automatic parse from the BIOS config */
16191 err = alc662_parse_auto_config(codec);
16192 if (err < 0) {
16193 alc_free(codec);
16194 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016195 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016196 printk(KERN_INFO
16197 "hda_codec: Cannot set up configuration "
16198 "from BIOS. Using base mode...\n");
16199 board_config = ALC662_3ST_2ch_DIG;
16200 }
16201 }
16202
16203 if (board_config != ALC662_AUTO)
16204 setup_preset(spec, &alc662_presets[board_config]);
16205
Kailang Yang6dda9f42008-05-27 12:05:31 +020016206 if (codec->vendor_id == 0x10ec0663) {
16207 spec->stream_name_analog = "ALC663 Analog";
16208 spec->stream_name_digital = "ALC663 Digital";
16209 } else {
16210 spec->stream_name_analog = "ALC662 Analog";
16211 spec->stream_name_digital = "ALC662 Digital";
16212 }
16213
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016214 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16215 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16216
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016217 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16218 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16219
Takashi Iwaie1406342008-02-11 18:32:32 +010016220 spec->adc_nids = alc662_adc_nids;
16221 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16222 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016223
Takashi Iwai2134ea42008-01-10 16:53:55 +010016224 spec->vmaster_nid = 0x02;
16225
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016226 codec->patch_ops = alc_patch_ops;
16227 if (board_config == ALC662_AUTO)
16228 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016229#ifdef CONFIG_SND_HDA_POWER_SAVE
16230 if (!spec->loopback.amplist)
16231 spec->loopback.amplist = alc662_loopbacks;
16232#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016233
16234 return 0;
16235}
16236
16237/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016238 * patch entries
16239 */
16240struct hda_codec_preset snd_hda_preset_realtek[] = {
16241 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016242 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016243 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016244 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016245 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016246 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016247 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016248 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16249 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16250 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016251 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16252 .patch = patch_alc883 },
16253 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16254 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016255 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016256 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016257 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016258 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020016259 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016260 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016261 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016262 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016263 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016264 {} /* terminator */
16265};