blob: 4cfea551cab84cc4674fb6bad6e365fde3094f16 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 ALC262_AUTO,
108 ALC262_MODEL_LAST /* last tag */
109};
110
Kailang Yanga361d842007-06-05 12:30:55 +0200111/* ALC268 models */
112enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200113 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200115 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200116 ALC268_ACER,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100133 ALC269_AUTO,
134 ALC269_MODEL_LAST /* last tag */
135};
136
Kailang Yangdf694da2005-12-05 19:42:22 +0100137/* ALC861 models */
138enum {
139 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200140 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100141 ALC861_3ST_DIG,
142 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200143 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200144 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200145 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100146 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100147 ALC861_AUTO,
148 ALC861_MODEL_LAST,
149};
150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100151/* ALC861-VD models */
152enum {
153 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200154 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100155 ALC861VD_3ST,
156 ALC861VD_3ST_DIG,
157 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200158 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200159 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200160 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_AUTO,
162 ALC861VD_MODEL_LAST,
163};
164
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200165/* ALC662 models */
166enum {
167 ALC662_3ST_2ch_DIG,
168 ALC662_3ST_6ch_DIG,
169 ALC662_3ST_6ch,
170 ALC662_5ST_DIG,
171 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200172 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100173 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200174 ALC663_ASUS_M51VA,
175 ALC663_ASUS_G71V,
176 ALC663_ASUS_H13,
177 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200178 ALC662_ECS,
179 ALC663_ASUS_MODE1,
180 ALC662_ASUS_MODE2,
181 ALC663_ASUS_MODE3,
182 ALC663_ASUS_MODE4,
183 ALC663_ASUS_MODE5,
184 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200185 ALC662_AUTO,
186 ALC662_MODEL_LAST,
187};
188
Kailang Yangdf694da2005-12-05 19:42:22 +0100189/* ALC882 models */
190enum {
191 ALC882_3ST_DIG,
192 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200193 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200194 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC882_TARGA,
196 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200197 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100198 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200199 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200200 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100202 ALC882_MODEL_LAST,
203};
204
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200205/* ALC883 models */
206enum {
207 ALC883_3ST_2ch_DIG,
208 ALC883_3ST_6ch_DIG,
209 ALC883_3ST_6ch,
210 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200211 ALC883_TARGA_DIG,
212 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200213 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200214 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200215 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200216 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100217 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200218 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200219 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200220 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200221 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200222 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200223 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100224 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100225 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100226 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100227 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200228 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_ASUS_M90V,
230 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200231 ALC883_AUTO,
232 ALC883_MODEL_LAST,
233};
234
Kailang Yangdf694da2005-12-05 19:42:22 +0100235/* for GPIO Poll */
236#define GPIO_MASK 0x03
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238struct alc_spec {
239 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 unsigned int num_mixers;
242
Kailang Yangdf694da2005-12-05 19:42:22 +0100243 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200244 * don't forget NULL
245 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200246 */
247 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Takashi Iwai16ded522005-06-10 19:58:24 +0200249 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 struct hda_pcm_stream *stream_analog_playback;
251 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100252 struct hda_pcm_stream *stream_analog_alt_playback;
253 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200255 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 struct hda_pcm_stream *stream_digital_playback;
257 struct hda_pcm_stream *stream_digital_capture;
258
259 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200260 struct hda_multi_out multiout; /* playback set-up
261 * max_channels, dacs must be set
262 * dig_out_nid and hp_nid are optional
263 */
Takashi Iwai63300792008-01-24 15:31:36 +0100264 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266 /* capture */
267 unsigned int num_adc_nids;
268 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100269 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200270 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200273 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 const struct hda_input_mux *input_mux;
275 unsigned int cur_mux[3];
276
277 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100278 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200280 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100283 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200284
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200285 /* dynamic controls, init_verbs and input_mux */
286 struct auto_pin_cfg autocfg;
287 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100288 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200289 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200290 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100291
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100292 /* hooks */
293 void (*init_hook)(struct hda_codec *codec);
294 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
295
Takashi Iwai834be882006-03-01 14:16:17 +0100296 /* for pin sensing */
297 unsigned int sense_updated: 1;
298 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100299 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200300
Takashi Iwai2134ea42008-01-10 16:53:55 +0100301 /* for virtual master */
302 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200303#ifdef CONFIG_SND_HDA_POWER_SAVE
304 struct hda_loopback_check loopback;
305#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200306
307 /* for PLL fix */
308 hda_nid_t pll_nid;
309 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100310};
311
312/*
313 * configuration template - to be copied to the spec instance
314 */
315struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200316 struct snd_kcontrol_new *mixers[5]; /* should be identical size
317 * with spec
318 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100319 const struct hda_verb *init_verbs[5];
320 unsigned int num_dacs;
321 hda_nid_t *dac_nids;
322 hda_nid_t dig_out_nid; /* optional */
323 hda_nid_t hp_nid; /* optional */
324 unsigned int num_adc_nids;
325 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100326 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100327 hda_nid_t dig_in_nid;
328 unsigned int num_channel_mode;
329 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200330 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200331 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100332 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100333 void (*unsol_event)(struct hda_codec *, unsigned int);
334 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200335#ifdef CONFIG_SND_HDA_POWER_SAVE
336 struct hda_amp_list *loopbacks;
337#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338};
339
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341/*
342 * input MUX handling
343 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200344static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346{
347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200349 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
350 if (mux_idx >= spec->num_mux_defs)
351 mux_idx = 0;
352 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353}
354
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200355static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357{
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 struct alc_spec *spec = codec->spec;
360 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
361
362 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
363 return 0;
364}
365
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200366static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
371 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200372 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100373 hda_nid_t nid = spec->capsrc_nids ?
374 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200375 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100376 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380/*
381 * channel mode setting
382 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200383static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385{
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100388 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
389 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200392static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100397 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200398 spec->num_channel_mode,
399 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200407 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
408 spec->num_channel_mode,
409 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200410 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200411 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
412 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413}
414
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200417 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100418 * being part of a format specifier. Maximum allowed length of a value is
419 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100420 *
421 * Note: some retasking pin complexes seem to ignore requests for input
422 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
423 * are requested. Therefore order this list so that this behaviour will not
424 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200425 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
426 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200427 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100428static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100429 "Mic 50pc bias", "Mic 80pc bias",
430 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431};
432static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100433 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434};
435/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200436 * in the pin being assumed to be exclusively an input or an output pin. In
437 * addition, "input" pins may or may not process the mic bias option
438 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
439 * accept requests for bias as of chip versions up to March 2006) and/or
440 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100441 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200442#define ALC_PIN_DIR_IN 0x00
443#define ALC_PIN_DIR_OUT 0x01
444#define ALC_PIN_DIR_INOUT 0x02
445#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
446#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100447
Kailang Yangea1fb292008-08-26 12:58:38 +0200448/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100449 * For each direction the minimum and maximum values are given.
450 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100452 { 0, 2 }, /* ALC_PIN_DIR_IN */
453 { 3, 4 }, /* ALC_PIN_DIR_OUT */
454 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
456 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457};
458#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
459#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
460#define alc_pin_mode_n_items(_dir) \
461 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
462
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200463static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200465{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100466 unsigned int item_num = uinfo->value.enumerated.item;
467 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
468
469 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200470 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
472
473 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
474 item_num = alc_pin_mode_min(dir);
475 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200476 return 0;
477}
478
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200479static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200481{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200486 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
488 AC_VERB_GET_PIN_WIDGET_CONTROL,
489 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200490
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491 /* Find enumerated value for current pinctl setting */
492 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200493 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496 return 0;
497}
498
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501{
502 signed int change;
503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
504 hda_nid_t nid = kcontrol->private_value & 0xffff;
505 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
506 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200507 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
508 AC_VERB_GET_PIN_WIDGET_CONTROL,
509 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200511 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 val = alc_pin_mode_min(dir);
513
514 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100515 if (change) {
516 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200517 snd_hda_codec_write_cache(codec, nid, 0,
518 AC_VERB_SET_PIN_WIDGET_CONTROL,
519 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100520
Kailang Yangea1fb292008-08-26 12:58:38 +0200521 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100522 * for the requested pin mode. Enum values of 2 or less are
523 * input modes.
524 *
525 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200526 * reduces noise slightly (particularly on input) so we'll
527 * do it. However, having both input and output buffers
528 * enabled simultaneously doesn't seem to be problematic if
529 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100530 */
531 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200532 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
533 HDA_AMP_MUTE, HDA_AMP_MUTE);
534 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
535 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100536 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200537 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
538 HDA_AMP_MUTE, HDA_AMP_MUTE);
539 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
540 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100541 }
542 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543 return change;
544}
545
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100546#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200547 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 .info = alc_pin_mode_info, \
549 .get = alc_pin_mode_get, \
550 .put = alc_pin_mode_put, \
551 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100552
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100553/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
554 * together using a mask with more than one bit set. This control is
555 * currently used only by the ALC260 test model. At this stage they are not
556 * needed for any "production" models.
557 */
558#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200559#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200560
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100563{
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
566 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
567 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 unsigned int val = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100570
571 *valp = (val & mask) != 0;
572 return 0;
573}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
575 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100576{
577 signed int change;
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 hda_nid_t nid = kcontrol->private_value & 0xffff;
580 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
581 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
583 AC_VERB_GET_GPIO_DATA,
584 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100585
586 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200587 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
588 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100589 gpio_data &= ~mask;
590 else
591 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200592 snd_hda_codec_write_cache(codec, nid, 0,
593 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100594
595 return change;
596}
597#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
599 .info = alc_gpio_data_info, \
600 .get = alc_gpio_data_get, \
601 .put = alc_gpio_data_put, \
602 .private_value = nid | (mask<<16) }
603#endif /* CONFIG_SND_DEBUG */
604
Jonathan Woithe92621f12006-02-28 11:47:47 +0100605/* A switch control to allow the enabling of the digital IO pins on the
606 * ALC260. This is incredibly simplistic; the intention of this control is
607 * to provide something in the test model allowing digital outputs to be
608 * identified if present. If models are found which can utilise these
609 * outputs a more complete mixer control can be devised for those models if
610 * necessary.
611 */
612#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200613#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200614
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100617{
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
621 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100623 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100624
625 *valp = (val & mask) != 0;
626 return 0;
627}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200628static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100630{
631 signed int change;
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 hda_nid_t nid = kcontrol->private_value & 0xffff;
634 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
635 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200636 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100637 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100639
640 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100642 if (val==0)
643 ctrl_data &= ~mask;
644 else
645 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200646 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
647 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100648
649 return change;
650}
651#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
652 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
653 .info = alc_spdif_ctrl_info, \
654 .get = alc_spdif_ctrl_get, \
655 .put = alc_spdif_ctrl_put, \
656 .private_value = nid | (mask<<16) }
657#endif /* CONFIG_SND_DEBUG */
658
Jonathan Woithef8225f62008-01-08 12:16:54 +0100659/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
660 * Again, this is only used in the ALC26x test models to help identify when
661 * the EAPD line must be asserted for features to work.
662 */
663#ifdef CONFIG_SND_DEBUG
664#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
665
666static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
668{
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
674 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
675
676 *valp = (val & mask) != 0;
677 return 0;
678}
679
680static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
682{
683 int change;
684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
685 hda_nid_t nid = kcontrol->private_value & 0xffff;
686 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
687 long val = *ucontrol->value.integer.value;
688 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
689 AC_VERB_GET_EAPD_BTLENABLE,
690 0x00);
691
692 /* Set/unset the masked control bit(s) as needed */
693 change = (!val ? 0 : mask) != (ctrl_data & mask);
694 if (!val)
695 ctrl_data &= ~mask;
696 else
697 ctrl_data |= mask;
698 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
699 ctrl_data);
700
701 return change;
702}
703
704#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
706 .info = alc_eapd_ctrl_info, \
707 .get = alc_eapd_ctrl_get, \
708 .put = alc_eapd_ctrl_put, \
709 .private_value = nid | (mask<<16) }
710#endif /* CONFIG_SND_DEBUG */
711
Kailang Yangdf694da2005-12-05 19:42:22 +0100712/*
713 * set up from the preset table
714 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200715static void setup_preset(struct alc_spec *spec,
716 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100717{
718 int i;
719
720 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
721 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
723 i++)
724 spec->init_verbs[spec->num_init_verbs++] =
725 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200726
Kailang Yangdf694da2005-12-05 19:42:22 +0100727 spec->channel_mode = preset->channel_mode;
728 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200729 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100730
731 spec->multiout.max_channels = spec->channel_mode[0].channels;
732
733 spec->multiout.num_dacs = preset->num_dacs;
734 spec->multiout.dac_nids = preset->dac_nids;
735 spec->multiout.dig_out_nid = preset->dig_out_nid;
736 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200737
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200738 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200739 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200740 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100741 spec->input_mux = preset->input_mux;
742
743 spec->num_adc_nids = preset->num_adc_nids;
744 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100745 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100746 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100747
748 spec->unsol_event = preset->unsol_event;
749 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200750#ifdef CONFIG_SND_HDA_POWER_SAVE
751 spec->loopback.amplist = preset->loopbacks;
752#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100753}
754
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200755/* Enable GPIO mask and set output */
756static struct hda_verb alc_gpio1_init_verbs[] = {
757 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
759 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
760 { }
761};
762
763static struct hda_verb alc_gpio2_init_verbs[] = {
764 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
766 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
767 { }
768};
769
Kailang Yangbdd148a2007-05-08 15:19:08 +0200770static struct hda_verb alc_gpio3_init_verbs[] = {
771 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
772 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
773 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
774 { }
775};
776
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200777/*
778 * Fix hardware PLL issue
779 * On some codecs, the analog PLL gating control must be off while
780 * the default value is 1.
781 */
782static void alc_fix_pll(struct hda_codec *codec)
783{
784 struct alc_spec *spec = codec->spec;
785 unsigned int val;
786
787 if (!spec->pll_nid)
788 return;
789 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
790 spec->pll_coef_idx);
791 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
792 AC_VERB_GET_PROC_COEF, 0);
793 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
794 spec->pll_coef_idx);
795 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
796 val & ~(1 << spec->pll_coef_bit));
797}
798
799static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
800 unsigned int coef_idx, unsigned int coef_bit)
801{
802 struct alc_spec *spec = codec->spec;
803 spec->pll_nid = nid;
804 spec->pll_coef_idx = coef_idx;
805 spec->pll_coef_bit = coef_bit;
806 alc_fix_pll(codec);
807}
808
Kailang Yangc9b58002007-10-16 14:30:01 +0200809static void alc_sku_automute(struct hda_codec *codec)
810{
811 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200812 unsigned int present;
813 unsigned int hp_nid = spec->autocfg.hp_pins[0];
814 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
815
816 /* need to execute and sync at first */
817 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
818 present = snd_hda_codec_read(codec, hp_nid, 0,
819 AC_VERB_GET_PIN_SENSE, 0);
820 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100821 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
822 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200823}
824
825/* unsolicited event for HP jack sensing */
826static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
827{
828 if (codec->vendor_id == 0x10ec0880)
829 res >>= 28;
830 else
831 res >>= 26;
832 if (res != ALC880_HP_EVENT)
833 return;
834
835 alc_sku_automute(codec);
836}
837
Kailang Yangf9423e72008-05-27 12:32:25 +0200838/* additional initialization for ALC888 variants */
839static void alc888_coef_init(struct hda_codec *codec)
840{
841 unsigned int tmp;
842
843 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
844 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
845 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
846 if ((tmp & 0xf0) == 2)
847 /* alc888S-VC */
848 snd_hda_codec_read(codec, 0x20, 0,
849 AC_VERB_SET_PROC_COEF, 0x830);
850 else
851 /* alc888-VB */
852 snd_hda_codec_read(codec, 0x20, 0,
853 AC_VERB_SET_PROC_COEF, 0x3030);
854}
855
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200856/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
857 * 31 ~ 16 : Manufacture ID
858 * 15 ~ 8 : SKU ID
859 * 7 ~ 0 : Assembly ID
860 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
861 */
862static void alc_subsystem_id(struct hda_codec *codec,
863 unsigned int porta, unsigned int porte,
864 unsigned int portd)
865{
Kailang Yangc9b58002007-10-16 14:30:01 +0200866 unsigned int ass, tmp, i;
867 unsigned nid;
868 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200869
Kailang Yangc9b58002007-10-16 14:30:01 +0200870 ass = codec->subsystem_id & 0xffff;
871 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
872 goto do_sku;
873
Kailang Yangea1fb292008-08-26 12:58:38 +0200874 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200875 * 31~30 : port conetcivity
876 * 29~21 : reserve
877 * 20 : PCBEEP input
878 * 19~16 : Check sum (15:1)
879 * 15~1 : Custom
880 * 0 : override
881 */
882 nid = 0x1d;
883 if (codec->vendor_id == 0x10ec0260)
884 nid = 0x17;
885 ass = snd_hda_codec_read(codec, nid, 0,
886 AC_VERB_GET_CONFIG_DEFAULT, 0);
887 if (!(ass & 1) && !(ass & 0x100000))
888 return;
889 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200890 return;
891
Kailang Yangc9b58002007-10-16 14:30:01 +0200892 /* check sum */
893 tmp = 0;
894 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100895 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200896 tmp++;
897 }
898 if (((ass >> 16) & 0xf) != tmp)
899 return;
900do_sku:
901 /*
902 * 0 : override
903 * 1 : Swap Jack
904 * 2 : 0 --> Desktop, 1 --> Laptop
905 * 3~5 : External Amplifier control
906 * 7~6 : Reserved
907 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200908 tmp = (ass & 0x38) >> 3; /* external Amp control */
909 switch (tmp) {
910 case 1:
911 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
912 break;
913 case 3:
914 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
915 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200916 case 7:
917 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
918 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200920 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200921 case 0x10ec0260:
922 snd_hda_codec_write(codec, 0x0f, 0,
923 AC_VERB_SET_EAPD_BTLENABLE, 2);
924 snd_hda_codec_write(codec, 0x10, 0,
925 AC_VERB_SET_EAPD_BTLENABLE, 2);
926 break;
927 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200928 case 0x10ec0267:
929 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200930 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200931 case 0x10ec0660:
932 case 0x10ec0662:
933 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200934 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200935 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200936 snd_hda_codec_write(codec, 0x14, 0,
937 AC_VERB_SET_EAPD_BTLENABLE, 2);
938 snd_hda_codec_write(codec, 0x15, 0,
939 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200940 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200941 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200942 switch (codec->vendor_id) {
943 case 0x10ec0260:
944 snd_hda_codec_write(codec, 0x1a, 0,
945 AC_VERB_SET_COEF_INDEX, 7);
946 tmp = snd_hda_codec_read(codec, 0x1a, 0,
947 AC_VERB_GET_PROC_COEF, 0);
948 snd_hda_codec_write(codec, 0x1a, 0,
949 AC_VERB_SET_COEF_INDEX, 7);
950 snd_hda_codec_write(codec, 0x1a, 0,
951 AC_VERB_SET_PROC_COEF,
952 tmp | 0x2010);
953 break;
954 case 0x10ec0262:
955 case 0x10ec0880:
956 case 0x10ec0882:
957 case 0x10ec0883:
958 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200959 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200960 snd_hda_codec_write(codec, 0x20, 0,
961 AC_VERB_SET_COEF_INDEX, 7);
962 tmp = snd_hda_codec_read(codec, 0x20, 0,
963 AC_VERB_GET_PROC_COEF, 0);
964 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200965 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200966 snd_hda_codec_write(codec, 0x20, 0,
967 AC_VERB_SET_PROC_COEF,
968 tmp | 0x2010);
969 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200970 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200971 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200972 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 case 0x10ec0267:
974 case 0x10ec0268:
975 snd_hda_codec_write(codec, 0x20, 0,
976 AC_VERB_SET_COEF_INDEX, 7);
977 tmp = snd_hda_codec_read(codec, 0x20, 0,
978 AC_VERB_GET_PROC_COEF, 0);
979 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200980 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200981 snd_hda_codec_write(codec, 0x20, 0,
982 AC_VERB_SET_PROC_COEF,
983 tmp | 0x3000);
984 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200985 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200986 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200987 break;
988 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200989
Kailang Yang8c427222008-01-10 13:03:59 +0100990 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200991 * when the external headphone out jack is plugged"
992 */
Kailang Yang8c427222008-01-10 13:03:59 +0100993 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200994 return;
995 /*
996 * 10~8 : Jack location
997 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
998 * 14~13: Resvered
999 * 15 : 1 --> enable the function "Mute internal speaker
1000 * when the external headphone out jack is plugged"
1001 */
1002 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001003 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001004 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001005 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001006 else
1007 return;
1008 }
1009
1010 if (!spec->autocfg.hp_pins[0]) {
1011 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1012 if (tmp == 0)
1013 spec->autocfg.hp_pins[0] = porta;
1014 else if (tmp == 1)
1015 spec->autocfg.hp_pins[0] = porte;
1016 else if (tmp == 2)
1017 spec->autocfg.hp_pins[0] = portd;
1018 else
1019 return;
1020 }
1021
1022 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1023 AC_VERB_SET_UNSOLICITED_ENABLE,
1024 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001025
Kailang Yangc9b58002007-10-16 14:30:01 +02001026 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001027}
1028
Takashi Iwai41e41f12005-06-08 14:48:49 +02001029/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001030 * Fix-up pin default configurations
1031 */
1032
1033struct alc_pincfg {
1034 hda_nid_t nid;
1035 u32 val;
1036};
1037
1038static void alc_fix_pincfg(struct hda_codec *codec,
1039 const struct snd_pci_quirk *quirk,
1040 const struct alc_pincfg **pinfix)
1041{
1042 const struct alc_pincfg *cfg;
1043
1044 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1045 if (!quirk)
1046 return;
1047
1048 cfg = pinfix[quirk->value];
1049 for (; cfg->nid; cfg++) {
1050 int i;
1051 u32 val = cfg->val;
1052 for (i = 0; i < 4; i++) {
1053 snd_hda_codec_write(codec, cfg->nid, 0,
1054 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1055 val & 0xff);
1056 val >>= 8;
1057 }
1058 }
1059}
1060
1061/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001062 * ALC880 3-stack model
1063 *
1064 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001065 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1066 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 */
1068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069static hda_nid_t alc880_dac_nids[4] = {
1070 /* front, rear, clfe, rear_surr */
1071 0x02, 0x05, 0x04, 0x03
1072};
1073
1074static hda_nid_t alc880_adc_nids[3] = {
1075 /* ADC0-2 */
1076 0x07, 0x08, 0x09,
1077};
1078
1079/* The datasheet says the node 0x07 is connected from inputs,
1080 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001081 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001083static hda_nid_t alc880_adc_nids_alt[2] = {
1084 /* ADC1-2 */
1085 0x08, 0x09,
1086};
1087
1088#define ALC880_DIGOUT_NID 0x06
1089#define ALC880_DIGIN_NID 0x0a
1090
1091static struct hda_input_mux alc880_capture_source = {
1092 .num_items = 4,
1093 .items = {
1094 { "Mic", 0x0 },
1095 { "Front Mic", 0x3 },
1096 { "Line", 0x2 },
1097 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001099};
1100
1101/* channel source setting (2/6 channel selection for 3-stack) */
1102/* 2ch mode */
1103static struct hda_verb alc880_threestack_ch2_init[] = {
1104 /* set line-in to input, mute it */
1105 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1106 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1107 /* set mic-in to input vref 80%, mute it */
1108 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1109 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 { } /* end */
1111};
1112
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001113/* 6ch mode */
1114static struct hda_verb alc880_threestack_ch6_init[] = {
1115 /* set line-in to output, unmute it */
1116 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1117 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1118 /* set mic-in to output, unmute it */
1119 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1120 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1121 { } /* end */
1122};
1123
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001124static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125 { 2, alc880_threestack_ch2_init },
1126 { 6, alc880_threestack_ch6_init },
1127};
1128
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001129static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001133 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1146 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1147 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001149 {
1150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001152 .info = alc_ch_mode_info,
1153 .get = alc_ch_mode_get,
1154 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155 },
1156 { } /* end */
1157};
1158
1159/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001160static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001161 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1163 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1165 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1167 {
1168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1169 /* The multiple "Capture Source" controls confuse alsamixer
1170 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001171 */
1172 /* .name = "Capture Source", */
1173 .name = "Input Source",
1174 .count = 3,
1175 .info = alc_mux_enum_info,
1176 .get = alc_mux_enum_get,
1177 .put = alc_mux_enum_put,
1178 },
1179 { } /* end */
1180};
1181
1182/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001183static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 {
1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1190 /* The multiple "Capture Source" controls confuse alsamixer
1191 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 */
1193 /* .name = "Capture Source", */
1194 .name = "Input Source",
1195 .count = 2,
1196 .info = alc_mux_enum_info,
1197 .get = alc_mux_enum_get,
1198 .put = alc_mux_enum_put,
1199 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 { } /* end */
1201};
1202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001203
1204
1205/*
1206 * ALC880 5-stack model
1207 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001208 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1209 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001210 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1211 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1212 */
1213
1214/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001215static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001216 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001217 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 { } /* end */
1219};
1220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001221/* channel source setting (6/8 channel selection for 5-stack) */
1222/* 6ch mode */
1223static struct hda_verb alc880_fivestack_ch6_init[] = {
1224 /* set line-in to input, mute it */
1225 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1226 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001227 { } /* end */
1228};
1229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001230/* 8ch mode */
1231static struct hda_verb alc880_fivestack_ch8_init[] = {
1232 /* set line-in to output, unmute it */
1233 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1234 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1235 { } /* end */
1236};
1237
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001238static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001239 { 6, alc880_fivestack_ch6_init },
1240 { 8, alc880_fivestack_ch8_init },
1241};
1242
1243
1244/*
1245 * ALC880 6-stack model
1246 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001247 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1248 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001249 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1250 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1251 */
1252
1253static hda_nid_t alc880_6st_dac_nids[4] = {
1254 /* front, rear, clfe, rear_surr */
1255 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001256};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257
1258static struct hda_input_mux alc880_6stack_capture_source = {
1259 .num_items = 4,
1260 .items = {
1261 { "Mic", 0x0 },
1262 { "Front Mic", 0x1 },
1263 { "Line", 0x2 },
1264 { "CD", 0x4 },
1265 },
1266};
1267
1268/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001269static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001270 { 8, NULL },
1271};
1272
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001273static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001275 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001276 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001277 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001278 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1279 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001280 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1281 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001282 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001283 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001284 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1285 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1292 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1293 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001294 {
1295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1296 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001297 .info = alc_ch_mode_info,
1298 .get = alc_ch_mode_get,
1299 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001300 },
1301 { } /* end */
1302};
1303
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304
1305/*
1306 * ALC880 W810 model
1307 *
1308 * W810 has rear IO for:
1309 * Front (DAC 02)
1310 * Surround (DAC 03)
1311 * Center/LFE (DAC 04)
1312 * Digital out (06)
1313 *
1314 * The system also has a pair of internal speakers, and a headphone jack.
1315 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001316 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001317 * There is a variable resistor to control the speaker or headphone
1318 * volume. This is a hardware-only device without a software API.
1319 *
1320 * Plugging headphones in will disable the internal speakers. This is
1321 * implemented in hardware, not via the driver using jack sense. In
1322 * a similar fashion, plugging into the rear socket marked "front" will
1323 * disable both the speakers and headphones.
1324 *
1325 * For input, there's a microphone jack, and an "audio in" jack.
1326 * These may not do anything useful with this driver yet, because I
1327 * haven't setup any initialization verbs for these yet...
1328 */
1329
1330static hda_nid_t alc880_w810_dac_nids[3] = {
1331 /* front, rear/surround, clfe */
1332 0x02, 0x03, 0x04
1333};
1334
1335/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001336static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001337 { 6, NULL }
1338};
1339
1340/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001341static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001342 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001343 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001344 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001345 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001346 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1347 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001348 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1349 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1351 { } /* end */
1352};
1353
1354
1355/*
1356 * Z710V model
1357 *
1358 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001359 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1360 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001361 */
1362
1363static hda_nid_t alc880_z71v_dac_nids[1] = {
1364 0x02
1365};
1366#define ALC880_Z71V_HP_DAC 0x03
1367
1368/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001369static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001370 { 2, NULL }
1371};
1372
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001373static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001375 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001376 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001377 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1382 { } /* end */
1383};
1384
1385
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001386/*
1387 * ALC880 F1734 model
1388 *
1389 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1390 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1391 */
1392
1393static hda_nid_t alc880_f1734_dac_nids[1] = {
1394 0x03
1395};
1396#define ALC880_F1734_HP_DAC 0x02
1397
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001398static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001400 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001401 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1402 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1406 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001407 { } /* end */
1408};
1409
Takashi Iwai937b4162008-02-11 14:52:36 +01001410static struct hda_input_mux alc880_f1734_capture_source = {
1411 .num_items = 2,
1412 .items = {
1413 { "Mic", 0x1 },
1414 { "CD", 0x4 },
1415 },
1416};
1417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001419/*
1420 * ALC880 ASUS model
1421 *
1422 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1423 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1424 * Mic = 0x18, Line = 0x1a
1425 */
1426
1427#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1428#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1429
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001430static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001434 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001435 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1436 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001437 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1438 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001439 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1440 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1441 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1442 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 {
1446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1447 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001448 .info = alc_ch_mode_info,
1449 .get = alc_ch_mode_get,
1450 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 },
1452 { } /* end */
1453};
1454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455/*
1456 * ALC880 ASUS W1V model
1457 *
1458 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1459 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1460 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1461 */
1462
1463/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001464static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1466 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001467 { } /* end */
1468};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001470/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001471static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001472 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1473 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1474 { } /* end */
1475};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001476
Kailang Yangdf694da2005-12-05 19:42:22 +01001477/* TCL S700 */
1478static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1480 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1482 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1483 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1486 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1487 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1488 {
1489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1490 /* The multiple "Capture Source" controls confuse alsamixer
1491 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001492 */
1493 /* .name = "Capture Source", */
1494 .name = "Input Source",
1495 .count = 1,
1496 .info = alc_mux_enum_info,
1497 .get = alc_mux_enum_get,
1498 .put = alc_mux_enum_put,
1499 },
1500 { } /* end */
1501};
1502
Kailang Yangccc656c2006-10-17 12:32:26 +02001503/* Uniwill */
1504static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001505 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1506 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1507 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1508 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001509 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1510 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1511 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1512 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1513 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1514 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1515 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1516 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1519 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1521 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1522 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1523 {
1524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1525 .name = "Channel Mode",
1526 .info = alc_ch_mode_info,
1527 .get = alc_ch_mode_get,
1528 .put = alc_ch_mode_put,
1529 },
1530 { } /* end */
1531};
1532
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001533static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1535 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1536 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1537 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1539 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1540 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1543 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1544 { } /* end */
1545};
1546
Kailang Yangccc656c2006-10-17 12:32:26 +02001547static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001548 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1549 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1550 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1551 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1554 { } /* end */
1555};
1556
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001558 * virtual master controls
1559 */
1560
1561/*
1562 * slave controls for virtual master
1563 */
1564static const char *alc_slave_vols[] = {
1565 "Front Playback Volume",
1566 "Surround Playback Volume",
1567 "Center Playback Volume",
1568 "LFE Playback Volume",
1569 "Side Playback Volume",
1570 "Headphone Playback Volume",
1571 "Speaker Playback Volume",
1572 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001573 "Line-Out Playback Volume",
1574 NULL,
1575};
1576
1577static const char *alc_slave_sws[] = {
1578 "Front Playback Switch",
1579 "Surround Playback Switch",
1580 "Center Playback Switch",
1581 "LFE Playback Switch",
1582 "Side Playback Switch",
1583 "Headphone Playback Switch",
1584 "Speaker Playback Switch",
1585 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001586 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001587 NULL,
1588};
1589
1590/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001591 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 */
1593static int alc_build_controls(struct hda_codec *codec)
1594{
1595 struct alc_spec *spec = codec->spec;
1596 int err;
1597 int i;
1598
1599 for (i = 0; i < spec->num_mixers; i++) {
1600 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1601 if (err < 0)
1602 return err;
1603 }
1604
1605 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001606 err = snd_hda_create_spdif_out_ctls(codec,
1607 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608 if (err < 0)
1609 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001610 err = snd_hda_create_spdif_share_sw(codec,
1611 &spec->multiout);
1612 if (err < 0)
1613 return err;
1614 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615 }
1616 if (spec->dig_in_nid) {
1617 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1618 if (err < 0)
1619 return err;
1620 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001621
1622 /* if we have no master control, let's create it */
1623 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001624 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001625 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001626 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001627 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001628 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001629 if (err < 0)
1630 return err;
1631 }
1632 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1633 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1634 NULL, alc_slave_sws);
1635 if (err < 0)
1636 return err;
1637 }
1638
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639 return 0;
1640}
1641
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001642
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643/*
1644 * initialize the codec volumes, etc
1645 */
1646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647/*
1648 * generic initialization of ADC, input mixers and output mixers
1649 */
1650static struct hda_verb alc880_volume_init_verbs[] = {
1651 /*
1652 * Unmute ADC0-2 and set the default input to mic-in
1653 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001654 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001656 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001658 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1662 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001663 * Note: PASD motherboards uses the Line In 2 as the input for front
1664 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675 /*
1676 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 /* set vol=0 to output mixers */
1679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1683 /* set up input amps for analog loopback */
1684 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693
1694 { }
1695};
1696
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001697/*
1698 * 3-stack pin configuration:
1699 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1700 */
1701static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1702 /*
1703 * preset connection lists of input pins
1704 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1705 */
1706 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1707 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1708 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1709
1710 /*
1711 * Set pin mode and muting
1712 */
1713 /* set front pin widgets 0x14 for output */
1714 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1716 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1719 /* Mic2 (as headphone out) for HP output */
1720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 /* Line In pin widget for input */
1723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1725 /* Line2 (as front mic) pin widget for input and vref at 80% */
1726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1728 /* CD pin widget for input */
1729 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1730
1731 { }
1732};
1733
1734/*
1735 * 5-stack pin configuration:
1736 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1737 * line-in/side = 0x1a, f-mic = 0x1b
1738 */
1739static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1740 /*
1741 * preset connection lists of input pins
1742 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1743 */
1744 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1745 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1746
1747 /*
1748 * Set pin mode and muting
1749 */
1750 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001751 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1753 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1754 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001755 /* unmute pins for output (no gain on this amp) */
1756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1760
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1764 /* Mic2 (as headphone out) for HP output */
1765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767 /* Line In pin widget for input */
1768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1770 /* Line2 (as front mic) pin widget for input and vref at 80% */
1771 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1772 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1773 /* CD pin widget for input */
1774 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775
1776 { }
1777};
1778
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001779/*
1780 * W810 pin configuration:
1781 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1782 */
1783static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 /* hphone/speaker input selector: front DAC */
1785 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1786
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1793
1794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001795 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797 { }
1798};
1799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800/*
1801 * Z71V pin configuration:
1802 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1803 */
1804static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001809
Takashi Iwai16ded522005-06-10 19:58:24 +02001810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001812 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001813 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001814
1815 { }
1816};
1817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818/*
1819 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001820 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1821 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001822 */
1823static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1824 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1825
Takashi Iwai16ded522005-06-10 19:58:24 +02001826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001830 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001831 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001832 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1834
Takashi Iwai16ded522005-06-10 19:58:24 +02001835 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001837 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001843 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845 { }
1846};
Takashi Iwai16ded522005-06-10 19:58:24 +02001847
Kailang Yangccc656c2006-10-17 12:32:26 +02001848/*
1849 * Uniwill pin configuration:
1850 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1851 * line = 0x1a
1852 */
1853static struct hda_verb alc880_uniwill_init_verbs[] = {
1854 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1855
1856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1870
1871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1873 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1877 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1878 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1880
1881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1883
1884 { }
1885};
1886
1887/*
1888* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001889* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001890 */
1891static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1892 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1893
1894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1906
1907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1913
1914 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1915 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1916
1917 { }
1918};
1919
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001920static struct hda_verb alc880_beep_init_verbs[] = {
1921 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1922 { }
1923};
1924
Kailang Yangccc656c2006-10-17 12:32:26 +02001925/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001926static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001927{
1928 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001929 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001930
1931 present = snd_hda_codec_read(codec, 0x14, 0,
1932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001933 bits = present ? HDA_AMP_MUTE : 0;
1934 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1935 HDA_AMP_MUTE, bits);
1936 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1937 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001938}
1939
1940/* auto-toggle front mic */
1941static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1942{
1943 unsigned int present;
1944 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001945
1946 present = snd_hda_codec_read(codec, 0x18, 0,
1947 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001948 bits = present ? HDA_AMP_MUTE : 0;
1949 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001950}
1951
1952static void alc880_uniwill_automute(struct hda_codec *codec)
1953{
1954 alc880_uniwill_hp_automute(codec);
1955 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001956}
1957
1958static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1959 unsigned int res)
1960{
1961 /* Looks like the unsol event is incompatible with the standard
1962 * definition. 4bit tag is placed at 28 bit!
1963 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001964 switch (res >> 28) {
1965 case ALC880_HP_EVENT:
1966 alc880_uniwill_hp_automute(codec);
1967 break;
1968 case ALC880_MIC_EVENT:
1969 alc880_uniwill_mic_automute(codec);
1970 break;
1971 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001972}
1973
1974static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1975{
1976 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001977 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001978
1979 present = snd_hda_codec_read(codec, 0x14, 0,
1980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001981 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001982 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001983}
1984
1985static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1986{
1987 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001988
Kailang Yangccc656c2006-10-17 12:32:26 +02001989 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001990 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1991 present &= HDA_AMP_VOLMASK;
1992 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1993 HDA_AMP_VOLMASK, present);
1994 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1995 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001996}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001997
Kailang Yangccc656c2006-10-17 12:32:26 +02001998static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1999 unsigned int res)
2000{
2001 /* Looks like the unsol event is incompatible with the standard
2002 * definition. 4bit tag is placed at 28 bit!
2003 */
2004 if ((res >> 28) == ALC880_HP_EVENT)
2005 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002006 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002007 alc880_uniwill_p53_dcvol_automute(codec);
2008}
2009
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002010/*
2011 * F1734 pin configuration:
2012 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2013 */
2014static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002015 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2017 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2018 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2019 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2020
2021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2025
2026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002028 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002035
Takashi Iwai937b4162008-02-11 14:52:36 +01002036 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2037 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2038
Takashi Iwai16ded522005-06-10 19:58:24 +02002039 { }
2040};
2041
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042/*
2043 * ASUS pin configuration:
2044 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2045 */
2046static struct hda_verb alc880_pin_asus_init_verbs[] = {
2047 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2048 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2049 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2050 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2051
2052 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2056 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2060
2061 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071 { }
2072};
2073
2074/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002075#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2076#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077
Kailang Yangdf694da2005-12-05 19:42:22 +01002078/* Clevo m520g init */
2079static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2080 /* headphone output */
2081 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2082 /* line-out */
2083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2085 /* Line-in */
2086 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2088 /* CD */
2089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2090 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 /* Mic1 (rear panel) */
2092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2093 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 /* Mic2 (front panel) */
2095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 /* headphone */
2098 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2099 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2100 /* change to EAPD mode */
2101 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2102 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2103
2104 { }
2105};
2106
2107static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002108 /* change to EAPD mode */
2109 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2110 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2111
Kailang Yangdf694da2005-12-05 19:42:22 +01002112 /* Headphone output */
2113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2114 /* Front output*/
2115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2116 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2117
2118 /* Line In pin widget for input */
2119 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2120 /* CD pin widget for input */
2121 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2123 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2124
2125 /* change to EAPD mode */
2126 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2127 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2128
2129 { }
2130};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002131
2132/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002133 * LG m1 express dual
2134 *
2135 * Pin assignment:
2136 * Rear Line-In/Out (blue): 0x14
2137 * Build-in Mic-In: 0x15
2138 * Speaker-out: 0x17
2139 * HP-Out (green): 0x1b
2140 * Mic-In/Out (red): 0x19
2141 * SPDIF-Out: 0x1e
2142 */
2143
2144/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2145static hda_nid_t alc880_lg_dac_nids[3] = {
2146 0x05, 0x02, 0x03
2147};
2148
2149/* seems analog CD is not working */
2150static struct hda_input_mux alc880_lg_capture_source = {
2151 .num_items = 3,
2152 .items = {
2153 { "Mic", 0x1 },
2154 { "Line", 0x5 },
2155 { "Internal Mic", 0x6 },
2156 },
2157};
2158
2159/* 2,4,6 channel modes */
2160static struct hda_verb alc880_lg_ch2_init[] = {
2161 /* set line-in and mic-in to input */
2162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2163 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2164 { }
2165};
2166
2167static struct hda_verb alc880_lg_ch4_init[] = {
2168 /* set line-in to out and mic-in to input */
2169 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2170 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2171 { }
2172};
2173
2174static struct hda_verb alc880_lg_ch6_init[] = {
2175 /* set line-in and mic-in to output */
2176 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2177 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2178 { }
2179};
2180
2181static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2182 { 2, alc880_lg_ch2_init },
2183 { 4, alc880_lg_ch4_init },
2184 { 6, alc880_lg_ch6_init },
2185};
2186
2187static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2202 {
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2208 },
2209 { } /* end */
2210};
2211
2212static struct hda_verb alc880_lg_init_verbs[] = {
2213 /* set capture source to mic-in */
2214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2217 /* mute all amp mixer inputs */
2218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002221 /* line-in to input */
2222 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 /* built-in mic */
2225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2227 /* speaker-out */
2228 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2229 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2230 /* mic-in to input */
2231 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* HP-out */
2235 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2238 /* jack sense */
2239 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2240 { }
2241};
2242
2243/* toggle speaker-output according to the hp-jack state */
2244static void alc880_lg_automute(struct hda_codec *codec)
2245{
2246 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002247 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002248
2249 present = snd_hda_codec_read(codec, 0x1b, 0,
2250 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002251 bits = present ? HDA_AMP_MUTE : 0;
2252 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2253 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002254}
2255
2256static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2257{
2258 /* Looks like the unsol event is incompatible with the standard
2259 * definition. 4bit tag is placed at 28 bit!
2260 */
2261 if ((res >> 28) == 0x01)
2262 alc880_lg_automute(codec);
2263}
2264
2265/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002266 * LG LW20
2267 *
2268 * Pin assignment:
2269 * Speaker-out: 0x14
2270 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002271 * Built-in Mic-In: 0x19
2272 * Line-In: 0x1b
2273 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002274 * SPDIF-Out: 0x1e
2275 */
2276
Takashi Iwaid6815182006-03-23 16:06:23 +01002277static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002278 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002279 .items = {
2280 { "Mic", 0x0 },
2281 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002282 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002283 },
2284};
2285
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002286#define alc880_lg_lw_modes alc880_threestack_modes
2287
Takashi Iwaid6815182006-03-23 16:06:23 +01002288static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002289 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2290 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2291 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2292 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2293 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2295 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2296 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2300 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2301 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2302 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002303 {
2304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2305 .name = "Channel Mode",
2306 .info = alc_ch_mode_info,
2307 .get = alc_ch_mode_get,
2308 .put = alc_ch_mode_put,
2309 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002310 { } /* end */
2311};
2312
2313static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002314 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2315 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2316 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2317
Takashi Iwaid6815182006-03-23 16:06:23 +01002318 /* set capture source to mic-in */
2319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002323 /* speaker-out */
2324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2326 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2328 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2329 /* mic-in to input */
2330 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2332 /* built-in mic */
2333 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2335 /* jack sense */
2336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2337 { }
2338};
2339
2340/* toggle speaker-output according to the hp-jack state */
2341static void alc880_lg_lw_automute(struct hda_codec *codec)
2342{
2343 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002344 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002345
2346 present = snd_hda_codec_read(codec, 0x1b, 0,
2347 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002348 bits = present ? HDA_AMP_MUTE : 0;
2349 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2350 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002351}
2352
2353static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2354{
2355 /* Looks like the unsol event is incompatible with the standard
2356 * definition. 4bit tag is placed at 28 bit!
2357 */
2358 if ((res >> 28) == 0x01)
2359 alc880_lg_lw_automute(codec);
2360}
2361
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002362static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2363 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2364 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2367 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2368 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2369 { } /* end */
2370};
2371
2372static struct hda_input_mux alc880_medion_rim_capture_source = {
2373 .num_items = 2,
2374 .items = {
2375 { "Mic", 0x0 },
2376 { "Internal Mic", 0x1 },
2377 },
2378};
2379
2380static struct hda_verb alc880_medion_rim_init_verbs[] = {
2381 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2382
2383 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2384 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2385
2386 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2389 /* Mic2 (as headphone out) for HP output */
2390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2392 /* Internal Speaker */
2393 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2395
2396 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2397 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2398
2399 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2400 { }
2401};
2402
2403/* toggle speaker-output according to the hp-jack state */
2404static void alc880_medion_rim_automute(struct hda_codec *codec)
2405{
2406 unsigned int present;
2407 unsigned char bits;
2408
2409 present = snd_hda_codec_read(codec, 0x14, 0,
2410 AC_VERB_GET_PIN_SENSE, 0)
2411 & AC_PINSENSE_PRESENCE;
2412 bits = present ? HDA_AMP_MUTE : 0;
2413 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2414 HDA_AMP_MUTE, bits);
2415 if (present)
2416 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2417 else
2418 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2419}
2420
2421static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2422 unsigned int res)
2423{
2424 /* Looks like the unsol event is incompatible with the standard
2425 * definition. 4bit tag is placed at 28 bit!
2426 */
2427 if ((res >> 28) == ALC880_HP_EVENT)
2428 alc880_medion_rim_automute(codec);
2429}
2430
Takashi Iwaicb53c622007-08-10 17:21:45 +02002431#ifdef CONFIG_SND_HDA_POWER_SAVE
2432static struct hda_amp_list alc880_loopbacks[] = {
2433 { 0x0b, HDA_INPUT, 0 },
2434 { 0x0b, HDA_INPUT, 1 },
2435 { 0x0b, HDA_INPUT, 2 },
2436 { 0x0b, HDA_INPUT, 3 },
2437 { 0x0b, HDA_INPUT, 4 },
2438 { } /* end */
2439};
2440
2441static struct hda_amp_list alc880_lg_loopbacks[] = {
2442 { 0x0b, HDA_INPUT, 1 },
2443 { 0x0b, HDA_INPUT, 6 },
2444 { 0x0b, HDA_INPUT, 7 },
2445 { } /* end */
2446};
2447#endif
2448
Takashi Iwaid6815182006-03-23 16:06:23 +01002449/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002450 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002451 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002452
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453static int alc_init(struct hda_codec *codec)
2454{
2455 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456 unsigned int i;
2457
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002458 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002459 if (codec->vendor_id == 0x10ec0888)
2460 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002462 for (i = 0; i < spec->num_init_verbs; i++)
2463 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002464
2465 if (spec->init_hook)
2466 spec->init_hook(codec);
2467
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 return 0;
2469}
2470
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002471static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2472{
2473 struct alc_spec *spec = codec->spec;
2474
2475 if (spec->unsol_event)
2476 spec->unsol_event(codec, res);
2477}
2478
Takashi Iwaicb53c622007-08-10 17:21:45 +02002479#ifdef CONFIG_SND_HDA_POWER_SAVE
2480static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2481{
2482 struct alc_spec *spec = codec->spec;
2483 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2484}
2485#endif
2486
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487/*
2488 * Analog playback callbacks
2489 */
2490static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2491 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002492 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493{
2494 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002495 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2496 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497}
2498
2499static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2500 struct hda_codec *codec,
2501 unsigned int stream_tag,
2502 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002503 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002504{
2505 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002506 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2507 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508}
2509
2510static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2511 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002512 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513{
2514 struct alc_spec *spec = codec->spec;
2515 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2516}
2517
2518/*
2519 * Digital out
2520 */
2521static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2522 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002523 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524{
2525 struct alc_spec *spec = codec->spec;
2526 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2527}
2528
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002529static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2530 struct hda_codec *codec,
2531 unsigned int stream_tag,
2532 unsigned int format,
2533 struct snd_pcm_substream *substream)
2534{
2535 struct alc_spec *spec = codec->spec;
2536 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2537 stream_tag, format, substream);
2538}
2539
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2541 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002542 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543{
2544 struct alc_spec *spec = codec->spec;
2545 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2546}
2547
2548/*
2549 * Analog capture
2550 */
Takashi Iwai63300792008-01-24 15:31:36 +01002551static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 struct hda_codec *codec,
2553 unsigned int stream_tag,
2554 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002555 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556{
2557 struct alc_spec *spec = codec->spec;
2558
Takashi Iwai63300792008-01-24 15:31:36 +01002559 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 stream_tag, 0, format);
2561 return 0;
2562}
2563
Takashi Iwai63300792008-01-24 15:31:36 +01002564static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002566 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567{
2568 struct alc_spec *spec = codec->spec;
2569
Takashi Iwai888afa12008-03-18 09:57:50 +01002570 snd_hda_codec_cleanup_stream(codec,
2571 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 return 0;
2573}
2574
2575
2576/*
2577 */
2578static struct hda_pcm_stream alc880_pcm_analog_playback = {
2579 .substreams = 1,
2580 .channels_min = 2,
2581 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 .ops = {
2584 .open = alc880_playback_pcm_open,
2585 .prepare = alc880_playback_pcm_prepare,
2586 .cleanup = alc880_playback_pcm_cleanup
2587 },
2588};
2589
2590static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002591 .substreams = 1,
2592 .channels_min = 2,
2593 .channels_max = 2,
2594 /* NID is set in alc_build_pcms */
2595};
2596
2597static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2598 .substreams = 1,
2599 .channels_min = 2,
2600 .channels_max = 2,
2601 /* NID is set in alc_build_pcms */
2602};
2603
2604static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2605 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 .channels_min = 2,
2607 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002610 .prepare = alc880_alt_capture_pcm_prepare,
2611 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 },
2613};
2614
2615static struct hda_pcm_stream alc880_pcm_digital_playback = {
2616 .substreams = 1,
2617 .channels_min = 2,
2618 .channels_max = 2,
2619 /* NID is set in alc_build_pcms */
2620 .ops = {
2621 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002622 .close = alc880_dig_playback_pcm_close,
2623 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002624 },
2625};
2626
2627static struct hda_pcm_stream alc880_pcm_digital_capture = {
2628 .substreams = 1,
2629 .channels_min = 2,
2630 .channels_max = 2,
2631 /* NID is set in alc_build_pcms */
2632};
2633
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002634/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002635static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002636 .substreams = 0,
2637 .channels_min = 0,
2638 .channels_max = 0,
2639};
2640
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641static int alc_build_pcms(struct hda_codec *codec)
2642{
2643 struct alc_spec *spec = codec->spec;
2644 struct hda_pcm *info = spec->pcm_rec;
2645 int i;
2646
2647 codec->num_pcms = 1;
2648 codec->pcm_info = info;
2649
2650 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002651 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002652 if (snd_BUG_ON(!spec->multiout.dac_nids))
2653 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002654 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2655 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2656 }
2657 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002658 if (snd_BUG_ON(!spec->adc_nids))
2659 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002660 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2661 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2662 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663
Takashi Iwai4a471b72005-12-07 13:56:29 +01002664 if (spec->channel_mode) {
2665 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2666 for (i = 0; i < spec->num_channel_mode; i++) {
2667 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2668 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2669 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 }
2671 }
2672
Takashi Iwaie08a0072006-09-07 17:52:14 +02002673 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002675 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002676 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002678 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002679 if (spec->multiout.dig_out_nid &&
2680 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2682 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2683 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002684 if (spec->dig_in_nid &&
2685 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2687 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2688 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002689 /* FIXME: do we need this for all Realtek codec models? */
2690 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691 }
2692
Takashi Iwaie08a0072006-09-07 17:52:14 +02002693 /* If the use of more than one ADC is requested for the current
2694 * model, configure a second analog capture-only PCM.
2695 */
2696 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002697 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2698 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002699 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002700 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002701 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002702 if (spec->alt_dac_nid) {
2703 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2704 *spec->stream_analog_alt_playback;
2705 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2706 spec->alt_dac_nid;
2707 } else {
2708 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2709 alc_pcm_null_stream;
2710 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2711 }
2712 if (spec->num_adc_nids > 1) {
2713 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2714 *spec->stream_analog_alt_capture;
2715 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2716 spec->adc_nids[1];
2717 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2718 spec->num_adc_nids - 1;
2719 } else {
2720 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2721 alc_pcm_null_stream;
2722 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002723 }
2724 }
2725
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 return 0;
2727}
2728
2729static void alc_free(struct hda_codec *codec)
2730{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 struct alc_spec *spec = codec->spec;
2732 unsigned int i;
2733
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002734 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735 return;
2736
2737 if (spec->kctl_alloc) {
2738 for (i = 0; i < spec->num_kctl_used; i++)
2739 kfree(spec->kctl_alloc[i].name);
2740 kfree(spec->kctl_alloc);
2741 }
2742 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002743 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744}
2745
2746/*
2747 */
2748static struct hda_codec_ops alc_patch_ops = {
2749 .build_controls = alc_build_controls,
2750 .build_pcms = alc_build_pcms,
2751 .init = alc_init,
2752 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002753 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002754#ifdef CONFIG_SND_HDA_POWER_SAVE
2755 .check_power_status = alc_check_power_status,
2756#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002757};
2758
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002759
2760/*
2761 * Test configuration for debugging
2762 *
2763 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2764 * enum controls.
2765 */
2766#ifdef CONFIG_SND_DEBUG
2767static hda_nid_t alc880_test_dac_nids[4] = {
2768 0x02, 0x03, 0x04, 0x05
2769};
2770
2771static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002772 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002773 .items = {
2774 { "In-1", 0x0 },
2775 { "In-2", 0x1 },
2776 { "In-3", 0x2 },
2777 { "In-4", 0x3 },
2778 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002779 { "Front", 0x5 },
2780 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002781 },
2782};
2783
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002784static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002785 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002786 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002787 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002788 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002789};
2790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002791static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2792 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002793{
2794 static char *texts[] = {
2795 "N/A", "Line Out", "HP Out",
2796 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2797 };
2798 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2799 uinfo->count = 1;
2800 uinfo->value.enumerated.items = 8;
2801 if (uinfo->value.enumerated.item >= 8)
2802 uinfo->value.enumerated.item = 7;
2803 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2804 return 0;
2805}
2806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002807static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2808 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002809{
2810 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2811 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2812 unsigned int pin_ctl, item = 0;
2813
2814 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2815 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2816 if (pin_ctl & AC_PINCTL_OUT_EN) {
2817 if (pin_ctl & AC_PINCTL_HP_EN)
2818 item = 2;
2819 else
2820 item = 1;
2821 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2822 switch (pin_ctl & AC_PINCTL_VREFEN) {
2823 case AC_PINCTL_VREF_HIZ: item = 3; break;
2824 case AC_PINCTL_VREF_50: item = 4; break;
2825 case AC_PINCTL_VREF_GRD: item = 5; break;
2826 case AC_PINCTL_VREF_80: item = 6; break;
2827 case AC_PINCTL_VREF_100: item = 7; break;
2828 }
2829 }
2830 ucontrol->value.enumerated.item[0] = item;
2831 return 0;
2832}
2833
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002834static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2835 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002836{
2837 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2838 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2839 static unsigned int ctls[] = {
2840 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2841 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2842 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2843 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2844 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2845 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2846 };
2847 unsigned int old_ctl, new_ctl;
2848
2849 old_ctl = snd_hda_codec_read(codec, nid, 0,
2850 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2851 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2852 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002853 int val;
2854 snd_hda_codec_write_cache(codec, nid, 0,
2855 AC_VERB_SET_PIN_WIDGET_CONTROL,
2856 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002857 val = ucontrol->value.enumerated.item[0] >= 3 ?
2858 HDA_AMP_MUTE : 0;
2859 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2860 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002861 return 1;
2862 }
2863 return 0;
2864}
2865
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002866static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2867 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002868{
2869 static char *texts[] = {
2870 "Front", "Surround", "CLFE", "Side"
2871 };
2872 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2873 uinfo->count = 1;
2874 uinfo->value.enumerated.items = 4;
2875 if (uinfo->value.enumerated.item >= 4)
2876 uinfo->value.enumerated.item = 3;
2877 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2878 return 0;
2879}
2880
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002881static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2882 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002883{
2884 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2885 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2886 unsigned int sel;
2887
2888 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2889 ucontrol->value.enumerated.item[0] = sel & 3;
2890 return 0;
2891}
2892
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002893static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2894 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002895{
2896 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2897 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2898 unsigned int sel;
2899
2900 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2901 if (ucontrol->value.enumerated.item[0] != sel) {
2902 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002903 snd_hda_codec_write_cache(codec, nid, 0,
2904 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002905 return 1;
2906 }
2907 return 0;
2908}
2909
2910#define PIN_CTL_TEST(xname,nid) { \
2911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2912 .name = xname, \
2913 .info = alc_test_pin_ctl_info, \
2914 .get = alc_test_pin_ctl_get, \
2915 .put = alc_test_pin_ctl_put, \
2916 .private_value = nid \
2917 }
2918
2919#define PIN_SRC_TEST(xname,nid) { \
2920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2921 .name = xname, \
2922 .info = alc_test_pin_src_info, \
2923 .get = alc_test_pin_src_get, \
2924 .put = alc_test_pin_src_put, \
2925 .private_value = nid \
2926 }
2927
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002928static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2930 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2931 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2932 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002933 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2934 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2935 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2936 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002937 PIN_CTL_TEST("Front Pin Mode", 0x14),
2938 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2939 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2940 PIN_CTL_TEST("Side Pin Mode", 0x17),
2941 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2942 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2943 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2944 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2945 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2946 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2947 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2948 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2949 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2950 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2951 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2952 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2953 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2954 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2955 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2956 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002959 {
2960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2961 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002962 .info = alc_ch_mode_info,
2963 .get = alc_ch_mode_get,
2964 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002965 },
2966 { } /* end */
2967};
2968
2969static struct hda_verb alc880_test_init_verbs[] = {
2970 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2973 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2974 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2975 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2976 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2977 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2978 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002979 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2981 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2983 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002984 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002989 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002990 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002994 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002995 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2996 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002997 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003000 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3004 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003005 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003007 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003012 /* Analog input/passthru */
3013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003018 { }
3019};
3020#endif
3021
Linus Torvalds1da177e2005-04-16 15:20:36 -07003022/*
3023 */
3024
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003025static const char *alc880_models[ALC880_MODEL_LAST] = {
3026 [ALC880_3ST] = "3stack",
3027 [ALC880_TCL_S700] = "tcl",
3028 [ALC880_3ST_DIG] = "3stack-digout",
3029 [ALC880_CLEVO] = "clevo",
3030 [ALC880_5ST] = "5stack",
3031 [ALC880_5ST_DIG] = "5stack-digout",
3032 [ALC880_W810] = "w810",
3033 [ALC880_Z71V] = "z71v",
3034 [ALC880_6ST] = "6stack",
3035 [ALC880_6ST_DIG] = "6stack-digout",
3036 [ALC880_ASUS] = "asus",
3037 [ALC880_ASUS_W1V] = "asus-w1v",
3038 [ALC880_ASUS_DIG] = "asus-dig",
3039 [ALC880_ASUS_DIG2] = "asus-dig2",
3040 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003041 [ALC880_UNIWILL_P53] = "uniwill-p53",
3042 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003043 [ALC880_F1734] = "F1734",
3044 [ALC880_LG] = "lg",
3045 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003046 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003047#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003048 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003049#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003050 [ALC880_AUTO] = "auto",
3051};
3052
3053static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003054 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003055 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3056 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3057 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3058 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3059 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3060 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3061 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3062 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003063 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3064 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003065 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3066 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3067 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3068 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3069 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3070 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3071 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3072 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3073 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3074 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003075 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003076 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3077 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3078 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003079 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003080 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003081 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3082 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003083 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3084 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003085 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3086 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3087 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3088 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003089 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3090 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003091 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003092 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003093 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003094 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003095 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3096 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003097 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003098 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003099 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003100 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003101 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003102 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003103 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003104 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003105 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003106 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3107 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003108 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003109 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3110 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3111 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3112 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003113 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3114 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003115 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003116 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003117 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3118 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003119 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3120 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3121 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003122 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3123 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3124 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125 {}
3126};
3127
Takashi Iwai16ded522005-06-10 19:58:24 +02003128/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003129 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003131static struct alc_config_preset alc880_presets[] = {
3132 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003134 .init_verbs = { alc880_volume_init_verbs,
3135 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003137 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3139 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003140 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 .input_mux = &alc880_capture_source,
3142 },
3143 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003145 .init_verbs = { alc880_volume_init_verbs,
3146 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003147 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003148 .dac_nids = alc880_dac_nids,
3149 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003150 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3151 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003152 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003153 .input_mux = &alc880_capture_source,
3154 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003155 [ALC880_TCL_S700] = {
3156 .mixers = { alc880_tcl_s700_mixer },
3157 .init_verbs = { alc880_volume_init_verbs,
3158 alc880_pin_tcl_S700_init_verbs,
3159 alc880_gpio2_init_verbs },
3160 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3161 .dac_nids = alc880_dac_nids,
3162 .hp_nid = 0x03,
3163 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3164 .channel_mode = alc880_2_jack_modes,
3165 .input_mux = &alc880_capture_source,
3166 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003167 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003168 .mixers = { alc880_three_stack_mixer,
3169 alc880_five_stack_mixer},
3170 .init_verbs = { alc880_volume_init_verbs,
3171 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003172 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3173 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003174 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3175 .channel_mode = alc880_fivestack_modes,
3176 .input_mux = &alc880_capture_source,
3177 },
3178 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003179 .mixers = { alc880_three_stack_mixer,
3180 alc880_five_stack_mixer },
3181 .init_verbs = { alc880_volume_init_verbs,
3182 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003183 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3184 .dac_nids = alc880_dac_nids,
3185 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003186 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3187 .channel_mode = alc880_fivestack_modes,
3188 .input_mux = &alc880_capture_source,
3189 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003190 [ALC880_6ST] = {
3191 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003192 .init_verbs = { alc880_volume_init_verbs,
3193 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003194 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3195 .dac_nids = alc880_6st_dac_nids,
3196 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3197 .channel_mode = alc880_sixstack_modes,
3198 .input_mux = &alc880_6stack_capture_source,
3199 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003200 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003201 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003202 .init_verbs = { alc880_volume_init_verbs,
3203 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003204 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3205 .dac_nids = alc880_6st_dac_nids,
3206 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003207 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3208 .channel_mode = alc880_sixstack_modes,
3209 .input_mux = &alc880_6stack_capture_source,
3210 },
3211 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003213 .init_verbs = { alc880_volume_init_verbs,
3214 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003215 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003216 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3217 .dac_nids = alc880_w810_dac_nids,
3218 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003219 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3220 .channel_mode = alc880_w810_modes,
3221 .input_mux = &alc880_capture_source,
3222 },
3223 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003225 .init_verbs = { alc880_volume_init_verbs,
3226 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003227 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3228 .dac_nids = alc880_z71v_dac_nids,
3229 .dig_out_nid = ALC880_DIGOUT_NID,
3230 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003231 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3232 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003233 .input_mux = &alc880_capture_source,
3234 },
3235 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3240 .dac_nids = alc880_f1734_dac_nids,
3241 .hp_nid = 0x02,
3242 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3243 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003244 .input_mux = &alc880_f1734_capture_source,
3245 .unsol_event = alc880_uniwill_p53_unsol_event,
3246 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003247 },
3248 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003249 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003250 .init_verbs = { alc880_volume_init_verbs,
3251 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 alc880_gpio1_init_verbs },
3253 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3254 .dac_nids = alc880_asus_dac_nids,
3255 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3256 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003257 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 .input_mux = &alc880_capture_source,
3259 },
3260 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262 .init_verbs = { alc880_volume_init_verbs,
3263 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264 alc880_gpio1_init_verbs },
3265 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3266 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3269 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003270 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 .input_mux = &alc880_capture_source,
3272 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003273 [ALC880_ASUS_DIG2] = {
3274 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003275 .init_verbs = { alc880_volume_init_verbs,
3276 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003277 alc880_gpio2_init_verbs }, /* use GPIO2 */
3278 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3279 .dac_nids = alc880_asus_dac_nids,
3280 .dig_out_nid = ALC880_DIGOUT_NID,
3281 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3282 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003283 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003284 .input_mux = &alc880_capture_source,
3285 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003286 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003288 .init_verbs = { alc880_volume_init_verbs,
3289 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 alc880_gpio1_init_verbs },
3291 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3292 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003293 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3295 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003296 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003297 .input_mux = &alc880_capture_source,
3298 },
3299 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003300 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003301 .init_verbs = { alc880_volume_init_verbs,
3302 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003303 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3304 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003305 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003306 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3307 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003308 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003309 .input_mux = &alc880_capture_source,
3310 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003311 [ALC880_UNIWILL] = {
3312 .mixers = { alc880_uniwill_mixer },
3313 .init_verbs = { alc880_volume_init_verbs,
3314 alc880_uniwill_init_verbs },
3315 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3316 .dac_nids = alc880_asus_dac_nids,
3317 .dig_out_nid = ALC880_DIGOUT_NID,
3318 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3319 .channel_mode = alc880_threestack_modes,
3320 .need_dac_fix = 1,
3321 .input_mux = &alc880_capture_source,
3322 .unsol_event = alc880_uniwill_unsol_event,
3323 .init_hook = alc880_uniwill_automute,
3324 },
3325 [ALC880_UNIWILL_P53] = {
3326 .mixers = { alc880_uniwill_p53_mixer },
3327 .init_verbs = { alc880_volume_init_verbs,
3328 alc880_uniwill_p53_init_verbs },
3329 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3330 .dac_nids = alc880_asus_dac_nids,
3331 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003332 .channel_mode = alc880_threestack_modes,
3333 .input_mux = &alc880_capture_source,
3334 .unsol_event = alc880_uniwill_p53_unsol_event,
3335 .init_hook = alc880_uniwill_p53_hp_automute,
3336 },
3337 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003338 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003339 alc880_pcbeep_mixer, },
3340 .init_verbs = { alc880_volume_init_verbs,
3341 alc880_uniwill_p53_init_verbs,
3342 alc880_beep_init_verbs },
3343 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3344 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003345 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003346 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3347 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003348 .input_mux = &alc880_capture_source,
3349 .unsol_event = alc880_uniwill_p53_unsol_event,
3350 .init_hook = alc880_uniwill_p53_hp_automute,
3351 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003352 [ALC880_CLEVO] = {
3353 .mixers = { alc880_three_stack_mixer },
3354 .init_verbs = { alc880_volume_init_verbs,
3355 alc880_pin_clevo_init_verbs },
3356 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3357 .dac_nids = alc880_dac_nids,
3358 .hp_nid = 0x03,
3359 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3360 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003361 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003362 .input_mux = &alc880_capture_source,
3363 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003364 [ALC880_LG] = {
3365 .mixers = { alc880_lg_mixer },
3366 .init_verbs = { alc880_volume_init_verbs,
3367 alc880_lg_init_verbs },
3368 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3369 .dac_nids = alc880_lg_dac_nids,
3370 .dig_out_nid = ALC880_DIGOUT_NID,
3371 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3372 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003373 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003374 .input_mux = &alc880_lg_capture_source,
3375 .unsol_event = alc880_lg_unsol_event,
3376 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003377#ifdef CONFIG_SND_HDA_POWER_SAVE
3378 .loopbacks = alc880_lg_loopbacks,
3379#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003380 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003381 [ALC880_LG_LW] = {
3382 .mixers = { alc880_lg_lw_mixer },
3383 .init_verbs = { alc880_volume_init_verbs,
3384 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003385 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003386 .dac_nids = alc880_dac_nids,
3387 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003388 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3389 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003390 .input_mux = &alc880_lg_lw_capture_source,
3391 .unsol_event = alc880_lg_lw_unsol_event,
3392 .init_hook = alc880_lg_lw_automute,
3393 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003394 [ALC880_MEDION_RIM] = {
3395 .mixers = { alc880_medion_rim_mixer },
3396 .init_verbs = { alc880_volume_init_verbs,
3397 alc880_medion_rim_init_verbs,
3398 alc_gpio2_init_verbs },
3399 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3400 .dac_nids = alc880_dac_nids,
3401 .dig_out_nid = ALC880_DIGOUT_NID,
3402 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3403 .channel_mode = alc880_2_jack_modes,
3404 .input_mux = &alc880_medion_rim_capture_source,
3405 .unsol_event = alc880_medion_rim_unsol_event,
3406 .init_hook = alc880_medion_rim_automute,
3407 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003408#ifdef CONFIG_SND_DEBUG
3409 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410 .mixers = { alc880_test_mixer },
3411 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003412 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3413 .dac_nids = alc880_test_dac_nids,
3414 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003415 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3416 .channel_mode = alc880_test_modes,
3417 .input_mux = &alc880_test_capture_source,
3418 },
3419#endif
3420};
3421
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003422/*
3423 * Automatic parse of I/O pins from the BIOS configuration
3424 */
3425
3426#define NUM_CONTROL_ALLOC 32
3427#define NUM_VERB_ALLOC 32
3428
3429enum {
3430 ALC_CTL_WIDGET_VOL,
3431 ALC_CTL_WIDGET_MUTE,
3432 ALC_CTL_BIND_MUTE,
3433};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003434static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003435 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3436 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003437 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438};
3439
3440/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441static int add_control(struct alc_spec *spec, int type, const char *name,
3442 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003443{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003444 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003445
3446 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3447 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003449 /* array + terminator */
3450 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3451 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452 return -ENOMEM;
3453 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003454 memcpy(knew, spec->kctl_alloc,
3455 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 kfree(spec->kctl_alloc);
3457 }
3458 spec->kctl_alloc = knew;
3459 spec->num_kctl_alloc = num;
3460 }
3461
3462 knew = &spec->kctl_alloc[spec->num_kctl_used];
3463 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003464 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003465 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003466 return -ENOMEM;
3467 knew->private_value = val;
3468 spec->num_kctl_used++;
3469 return 0;
3470}
3471
3472#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3473#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3474#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3475#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3476#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3477#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3478#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3479#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3480#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3481#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3482#define ALC880_PIN_CD_NID 0x1c
3483
3484/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003485static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3486 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003487{
3488 hda_nid_t nid;
3489 int assigned[4];
3490 int i, j;
3491
3492 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003493 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003494
3495 /* check the pins hardwired to audio widget */
3496 for (i = 0; i < cfg->line_outs; i++) {
3497 nid = cfg->line_out_pins[i];
3498 if (alc880_is_fixed_pin(nid)) {
3499 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003500 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 assigned[idx] = 1;
3502 }
3503 }
3504 /* left pins can be connect to any audio widget */
3505 for (i = 0; i < cfg->line_outs; i++) {
3506 nid = cfg->line_out_pins[i];
3507 if (alc880_is_fixed_pin(nid))
3508 continue;
3509 /* search for an empty channel */
3510 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003511 if (!assigned[j]) {
3512 spec->multiout.dac_nids[i] =
3513 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003514 assigned[j] = 1;
3515 break;
3516 }
3517 }
3518 }
3519 spec->multiout.num_dacs = cfg->line_outs;
3520 return 0;
3521}
3522
3523/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003524static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3525 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003526{
3527 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 static const char *chname[4] = {
3529 "Front", "Surround", NULL /*CLFE*/, "Side"
3530 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 hda_nid_t nid;
3532 int i, err;
3533
3534 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003535 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003536 continue;
3537 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3538 if (i == 2) {
3539 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003540 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3541 "Center Playback Volume",
3542 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3543 HDA_OUTPUT));
3544 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003546 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3547 "LFE Playback Volume",
3548 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3549 HDA_OUTPUT));
3550 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003552 err = add_control(spec, ALC_CTL_BIND_MUTE,
3553 "Center Playback Switch",
3554 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3555 HDA_INPUT));
3556 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003558 err = add_control(spec, ALC_CTL_BIND_MUTE,
3559 "LFE Playback Switch",
3560 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3561 HDA_INPUT));
3562 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563 return err;
3564 } else {
3565 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003566 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3567 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3568 HDA_OUTPUT));
3569 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570 return err;
3571 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003572 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3573 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3574 HDA_INPUT));
3575 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003576 return err;
3577 }
3578 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579 return 0;
3580}
3581
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003582/* add playback controls for speaker and HP outputs */
3583static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3584 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585{
3586 hda_nid_t nid;
3587 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003588 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003591 return 0;
3592
3593 if (alc880_is_fixed_pin(pin)) {
3594 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003595 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003596 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003598 else
3599 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 /* control HP volume/switch on the output mixer amp */
3601 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003602 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003603 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3604 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3605 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003606 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003607 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003608 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3609 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003611 return err;
3612 } else if (alc880_is_multi_pin(pin)) {
3613 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003614 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003615 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003616 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3617 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3618 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003619 return err;
3620 }
3621 return 0;
3622}
3623
3624/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003625static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3626 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003627 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003628{
3629 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003630 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003631
3632 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003633 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3634 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3635 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003636 return err;
3637 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003638 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3639 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3640 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003641 return err;
3642 return 0;
3643}
3644
3645/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003646static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3647 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003648{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003649 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003650 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003651
3652 for (i = 0; i < AUTO_PIN_LAST; i++) {
3653 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003654 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003655 err = new_analog_input(spec, cfg->input_pins[i],
3656 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003657 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003658 if (err < 0)
3659 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003660 imux->items[imux->num_items].label =
3661 auto_pin_cfg_labels[i];
3662 imux->items[imux->num_items].index =
3663 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003664 imux->num_items++;
3665 }
3666 }
3667 return 0;
3668}
3669
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003670static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3671 unsigned int pin_type)
3672{
3673 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3674 pin_type);
3675 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003676 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3677 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003678}
3679
Kailang Yangdf694da2005-12-05 19:42:22 +01003680static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3681 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003682 int dac_idx)
3683{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003684 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003685 /* need the manual connection? */
3686 if (alc880_is_multi_pin(nid)) {
3687 struct alc_spec *spec = codec->spec;
3688 int idx = alc880_multi_pin_idx(nid);
3689 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3690 AC_VERB_SET_CONNECT_SEL,
3691 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3692 }
3693}
3694
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003695static int get_pin_type(int line_out_type)
3696{
3697 if (line_out_type == AUTO_PIN_HP_OUT)
3698 return PIN_HP;
3699 else
3700 return PIN_OUT;
3701}
3702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703static void alc880_auto_init_multi_out(struct hda_codec *codec)
3704{
3705 struct alc_spec *spec = codec->spec;
3706 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003707
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003708 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709 for (i = 0; i < spec->autocfg.line_outs; i++) {
3710 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003711 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3712 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003713 }
3714}
3715
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003716static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717{
3718 struct alc_spec *spec = codec->spec;
3719 hda_nid_t pin;
3720
Takashi Iwai82bc9552006-03-21 11:24:42 +01003721 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003722 if (pin) /* connect to front */
3723 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003724 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 if (pin) /* connect to front */
3726 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3727}
3728
3729static void alc880_auto_init_analog_input(struct hda_codec *codec)
3730{
3731 struct alc_spec *spec = codec->spec;
3732 int i;
3733
3734 for (i = 0; i < AUTO_PIN_LAST; i++) {
3735 hda_nid_t nid = spec->autocfg.input_pins[i];
3736 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 snd_hda_codec_write(codec, nid, 0,
3738 AC_VERB_SET_PIN_WIDGET_CONTROL,
3739 i <= AUTO_PIN_FRONT_MIC ?
3740 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003741 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003742 snd_hda_codec_write(codec, nid, 0,
3743 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 AMP_OUT_MUTE);
3745 }
3746 }
3747}
3748
3749/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003750/* return 1 if successful, 0 if the proper config is not found,
3751 * or a negative error code
3752 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753static int alc880_parse_auto_config(struct hda_codec *codec)
3754{
3755 struct alc_spec *spec = codec->spec;
3756 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003757 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003759 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3760 alc880_ignore);
3761 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003763 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003764 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003765
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003766 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3767 if (err < 0)
3768 return err;
3769 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3770 if (err < 0)
3771 return err;
3772 err = alc880_auto_create_extra_out(spec,
3773 spec->autocfg.speaker_pins[0],
3774 "Speaker");
3775 if (err < 0)
3776 return err;
3777 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3778 "Headphone");
3779 if (err < 0)
3780 return err;
3781 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3782 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003783 return err;
3784
3785 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3786
3787 if (spec->autocfg.dig_out_pin)
3788 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3789 if (spec->autocfg.dig_in_pin)
3790 spec->dig_in_nid = ALC880_DIGIN_NID;
3791
3792 if (spec->kctl_alloc)
3793 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3794
3795 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3796
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003797 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 spec->input_mux = &spec->private_imux;
3799
3800 return 1;
3801}
3802
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003803/* additional initialization for auto-configuration model */
3804static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003806 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003808 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003810 if (spec->unsol_event)
3811 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812}
3813
3814/*
3815 * OK, here we have finally the patch for ALC880
3816 */
3817
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818static int patch_alc880(struct hda_codec *codec)
3819{
3820 struct alc_spec *spec;
3821 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003822 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003823
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003824 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003825 if (spec == NULL)
3826 return -ENOMEM;
3827
3828 codec->spec = spec;
3829
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003830 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3831 alc880_models,
3832 alc880_cfg_tbl);
3833 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003834 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3835 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003836 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003837 }
3838
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003839 if (board_config == ALC880_AUTO) {
3840 /* automatic parse from the BIOS config */
3841 err = alc880_parse_auto_config(codec);
3842 if (err < 0) {
3843 alc_free(codec);
3844 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003845 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003846 printk(KERN_INFO
3847 "hda_codec: Cannot set up configuration "
3848 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 board_config = ALC880_3ST;
3850 }
3851 }
3852
Kailang Yangdf694da2005-12-05 19:42:22 +01003853 if (board_config != ALC880_AUTO)
3854 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003855
3856 spec->stream_name_analog = "ALC880 Analog";
3857 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3858 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003859 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003860
3861 spec->stream_name_digital = "ALC880 Digital";
3862 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3863 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3864
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003865 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003866 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003867 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003868 /* get type */
3869 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003870 if (wcap != AC_WID_AUD_IN) {
3871 spec->adc_nids = alc880_adc_nids_alt;
3872 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003873 spec->mixers[spec->num_mixers] =
3874 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003875 spec->num_mixers++;
3876 } else {
3877 spec->adc_nids = alc880_adc_nids;
3878 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3879 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3880 spec->num_mixers++;
3881 }
3882 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883
Takashi Iwai2134ea42008-01-10 16:53:55 +01003884 spec->vmaster_nid = 0x0c;
3885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003887 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003888 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003889#ifdef CONFIG_SND_HDA_POWER_SAVE
3890 if (!spec->loopback.amplist)
3891 spec->loopback.amplist = alc880_loopbacks;
3892#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003893
3894 return 0;
3895}
3896
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003897
Linus Torvalds1da177e2005-04-16 15:20:36 -07003898/*
3899 * ALC260 support
3900 */
3901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003902static hda_nid_t alc260_dac_nids[1] = {
3903 /* front */
3904 0x02,
3905};
3906
3907static hda_nid_t alc260_adc_nids[1] = {
3908 /* ADC0 */
3909 0x04,
3910};
3911
Kailang Yangdf694da2005-12-05 19:42:22 +01003912static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003913 /* ADC1 */
3914 0x05,
3915};
3916
Kailang Yangdf694da2005-12-05 19:42:22 +01003917static hda_nid_t alc260_hp_adc_nids[2] = {
3918 /* ADC1, 0 */
3919 0x05, 0x04
3920};
3921
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003922/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3923 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3924 */
3925static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003926 /* ADC0, ADC1 */
3927 0x04, 0x05
3928};
3929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003930#define ALC260_DIGOUT_NID 0x03
3931#define ALC260_DIGIN_NID 0x06
3932
3933static struct hda_input_mux alc260_capture_source = {
3934 .num_items = 4,
3935 .items = {
3936 { "Mic", 0x0 },
3937 { "Front Mic", 0x1 },
3938 { "Line", 0x2 },
3939 { "CD", 0x4 },
3940 },
3941};
3942
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003943/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003944 * headphone jack and the internal CD lines since these are the only pins at
3945 * which audio can appear. For flexibility, also allow the option of
3946 * recording the mixer output on the second ADC (ADC0 doesn't have a
3947 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003948 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003949static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3950 {
3951 .num_items = 3,
3952 .items = {
3953 { "Mic/Line", 0x0 },
3954 { "CD", 0x4 },
3955 { "Headphone", 0x2 },
3956 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003957 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003958 {
3959 .num_items = 4,
3960 .items = {
3961 { "Mic/Line", 0x0 },
3962 { "CD", 0x4 },
3963 { "Headphone", 0x2 },
3964 { "Mixer", 0x5 },
3965 },
3966 },
3967
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003968};
3969
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003970/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3971 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003972 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003973static struct hda_input_mux alc260_acer_capture_sources[2] = {
3974 {
3975 .num_items = 4,
3976 .items = {
3977 { "Mic", 0x0 },
3978 { "Line", 0x2 },
3979 { "CD", 0x4 },
3980 { "Headphone", 0x5 },
3981 },
3982 },
3983 {
3984 .num_items = 5,
3985 .items = {
3986 { "Mic", 0x0 },
3987 { "Line", 0x2 },
3988 { "CD", 0x4 },
3989 { "Headphone", 0x6 },
3990 { "Mixer", 0x5 },
3991 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003992 },
3993};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003994/*
3995 * This is just place-holder, so there's something for alc_build_pcms to look
3996 * at when it calculates the maximum number of channels. ALC260 has no mixer
3997 * element which allows changing the channel mode, so the verb list is
3998 * never used.
3999 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004000static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004001 { 2, NULL },
4002};
4003
Kailang Yangdf694da2005-12-05 19:42:22 +01004004
4005/* Mixer combinations
4006 *
4007 * basic: base_output + input + pc_beep + capture
4008 * HP: base_output + input + capture_alt
4009 * HP_3013: hp_3013 + input + capture
4010 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004011 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004012 */
4013
4014static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004015 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004016 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004017 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4018 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4019 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4020 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4021 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004022};
Kailang Yangdf694da2005-12-05 19:42:22 +01004023
4024static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4027 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4028 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4030 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004033 { } /* end */
4034};
4035
Kailang Yangdf694da2005-12-05 19:42:22 +01004036static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4037 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4038 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4039 { } /* end */
4040};
4041
Takashi Iwaibec15c32008-01-28 18:16:30 +01004042/* update HP, line and mono out pins according to the master switch */
4043static void alc260_hp_master_update(struct hda_codec *codec,
4044 hda_nid_t hp, hda_nid_t line,
4045 hda_nid_t mono)
4046{
4047 struct alc_spec *spec = codec->spec;
4048 unsigned int val = spec->master_sw ? PIN_HP : 0;
4049 /* change HP and line-out pins */
4050 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4051 val);
4052 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4053 val);
4054 /* mono (speaker) depending on the HP jack sense */
4055 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4056 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4057 val);
4058}
4059
4060static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4061 struct snd_ctl_elem_value *ucontrol)
4062{
4063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4064 struct alc_spec *spec = codec->spec;
4065 *ucontrol->value.integer.value = spec->master_sw;
4066 return 0;
4067}
4068
4069static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4070 struct snd_ctl_elem_value *ucontrol)
4071{
4072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4073 struct alc_spec *spec = codec->spec;
4074 int val = !!*ucontrol->value.integer.value;
4075 hda_nid_t hp, line, mono;
4076
4077 if (val == spec->master_sw)
4078 return 0;
4079 spec->master_sw = val;
4080 hp = (kcontrol->private_value >> 16) & 0xff;
4081 line = (kcontrol->private_value >> 8) & 0xff;
4082 mono = kcontrol->private_value & 0xff;
4083 alc260_hp_master_update(codec, hp, line, mono);
4084 return 1;
4085}
4086
4087static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4088 {
4089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4090 .name = "Master Playback Switch",
4091 .info = snd_ctl_boolean_mono_info,
4092 .get = alc260_hp_master_sw_get,
4093 .put = alc260_hp_master_sw_put,
4094 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4095 },
4096 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4097 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4099 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4100 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4101 HDA_OUTPUT),
4102 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4103 { } /* end */
4104};
4105
4106static struct hda_verb alc260_hp_unsol_verbs[] = {
4107 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4108 {},
4109};
4110
4111static void alc260_hp_automute(struct hda_codec *codec)
4112{
4113 struct alc_spec *spec = codec->spec;
4114 unsigned int present;
4115
4116 present = snd_hda_codec_read(codec, 0x10, 0,
4117 AC_VERB_GET_PIN_SENSE, 0);
4118 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4119 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4120}
4121
4122static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4123{
4124 if ((res >> 26) == ALC880_HP_EVENT)
4125 alc260_hp_automute(codec);
4126}
4127
Kailang Yangdf694da2005-12-05 19:42:22 +01004128static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004129 {
4130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4131 .name = "Master Playback Switch",
4132 .info = snd_ctl_boolean_mono_info,
4133 .get = alc260_hp_master_sw_get,
4134 .put = alc260_hp_master_sw_put,
4135 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4136 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004137 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4138 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4139 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4140 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4141 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004143 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4144 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 { } /* end */
4146};
4147
Kailang Yang3f878302008-08-26 13:02:23 +02004148static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4149 .ops = &snd_hda_bind_vol,
4150 .values = {
4151 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4152 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4153 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4154 0
4155 },
4156};
4157
4158static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4159 .ops = &snd_hda_bind_sw,
4160 .values = {
4161 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4162 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4163 0
4164 },
4165};
4166
4167static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4168 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4169 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4170 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4172 { } /* end */
4173};
4174
Takashi Iwaibec15c32008-01-28 18:16:30 +01004175static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4176 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4177 {},
4178};
4179
4180static void alc260_hp_3013_automute(struct hda_codec *codec)
4181{
4182 struct alc_spec *spec = codec->spec;
4183 unsigned int present;
4184
4185 present = snd_hda_codec_read(codec, 0x15, 0,
4186 AC_VERB_GET_PIN_SENSE, 0);
4187 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4188 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4189}
4190
4191static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4192 unsigned int res)
4193{
4194 if ((res >> 26) == ALC880_HP_EVENT)
4195 alc260_hp_3013_automute(codec);
4196}
4197
Kailang Yang3f878302008-08-26 13:02:23 +02004198static void alc260_hp_3012_automute(struct hda_codec *codec)
4199{
4200 unsigned int present, bits;
4201
4202 present = snd_hda_codec_read(codec, 0x10, 0,
4203 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4204
4205 bits = present ? 0 : PIN_OUT;
4206 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4207 bits);
4208 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4209 bits);
4210 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4211 bits);
4212}
4213
4214static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4215 unsigned int res)
4216{
4217 if ((res >> 26) == ALC880_HP_EVENT)
4218 alc260_hp_3012_automute(codec);
4219}
4220
4221/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004222 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4223 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004224static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004226 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004227 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004228 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4229 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4230 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4231 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004232 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004233 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4234 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004235 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4236 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004237 { } /* end */
4238};
4239
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004240/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4241 * versions of the ALC260 don't act on requests to enable mic bias from NID
4242 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4243 * datasheet doesn't mention this restriction. At this stage it's not clear
4244 * whether this behaviour is intentional or is a hardware bug in chip
4245 * revisions available in early 2006. Therefore for now allow the
4246 * "Headphone Jack Mode" control to span all choices, but if it turns out
4247 * that the lack of mic bias for this NID is intentional we could change the
4248 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4249 *
4250 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4251 * don't appear to make the mic bias available from the "line" jack, even
4252 * though the NID used for this jack (0x14) can supply it. The theory is
4253 * that perhaps Acer have included blocking capacitors between the ALC260
4254 * and the output jack. If this turns out to be the case for all such
4255 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4256 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004257 *
4258 * The C20x Tablet series have a mono internal speaker which is controlled
4259 * via the chip's Mono sum widget and pin complex, so include the necessary
4260 * controls for such models. On models without a "mono speaker" the control
4261 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004262 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004263static struct snd_kcontrol_new alc260_acer_mixer[] = {
4264 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4265 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004266 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004267 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004268 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004269 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004270 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004271 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4272 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4274 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4275 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4276 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4277 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4278 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4279 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4280 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4281 { } /* end */
4282};
4283
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004284/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4285 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4286 */
4287static struct snd_kcontrol_new alc260_will_mixer[] = {
4288 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4289 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4291 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4292 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4293 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4294 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4295 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4296 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4297 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4298 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4299 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4300 { } /* end */
4301};
4302
4303/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4304 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4305 */
4306static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4307 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4308 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4310 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4311 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4312 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4313 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4314 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4315 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4316 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4317 { } /* end */
4318};
4319
Kailang Yangdf694da2005-12-05 19:42:22 +01004320/* capture mixer elements */
4321static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004322 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4323 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4325 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004326 {
4327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004328 /* The multiple "Capture Source" controls confuse alsamixer
4329 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004330 */
4331 /* .name = "Capture Source", */
4332 .name = "Input Source",
4333 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004334 .info = alc_mux_enum_info,
4335 .get = alc_mux_enum_get,
4336 .put = alc_mux_enum_put,
4337 },
4338 { } /* end */
4339};
4340
Kailang Yangdf694da2005-12-05 19:42:22 +01004341static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4342 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4343 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4344 {
4345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4346 /* The multiple "Capture Source" controls confuse alsamixer
4347 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 */
4349 /* .name = "Capture Source", */
4350 .name = "Input Source",
4351 .count = 1,
4352 .info = alc_mux_enum_info,
4353 .get = alc_mux_enum_get,
4354 .put = alc_mux_enum_put,
4355 },
4356 { } /* end */
4357};
4358
4359/*
4360 * initialization verbs
4361 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004362static struct hda_verb alc260_init_verbs[] = {
4363 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004366 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004367 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004368 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004369 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004370 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004373 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004374 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004375 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004376 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004377 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004378 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004379 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004380 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4381 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004383 /* set connection select to line in (default select for this ADC) */
4384 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004385 /* mute capture amp left and right */
4386 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4387 /* set connection select to line in (default select for this ADC) */
4388 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004389 /* set vol=0 Line-Out mixer amp left and right */
4390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4391 /* unmute pin widget amp left and right (no gain on this amp) */
4392 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4393 /* set vol=0 HP mixer amp left and right */
4394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4395 /* unmute pin widget amp left and right (no gain on this amp) */
4396 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4397 /* set vol=0 Mono mixer amp left and right */
4398 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4399 /* unmute pin widget amp left and right (no gain on this amp) */
4400 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4401 /* unmute LINE-2 out pin */
4402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004403 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4404 * Line In 2 = 0x03
4405 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004406 /* mute analog inputs */
4407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004412 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004413 /* mute Front out path */
4414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4416 /* mute Headphone out path */
4417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4419 /* mute Mono out path */
4420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004422 { }
4423};
4424
Takashi Iwai474167d2006-05-17 17:17:43 +02004425#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004426static struct hda_verb alc260_hp_init_verbs[] = {
4427 /* Headphone and output */
4428 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4429 /* mono output */
4430 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4431 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4432 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4433 /* Mic2 (front panel) pin widget for input and vref at 80% */
4434 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4435 /* Line In pin widget for input */
4436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4437 /* Line-2 pin widget for output */
4438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4439 /* CD pin widget for input */
4440 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4441 /* unmute amp left and right */
4442 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4443 /* set connection select to line in (default select for this ADC) */
4444 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4445 /* unmute Line-Out mixer amp left and right (volume = 0) */
4446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4447 /* mute pin widget amp left and right (no gain on this amp) */
4448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4449 /* unmute HP mixer amp left and right (volume = 0) */
4450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4451 /* mute pin widget amp left and right (no gain on this amp) */
4452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004453 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4454 * Line In 2 = 0x03
4455 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004456 /* mute analog inputs */
4457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004462 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4463 /* Unmute Front out path */
4464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4466 /* Unmute Headphone out path */
4467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4469 /* Unmute Mono out path */
4470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4472 { }
4473};
Takashi Iwai474167d2006-05-17 17:17:43 +02004474#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004475
4476static struct hda_verb alc260_hp_3013_init_verbs[] = {
4477 /* Line out and output */
4478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4479 /* mono output */
4480 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4481 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4483 /* Mic2 (front panel) pin widget for input and vref at 80% */
4484 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4485 /* Line In pin widget for input */
4486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4487 /* Headphone pin widget for output */
4488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4489 /* CD pin widget for input */
4490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4491 /* unmute amp left and right */
4492 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4493 /* set connection select to line in (default select for this ADC) */
4494 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4495 /* unmute Line-Out mixer amp left and right (volume = 0) */
4496 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4497 /* mute pin widget amp left and right (no gain on this amp) */
4498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4499 /* unmute HP mixer amp left and right (volume = 0) */
4500 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4501 /* mute pin widget amp left and right (no gain on this amp) */
4502 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004503 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4504 * Line In 2 = 0x03
4505 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004506 /* mute analog inputs */
4507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004512 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4513 /* Unmute Front out path */
4514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4516 /* Unmute Headphone out path */
4517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4519 /* Unmute Mono out path */
4520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4521 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4522 { }
4523};
4524
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004525/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004526 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4527 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004528 */
4529static struct hda_verb alc260_fujitsu_init_verbs[] = {
4530 /* Disable all GPIOs */
4531 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4532 /* Internal speaker is connected to headphone pin */
4533 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4534 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004536 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4537 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4538 /* Ensure all other unused pins are disabled and muted. */
4539 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004541 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004542 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004543 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004544 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004547
Jonathan Woithef7ace402006-02-28 11:46:14 +01004548 /* Disable digital (SPDIF) pins */
4549 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4550 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004551
Kailang Yangea1fb292008-08-26 12:58:38 +02004552 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004553 * when acting as an output.
4554 */
4555 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4556
4557 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4559 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4564 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4565 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4566 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004567
Jonathan Woithef7ace402006-02-28 11:46:14 +01004568 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4569 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4570 /* Unmute Line1 pin widget output buffer since it starts as an output.
4571 * If the pin mode is changed by the user the pin mode control will
4572 * take care of enabling the pin's input/output buffers as needed.
4573 * Therefore there's no need to enable the input buffer at this
4574 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004575 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004577 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004578 * mixer ctrl)
4579 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004580 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004581
Jonathan Woithef7ace402006-02-28 11:46:14 +01004582 /* Mute capture amp left and right */
4583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004584 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004585 * in (on mic1 pin)
4586 */
4587 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004588
Jonathan Woithef7ace402006-02-28 11:46:14 +01004589 /* Do the same for the second ADC: mute capture input amp and
4590 * set ADC connection to line in (on mic1 pin)
4591 */
4592 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4593 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004594
Jonathan Woithef7ace402006-02-28 11:46:14 +01004595 /* Mute all inputs to mixer widget (even unconnected ones) */
4596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004604
4605 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004606};
4607
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004608/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4609 * similar laptops (adapted from Fujitsu init verbs).
4610 */
4611static struct hda_verb alc260_acer_init_verbs[] = {
4612 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4613 * the headphone jack. Turn this on and rely on the standard mute
4614 * methods whenever the user wants to turn these outputs off.
4615 */
4616 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4617 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4618 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4619 /* Internal speaker/Headphone jack is connected to Line-out pin */
4620 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4621 /* Internal microphone/Mic jack is connected to Mic1 pin */
4622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4623 /* Line In jack is connected to Line1 pin */
4624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004625 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4626 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004627 /* Ensure all other unused pins are disabled and muted. */
4628 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4629 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004630 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4631 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4634 /* Disable digital (SPDIF) pins */
4635 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4636 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4637
Kailang Yangea1fb292008-08-26 12:58:38 +02004638 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004639 * bus when acting as outputs.
4640 */
4641 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4642 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4643
4644 /* Start with output sum widgets muted and their output gains at min */
4645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4650 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4651 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4653 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4654
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655 /* Unmute Line-out pin widget amp left and right
4656 * (no equiv mixer ctrl)
4657 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004659 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4660 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004661 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4662 * inputs. If the pin mode is changed by the user the pin mode control
4663 * will take care of enabling the pin's input/output buffers as needed.
4664 * Therefore there's no need to enable the input buffer at this
4665 * stage.
4666 */
4667 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4669
4670 /* Mute capture amp left and right */
4671 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4672 /* Set ADC connection select to match default mixer setting - mic
4673 * (on mic1 pin)
4674 */
4675 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4676
4677 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004678 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004679 */
4680 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004681 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004682
4683 /* Mute all inputs to mixer widget (even unconnected ones) */
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4692
4693 { }
4694};
4695
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004696static struct hda_verb alc260_will_verbs[] = {
4697 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4698 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4699 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4700 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4701 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4702 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4703 {}
4704};
4705
4706static struct hda_verb alc260_replacer_672v_verbs[] = {
4707 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4708 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4709 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4710
4711 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4712 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4713 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4714
4715 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4716 {}
4717};
4718
4719/* toggle speaker-output according to the hp-jack state */
4720static void alc260_replacer_672v_automute(struct hda_codec *codec)
4721{
4722 unsigned int present;
4723
4724 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4725 present = snd_hda_codec_read(codec, 0x0f, 0,
4726 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4727 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004728 snd_hda_codec_write_cache(codec, 0x01, 0,
4729 AC_VERB_SET_GPIO_DATA, 1);
4730 snd_hda_codec_write_cache(codec, 0x0f, 0,
4731 AC_VERB_SET_PIN_WIDGET_CONTROL,
4732 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004733 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004734 snd_hda_codec_write_cache(codec, 0x01, 0,
4735 AC_VERB_SET_GPIO_DATA, 0);
4736 snd_hda_codec_write_cache(codec, 0x0f, 0,
4737 AC_VERB_SET_PIN_WIDGET_CONTROL,
4738 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004739 }
4740}
4741
4742static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4743 unsigned int res)
4744{
4745 if ((res >> 26) == ALC880_HP_EVENT)
4746 alc260_replacer_672v_automute(codec);
4747}
4748
Kailang Yang3f878302008-08-26 13:02:23 +02004749static struct hda_verb alc260_hp_dc7600_verbs[] = {
4750 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4751 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4752 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4753 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4754 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4756 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4757 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4758 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4759 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4760 {}
4761};
4762
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004763/* Test configuration for debugging, modelled after the ALC880 test
4764 * configuration.
4765 */
4766#ifdef CONFIG_SND_DEBUG
4767static hda_nid_t alc260_test_dac_nids[1] = {
4768 0x02,
4769};
4770static hda_nid_t alc260_test_adc_nids[2] = {
4771 0x04, 0x05,
4772};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004773/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004774 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004775 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004776 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004777static struct hda_input_mux alc260_test_capture_sources[2] = {
4778 {
4779 .num_items = 7,
4780 .items = {
4781 { "MIC1 pin", 0x0 },
4782 { "MIC2 pin", 0x1 },
4783 { "LINE1 pin", 0x2 },
4784 { "LINE2 pin", 0x3 },
4785 { "CD pin", 0x4 },
4786 { "LINE-OUT pin", 0x5 },
4787 { "HP-OUT pin", 0x6 },
4788 },
4789 },
4790 {
4791 .num_items = 8,
4792 .items = {
4793 { "MIC1 pin", 0x0 },
4794 { "MIC2 pin", 0x1 },
4795 { "LINE1 pin", 0x2 },
4796 { "LINE2 pin", 0x3 },
4797 { "CD pin", 0x4 },
4798 { "Mixer", 0x5 },
4799 { "LINE-OUT pin", 0x6 },
4800 { "HP-OUT pin", 0x7 },
4801 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004802 },
4803};
4804static struct snd_kcontrol_new alc260_test_mixer[] = {
4805 /* Output driver widgets */
4806 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4807 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4808 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4809 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4810 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4811 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4812
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004813 /* Modes for retasking pin widgets
4814 * Note: the ALC260 doesn't seem to act on requests to enable mic
4815 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4816 * mention this restriction. At this stage it's not clear whether
4817 * this behaviour is intentional or is a hardware bug in chip
4818 * revisions available at least up until early 2006. Therefore for
4819 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4820 * choices, but if it turns out that the lack of mic bias for these
4821 * NIDs is intentional we could change their modes from
4822 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4823 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004824 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4825 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4826 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4827 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4828 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4829 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4830
4831 /* Loopback mixer controls */
4832 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4833 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4834 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4835 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4836 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4837 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4838 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4839 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4840 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4841 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4842 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4843 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4844 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4845 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4846 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4847 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004848
4849 /* Controls for GPIO pins, assuming they are configured as outputs */
4850 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4851 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4852 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4853 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4854
Jonathan Woithe92621f12006-02-28 11:47:47 +01004855 /* Switches to allow the digital IO pins to be enabled. The datasheet
4856 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004857 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004858 */
4859 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4860 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4861
Jonathan Woithef8225f62008-01-08 12:16:54 +01004862 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4863 * this output to turn on an external amplifier.
4864 */
4865 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4866 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4867
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004868 { } /* end */
4869};
4870static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004871 /* Enable all GPIOs as outputs with an initial value of 0 */
4872 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4873 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4874 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4875
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004876 /* Enable retasking pins as output, initially without power amp */
4877 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4878 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4881 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4882 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4883
Jonathan Woithe92621f12006-02-28 11:47:47 +01004884 /* Disable digital (SPDIF) pins initially, but users can enable
4885 * them via a mixer switch. In the case of SPDIF-out, this initverb
4886 * payload also sets the generation to 0, output to be in "consumer"
4887 * PCM format, copyright asserted, no pre-emphasis and no validity
4888 * control.
4889 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004890 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4891 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4892
Kailang Yangea1fb292008-08-26 12:58:38 +02004893 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004894 * OUT1 sum bus when acting as an output.
4895 */
4896 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4897 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4898 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4899 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4900
4901 /* Start with output sum widgets muted and their output gains at min */
4902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4911
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004912 /* Unmute retasking pin widget output buffers since the default
4913 * state appears to be output. As the pin mode is changed by the
4914 * user the pin mode control will take care of enabling the pin's
4915 * input/output buffers as needed.
4916 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004917 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4918 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4923 /* Also unmute the mono-out pin widget */
4924 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4925
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004926 /* Mute capture amp left and right */
4927 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004928 /* Set ADC connection select to match default mixer setting (mic1
4929 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004930 */
4931 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4932
4933 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004934 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004935 */
4936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4937 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4938
4939 /* Mute all inputs to mixer widget (even unconnected ones) */
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4948
4949 { }
4950};
4951#endif
4952
Takashi Iwai63300792008-01-24 15:31:36 +01004953#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4954#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004955
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004956#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4957#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4958
Kailang Yangdf694da2005-12-05 19:42:22 +01004959/*
4960 * for BIOS auto-configuration
4961 */
4962
4963static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4964 const char *pfx)
4965{
4966 hda_nid_t nid_vol;
4967 unsigned long vol_val, sw_val;
4968 char name[32];
4969 int err;
4970
4971 if (nid >= 0x0f && nid < 0x11) {
4972 nid_vol = nid - 0x7;
4973 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4974 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4975 } else if (nid == 0x11) {
4976 nid_vol = nid - 0x7;
4977 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4978 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4979 } else if (nid >= 0x12 && nid <= 0x15) {
4980 nid_vol = 0x08;
4981 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4982 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4983 } else
4984 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004985
Kailang Yangdf694da2005-12-05 19:42:22 +01004986 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004987 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4988 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004989 return err;
4990 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004991 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4992 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004993 return err;
4994 return 1;
4995}
4996
4997/* add playback controls from the parsed DAC table */
4998static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4999 const struct auto_pin_cfg *cfg)
5000{
5001 hda_nid_t nid;
5002 int err;
5003
5004 spec->multiout.num_dacs = 1;
5005 spec->multiout.dac_nids = spec->private_dac_nids;
5006 spec->multiout.dac_nids[0] = 0x02;
5007
5008 nid = cfg->line_out_pins[0];
5009 if (nid) {
5010 err = alc260_add_playback_controls(spec, nid, "Front");
5011 if (err < 0)
5012 return err;
5013 }
5014
Takashi Iwai82bc9552006-03-21 11:24:42 +01005015 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005016 if (nid) {
5017 err = alc260_add_playback_controls(spec, nid, "Speaker");
5018 if (err < 0)
5019 return err;
5020 }
5021
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005022 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005023 if (nid) {
5024 err = alc260_add_playback_controls(spec, nid, "Headphone");
5025 if (err < 0)
5026 return err;
5027 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005028 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005029}
5030
5031/* create playback/capture controls for input pins */
5032static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5033 const struct auto_pin_cfg *cfg)
5034{
Kailang Yangdf694da2005-12-05 19:42:22 +01005035 struct hda_input_mux *imux = &spec->private_imux;
5036 int i, err, idx;
5037
5038 for (i = 0; i < AUTO_PIN_LAST; i++) {
5039 if (cfg->input_pins[i] >= 0x12) {
5040 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005041 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005042 auto_pin_cfg_labels[i], idx,
5043 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005044 if (err < 0)
5045 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005046 imux->items[imux->num_items].label =
5047 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 imux->items[imux->num_items].index = idx;
5049 imux->num_items++;
5050 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005051 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005052 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005053 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005054 auto_pin_cfg_labels[i], idx,
5055 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005056 if (err < 0)
5057 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005058 imux->items[imux->num_items].label =
5059 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005060 imux->items[imux->num_items].index = idx;
5061 imux->num_items++;
5062 }
5063 }
5064 return 0;
5065}
5066
5067static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5068 hda_nid_t nid, int pin_type,
5069 int sel_idx)
5070{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005071 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005072 /* need the manual connection? */
5073 if (nid >= 0x12) {
5074 int idx = nid - 0x12;
5075 snd_hda_codec_write(codec, idx + 0x0b, 0,
5076 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005077 }
5078}
5079
5080static void alc260_auto_init_multi_out(struct hda_codec *codec)
5081{
5082 struct alc_spec *spec = codec->spec;
5083 hda_nid_t nid;
5084
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005085 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005087 if (nid) {
5088 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5089 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5090 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005091
Takashi Iwai82bc9552006-03-21 11:24:42 +01005092 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005093 if (nid)
5094 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5095
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005096 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005097 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005098 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099}
Kailang Yangdf694da2005-12-05 19:42:22 +01005100
5101#define ALC260_PIN_CD_NID 0x16
5102static void alc260_auto_init_analog_input(struct hda_codec *codec)
5103{
5104 struct alc_spec *spec = codec->spec;
5105 int i;
5106
5107 for (i = 0; i < AUTO_PIN_LAST; i++) {
5108 hda_nid_t nid = spec->autocfg.input_pins[i];
5109 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005110 snd_hda_codec_write(codec, nid, 0,
5111 AC_VERB_SET_PIN_WIDGET_CONTROL,
5112 i <= AUTO_PIN_FRONT_MIC ?
5113 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005114 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005115 snd_hda_codec_write(codec, nid, 0,
5116 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005117 AMP_OUT_MUTE);
5118 }
5119 }
5120}
5121
5122/*
5123 * generic initialization of ADC, input mixers and output mixers
5124 */
5125static struct hda_verb alc260_volume_init_verbs[] = {
5126 /*
5127 * Unmute ADC0-1 and set the default input to mic-in
5128 */
5129 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5130 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5131 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5132 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005133
Kailang Yangdf694da2005-12-05 19:42:22 +01005134 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5135 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005136 * Note: PASD motherboards uses the Line In 2 as the input for
5137 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005138 */
5139 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005140 /* mute analog inputs */
5141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005146
5147 /*
5148 * Set up output mixers (0x08 - 0x0a)
5149 */
5150 /* set vol=0 to output mixers */
5151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5153 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5154 /* set up input amps for analog loopback */
5155 /* Amp Indices: DAC = 0, mixer = 1 */
5156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5160 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5161 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005162
Kailang Yangdf694da2005-12-05 19:42:22 +01005163 { }
5164};
5165
5166static int alc260_parse_auto_config(struct hda_codec *codec)
5167{
5168 struct alc_spec *spec = codec->spec;
5169 unsigned int wcap;
5170 int err;
5171 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5172
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005173 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5174 alc260_ignore);
5175 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005177 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5178 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005179 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005181 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005182 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5183 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005184 return err;
5185
5186 spec->multiout.max_channels = 2;
5187
5188 if (spec->autocfg.dig_out_pin)
5189 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5190 if (spec->kctl_alloc)
5191 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5192
5193 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5194
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005195 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 spec->input_mux = &spec->private_imux;
5197
5198 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005199 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005201 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 spec->adc_nids = alc260_adc_nids_alt;
5203 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5204 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005205 } else {
5206 spec->adc_nids = alc260_adc_nids;
5207 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5208 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005209 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005210 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005211
5212 return 1;
5213}
5214
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005215/* additional initialization for auto-configuration model */
5216static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005217{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005218 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005219 alc260_auto_init_multi_out(codec);
5220 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005221 if (spec->unsol_event)
5222 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005223}
5224
Takashi Iwaicb53c622007-08-10 17:21:45 +02005225#ifdef CONFIG_SND_HDA_POWER_SAVE
5226static struct hda_amp_list alc260_loopbacks[] = {
5227 { 0x07, HDA_INPUT, 0 },
5228 { 0x07, HDA_INPUT, 1 },
5229 { 0x07, HDA_INPUT, 2 },
5230 { 0x07, HDA_INPUT, 3 },
5231 { 0x07, HDA_INPUT, 4 },
5232 { } /* end */
5233};
5234#endif
5235
Kailang Yangdf694da2005-12-05 19:42:22 +01005236/*
5237 * ALC260 configurations
5238 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005239static const char *alc260_models[ALC260_MODEL_LAST] = {
5240 [ALC260_BASIC] = "basic",
5241 [ALC260_HP] = "hp",
5242 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005243 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005244 [ALC260_FUJITSU_S702X] = "fujitsu",
5245 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005246 [ALC260_WILL] = "will",
5247 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005248#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005249 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005250#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005251 [ALC260_AUTO] = "auto",
5252};
5253
5254static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005255 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005256 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005257 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005258 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005259 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005260 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005261 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005262 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5263 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5264 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5265 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5266 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5267 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5268 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5269 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5270 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005271 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005272 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005273 {}
5274};
5275
Kailang Yangdf694da2005-12-05 19:42:22 +01005276static struct alc_config_preset alc260_presets[] = {
5277 [ALC260_BASIC] = {
5278 .mixers = { alc260_base_output_mixer,
5279 alc260_input_mixer,
5280 alc260_pc_beep_mixer,
5281 alc260_capture_mixer },
5282 .init_verbs = { alc260_init_verbs },
5283 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5284 .dac_nids = alc260_dac_nids,
5285 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5286 .adc_nids = alc260_adc_nids,
5287 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5288 .channel_mode = alc260_modes,
5289 .input_mux = &alc260_capture_source,
5290 },
5291 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005292 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005293 alc260_input_mixer,
5294 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005295 .init_verbs = { alc260_init_verbs,
5296 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005297 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5298 .dac_nids = alc260_dac_nids,
5299 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5300 .adc_nids = alc260_hp_adc_nids,
5301 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5302 .channel_mode = alc260_modes,
5303 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005304 .unsol_event = alc260_hp_unsol_event,
5305 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 },
Kailang Yang3f878302008-08-26 13:02:23 +02005307 [ALC260_HP_DC7600] = {
5308 .mixers = { alc260_hp_dc7600_mixer,
5309 alc260_input_mixer,
5310 alc260_capture_alt_mixer },
5311 .init_verbs = { alc260_init_verbs,
5312 alc260_hp_dc7600_verbs },
5313 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5314 .dac_nids = alc260_dac_nids,
5315 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5316 .adc_nids = alc260_hp_adc_nids,
5317 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5318 .channel_mode = alc260_modes,
5319 .input_mux = &alc260_capture_source,
5320 .unsol_event = alc260_hp_3012_unsol_event,
5321 .init_hook = alc260_hp_3012_automute,
5322 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 [ALC260_HP_3013] = {
5324 .mixers = { alc260_hp_3013_mixer,
5325 alc260_input_mixer,
5326 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005327 .init_verbs = { alc260_hp_3013_init_verbs,
5328 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005329 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5330 .dac_nids = alc260_dac_nids,
5331 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5332 .adc_nids = alc260_hp_adc_nids,
5333 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5334 .channel_mode = alc260_modes,
5335 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005336 .unsol_event = alc260_hp_3013_unsol_event,
5337 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005338 },
5339 [ALC260_FUJITSU_S702X] = {
5340 .mixers = { alc260_fujitsu_mixer,
5341 alc260_capture_mixer },
5342 .init_verbs = { alc260_fujitsu_init_verbs },
5343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5344 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5346 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5348 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005349 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5350 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005352 [ALC260_ACER] = {
5353 .mixers = { alc260_acer_mixer,
5354 alc260_capture_mixer },
5355 .init_verbs = { alc260_acer_init_verbs },
5356 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5357 .dac_nids = alc260_dac_nids,
5358 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5359 .adc_nids = alc260_dual_adc_nids,
5360 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5361 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005362 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5363 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005364 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005365 [ALC260_WILL] = {
5366 .mixers = { alc260_will_mixer,
5367 alc260_capture_mixer },
5368 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5369 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5370 .dac_nids = alc260_dac_nids,
5371 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5372 .adc_nids = alc260_adc_nids,
5373 .dig_out_nid = ALC260_DIGOUT_NID,
5374 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5375 .channel_mode = alc260_modes,
5376 .input_mux = &alc260_capture_source,
5377 },
5378 [ALC260_REPLACER_672V] = {
5379 .mixers = { alc260_replacer_672v_mixer,
5380 alc260_capture_mixer },
5381 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5382 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5383 .dac_nids = alc260_dac_nids,
5384 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5385 .adc_nids = alc260_adc_nids,
5386 .dig_out_nid = ALC260_DIGOUT_NID,
5387 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5388 .channel_mode = alc260_modes,
5389 .input_mux = &alc260_capture_source,
5390 .unsol_event = alc260_replacer_672v_unsol_event,
5391 .init_hook = alc260_replacer_672v_automute,
5392 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005393#ifdef CONFIG_SND_DEBUG
5394 [ALC260_TEST] = {
5395 .mixers = { alc260_test_mixer,
5396 alc260_capture_mixer },
5397 .init_verbs = { alc260_test_init_verbs },
5398 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5399 .dac_nids = alc260_test_dac_nids,
5400 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5401 .adc_nids = alc260_test_adc_nids,
5402 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5403 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005404 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5405 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005406 },
5407#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005408};
5409
Linus Torvalds1da177e2005-04-16 15:20:36 -07005410static int patch_alc260(struct hda_codec *codec)
5411{
5412 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005413 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005414
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005415 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005416 if (spec == NULL)
5417 return -ENOMEM;
5418
5419 codec->spec = spec;
5420
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005421 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5422 alc260_models,
5423 alc260_cfg_tbl);
5424 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005425 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5426 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005427 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005428 }
5429
Kailang Yangdf694da2005-12-05 19:42:22 +01005430 if (board_config == ALC260_AUTO) {
5431 /* automatic parse from the BIOS config */
5432 err = alc260_parse_auto_config(codec);
5433 if (err < 0) {
5434 alc_free(codec);
5435 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005436 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005437 printk(KERN_INFO
5438 "hda_codec: Cannot set up configuration "
5439 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005440 board_config = ALC260_BASIC;
5441 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005442 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005443
Kailang Yangdf694da2005-12-05 19:42:22 +01005444 if (board_config != ALC260_AUTO)
5445 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005446
5447 spec->stream_name_analog = "ALC260 Analog";
5448 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5449 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5450
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005451 spec->stream_name_digital = "ALC260 Digital";
5452 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5453 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5454
Takashi Iwai2134ea42008-01-10 16:53:55 +01005455 spec->vmaster_nid = 0x08;
5456
Linus Torvalds1da177e2005-04-16 15:20:36 -07005457 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005458 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005459 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005460#ifdef CONFIG_SND_HDA_POWER_SAVE
5461 if (!spec->loopback.amplist)
5462 spec->loopback.amplist = alc260_loopbacks;
5463#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005464
5465 return 0;
5466}
5467
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005468
Linus Torvalds1da177e2005-04-16 15:20:36 -07005469/*
5470 * ALC882 support
5471 *
5472 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5473 * configuration. Each pin widget can choose any input DACs and a mixer.
5474 * Each ADC is connected from a mixer of all inputs. This makes possible
5475 * 6-channel independent captures.
5476 *
5477 * In addition, an independent DAC for the multi-playback (not used in this
5478 * driver yet).
5479 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005480#define ALC882_DIGOUT_NID 0x06
5481#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005482
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005483static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005484 { 8, NULL }
5485};
5486
5487static hda_nid_t alc882_dac_nids[4] = {
5488 /* front, rear, clfe, rear_surr */
5489 0x02, 0x03, 0x04, 0x05
5490};
5491
Kailang Yangdf694da2005-12-05 19:42:22 +01005492/* identical with ALC880 */
5493#define alc882_adc_nids alc880_adc_nids
5494#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005495
Takashi Iwaie1406342008-02-11 18:32:32 +01005496static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5497static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5498
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499/* input MUX */
5500/* FIXME: should be a matrix-type input source selection */
5501
5502static struct hda_input_mux alc882_capture_source = {
5503 .num_items = 4,
5504 .items = {
5505 { "Mic", 0x0 },
5506 { "Front Mic", 0x1 },
5507 { "Line", 0x2 },
5508 { "CD", 0x4 },
5509 },
5510};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511#define alc882_mux_enum_info alc_mux_enum_info
5512#define alc882_mux_enum_get alc_mux_enum_get
5513
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005514static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5515 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516{
5517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5518 struct alc_spec *spec = codec->spec;
5519 const struct hda_input_mux *imux = spec->input_mux;
5520 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005521 hda_nid_t nid = spec->capsrc_nids ?
5522 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5524 unsigned int i, idx;
5525
5526 idx = ucontrol->value.enumerated.item[0];
5527 if (idx >= imux->num_items)
5528 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005529 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005530 return 0;
5531 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005532 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5533 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005534 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005535 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005536 }
5537 *cur_val = idx;
5538 return 1;
5539}
5540
Kailang Yangdf694da2005-12-05 19:42:22 +01005541/*
Kailang Yang272a5272007-05-14 11:00:38 +02005542 * 2ch mode
5543 */
5544static struct hda_verb alc882_3ST_ch2_init[] = {
5545 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5546 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5547 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5548 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5549 { } /* end */
5550};
5551
5552/*
5553 * 6ch mode
5554 */
5555static struct hda_verb alc882_3ST_ch6_init[] = {
5556 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5557 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5558 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5559 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5560 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5561 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5562 { } /* end */
5563};
5564
5565static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5566 { 2, alc882_3ST_ch2_init },
5567 { 6, alc882_3ST_ch6_init },
5568};
5569
5570/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005571 * 6ch mode
5572 */
5573static struct hda_verb alc882_sixstack_ch6_init[] = {
5574 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5575 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5576 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5577 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5578 { } /* end */
5579};
5580
5581/*
5582 * 8ch mode
5583 */
5584static struct hda_verb alc882_sixstack_ch8_init[] = {
5585 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5586 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5587 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5588 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5589 { } /* end */
5590};
5591
5592static struct hda_channel_mode alc882_sixstack_modes[2] = {
5593 { 6, alc882_sixstack_ch6_init },
5594 { 8, alc882_sixstack_ch8_init },
5595};
5596
Takashi Iwai87350ad2007-08-16 18:19:38 +02005597/*
5598 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5599 */
5600
5601/*
5602 * 2ch mode
5603 */
5604static struct hda_verb alc885_mbp_ch2_init[] = {
5605 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5606 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5607 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5608 { } /* end */
5609};
5610
5611/*
5612 * 6ch mode
5613 */
5614static struct hda_verb alc885_mbp_ch6_init[] = {
5615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5618 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5620 { } /* end */
5621};
5622
5623static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5624 { 2, alc885_mbp_ch2_init },
5625 { 6, alc885_mbp_ch6_init },
5626};
5627
5628
Linus Torvalds1da177e2005-04-16 15:20:36 -07005629/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5630 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5631 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005632static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005633 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005634 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005635 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005636 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005637 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5638 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005639 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5640 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005641 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005642 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005649 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005652 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005653 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5654 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5655 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005656 { } /* end */
5657};
5658
Takashi Iwai87350ad2007-08-16 18:19:38 +02005659static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5661 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5662 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5663 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5665 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5667 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005668 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5670 { } /* end */
5671};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005672static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5673 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5674 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5675 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5676 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5677 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5678 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5680 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5682 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5683 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5684 { } /* end */
5685};
5686
Kailang Yang272a5272007-05-14 11:00:38 +02005687static struct snd_kcontrol_new alc882_targa_mixer[] = {
5688 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5689 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5691 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5692 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5693 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5694 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005698 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5699 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005700 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005701 { } /* end */
5702};
5703
5704/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5705 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5706 */
5707static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5709 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5711 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5716 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5717 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005721 { } /* end */
5722};
5723
Takashi Iwai914759b2007-09-06 14:52:04 +02005724static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5725 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5726 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5730 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5731 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5735 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5736 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5737 { } /* end */
5738};
5739
Kailang Yangdf694da2005-12-05 19:42:22 +01005740static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5741 {
5742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5743 .name = "Channel Mode",
5744 .info = alc_ch_mode_info,
5745 .get = alc_ch_mode_get,
5746 .put = alc_ch_mode_put,
5747 },
5748 { } /* end */
5749};
5750
Linus Torvalds1da177e2005-04-16 15:20:36 -07005751static struct hda_verb alc882_init_verbs[] = {
5752 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005756 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005760 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005764 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5766 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5767 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005768
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005769 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005772 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005773 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005777 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005779 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005780 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005781 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005782 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005783 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005784 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005785 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005786 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005787 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5788 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005789 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005790 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5791 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5794 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5796 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5797 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005798 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005799 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005800
5801 /* FIXME: use matrix-type input source selection */
5802 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5803 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005808 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005813 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5818 /* ADC1: mute amp left and right */
5819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005820 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005821 /* ADC2: mute amp left and right */
5822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005823 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005824 /* ADC3: mute amp left and right */
5825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005826 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005827
5828 { }
5829};
5830
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005831static struct hda_verb alc882_eapd_verbs[] = {
5832 /* change to EAPD mode */
5833 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005834 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005835 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005836};
5837
Tobin Davis9102cd12006-12-15 10:02:12 +01005838/* Mac Pro test */
5839static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5840 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5843 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5844 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5845 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5846 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5847 { } /* end */
5848};
5849
5850static struct hda_verb alc882_macpro_init_verbs[] = {
5851 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5855 /* Front Pin: output 0 (0x0c) */
5856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5858 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5859 /* Front Mic pin: input vref at 80% */
5860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5862 /* Speaker: output */
5863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5865 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5866 /* Headphone output (output 0 - 0x0c) */
5867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5868 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5869 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5870
5871 /* FIXME: use matrix-type input source selection */
5872 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5873 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5875 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5876 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5877 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5878 /* Input mixer2 */
5879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5880 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5883 /* Input mixer3 */
5884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5888 /* ADC1: mute amp left and right */
5889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5890 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5891 /* ADC2: mute amp left and right */
5892 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5893 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5894 /* ADC3: mute amp left and right */
5895 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5896 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5897
5898 { }
5899};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005900
Takashi Iwai87350ad2007-08-16 18:19:38 +02005901/* Macbook Pro rev3 */
5902static struct hda_verb alc885_mbp3_init_verbs[] = {
5903 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5907 /* Rear mixer */
5908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5911 /* Front Pin: output 0 (0x0c) */
5912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5914 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5915 /* HP Pin: output 0 (0x0d) */
5916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5919 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5920 /* Mic (rear) pin: input vref at 80% */
5921 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5923 /* Front Mic pin: input vref at 80% */
5924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5926 /* Line In pin: use output 1 when in LineOut mode */
5927 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5929 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5930
5931 /* FIXME: use matrix-type input source selection */
5932 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5933 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5938 /* Input mixer2 */
5939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5940 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5941 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5943 /* Input mixer3 */
5944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5948 /* ADC1: mute amp left and right */
5949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5950 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5951 /* ADC2: mute amp left and right */
5952 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5954 /* ADC3: mute amp left and right */
5955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5957
5958 { }
5959};
5960
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005961/* iMac 24 mixer. */
5962static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5963 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5964 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5965 { } /* end */
5966};
5967
5968/* iMac 24 init verbs. */
5969static struct hda_verb alc885_imac24_init_verbs[] = {
5970 /* Internal speakers: output 0 (0x0c) */
5971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5973 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5974 /* Internal speakers: output 0 (0x0c) */
5975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5977 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5978 /* Headphone: output 0 (0x0c) */
5979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5981 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5982 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5983 /* Front Mic: input vref at 80% */
5984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5985 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5986 { }
5987};
5988
5989/* Toggle speaker-output according to the hp-jack state */
5990static void alc885_imac24_automute(struct hda_codec *codec)
5991{
5992 unsigned int present;
5993
5994 present = snd_hda_codec_read(codec, 0x14, 0,
5995 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005996 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5997 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5998 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5999 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006000}
6001
6002/* Processes unsolicited events. */
6003static void alc885_imac24_unsol_event(struct hda_codec *codec,
6004 unsigned int res)
6005{
6006 /* Headphone insertion or removal. */
6007 if ((res >> 26) == ALC880_HP_EVENT)
6008 alc885_imac24_automute(codec);
6009}
6010
Takashi Iwai87350ad2007-08-16 18:19:38 +02006011static void alc885_mbp3_automute(struct hda_codec *codec)
6012{
6013 unsigned int present;
6014
6015 present = snd_hda_codec_read(codec, 0x15, 0,
6016 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6017 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6018 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6019 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6020 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6021
6022}
6023static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6024 unsigned int res)
6025{
6026 /* Headphone insertion or removal. */
6027 if ((res >> 26) == ALC880_HP_EVENT)
6028 alc885_mbp3_automute(codec);
6029}
6030
6031
Kailang Yang272a5272007-05-14 11:00:38 +02006032static struct hda_verb alc882_targa_verbs[] = {
6033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6035
6036 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6037 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006038
Kailang Yang272a5272007-05-14 11:00:38 +02006039 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6040 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6042
6043 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6044 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6045 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6046 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6047 { } /* end */
6048};
6049
6050/* toggle speaker-output according to the hp-jack state */
6051static void alc882_targa_automute(struct hda_codec *codec)
6052{
6053 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006054
Kailang Yang272a5272007-05-14 11:00:38 +02006055 present = snd_hda_codec_read(codec, 0x14, 0,
6056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006057 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6058 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006059 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6060 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006061}
6062
6063static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6064{
6065 /* Looks like the unsol event is incompatible with the standard
6066 * definition. 4bit tag is placed at 26 bit!
6067 */
6068 if (((res >> 26) == ALC880_HP_EVENT)) {
6069 alc882_targa_automute(codec);
6070 }
6071}
6072
6073static struct hda_verb alc882_asus_a7j_verbs[] = {
6074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6076
6077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6079 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006080
Kailang Yang272a5272007-05-14 11:00:38 +02006081 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6083 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6084
6085 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6086 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6087 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6088 { } /* end */
6089};
6090
Takashi Iwai914759b2007-09-06 14:52:04 +02006091static struct hda_verb alc882_asus_a7m_verbs[] = {
6092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6094
6095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6097 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006098
Takashi Iwai914759b2007-09-06 14:52:04 +02006099 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6100 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6101 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6102
6103 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6104 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6105 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6106 { } /* end */
6107};
6108
Tobin Davis9102cd12006-12-15 10:02:12 +01006109static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6110{
6111 unsigned int gpiostate, gpiomask, gpiodir;
6112
6113 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6114 AC_VERB_GET_GPIO_DATA, 0);
6115
6116 if (!muted)
6117 gpiostate |= (1 << pin);
6118 else
6119 gpiostate &= ~(1 << pin);
6120
6121 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6122 AC_VERB_GET_GPIO_MASK, 0);
6123 gpiomask |= (1 << pin);
6124
6125 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6126 AC_VERB_GET_GPIO_DIRECTION, 0);
6127 gpiodir |= (1 << pin);
6128
6129
6130 snd_hda_codec_write(codec, codec->afg, 0,
6131 AC_VERB_SET_GPIO_MASK, gpiomask);
6132 snd_hda_codec_write(codec, codec->afg, 0,
6133 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6134
6135 msleep(1);
6136
6137 snd_hda_codec_write(codec, codec->afg, 0,
6138 AC_VERB_SET_GPIO_DATA, gpiostate);
6139}
6140
Takashi Iwai7debbe52007-08-16 15:01:03 +02006141/* set up GPIO at initialization */
6142static void alc885_macpro_init_hook(struct hda_codec *codec)
6143{
6144 alc882_gpio_mute(codec, 0, 0);
6145 alc882_gpio_mute(codec, 1, 0);
6146}
6147
6148/* set up GPIO and update auto-muting at initialization */
6149static void alc885_imac24_init_hook(struct hda_codec *codec)
6150{
6151 alc885_macpro_init_hook(codec);
6152 alc885_imac24_automute(codec);
6153}
6154
Kailang Yangdf694da2005-12-05 19:42:22 +01006155/*
6156 * generic initialization of ADC, input mixers and output mixers
6157 */
6158static struct hda_verb alc882_auto_init_verbs[] = {
6159 /*
6160 * Unmute ADC0-2 and set the default input to mic-in
6161 */
6162 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6168
Takashi Iwaicb53c622007-08-10 17:21:45 +02006169 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006170 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006171 * Note: PASD motherboards uses the Line In 2 as the input for
6172 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006173 */
6174 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006180
6181 /*
6182 * Set up output mixers (0x0c - 0x0f)
6183 */
6184 /* set vol=0 to output mixers */
6185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6186 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6187 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6188 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6189 /* set up input amps for analog loopback */
6190 /* Amp Indices: DAC = 0, mixer = 1 */
6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6199 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6200 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6201
6202 /* FIXME: use matrix-type input source selection */
6203 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6204 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6209 /* Input mixer2 */
6210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6214 /* Input mixer3 */
6215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6219
6220 { }
6221};
6222
6223/* capture mixer elements */
6224static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6225 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6226 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6227 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6228 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6229 {
6230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6231 /* The multiple "Capture Source" controls confuse alsamixer
6232 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 */
6234 /* .name = "Capture Source", */
6235 .name = "Input Source",
6236 .count = 2,
6237 .info = alc882_mux_enum_info,
6238 .get = alc882_mux_enum_get,
6239 .put = alc882_mux_enum_put,
6240 },
6241 { } /* end */
6242};
6243
6244static struct snd_kcontrol_new alc882_capture_mixer[] = {
6245 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6246 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6247 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6248 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6249 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6250 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6251 {
6252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6253 /* The multiple "Capture Source" controls confuse alsamixer
6254 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 */
6256 /* .name = "Capture Source", */
6257 .name = "Input Source",
6258 .count = 3,
6259 .info = alc882_mux_enum_info,
6260 .get = alc882_mux_enum_get,
6261 .put = alc882_mux_enum_put,
6262 },
6263 { } /* end */
6264};
6265
Takashi Iwaicb53c622007-08-10 17:21:45 +02006266#ifdef CONFIG_SND_HDA_POWER_SAVE
6267#define alc882_loopbacks alc880_loopbacks
6268#endif
6269
Kailang Yangdf694da2005-12-05 19:42:22 +01006270/* pcm configuration: identiacal with ALC880 */
6271#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6272#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6273#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6274#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6275
6276/*
6277 * configuration and preset
6278 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006279static const char *alc882_models[ALC882_MODEL_LAST] = {
6280 [ALC882_3ST_DIG] = "3stack-dig",
6281 [ALC882_6ST_DIG] = "6stack-dig",
6282 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006283 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006284 [ALC882_TARGA] = "targa",
6285 [ALC882_ASUS_A7J] = "asus-a7j",
6286 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006287 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006288 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006289 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006290 [ALC882_AUTO] = "auto",
6291};
6292
6293static struct snd_pci_quirk alc882_cfg_tbl[] = {
6294 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006295 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006296 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006297 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006298 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006299 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006300 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006301 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006302 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006303 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6304 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6305 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006306 {}
6307};
6308
6309static struct alc_config_preset alc882_presets[] = {
6310 [ALC882_3ST_DIG] = {
6311 .mixers = { alc882_base_mixer },
6312 .init_verbs = { alc882_init_verbs },
6313 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6314 .dac_nids = alc882_dac_nids,
6315 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 .dig_in_nid = ALC882_DIGIN_NID,
6317 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6318 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006319 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006320 .input_mux = &alc882_capture_source,
6321 },
6322 [ALC882_6ST_DIG] = {
6323 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6324 .init_verbs = { alc882_init_verbs },
6325 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6326 .dac_nids = alc882_dac_nids,
6327 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 .dig_in_nid = ALC882_DIGIN_NID,
6329 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6330 .channel_mode = alc882_sixstack_modes,
6331 .input_mux = &alc882_capture_source,
6332 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006333 [ALC882_ARIMA] = {
6334 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6335 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6336 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6337 .dac_nids = alc882_dac_nids,
6338 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6339 .channel_mode = alc882_sixstack_modes,
6340 .input_mux = &alc882_capture_source,
6341 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006342 [ALC882_W2JC] = {
6343 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6344 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6345 alc880_gpio1_init_verbs },
6346 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6347 .dac_nids = alc882_dac_nids,
6348 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6349 .channel_mode = alc880_threestack_modes,
6350 .need_dac_fix = 1,
6351 .input_mux = &alc882_capture_source,
6352 .dig_out_nid = ALC882_DIGOUT_NID,
6353 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006354 [ALC885_MBP3] = {
6355 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6356 .init_verbs = { alc885_mbp3_init_verbs,
6357 alc880_gpio1_init_verbs },
6358 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6359 .dac_nids = alc882_dac_nids,
6360 .channel_mode = alc885_mbp_6ch_modes,
6361 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6362 .input_mux = &alc882_capture_source,
6363 .dig_out_nid = ALC882_DIGOUT_NID,
6364 .dig_in_nid = ALC882_DIGIN_NID,
6365 .unsol_event = alc885_mbp3_unsol_event,
6366 .init_hook = alc885_mbp3_automute,
6367 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006368 [ALC885_MACPRO] = {
6369 .mixers = { alc882_macpro_mixer },
6370 .init_verbs = { alc882_macpro_init_verbs },
6371 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6372 .dac_nids = alc882_dac_nids,
6373 .dig_out_nid = ALC882_DIGOUT_NID,
6374 .dig_in_nid = ALC882_DIGIN_NID,
6375 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6376 .channel_mode = alc882_ch_modes,
6377 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006378 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006379 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006380 [ALC885_IMAC24] = {
6381 .mixers = { alc885_imac24_mixer },
6382 .init_verbs = { alc885_imac24_init_verbs },
6383 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6384 .dac_nids = alc882_dac_nids,
6385 .dig_out_nid = ALC882_DIGOUT_NID,
6386 .dig_in_nid = ALC882_DIGIN_NID,
6387 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6388 .channel_mode = alc882_ch_modes,
6389 .input_mux = &alc882_capture_source,
6390 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006391 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006392 },
Kailang Yang272a5272007-05-14 11:00:38 +02006393 [ALC882_TARGA] = {
6394 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6395 alc882_capture_mixer },
6396 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6397 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6398 .dac_nids = alc882_dac_nids,
6399 .dig_out_nid = ALC882_DIGOUT_NID,
6400 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6401 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006402 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006403 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6404 .channel_mode = alc882_3ST_6ch_modes,
6405 .need_dac_fix = 1,
6406 .input_mux = &alc882_capture_source,
6407 .unsol_event = alc882_targa_unsol_event,
6408 .init_hook = alc882_targa_automute,
6409 },
6410 [ALC882_ASUS_A7J] = {
6411 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6412 alc882_capture_mixer },
6413 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6414 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6415 .dac_nids = alc882_dac_nids,
6416 .dig_out_nid = ALC882_DIGOUT_NID,
6417 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6418 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006419 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006420 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6421 .channel_mode = alc882_3ST_6ch_modes,
6422 .need_dac_fix = 1,
6423 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006424 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006425 [ALC882_ASUS_A7M] = {
6426 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6427 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6428 alc880_gpio1_init_verbs,
6429 alc882_asus_a7m_verbs },
6430 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6431 .dac_nids = alc882_dac_nids,
6432 .dig_out_nid = ALC882_DIGOUT_NID,
6433 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6434 .channel_mode = alc880_threestack_modes,
6435 .need_dac_fix = 1,
6436 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006437 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006438};
6439
6440
6441/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006442 * Pin config fixes
6443 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006444enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006445 PINFIX_ABIT_AW9D_MAX
6446};
6447
6448static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6449 { 0x15, 0x01080104 }, /* side */
6450 { 0x16, 0x01011012 }, /* rear */
6451 { 0x17, 0x01016011 }, /* clfe */
6452 { }
6453};
6454
6455static const struct alc_pincfg *alc882_pin_fixes[] = {
6456 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6457};
6458
6459static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6460 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6461 {}
6462};
6463
6464/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006465 * BIOS auto configuration
6466 */
6467static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6468 hda_nid_t nid, int pin_type,
6469 int dac_idx)
6470{
6471 /* set as output */
6472 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006473 int idx;
6474
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006475 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6477 idx = 4;
6478 else
6479 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006480 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6481
6482}
6483
6484static void alc882_auto_init_multi_out(struct hda_codec *codec)
6485{
6486 struct alc_spec *spec = codec->spec;
6487 int i;
6488
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006489 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006491 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006492 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006493 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006494 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006495 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006496 }
6497}
6498
6499static void alc882_auto_init_hp_out(struct hda_codec *codec)
6500{
6501 struct alc_spec *spec = codec->spec;
6502 hda_nid_t pin;
6503
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006504 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006505 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006506 /* use dac 0 */
6507 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006508 pin = spec->autocfg.speaker_pins[0];
6509 if (pin)
6510 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006511}
6512
6513#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6514#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6515
6516static void alc882_auto_init_analog_input(struct hda_codec *codec)
6517{
6518 struct alc_spec *spec = codec->spec;
6519 int i;
6520
6521 for (i = 0; i < AUTO_PIN_LAST; i++) {
6522 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006523 unsigned int vref;
6524 if (!nid)
6525 continue;
6526 vref = PIN_IN;
6527 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006528 unsigned int pincap;
6529 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6530 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006531 AC_PINCAP_VREF_80)
6532 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006533 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006534 snd_hda_codec_write(codec, nid, 0,
6535 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6536 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6537 snd_hda_codec_write(codec, nid, 0,
6538 AC_VERB_SET_AMP_GAIN_MUTE,
6539 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006540 }
6541}
6542
Takashi Iwaif511b012008-08-15 16:46:42 +02006543static void alc882_auto_init_input_src(struct hda_codec *codec)
6544{
6545 struct alc_spec *spec = codec->spec;
6546 const struct hda_input_mux *imux = spec->input_mux;
6547 int c;
6548
6549 for (c = 0; c < spec->num_adc_nids; c++) {
6550 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6551 hda_nid_t nid = spec->capsrc_nids[c];
6552 int conns, mute, idx, item;
6553
6554 conns = snd_hda_get_connections(codec, nid, conn_list,
6555 ARRAY_SIZE(conn_list));
6556 if (conns < 0)
6557 continue;
6558 for (idx = 0; idx < conns; idx++) {
6559 /* if the current connection is the selected one,
6560 * unmute it as default - otherwise mute it
6561 */
6562 mute = AMP_IN_MUTE(idx);
6563 for (item = 0; item < imux->num_items; item++) {
6564 if (imux->items[item].index == idx) {
6565 if (spec->cur_mux[c] == item)
6566 mute = AMP_IN_UNMUTE(idx);
6567 break;
6568 }
6569 }
6570 snd_hda_codec_write(codec, nid, 0,
6571 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6572 }
6573 }
6574}
6575
Takashi Iwai776e1842007-08-29 15:07:11 +02006576/* add mic boosts if needed */
6577static int alc_auto_add_mic_boost(struct hda_codec *codec)
6578{
6579 struct alc_spec *spec = codec->spec;
6580 int err;
6581 hda_nid_t nid;
6582
6583 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006584 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006585 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6586 "Mic Boost",
6587 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6588 if (err < 0)
6589 return err;
6590 }
6591 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006592 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006593 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6594 "Front Mic Boost",
6595 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6596 if (err < 0)
6597 return err;
6598 }
6599 return 0;
6600}
6601
Kailang Yangdf694da2005-12-05 19:42:22 +01006602/* almost identical with ALC880 parser... */
6603static int alc882_parse_auto_config(struct hda_codec *codec)
6604{
6605 struct alc_spec *spec = codec->spec;
6606 int err = alc880_parse_auto_config(codec);
6607
6608 if (err < 0)
6609 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006610 else if (!err)
6611 return 0; /* no config found */
6612
6613 err = alc_auto_add_mic_boost(codec);
6614 if (err < 0)
6615 return err;
6616
6617 /* hack - override the init verbs */
6618 spec->init_verbs[0] = alc882_auto_init_verbs;
6619
6620 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006621}
6622
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006623/* additional initialization for auto-configuration model */
6624static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006625{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006626 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006627 alc882_auto_init_multi_out(codec);
6628 alc882_auto_init_hp_out(codec);
6629 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006630 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006631 if (spec->unsol_event)
6632 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006633}
6634
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006635static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6636
Linus Torvalds1da177e2005-04-16 15:20:36 -07006637static int patch_alc882(struct hda_codec *codec)
6638{
6639 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006641
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006642 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006643 if (spec == NULL)
6644 return -ENOMEM;
6645
Linus Torvalds1da177e2005-04-16 15:20:36 -07006646 codec->spec = spec;
6647
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006648 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6649 alc882_models,
6650 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006651
Kailang Yangdf694da2005-12-05 19:42:22 +01006652 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006653 /* Pick up systems that don't supply PCI SSID */
6654 switch (codec->subsystem_id) {
6655 case 0x106b0c00: /* Mac Pro */
6656 board_config = ALC885_MACPRO;
6657 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006658 case 0x106b1000: /* iMac 24 */
6659 board_config = ALC885_IMAC24;
6660 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006661 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006662 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006663 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006664 board_config = ALC885_MBP3;
6665 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006666 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006667 /* ALC889A is handled better as ALC888-compatible */
6668 if (codec->revision_id == 0x100103) {
6669 alc_free(codec);
6670 return patch_alc883(codec);
6671 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006672 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6673 "trying auto-probe from BIOS...\n");
6674 board_config = ALC882_AUTO;
6675 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006677
Takashi Iwaif95474e2007-07-10 00:47:43 +02006678 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6679
Kailang Yangdf694da2005-12-05 19:42:22 +01006680 if (board_config == ALC882_AUTO) {
6681 /* automatic parse from the BIOS config */
6682 err = alc882_parse_auto_config(codec);
6683 if (err < 0) {
6684 alc_free(codec);
6685 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006686 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006687 printk(KERN_INFO
6688 "hda_codec: Cannot set up configuration "
6689 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006690 board_config = ALC882_3ST_DIG;
6691 }
6692 }
6693
6694 if (board_config != ALC882_AUTO)
6695 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006696
Kailang Yang2f893282008-05-27 12:14:47 +02006697 if (codec->vendor_id == 0x10ec0885) {
6698 spec->stream_name_analog = "ALC885 Analog";
6699 spec->stream_name_digital = "ALC885 Digital";
6700 } else {
6701 spec->stream_name_analog = "ALC882 Analog";
6702 spec->stream_name_digital = "ALC882 Digital";
6703 }
6704
Kailang Yangdf694da2005-12-05 19:42:22 +01006705 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6706 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006707 /* FIXME: setup DAC5 */
6708 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6709 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006710
Kailang Yangdf694da2005-12-05 19:42:22 +01006711 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6712 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006713
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006714 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006715 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006716 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006717 /* get type */
6718 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006719 if (wcap != AC_WID_AUD_IN) {
6720 spec->adc_nids = alc882_adc_nids_alt;
6721 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006722 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006723 spec->mixers[spec->num_mixers] =
6724 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006725 spec->num_mixers++;
6726 } else {
6727 spec->adc_nids = alc882_adc_nids;
6728 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006729 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006730 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6731 spec->num_mixers++;
6732 }
6733 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006734
Takashi Iwai2134ea42008-01-10 16:53:55 +01006735 spec->vmaster_nid = 0x0c;
6736
Linus Torvalds1da177e2005-04-16 15:20:36 -07006737 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006738 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006739 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006740#ifdef CONFIG_SND_HDA_POWER_SAVE
6741 if (!spec->loopback.amplist)
6742 spec->loopback.amplist = alc882_loopbacks;
6743#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006744
6745 return 0;
6746}
6747
6748/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006749 * ALC883 support
6750 *
6751 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6752 * configuration. Each pin widget can choose any input DACs and a mixer.
6753 * Each ADC is connected from a mixer of all inputs. This makes possible
6754 * 6-channel independent captures.
6755 *
6756 * In addition, an independent DAC for the multi-playback (not used in this
6757 * driver yet).
6758 */
6759#define ALC883_DIGOUT_NID 0x06
6760#define ALC883_DIGIN_NID 0x0a
6761
6762static hda_nid_t alc883_dac_nids[4] = {
6763 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006764 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006765};
6766
6767static hda_nid_t alc883_adc_nids[2] = {
6768 /* ADC1-2 */
6769 0x08, 0x09,
6770};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006771
Takashi Iwaie1406342008-02-11 18:32:32 +01006772static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6773
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006774/* input MUX */
6775/* FIXME: should be a matrix-type input source selection */
6776
6777static struct hda_input_mux alc883_capture_source = {
6778 .num_items = 4,
6779 .items = {
6780 { "Mic", 0x0 },
6781 { "Front Mic", 0x1 },
6782 { "Line", 0x2 },
6783 { "CD", 0x4 },
6784 },
6785};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006786
Jiang zhe17bba1b2008-06-04 12:11:07 +02006787static struct hda_input_mux alc883_3stack_6ch_intel = {
6788 .num_items = 4,
6789 .items = {
6790 { "Mic", 0x1 },
6791 { "Front Mic", 0x0 },
6792 { "Line", 0x2 },
6793 { "CD", 0x4 },
6794 },
6795};
6796
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006797static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6798 .num_items = 2,
6799 .items = {
6800 { "Mic", 0x1 },
6801 { "Line", 0x2 },
6802 },
6803};
6804
Kailang Yang272a5272007-05-14 11:00:38 +02006805static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6806 .num_items = 4,
6807 .items = {
6808 { "Mic", 0x0 },
6809 { "iMic", 0x1 },
6810 { "Line", 0x2 },
6811 { "CD", 0x4 },
6812 },
6813};
6814
Jiang zhefb97dc62008-03-06 11:07:11 +01006815static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6816 .num_items = 2,
6817 .items = {
6818 { "Mic", 0x0 },
6819 { "Int Mic", 0x1 },
6820 },
6821};
6822
Kailang Yange2757d52008-08-26 13:17:46 +02006823static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6824 .num_items = 3,
6825 .items = {
6826 { "Mic", 0x0 },
6827 { "Front Mic", 0x1 },
6828 { "Line", 0x4 },
6829 },
6830};
6831
6832static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6833 .num_items = 2,
6834 .items = {
6835 { "Mic", 0x0 },
6836 { "Line", 0x2 },
6837 },
6838};
6839
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006840#define alc883_mux_enum_info alc_mux_enum_info
6841#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006842/* ALC883 has the ALC882-type input selection */
6843#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006844
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006845/*
6846 * 2ch mode
6847 */
6848static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6849 { 2, NULL }
6850};
6851
6852/*
6853 * 2ch mode
6854 */
6855static struct hda_verb alc883_3ST_ch2_init[] = {
6856 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6857 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6860 { } /* end */
6861};
6862
6863/*
Tobin Davisb2011312007-09-17 12:45:11 +02006864 * 4ch mode
6865 */
6866static struct hda_verb alc883_3ST_ch4_init[] = {
6867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6869 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6870 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6871 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6872 { } /* end */
6873};
6874
6875/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006876 * 6ch mode
6877 */
6878static struct hda_verb alc883_3ST_ch6_init[] = {
6879 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6880 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6881 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6884 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6885 { } /* end */
6886};
6887
Tobin Davisb2011312007-09-17 12:45:11 +02006888static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006889 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006890 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006891 { 6, alc883_3ST_ch6_init },
6892};
6893
6894/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006895 * 2ch mode
6896 */
6897static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6898 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6899 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6902 { } /* end */
6903};
6904
6905/*
6906 * 4ch mode
6907 */
6908static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6909 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6910 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6911 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6912 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6913 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6914 { } /* end */
6915};
6916
6917/*
6918 * 6ch mode
6919 */
6920static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6921 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6922 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6923 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6926 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6927 { } /* end */
6928};
6929
6930static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6931 { 2, alc883_3ST_ch2_intel_init },
6932 { 4, alc883_3ST_ch4_intel_init },
6933 { 6, alc883_3ST_ch6_intel_init },
6934};
6935
6936/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006937 * 6ch mode
6938 */
6939static struct hda_verb alc883_sixstack_ch6_init[] = {
6940 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6941 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6942 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6943 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6944 { } /* end */
6945};
6946
6947/*
6948 * 8ch mode
6949 */
6950static struct hda_verb alc883_sixstack_ch8_init[] = {
6951 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6952 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6953 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { } /* end */
6956};
6957
6958static struct hda_channel_mode alc883_sixstack_modes[2] = {
6959 { 6, alc883_sixstack_ch6_init },
6960 { 8, alc883_sixstack_ch8_init },
6961};
6962
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006963static struct hda_verb alc883_medion_eapd_verbs[] = {
6964 /* eanable EAPD on medion laptop */
6965 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6966 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6967 { }
6968};
6969
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006970/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6971 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6972 */
6973
6974static struct snd_kcontrol_new alc883_base_mixer[] = {
6975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6978 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6979 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006994 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7000 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7001 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7002 {
7003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7004 /* .name = "Capture Source", */
7005 .name = "Input Source",
7006 .count = 2,
7007 .info = alc883_mux_enum_info,
7008 .get = alc883_mux_enum_get,
7009 .put = alc883_mux_enum_put,
7010 },
7011 { } /* end */
7012};
7013
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007014static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7027 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7030 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7031 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7032 {
7033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7034 /* .name = "Capture Source", */
7035 .name = "Input Source",
7036 .count = 2,
7037 .info = alc883_mux_enum_info,
7038 .get = alc883_mux_enum_get,
7039 .put = alc883_mux_enum_put,
7040 },
7041 { } /* end */
7042};
7043
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007044static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007045 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7046 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7048 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7052 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7053 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7054 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7057 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7058 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7059 {
7060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7061 /* .name = "Capture Source", */
7062 .name = "Input Source",
7063 .count = 2,
7064 .info = alc883_mux_enum_info,
7065 .get = alc883_mux_enum_get,
7066 .put = alc883_mux_enum_put,
7067 },
7068 { } /* end */
7069};
7070
Jiang zhefb97dc62008-03-06 11:07:11 +01007071static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7073 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7075 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7081 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7082 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7083 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7084 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7085 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7086 {
7087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7088 /* .name = "Capture Source", */
7089 .name = "Input Source",
7090 .count = 2,
7091 .info = alc883_mux_enum_info,
7092 .get = alc883_mux_enum_get,
7093 .put = alc883_mux_enum_put,
7094 },
7095 { } /* end */
7096};
7097
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007098static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7099 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7100 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7109 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7112 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7113 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7114 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7115 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7116 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7117 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7118 {
7119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7120 /* .name = "Capture Source", */
7121 .name = "Input Source",
7122 .count = 2,
7123 .info = alc883_mux_enum_info,
7124 .get = alc883_mux_enum_get,
7125 .put = alc883_mux_enum_put,
7126 },
7127 { } /* end */
7128};
7129
7130static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7132 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7133 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7134 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7135 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7136 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7137 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7138 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007148 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007149 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7150 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7151 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7152 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7153 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007154 {
7155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7156 /* .name = "Capture Source", */
7157 .name = "Input Source",
Kailang Yange2757d52008-08-26 13:17:46 +02007158 .count = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007159 .info = alc883_mux_enum_info,
7160 .get = alc883_mux_enum_get,
7161 .put = alc883_mux_enum_put,
7162 },
7163 { } /* end */
7164};
7165
Jiang zhe17bba1b2008-06-04 12:11:07 +02007166static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7167 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7168 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7170 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7172 HDA_OUTPUT),
7173 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7174 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7175 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7182 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7184 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7185 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7186 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7187 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7188 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7190 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7191 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7192 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7193 {
7194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7195 /* .name = "Capture Source", */
7196 .name = "Input Source",
7197 .count = 2,
7198 .info = alc883_mux_enum_info,
7199 .get = alc883_mux_enum_get,
7200 .put = alc883_mux_enum_put,
7201 },
7202 { } /* end */
7203};
7204
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007205static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007206 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007207 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007208 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007209 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007210 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7211 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007212 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7213 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007220 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007223 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7225 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7226 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7228 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7229
7230 {
7231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7232 /* .name = "Capture Source", */
7233 .name = "Input Source",
7234 .count = 1,
7235 .info = alc883_mux_enum_info,
7236 .get = alc883_mux_enum_get,
7237 .put = alc883_mux_enum_put,
7238 },
7239 { } /* end */
7240};
7241
Kailang Yangccc656c2006-10-17 12:32:26 +02007242static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7245 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7246 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7247 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7248 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7249 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7250 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7251 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7252 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7253 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7259 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7260 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7261 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7262 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7263 {
7264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7265 /* .name = "Capture Source", */
7266 .name = "Input Source",
7267 .count = 2,
7268 .info = alc883_mux_enum_info,
7269 .get = alc883_mux_enum_get,
7270 .put = alc883_mux_enum_put,
7271 },
7272 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007273};
Kailang Yangccc656c2006-10-17 12:32:26 +02007274
7275static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7278 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7279 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7280 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007284 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7285 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7286 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007287 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7288 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7289 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7290 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7291 {
7292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7293 /* .name = "Capture Source", */
7294 .name = "Input Source",
7295 .count = 2,
7296 .info = alc883_mux_enum_info,
7297 .get = alc883_mux_enum_get,
7298 .put = alc883_mux_enum_put,
7299 },
7300 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007301};
Kailang Yangccc656c2006-10-17 12:32:26 +02007302
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007303static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7305 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7307 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7310 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7312 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7313 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7314 {
7315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7316 /* .name = "Capture Source", */
7317 .name = "Input Source",
7318 .count = 1,
7319 .info = alc883_mux_enum_info,
7320 .get = alc883_mux_enum_get,
7321 .put = alc883_mux_enum_put,
7322 },
7323 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007325
Kailang Yang272a5272007-05-14 11:00:38 +02007326static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7327 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7328 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7334 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7335 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7338 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7339 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7340 {
7341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7342 /* .name = "Capture Source", */
7343 .name = "Input Source",
7344 .count = 2,
7345 .info = alc883_mux_enum_info,
7346 .get = alc883_mux_enum_get,
7347 .put = alc883_mux_enum_put,
7348 },
7349 { } /* end */
7350};
7351
7352static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7355 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7361 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7362 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7363 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7364 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7365 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7366 {
7367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7368 /* .name = "Capture Source", */
7369 .name = "Input Source",
7370 .count = 2,
7371 .info = alc883_mux_enum_info,
7372 .get = alc883_mux_enum_get,
7373 .put = alc883_mux_enum_put,
7374 },
7375 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007376};
Kailang Yang272a5272007-05-14 11:00:38 +02007377
Tobin Davis2880a862007-08-07 11:50:26 +02007378static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007379 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7380 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007387 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7388 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7391 {
7392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7393 /* .name = "Capture Source", */
7394 .name = "Input Source",
7395 .count = 2,
7396 .info = alc883_mux_enum_info,
7397 .get = alc883_mux_enum_get,
7398 .put = alc883_mux_enum_put,
7399 },
7400 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007401};
Tobin Davis2880a862007-08-07 11:50:26 +02007402
Kailang Yange2757d52008-08-26 13:17:46 +02007403static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7404 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7405 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7406 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7407 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7408 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7409 0x0d, 1, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7411 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7412 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7413 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7414 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7416 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7425 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7426 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7427 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7428 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7429 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7430 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7431 {
7432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7433 /* .name = "Capture Source", */
7434 .name = "Input Source",
7435 .count = 2,
7436 .info = alc883_mux_enum_info,
7437 .get = alc883_mux_enum_get,
7438 .put = alc883_mux_enum_put,
7439 },
7440 { } /* end */
7441};
7442
7443static struct hda_bind_ctls alc883_bind_cap_vol = {
7444 .ops = &snd_hda_bind_vol,
7445 .values = {
7446 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7447 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7448 0
7449 },
7450};
7451
7452static struct hda_bind_ctls alc883_bind_cap_switch = {
7453 .ops = &snd_hda_bind_sw,
7454 .values = {
7455 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7456 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7457 0
7458 },
7459};
7460
7461static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7462 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7463 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7470 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7471 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7472 {
7473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7474 /* .name = "Capture Source", */
7475 .name = "Input Source",
7476 .count = 1,
7477 .info = alc883_mux_enum_info,
7478 .get = alc883_mux_enum_get,
7479 .put = alc883_mux_enum_put,
7480 },
7481 { } /* end */
7482};
7483
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007484static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7485 {
7486 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7487 .name = "Channel Mode",
7488 .info = alc_ch_mode_info,
7489 .get = alc_ch_mode_get,
7490 .put = alc_ch_mode_put,
7491 },
7492 { } /* end */
7493};
7494
7495static struct hda_verb alc883_init_verbs[] = {
7496 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007498 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* ADC2: mute amp left and right */
7500 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7502 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7506 /* Rear mixer */
7507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7510 /* CLFE mixer */
7511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7514 /* Side mixer */
7515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7518
Takashi Iwaicb53c622007-08-10 17:21:45 +02007519 /* mute analog input loopbacks */
7520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007525
7526 /* Front Pin: output 0 (0x0c) */
7527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7529 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7530 /* Rear Pin: output 1 (0x0d) */
7531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7533 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7534 /* CLFE Pin: output 2 (0x0e) */
7535 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7536 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7537 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7538 /* Side Pin: output 3 (0x0f) */
7539 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7540 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7541 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7542 /* Mic (rear) pin: input vref at 80% */
7543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7545 /* Front Mic pin: input vref at 80% */
7546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7548 /* Line In pin: input */
7549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7551 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7553 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7554 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7555 /* CD pin widget for input */
7556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7557
7558 /* FIXME: use matrix-type input source selection */
7559 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7560 /* Input mixer2 */
7561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007565 /* Input mixer3 */
7566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007570 { }
7571};
7572
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007573/* toggle speaker-output according to the hp-jack state */
7574static void alc883_mitac_hp_automute(struct hda_codec *codec)
7575{
7576 unsigned int present;
7577
7578 present = snd_hda_codec_read(codec, 0x15, 0,
7579 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7580 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7581 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7582 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7583 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7584}
7585
7586/* auto-toggle front mic */
7587/*
7588static void alc883_mitac_mic_automute(struct hda_codec *codec)
7589{
7590 unsigned int present;
7591 unsigned char bits;
7592
7593 present = snd_hda_codec_read(codec, 0x18, 0,
7594 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7595 bits = present ? HDA_AMP_MUTE : 0;
7596 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7597}
7598*/
7599
7600static void alc883_mitac_automute(struct hda_codec *codec)
7601{
7602 alc883_mitac_hp_automute(codec);
7603 /* alc883_mitac_mic_automute(codec); */
7604}
7605
7606static void alc883_mitac_unsol_event(struct hda_codec *codec,
7607 unsigned int res)
7608{
7609 switch (res >> 26) {
7610 case ALC880_HP_EVENT:
7611 alc883_mitac_hp_automute(codec);
7612 break;
7613 case ALC880_MIC_EVENT:
7614 /* alc883_mitac_mic_automute(codec); */
7615 break;
7616 }
7617}
7618
7619static struct hda_verb alc883_mitac_verbs[] = {
7620 /* HP */
7621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7623 /* Subwoofer */
7624 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7625 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7626
7627 /* enable unsolicited event */
7628 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7629 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7630
7631 { } /* end */
7632};
7633
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007634static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007635 /* HP */
7636 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7638 /* Int speaker */
7639 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7640 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7641
7642 /* enable unsolicited event */
7643 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007644 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007645
7646 { } /* end */
7647};
7648
Jiang zhefb97dc62008-03-06 11:07:11 +01007649static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7650 /* HP */
7651 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7653 /* Subwoofer */
7654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7656
7657 /* enable unsolicited event */
7658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7659
7660 { } /* end */
7661};
7662
Kailang Yangccc656c2006-10-17 12:32:26 +02007663static struct hda_verb alc883_tagra_verbs[] = {
7664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7666
7667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007669
Kailang Yangccc656c2006-10-17 12:32:26 +02007670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7673
7674 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007675 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7676 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7677 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007678
7679 { } /* end */
7680};
7681
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007682static struct hda_verb alc883_lenovo_101e_verbs[] = {
7683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7684 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7686 { } /* end */
7687};
7688
Kailang Yang272a5272007-05-14 11:00:38 +02007689static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7690 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7692 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7694 { } /* end */
7695};
7696
7697static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7700 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7701 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7702 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7703 { } /* end */
7704};
7705
Kailang Yang189609a2007-08-20 11:31:23 +02007706static struct hda_verb alc883_haier_w66_verbs[] = {
7707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7709
7710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7711
7712 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7714 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7716 { } /* end */
7717};
7718
Kailang Yange2757d52008-08-26 13:17:46 +02007719static struct hda_verb alc888_lenovo_sky_verbs[] = {
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7725 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7726 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7727 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7728 { } /* end */
7729};
7730
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007731static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007732 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007733 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7734 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007735 { }
7736};
7737
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007738static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007739 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7740 { }
7741};
7742
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007743static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007744 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7745 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7746 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7747 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7748 { }
7749};
7750
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007751static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007752 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7753 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7754 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7755 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7756 { }
7757};
7758
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007759static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7760 { 2, alc888_3st_hp_2ch_init },
7761 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007762};
7763
Kailang Yang272a5272007-05-14 11:00:38 +02007764/* toggle front-jack and RCA according to the hp-jack state */
7765static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7766{
7767 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007768
Kailang Yang272a5272007-05-14 11:00:38 +02007769 present = snd_hda_codec_read(codec, 0x1b, 0,
7770 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007771 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7773 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7774 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007775}
7776
7777/* toggle RCA according to the front-jack state */
7778static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7779{
7780 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007781
Kailang Yang272a5272007-05-14 11:00:38 +02007782 present = snd_hda_codec_read(codec, 0x14, 0,
7783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007784 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7785 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007786}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007787
Kailang Yang272a5272007-05-14 11:00:38 +02007788static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7789 unsigned int res)
7790{
7791 if ((res >> 26) == ALC880_HP_EVENT)
7792 alc888_lenovo_ms7195_front_automute(codec);
7793 if ((res >> 26) == ALC880_FRONT_EVENT)
7794 alc888_lenovo_ms7195_rca_automute(codec);
7795}
7796
7797static struct hda_verb alc883_medion_md2_verbs[] = {
7798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7800
7801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7802
7803 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7804 { } /* end */
7805};
7806
7807/* toggle speaker-output according to the hp-jack state */
7808static void alc883_medion_md2_automute(struct hda_codec *codec)
7809{
7810 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007811
Kailang Yang272a5272007-05-14 11:00:38 +02007812 present = snd_hda_codec_read(codec, 0x14, 0,
7813 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007814 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7815 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007816}
7817
7818static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7819 unsigned int res)
7820{
7821 if ((res >> 26) == ALC880_HP_EVENT)
7822 alc883_medion_md2_automute(codec);
7823}
7824
Kailang Yangccc656c2006-10-17 12:32:26 +02007825/* toggle speaker-output according to the hp-jack state */
7826static void alc883_tagra_automute(struct hda_codec *codec)
7827{
7828 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007829 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007830
7831 present = snd_hda_codec_read(codec, 0x14, 0,
7832 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007833 bits = present ? HDA_AMP_MUTE : 0;
7834 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7835 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007836 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7837 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007838}
7839
7840static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7841{
7842 if ((res >> 26) == ALC880_HP_EVENT)
7843 alc883_tagra_automute(codec);
7844}
7845
Jiang zhe368c7a92008-03-04 11:20:33 +01007846/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007847static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007848{
7849 unsigned int present;
7850 unsigned char bits;
7851
7852 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7853 & AC_PINSENSE_PRESENCE;
7854 bits = present ? HDA_AMP_MUTE : 0;
7855 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7856 HDA_AMP_MUTE, bits);
7857}
7858
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007859static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7860{
7861 unsigned int present;
7862
7863 present = snd_hda_codec_read(codec, 0x18, 0,
7864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7865 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7866 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7867}
7868
7869static void alc883_clevo_m720_automute(struct hda_codec *codec)
7870{
7871 alc883_clevo_m720_hp_automute(codec);
7872 alc883_clevo_m720_mic_automute(codec);
7873}
7874
7875static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007876 unsigned int res)
7877{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007878 switch (res >> 26) {
7879 case ALC880_HP_EVENT:
7880 alc883_clevo_m720_hp_automute(codec);
7881 break;
7882 case ALC880_MIC_EVENT:
7883 alc883_clevo_m720_mic_automute(codec);
7884 break;
7885 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007886}
7887
Jiang zhefb97dc62008-03-06 11:07:11 +01007888/* toggle speaker-output according to the hp-jack state */
7889static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7890{
7891 unsigned int present;
7892 unsigned char bits;
7893
7894 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7895 & AC_PINSENSE_PRESENCE;
7896 bits = present ? HDA_AMP_MUTE : 0;
7897 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7898 HDA_AMP_MUTE, bits);
7899}
7900
7901static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7902 unsigned int res)
7903{
7904 if ((res >> 26) == ALC880_HP_EVENT)
7905 alc883_2ch_fujitsu_pi2515_automute(codec);
7906}
7907
Kailang Yang189609a2007-08-20 11:31:23 +02007908static void alc883_haier_w66_automute(struct hda_codec *codec)
7909{
7910 unsigned int present;
7911 unsigned char bits;
7912
7913 present = snd_hda_codec_read(codec, 0x1b, 0,
7914 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7915 bits = present ? 0x80 : 0;
7916 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7917 0x80, bits);
7918}
7919
7920static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7921 unsigned int res)
7922{
7923 if ((res >> 26) == ALC880_HP_EVENT)
7924 alc883_haier_w66_automute(codec);
7925}
7926
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007927static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7928{
7929 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007930 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007931
7932 present = snd_hda_codec_read(codec, 0x14, 0,
7933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007934 bits = present ? HDA_AMP_MUTE : 0;
7935 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7936 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007937}
7938
7939static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7940{
7941 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007942 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007943
7944 present = snd_hda_codec_read(codec, 0x1b, 0,
7945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007946 bits = present ? HDA_AMP_MUTE : 0;
7947 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7948 HDA_AMP_MUTE, bits);
7949 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7950 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007951}
7952
7953static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7954 unsigned int res)
7955{
7956 if ((res >> 26) == ALC880_HP_EVENT)
7957 alc883_lenovo_101e_all_automute(codec);
7958 if ((res >> 26) == ALC880_FRONT_EVENT)
7959 alc883_lenovo_101e_ispeaker_automute(codec);
7960}
7961
Takashi Iwai676a9b52007-08-16 15:23:35 +02007962/* toggle speaker-output according to the hp-jack state */
7963static void alc883_acer_aspire_automute(struct hda_codec *codec)
7964{
7965 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007966
Takashi Iwai676a9b52007-08-16 15:23:35 +02007967 present = snd_hda_codec_read(codec, 0x14, 0,
7968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7969 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7970 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7971 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7972 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7973}
7974
7975static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7976 unsigned int res)
7977{
7978 if ((res >> 26) == ALC880_HP_EVENT)
7979 alc883_acer_aspire_automute(codec);
7980}
7981
Kailang Yangd1a991a2007-08-15 16:21:59 +02007982static struct hda_verb alc883_acer_eapd_verbs[] = {
7983 /* HP Pin: output 0 (0x0c) */
7984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7985 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7986 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7987 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007991 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7992 /* eanable EAPD on medion laptop */
7993 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7994 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007995 /* enable unsolicited event */
7996 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007997 { }
7998};
7999
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008000static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8001{
8002 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008003
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008004 present = snd_hda_codec_read(codec, 0x1b, 0,
8005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8006 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8007 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8008 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8009 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8010 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8011 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8012 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8013 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8014}
8015
8016static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8017 unsigned int res)
8018{
8019 switch (res >> 26) {
8020 case ALC880_HP_EVENT:
8021 printk("hp_event\n");
8022 alc888_6st_dell_front_automute(codec);
8023 break;
8024 }
8025}
8026
Kailang Yange2757d52008-08-26 13:17:46 +02008027static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8028{
8029 unsigned int mute;
8030 unsigned int present;
8031
8032 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8033 present = snd_hda_codec_read(codec, 0x1b, 0,
8034 AC_VERB_GET_PIN_SENSE, 0);
8035 present = (present & 0x80000000) != 0;
8036 if (present) {
8037 /* mute internal speaker */
8038 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8039 HDA_AMP_MUTE, HDA_AMP_MUTE);
8040 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8041 HDA_AMP_MUTE, HDA_AMP_MUTE);
8042 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8043 HDA_AMP_MUTE, HDA_AMP_MUTE);
8044 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8045 HDA_AMP_MUTE, HDA_AMP_MUTE);
8046 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8047 HDA_AMP_MUTE, HDA_AMP_MUTE);
8048 } else {
8049 /* unmute internal speaker if necessary */
8050 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8051 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8052 HDA_AMP_MUTE, mute);
8053 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8054 HDA_AMP_MUTE, mute);
8055 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8056 HDA_AMP_MUTE, mute);
8057 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8058 HDA_AMP_MUTE, mute);
8059 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8060 HDA_AMP_MUTE, mute);
8061 }
8062}
8063
8064static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8065 unsigned int res)
8066{
8067 if ((res >> 26) == ALC880_HP_EVENT)
8068 alc888_lenovo_sky_front_automute(codec);
8069}
8070
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008071/*
8072 * generic initialization of ADC, input mixers and output mixers
8073 */
8074static struct hda_verb alc883_auto_init_verbs[] = {
8075 /*
8076 * Unmute ADC0-2 and set the default input to mic-in
8077 */
8078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8082
Takashi Iwaicb53c622007-08-10 17:21:45 +02008083 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008084 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008085 * Note: PASD motherboards uses the Line In 2 as the input for
8086 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008087 */
8088 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008094
8095 /*
8096 * Set up output mixers (0x0c - 0x0f)
8097 */
8098 /* set vol=0 to output mixers */
8099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8102 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8103 /* set up input amps for analog loopback */
8104 /* Amp Indices: DAC = 0, mixer = 1 */
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8113 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8114 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8115
8116 /* FIXME: use matrix-type input source selection */
8117 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8118 /* Input mixer1 */
8119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008122 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8124 /* Input mixer2 */
8125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008128 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008130
8131 { }
8132};
8133
8134/* capture mixer elements */
8135static struct snd_kcontrol_new alc883_capture_mixer[] = {
8136 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8137 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8138 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
8139 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
8140 {
8141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8142 /* The multiple "Capture Source" controls confuse alsamixer
8143 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008144 */
8145 /* .name = "Capture Source", */
8146 .name = "Input Source",
8147 .count = 2,
8148 .info = alc882_mux_enum_info,
8149 .get = alc882_mux_enum_get,
8150 .put = alc882_mux_enum_put,
8151 },
8152 { } /* end */
8153};
8154
Kailang Yange2757d52008-08-26 13:17:46 +02008155static struct hda_verb alc888_asus_m90v_verbs[] = {
8156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8159 /* enable unsolicited event */
8160 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8161 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8162 { } /* end */
8163};
8164
8165static void alc883_nb_mic_automute(struct hda_codec *codec)
8166{
8167 unsigned int present;
8168
8169 present = snd_hda_codec_read(codec, 0x18, 0,
8170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8171 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8172 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8173 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8174 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8175}
8176
8177static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8178{
8179 unsigned int present;
8180 unsigned char bits;
8181
8182 present = snd_hda_codec_read(codec, 0x1b, 0,
8183 AC_VERB_GET_PIN_SENSE, 0)
8184 & AC_PINSENSE_PRESENCE;
8185 bits = present ? 0 : PIN_OUT;
8186 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8187 bits);
8188 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8189 bits);
8190 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8191 bits);
8192}
8193
8194static void alc883_mode2_unsol_event(struct hda_codec *codec,
8195 unsigned int res)
8196{
8197 switch (res >> 26) {
8198 case ALC880_HP_EVENT:
8199 alc883_M90V_speaker_automute(codec);
8200 break;
8201 case ALC880_MIC_EVENT:
8202 alc883_nb_mic_automute(codec);
8203 break;
8204 }
8205}
8206
8207static void alc883_mode2_inithook(struct hda_codec *codec)
8208{
8209 alc883_M90V_speaker_automute(codec);
8210 alc883_nb_mic_automute(codec);
8211}
8212
8213static struct hda_verb alc888_asus_eee1601_verbs[] = {
8214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8219 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8220 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8221 /* enable unsolicited event */
8222 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8223 { } /* end */
8224};
8225
8226static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8227{
8228 unsigned int present;
8229 unsigned char bits;
8230
8231 present = snd_hda_codec_read(codec, 0x14, 0,
8232 AC_VERB_GET_PIN_SENSE, 0)
8233 & AC_PINSENSE_PRESENCE;
8234 bits = present ? 0 : PIN_OUT;
8235 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8236 bits);
8237}
8238
8239static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8240 unsigned int res)
8241{
8242 switch (res >> 26) {
8243 case ALC880_HP_EVENT:
8244 alc883_eee1601_speaker_automute(codec);
8245 break;
8246 }
8247}
8248
8249static void alc883_eee1601_inithook(struct hda_codec *codec)
8250{
8251 alc883_eee1601_speaker_automute(codec);
8252}
8253
Takashi Iwaicb53c622007-08-10 17:21:45 +02008254#ifdef CONFIG_SND_HDA_POWER_SAVE
8255#define alc883_loopbacks alc880_loopbacks
8256#endif
8257
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258/* pcm configuration: identiacal with ALC880 */
8259#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8260#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008261#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008262#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8263#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8264
8265/*
8266 * configuration and preset
8267 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008268static const char *alc883_models[ALC883_MODEL_LAST] = {
8269 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8270 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8271 [ALC883_3ST_6ch] = "3stack-6ch",
8272 [ALC883_6ST_DIG] = "6stack-dig",
8273 [ALC883_TARGA_DIG] = "targa-dig",
8274 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008275 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008276 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008277 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008278 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008279 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008280 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008281 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8282 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008283 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008284 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008285 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008286 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008287 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008288 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008289 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008290 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008291 [ALC883_AUTO] = "auto",
8292};
8293
8294static struct snd_pci_quirk alc883_cfg_tbl[] = {
8295 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008296 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8297 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8298 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008299 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008300 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008301 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008302 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008303 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8304 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008305 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008306 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008307 SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V),
8308 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008309 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008310 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008311 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8312 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008313 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008314 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008315 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008316 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8317 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8318 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008319 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008320 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008321 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008322 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8323 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8324 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8325 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8326 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8327 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8328 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8329 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8330 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008331 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8332 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008333 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008334 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008335 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008336 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008337 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008338 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008339 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8340 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008341 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008342 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008343 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008344 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008345 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008346 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008347 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8348 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008349 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008350 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008351 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008352 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008353 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8354 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008355 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008356 {}
8357};
8358
8359static struct alc_config_preset alc883_presets[] = {
8360 [ALC883_3ST_2ch_DIG] = {
8361 .mixers = { alc883_3ST_2ch_mixer },
8362 .init_verbs = { alc883_init_verbs },
8363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8364 .dac_nids = alc883_dac_nids,
8365 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008366 .dig_in_nid = ALC883_DIGIN_NID,
8367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8368 .channel_mode = alc883_3ST_2ch_modes,
8369 .input_mux = &alc883_capture_source,
8370 },
8371 [ALC883_3ST_6ch_DIG] = {
8372 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8373 .init_verbs = { alc883_init_verbs },
8374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8375 .dac_nids = alc883_dac_nids,
8376 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008377 .dig_in_nid = ALC883_DIGIN_NID,
8378 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8379 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008380 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008381 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008382 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008383 [ALC883_3ST_6ch] = {
8384 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8385 .init_verbs = { alc883_init_verbs },
8386 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8387 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8389 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008390 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008391 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008392 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008393 [ALC883_3ST_6ch_INTEL] = {
8394 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8395 .init_verbs = { alc883_init_verbs },
8396 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8397 .dac_nids = alc883_dac_nids,
8398 .dig_out_nid = ALC883_DIGOUT_NID,
8399 .dig_in_nid = ALC883_DIGIN_NID,
8400 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8401 .channel_mode = alc883_3ST_6ch_intel_modes,
8402 .need_dac_fix = 1,
8403 .input_mux = &alc883_3stack_6ch_intel,
8404 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008405 [ALC883_6ST_DIG] = {
8406 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8407 .init_verbs = { alc883_init_verbs },
8408 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8409 .dac_nids = alc883_dac_nids,
8410 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008411 .dig_in_nid = ALC883_DIGIN_NID,
8412 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8413 .channel_mode = alc883_sixstack_modes,
8414 .input_mux = &alc883_capture_source,
8415 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008416 [ALC883_TARGA_DIG] = {
8417 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8418 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8420 .dac_nids = alc883_dac_nids,
8421 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008422 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8423 .channel_mode = alc883_3ST_6ch_modes,
8424 .need_dac_fix = 1,
8425 .input_mux = &alc883_capture_source,
8426 .unsol_event = alc883_tagra_unsol_event,
8427 .init_hook = alc883_tagra_automute,
8428 },
8429 [ALC883_TARGA_2ch_DIG] = {
8430 .mixers = { alc883_tagra_2ch_mixer},
8431 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8433 .dac_nids = alc883_dac_nids,
8434 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8436 .channel_mode = alc883_3ST_2ch_modes,
8437 .input_mux = &alc883_capture_source,
8438 .unsol_event = alc883_tagra_unsol_event,
8439 .init_hook = alc883_tagra_automute,
8440 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008441 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008442 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008443 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8444 * and the headphone jack. Turn this on and rely on the
8445 * standard mute methods whenever the user wants to turn
8446 * these outputs off.
8447 */
8448 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8450 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008451 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8452 .channel_mode = alc883_3ST_2ch_modes,
8453 .input_mux = &alc883_capture_source,
8454 },
Tobin Davis2880a862007-08-07 11:50:26 +02008455 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008456 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008457 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8459 .dac_nids = alc883_dac_nids,
8460 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8462 .channel_mode = alc883_3ST_2ch_modes,
8463 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008464 .unsol_event = alc883_acer_aspire_unsol_event,
8465 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008466 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008467 [ALC883_MEDION] = {
8468 .mixers = { alc883_fivestack_mixer,
8469 alc883_chmode_mixer },
8470 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008471 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8473 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008474 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8475 .channel_mode = alc883_sixstack_modes,
8476 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008477 },
Kailang Yang272a5272007-05-14 11:00:38 +02008478 [ALC883_MEDION_MD2] = {
8479 .mixers = { alc883_medion_md2_mixer},
8480 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8482 .dac_nids = alc883_dac_nids,
8483 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008484 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8485 .channel_mode = alc883_3ST_2ch_modes,
8486 .input_mux = &alc883_capture_source,
8487 .unsol_event = alc883_medion_md2_unsol_event,
8488 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008489 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008490 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008491 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008492 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8494 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008495 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8496 .channel_mode = alc883_3ST_2ch_modes,
8497 .input_mux = &alc883_capture_source,
8498 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008499 [ALC883_CLEVO_M720] = {
8500 .mixers = { alc883_clevo_m720_mixer },
8501 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008502 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8503 .dac_nids = alc883_dac_nids,
8504 .dig_out_nid = ALC883_DIGOUT_NID,
8505 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8506 .channel_mode = alc883_3ST_2ch_modes,
8507 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008508 .unsol_event = alc883_clevo_m720_unsol_event,
8509 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008510 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008511 [ALC883_LENOVO_101E_2ch] = {
8512 .mixers = { alc883_lenovo_101e_2ch_mixer},
8513 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8514 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8515 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008516 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8517 .channel_mode = alc883_3ST_2ch_modes,
8518 .input_mux = &alc883_lenovo_101e_capture_source,
8519 .unsol_event = alc883_lenovo_101e_unsol_event,
8520 .init_hook = alc883_lenovo_101e_all_automute,
8521 },
Kailang Yang272a5272007-05-14 11:00:38 +02008522 [ALC883_LENOVO_NB0763] = {
8523 .mixers = { alc883_lenovo_nb0763_mixer },
8524 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8525 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8526 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8528 .channel_mode = alc883_3ST_2ch_modes,
8529 .need_dac_fix = 1,
8530 .input_mux = &alc883_lenovo_nb0763_capture_source,
8531 .unsol_event = alc883_medion_md2_unsol_event,
8532 .init_hook = alc883_medion_md2_automute,
8533 },
8534 [ALC888_LENOVO_MS7195_DIG] = {
8535 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8536 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8538 .dac_nids = alc883_dac_nids,
8539 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008540 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8541 .channel_mode = alc883_3ST_6ch_modes,
8542 .need_dac_fix = 1,
8543 .input_mux = &alc883_capture_source,
8544 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8545 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008546 },
8547 [ALC883_HAIER_W66] = {
8548 .mixers = { alc883_tagra_2ch_mixer},
8549 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8551 .dac_nids = alc883_dac_nids,
8552 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8554 .channel_mode = alc883_3ST_2ch_modes,
8555 .input_mux = &alc883_capture_source,
8556 .unsol_event = alc883_haier_w66_unsol_event,
8557 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008558 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008559 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008560 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008561 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8563 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008564 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8565 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008566 .need_dac_fix = 1,
8567 .input_mux = &alc883_capture_source,
8568 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008569 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008570 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008571 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8573 .dac_nids = alc883_dac_nids,
8574 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008575 .dig_in_nid = ALC883_DIGIN_NID,
8576 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8577 .channel_mode = alc883_sixstack_modes,
8578 .input_mux = &alc883_capture_source,
8579 .unsol_event = alc888_6st_dell_unsol_event,
8580 .init_hook = alc888_6st_dell_front_automute,
8581 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008582 [ALC883_MITAC] = {
8583 .mixers = { alc883_mitac_mixer },
8584 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8586 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008587 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8588 .channel_mode = alc883_3ST_2ch_modes,
8589 .input_mux = &alc883_capture_source,
8590 .unsol_event = alc883_mitac_unsol_event,
8591 .init_hook = alc883_mitac_automute,
8592 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008593 [ALC883_FUJITSU_PI2515] = {
8594 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8595 .init_verbs = { alc883_init_verbs,
8596 alc883_2ch_fujitsu_pi2515_verbs},
8597 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8598 .dac_nids = alc883_dac_nids,
8599 .dig_out_nid = ALC883_DIGOUT_NID,
8600 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8601 .channel_mode = alc883_3ST_2ch_modes,
8602 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8603 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8604 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8605 },
Kailang Yange2757d52008-08-26 13:17:46 +02008606 [ALC888_LENOVO_SKY] = {
8607 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8608 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8610 .dac_nids = alc883_dac_nids,
8611 .dig_out_nid = ALC883_DIGOUT_NID,
8612 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
8613 .adc_nids = alc883_adc_nids,
8614 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8615 .channel_mode = alc883_sixstack_modes,
8616 .need_dac_fix = 1,
8617 .input_mux = &alc883_lenovo_sky_capture_source,
8618 .unsol_event = alc883_lenovo_sky_unsol_event,
8619 .init_hook = alc888_lenovo_sky_front_automute,
8620 },
8621 [ALC888_ASUS_M90V] = {
8622 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8623 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8624 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8625 .dac_nids = alc883_dac_nids,
8626 .dig_out_nid = ALC883_DIGOUT_NID,
8627 .dig_in_nid = ALC883_DIGIN_NID,
8628 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8629 .channel_mode = alc883_3ST_6ch_modes,
8630 .need_dac_fix = 1,
8631 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8632 .unsol_event = alc883_mode2_unsol_event,
8633 .init_hook = alc883_mode2_inithook,
8634 },
8635 [ALC888_ASUS_EEE1601] = {
8636 .mixers = { alc883_asus_eee1601_mixer },
8637 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8638 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8639 .dac_nids = alc883_dac_nids,
8640 .dig_out_nid = ALC883_DIGOUT_NID,
8641 .dig_in_nid = ALC883_DIGIN_NID,
8642 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8643 .channel_mode = alc883_3ST_2ch_modes,
8644 .need_dac_fix = 1,
8645 .input_mux = &alc883_asus_eee1601_capture_source,
8646 .unsol_event = alc883_eee1601_unsol_event,
8647 .init_hook = alc883_eee1601_inithook,
8648 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008649};
8650
8651
8652/*
8653 * BIOS auto configuration
8654 */
8655static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8656 hda_nid_t nid, int pin_type,
8657 int dac_idx)
8658{
8659 /* set as output */
8660 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008661 int idx;
8662
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008663 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008664 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8665 idx = 4;
8666 else
8667 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008668 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8669
8670}
8671
8672static void alc883_auto_init_multi_out(struct hda_codec *codec)
8673{
8674 struct alc_spec *spec = codec->spec;
8675 int i;
8676
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008677 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008678 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008679 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008680 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008681 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008682 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008683 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008684 }
8685}
8686
8687static void alc883_auto_init_hp_out(struct hda_codec *codec)
8688{
8689 struct alc_spec *spec = codec->spec;
8690 hda_nid_t pin;
8691
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008692 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008693 if (pin) /* connect to front */
8694 /* use dac 0 */
8695 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008696 pin = spec->autocfg.speaker_pins[0];
8697 if (pin)
8698 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008699}
8700
8701#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8702#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8703
8704static void alc883_auto_init_analog_input(struct hda_codec *codec)
8705{
8706 struct alc_spec *spec = codec->spec;
8707 int i;
8708
8709 for (i = 0; i < AUTO_PIN_LAST; i++) {
8710 hda_nid_t nid = spec->autocfg.input_pins[i];
8711 if (alc883_is_input_pin(nid)) {
8712 snd_hda_codec_write(codec, nid, 0,
8713 AC_VERB_SET_PIN_WIDGET_CONTROL,
8714 (i <= AUTO_PIN_FRONT_MIC ?
8715 PIN_VREF80 : PIN_IN));
8716 if (nid != ALC883_PIN_CD_NID)
8717 snd_hda_codec_write(codec, nid, 0,
8718 AC_VERB_SET_AMP_GAIN_MUTE,
8719 AMP_OUT_MUTE);
8720 }
8721 }
8722}
8723
Takashi Iwaif511b012008-08-15 16:46:42 +02008724#define alc883_auto_init_input_src alc882_auto_init_input_src
8725
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008726/* almost identical with ALC880 parser... */
8727static int alc883_parse_auto_config(struct hda_codec *codec)
8728{
8729 struct alc_spec *spec = codec->spec;
8730 int err = alc880_parse_auto_config(codec);
8731
8732 if (err < 0)
8733 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008734 else if (!err)
8735 return 0; /* no config found */
8736
8737 err = alc_auto_add_mic_boost(codec);
8738 if (err < 0)
8739 return err;
8740
8741 /* hack - override the init verbs */
8742 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008743 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8744 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008745
8746 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008747}
8748
8749/* additional initialization for auto-configuration model */
8750static void alc883_auto_init(struct hda_codec *codec)
8751{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008752 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008753 alc883_auto_init_multi_out(codec);
8754 alc883_auto_init_hp_out(codec);
8755 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008756 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008757 if (spec->unsol_event)
8758 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008759}
8760
8761static int patch_alc883(struct hda_codec *codec)
8762{
8763 struct alc_spec *spec;
8764 int err, board_config;
8765
8766 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8767 if (spec == NULL)
8768 return -ENOMEM;
8769
8770 codec->spec = spec;
8771
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008772 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8773
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008774 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8775 alc883_models,
8776 alc883_cfg_tbl);
8777 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008778 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8779 "trying auto-probe from BIOS...\n");
8780 board_config = ALC883_AUTO;
8781 }
8782
8783 if (board_config == ALC883_AUTO) {
8784 /* automatic parse from the BIOS config */
8785 err = alc883_parse_auto_config(codec);
8786 if (err < 0) {
8787 alc_free(codec);
8788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008789 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008790 printk(KERN_INFO
8791 "hda_codec: Cannot set up configuration "
8792 "from BIOS. Using base mode...\n");
8793 board_config = ALC883_3ST_2ch_DIG;
8794 }
8795 }
8796
8797 if (board_config != ALC883_AUTO)
8798 setup_preset(spec, &alc883_presets[board_config]);
8799
Kailang Yang2f893282008-05-27 12:14:47 +02008800 switch (codec->vendor_id) {
8801 case 0x10ec0888:
8802 spec->stream_name_analog = "ALC888 Analog";
8803 spec->stream_name_digital = "ALC888 Digital";
8804 break;
8805 case 0x10ec0889:
8806 spec->stream_name_analog = "ALC889 Analog";
8807 spec->stream_name_digital = "ALC889 Digital";
8808 break;
8809 default:
8810 spec->stream_name_analog = "ALC883 Analog";
8811 spec->stream_name_digital = "ALC883 Digital";
8812 break;
8813 }
8814
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008815 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8816 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008817 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008818
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008819 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8820 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8821
Takashi Iwaie1406342008-02-11 18:32:32 +01008822 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8823 spec->adc_nids = alc883_adc_nids;
8824 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008825
Takashi Iwai2134ea42008-01-10 16:53:55 +01008826 spec->vmaster_nid = 0x0c;
8827
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008828 codec->patch_ops = alc_patch_ops;
8829 if (board_config == ALC883_AUTO)
8830 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008831
Takashi Iwaicb53c622007-08-10 17:21:45 +02008832#ifdef CONFIG_SND_HDA_POWER_SAVE
8833 if (!spec->loopback.amplist)
8834 spec->loopback.amplist = alc883_loopbacks;
8835#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008836
8837 return 0;
8838}
8839
8840/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008841 * ALC262 support
8842 */
8843
8844#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8845#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8846
8847#define alc262_dac_nids alc260_dac_nids
8848#define alc262_adc_nids alc882_adc_nids
8849#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008850#define alc262_capsrc_nids alc882_capsrc_nids
8851#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008852
8853#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008854#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008855
Kailang Yang4e555fe2008-08-26 13:05:55 +02008856static hda_nid_t alc262_dmic_adc_nids[1] = {
8857 /* ADC0 */
8858 0x09
8859};
8860
8861static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8862
Kailang Yangdf694da2005-12-05 19:42:22 +01008863static struct snd_kcontrol_new alc262_base_mixer[] = {
8864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008875 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008876 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008877 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008878 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8880 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8881 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008882 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008883};
8884
Kailang Yangccc656c2006-10-17 12:32:26 +02008885static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8886 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8887 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008894 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008897 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008898 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008899 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008900 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8901 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8902 { } /* end */
8903};
8904
Takashi Iwaice875f02008-01-28 18:17:43 +01008905/* update HP, line and mono-out pins according to the master switch */
8906static void alc262_hp_master_update(struct hda_codec *codec)
8907{
8908 struct alc_spec *spec = codec->spec;
8909 int val = spec->master_sw;
8910
8911 /* HP & line-out */
8912 snd_hda_codec_write_cache(codec, 0x1b, 0,
8913 AC_VERB_SET_PIN_WIDGET_CONTROL,
8914 val ? PIN_HP : 0);
8915 snd_hda_codec_write_cache(codec, 0x15, 0,
8916 AC_VERB_SET_PIN_WIDGET_CONTROL,
8917 val ? PIN_HP : 0);
8918 /* mono (speaker) depending on the HP jack sense */
8919 val = val && !spec->jack_present;
8920 snd_hda_codec_write_cache(codec, 0x16, 0,
8921 AC_VERB_SET_PIN_WIDGET_CONTROL,
8922 val ? PIN_OUT : 0);
8923}
8924
8925static void alc262_hp_bpc_automute(struct hda_codec *codec)
8926{
8927 struct alc_spec *spec = codec->spec;
8928 unsigned int presence;
8929 presence = snd_hda_codec_read(codec, 0x1b, 0,
8930 AC_VERB_GET_PIN_SENSE, 0);
8931 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8932 alc262_hp_master_update(codec);
8933}
8934
8935static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8936{
8937 if ((res >> 26) != ALC880_HP_EVENT)
8938 return;
8939 alc262_hp_bpc_automute(codec);
8940}
8941
8942static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8943{
8944 struct alc_spec *spec = codec->spec;
8945 unsigned int presence;
8946 presence = snd_hda_codec_read(codec, 0x15, 0,
8947 AC_VERB_GET_PIN_SENSE, 0);
8948 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8949 alc262_hp_master_update(codec);
8950}
8951
8952static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8953 unsigned int res)
8954{
8955 if ((res >> 26) != ALC880_HP_EVENT)
8956 return;
8957 alc262_hp_wildwest_automute(codec);
8958}
8959
8960static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8961 struct snd_ctl_elem_value *ucontrol)
8962{
8963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8964 struct alc_spec *spec = codec->spec;
8965 *ucontrol->value.integer.value = spec->master_sw;
8966 return 0;
8967}
8968
8969static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8970 struct snd_ctl_elem_value *ucontrol)
8971{
8972 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8973 struct alc_spec *spec = codec->spec;
8974 int val = !!*ucontrol->value.integer.value;
8975
8976 if (val == spec->master_sw)
8977 return 0;
8978 spec->master_sw = val;
8979 alc262_hp_master_update(codec);
8980 return 1;
8981}
8982
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008983static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008984 {
8985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8986 .name = "Master Playback Switch",
8987 .info = snd_ctl_boolean_mono_info,
8988 .get = alc262_hp_master_sw_get,
8989 .put = alc262_hp_master_sw_put,
8990 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8992 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008994 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8995 HDA_OUTPUT),
8996 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8997 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009003 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9008 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9009 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9010 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9011 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9012 { } /* end */
9013};
9014
Kailang Yangcd7509a2007-01-26 18:33:17 +01009015static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009016 {
9017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9018 .name = "Master Playback Switch",
9019 .info = snd_ctl_boolean_mono_info,
9020 .get = alc262_hp_master_sw_get,
9021 .put = alc262_hp_master_sw_put,
9022 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009023 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9024 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009027 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9028 HDA_OUTPUT),
9029 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9030 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009031 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9032 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009033 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009034 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9035 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9036 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9037 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9038 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9039 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9040 { } /* end */
9041};
9042
9043static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9044 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9045 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009046 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009047 { } /* end */
9048};
9049
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009050/* mute/unmute internal speaker according to the hp jack and mute state */
9051static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9052{
9053 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009054
9055 if (force || !spec->sense_updated) {
9056 unsigned int present;
9057 present = snd_hda_codec_read(codec, 0x15, 0,
9058 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009059 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009060 spec->sense_updated = 1;
9061 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009062 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9063 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009064}
9065
9066static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9067 unsigned int res)
9068{
9069 if ((res >> 26) != ALC880_HP_EVENT)
9070 return;
9071 alc262_hp_t5735_automute(codec, 1);
9072}
9073
9074static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9075{
9076 alc262_hp_t5735_automute(codec, 1);
9077}
9078
9079static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009080 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9081 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009082 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9087 { } /* end */
9088};
9089
9090static struct hda_verb alc262_hp_t5735_verbs[] = {
9091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9093
9094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9095 { }
9096};
9097
Kailang Yang8c427222008-01-10 13:03:59 +01009098static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009101 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9102 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9105 { } /* end */
9106};
9107
9108static struct hda_verb alc262_hp_rp5700_verbs[] = {
9109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9110 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9111 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9112 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9114 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9119 {}
9120};
9121
9122static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9123 .num_items = 1,
9124 .items = {
9125 { "Line", 0x1 },
9126 },
9127};
9128
Takashi Iwai0724ea22007-08-23 00:31:43 +02009129/* bind hp and internal speaker mute (with plug check) */
9130static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9131 struct snd_ctl_elem_value *ucontrol)
9132{
9133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9134 long *valp = ucontrol->value.integer.value;
9135 int change;
9136
9137 /* change hp mute */
9138 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9139 HDA_AMP_MUTE,
9140 valp[0] ? 0 : HDA_AMP_MUTE);
9141 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9142 HDA_AMP_MUTE,
9143 valp[1] ? 0 : HDA_AMP_MUTE);
9144 if (change) {
9145 /* change speaker according to HP jack state */
9146 struct alc_spec *spec = codec->spec;
9147 unsigned int mute;
9148 if (spec->jack_present)
9149 mute = HDA_AMP_MUTE;
9150 else
9151 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9152 HDA_OUTPUT, 0);
9153 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9154 HDA_AMP_MUTE, mute);
9155 }
9156 return change;
9157}
Takashi Iwai5b319542007-07-26 11:49:22 +02009158
Kailang Yang272a5272007-05-14 11:00:38 +02009159static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009160 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9161 {
9162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9163 .name = "Master Playback Switch",
9164 .info = snd_hda_mixer_amp_switch_info,
9165 .get = snd_hda_mixer_amp_switch_get,
9166 .put = alc262_sony_master_sw_put,
9167 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9168 },
Kailang Yang272a5272007-05-14 11:00:38 +02009169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9171 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9172 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9173 { } /* end */
9174};
9175
Kailang Yang83c34212007-07-05 11:43:05 +02009176static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9178 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9182 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9183 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9184 { } /* end */
9185};
Kailang Yang272a5272007-05-14 11:00:38 +02009186
Kailang Yangdf694da2005-12-05 19:42:22 +01009187#define alc262_capture_mixer alc882_capture_mixer
9188#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9189
9190/*
9191 * generic initialization of ADC, input mixers and output mixers
9192 */
9193static struct hda_verb alc262_init_verbs[] = {
9194 /*
9195 * Unmute ADC0-2 and set the default input to mic-in
9196 */
9197 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9199 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9203
Takashi Iwaicb53c622007-08-10 17:21:45 +02009204 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009205 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009206 * Note: PASD motherboards uses the Line In 2 as the input for
9207 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009208 */
9209 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9213 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009215
9216 /*
9217 * Set up output mixers (0x0c - 0x0e)
9218 */
9219 /* set vol=0 to output mixers */
9220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9222 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9223 /* set up input amps for analog loopback */
9224 /* Amp Indices: DAC = 0, mixer = 1 */
9225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9231
9232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9234 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9235 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9236 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9237 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9238
9239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009244
Kailang Yangdf694da2005-12-05 19:42:22 +01009245 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009247
Kailang Yangdf694da2005-12-05 19:42:22 +01009248 /* FIXME: use matrix-type input source selection */
9249 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9250 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9255 /* Input mixer2 */
9256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9260 /* Input mixer3 */
9261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009265
9266 { }
9267};
9268
Kailang Yang4e555fe2008-08-26 13:05:55 +02009269static struct hda_verb alc262_eapd_verbs[] = {
9270 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9271 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9272 { }
9273};
9274
Kailang Yangccc656c2006-10-17 12:32:26 +02009275static struct hda_verb alc262_hippo_unsol_verbs[] = {
9276 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9278 {}
9279};
9280
9281static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9283 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9285
9286 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9288 {}
9289};
9290
Kailang Yang272a5272007-05-14 11:00:38 +02009291static struct hda_verb alc262_sony_unsol_verbs[] = {
9292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9293 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9294 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9295
9296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009298 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009299};
9300
Kailang Yang4e555fe2008-08-26 13:05:55 +02009301static struct hda_input_mux alc262_dmic_capture_source = {
9302 .num_items = 2,
9303 .items = {
9304 { "Int DMic", 0x9 },
9305 { "Mic", 0x0 },
9306 },
9307};
9308
9309static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9310 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9311 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9315 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9316 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9317 {
9318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9319 /* The multiple "Capture Source" controls confuse alsamixer
9320 * So call somewhat different..
9321 */
9322 /* .name = "Capture Source", */
9323 .name = "Input Source",
9324 .count = 1,
9325 .info = alc_mux_enum_info,
9326 .get = alc_mux_enum_get,
9327 .put = alc_mux_enum_put,
9328 },
9329 { } /* end */
9330};
9331
9332static struct hda_verb alc262_toshiba_s06_verbs[] = {
9333 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9337 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9338 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9339 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9340 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9341 {}
9342};
9343
9344static void alc262_dmic_automute(struct hda_codec *codec)
9345{
9346 unsigned int present;
9347
9348 present = snd_hda_codec_read(codec, 0x18, 0,
9349 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9350 snd_hda_codec_write(codec, 0x22, 0,
9351 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9352}
9353
9354/* toggle speaker-output according to the hp-jack state */
9355static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9356{
9357 unsigned int present;
9358 unsigned char bits;
9359
9360 present = snd_hda_codec_read(codec, 0x15, 0,
9361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9362 bits = present ? 0 : PIN_OUT;
9363 snd_hda_codec_write(codec, 0x14, 0,
9364 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9365}
9366
9367
9368
9369/* unsolicited event for HP jack sensing */
9370static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9371 unsigned int res)
9372{
9373 if ((res >> 26) == ALC880_HP_EVENT)
9374 alc262_toshiba_s06_speaker_automute(codec);
9375 if ((res >> 26) == ALC880_MIC_EVENT)
9376 alc262_dmic_automute(codec);
9377
9378}
9379
9380static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9381{
9382 alc262_toshiba_s06_speaker_automute(codec);
9383 alc262_dmic_automute(codec);
9384}
9385
Kailang Yangccc656c2006-10-17 12:32:26 +02009386/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009387static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009388{
9389 struct alc_spec *spec = codec->spec;
9390 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009391 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009392
Takashi Iwai5b319542007-07-26 11:49:22 +02009393 /* need to execute and sync at first */
9394 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9395 present = snd_hda_codec_read(codec, 0x15, 0,
9396 AC_VERB_GET_PIN_SENSE, 0);
9397 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009398 if (spec->jack_present) {
9399 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009400 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9401 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009402 } else {
9403 /* unmute internal speaker if necessary */
9404 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009405 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9406 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009407 }
9408}
9409
9410/* unsolicited event for HP jack sensing */
9411static void alc262_hippo_unsol_event(struct hda_codec *codec,
9412 unsigned int res)
9413{
9414 if ((res >> 26) != ALC880_HP_EVENT)
9415 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009416 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009417}
9418
Takashi Iwai5b319542007-07-26 11:49:22 +02009419static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009420{
Kailang Yangccc656c2006-10-17 12:32:26 +02009421 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009422 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009423
Takashi Iwai5b319542007-07-26 11:49:22 +02009424 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9425 present = snd_hda_codec_read(codec, 0x1b, 0,
9426 AC_VERB_GET_PIN_SENSE, 0);
9427 present = (present & 0x80000000) != 0;
9428 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009429 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009430 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9431 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009432 } else {
9433 /* unmute internal speaker if necessary */
9434 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009435 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9436 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009437 }
9438}
9439
9440/* unsolicited event for HP jack sensing */
9441static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9442 unsigned int res)
9443{
9444 if ((res >> 26) != ALC880_HP_EVENT)
9445 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009446 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009447}
9448
Takashi Iwai834be882006-03-01 14:16:17 +01009449/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009450 * nec model
9451 * 0x15 = headphone
9452 * 0x16 = internal speaker
9453 * 0x18 = external mic
9454 */
9455
9456static struct snd_kcontrol_new alc262_nec_mixer[] = {
9457 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9458 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9459
9460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9463
9464 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9466 { } /* end */
9467};
9468
9469static struct hda_verb alc262_nec_verbs[] = {
9470 /* Unmute Speaker */
9471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9472
9473 /* Headphone */
9474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9476
9477 /* External mic to headphone */
9478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9479 /* External mic to speaker */
9480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9481 {}
9482};
9483
9484/*
Takashi Iwai834be882006-03-01 14:16:17 +01009485 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009486 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9487 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009488 */
9489
9490#define ALC_HP_EVENT 0x37
9491
9492static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9493 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009495 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9496 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009497 {}
9498};
9499
Jiang zhe0e31daf2008-03-20 12:12:39 +01009500static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9501 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9503 {}
9504};
9505
Takashi Iwai834be882006-03-01 14:16:17 +01009506static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009507 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009508 .items = {
9509 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009510 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009511 { "CD", 0x4 },
9512 },
9513};
9514
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009515static struct hda_input_mux alc262_HP_capture_source = {
9516 .num_items = 5,
9517 .items = {
9518 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009519 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009520 { "Line", 0x2 },
9521 { "CD", 0x4 },
9522 { "AUX IN", 0x6 },
9523 },
9524};
9525
zhejiangaccbe492007-08-31 12:36:05 +02009526static struct hda_input_mux alc262_HP_D7000_capture_source = {
9527 .num_items = 4,
9528 .items = {
9529 { "Mic", 0x0 },
9530 { "Front Mic", 0x2 },
9531 { "Line", 0x1 },
9532 { "CD", 0x4 },
9533 },
9534};
9535
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009536/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009537static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9538{
9539 struct alc_spec *spec = codec->spec;
9540 unsigned int mute;
9541
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009542 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009543 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009544 /* need to execute and sync at first */
9545 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009546 /* check laptop HP jack */
9547 present = snd_hda_codec_read(codec, 0x14, 0,
9548 AC_VERB_GET_PIN_SENSE, 0);
9549 /* need to execute and sync at first */
9550 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9551 /* check docking HP jack */
9552 present |= snd_hda_codec_read(codec, 0x1b, 0,
9553 AC_VERB_GET_PIN_SENSE, 0);
9554 if (present & AC_PINSENSE_PRESENCE)
9555 spec->jack_present = 1;
9556 else
9557 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009558 spec->sense_updated = 1;
9559 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009560 /* unmute internal speaker only if both HPs are unplugged and
9561 * master switch is on
9562 */
9563 if (spec->jack_present)
9564 mute = HDA_AMP_MUTE;
9565 else
Takashi Iwai834be882006-03-01 14:16:17 +01009566 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009567 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9568 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009569}
9570
9571/* unsolicited event for HP jack sensing */
9572static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9573 unsigned int res)
9574{
9575 if ((res >> 26) != ALC_HP_EVENT)
9576 return;
9577 alc262_fujitsu_automute(codec, 1);
9578}
9579
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009580static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9581{
9582 alc262_fujitsu_automute(codec, 1);
9583}
9584
Takashi Iwai834be882006-03-01 14:16:17 +01009585/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009586static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9587 .ops = &snd_hda_bind_vol,
9588 .values = {
9589 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9590 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9591 0
9592 },
9593};
Takashi Iwai834be882006-03-01 14:16:17 +01009594
Jiang zhe0e31daf2008-03-20 12:12:39 +01009595/* mute/unmute internal speaker according to the hp jack and mute state */
9596static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9597{
9598 struct alc_spec *spec = codec->spec;
9599 unsigned int mute;
9600
9601 if (force || !spec->sense_updated) {
9602 unsigned int present_int_hp;
9603 /* need to execute and sync at first */
9604 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9605 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9606 AC_VERB_GET_PIN_SENSE, 0);
9607 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9608 spec->sense_updated = 1;
9609 }
9610 if (spec->jack_present) {
9611 /* mute internal speaker */
9612 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9613 HDA_AMP_MUTE, HDA_AMP_MUTE);
9614 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9615 HDA_AMP_MUTE, HDA_AMP_MUTE);
9616 } else {
9617 /* unmute internal speaker if necessary */
9618 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9619 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9620 HDA_AMP_MUTE, mute);
9621 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9622 HDA_AMP_MUTE, mute);
9623 }
9624}
9625
9626/* unsolicited event for HP jack sensing */
9627static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9628 unsigned int res)
9629{
9630 if ((res >> 26) != ALC_HP_EVENT)
9631 return;
9632 alc262_lenovo_3000_automute(codec, 1);
9633}
9634
Takashi Iwai834be882006-03-01 14:16:17 +01009635/* bind hp and internal speaker mute (with plug check) */
9636static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9637 struct snd_ctl_elem_value *ucontrol)
9638{
9639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9640 long *valp = ucontrol->value.integer.value;
9641 int change;
9642
Tony Vroon5d9fab22008-03-14 17:09:18 +01009643 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9644 HDA_AMP_MUTE,
9645 valp ? 0 : HDA_AMP_MUTE);
9646 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9647 HDA_AMP_MUTE,
9648 valp ? 0 : HDA_AMP_MUTE);
9649
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009650 if (change)
9651 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009652 return change;
9653}
9654
9655static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009656 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009657 {
9658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9659 .name = "Master Playback Switch",
9660 .info = snd_hda_mixer_amp_switch_info,
9661 .get = snd_hda_mixer_amp_switch_get,
9662 .put = alc262_fujitsu_master_sw_put,
9663 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9664 },
9665 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9666 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009667 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9668 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009672 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9673 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9674 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009675 { } /* end */
9676};
9677
Jiang zhe0e31daf2008-03-20 12:12:39 +01009678/* bind hp and internal speaker mute (with plug check) */
9679static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9680 struct snd_ctl_elem_value *ucontrol)
9681{
9682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9683 long *valp = ucontrol->value.integer.value;
9684 int change;
9685
9686 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9687 HDA_AMP_MUTE,
9688 valp ? 0 : HDA_AMP_MUTE);
9689
9690 if (change)
9691 alc262_lenovo_3000_automute(codec, 0);
9692 return change;
9693}
9694
9695static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9696 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9697 {
9698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9699 .name = "Master Playback Switch",
9700 .info = snd_hda_mixer_amp_switch_info,
9701 .get = snd_hda_mixer_amp_switch_get,
9702 .put = alc262_lenovo_3000_master_sw_put,
9703 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9704 },
9705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9711 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9712 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9713 { } /* end */
9714};
9715
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009716static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9717 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9718 {
9719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9720 .name = "Master Playback Switch",
9721 .info = snd_hda_mixer_amp_switch_info,
9722 .get = snd_hda_mixer_amp_switch_get,
9723 .put = alc262_sony_master_sw_put,
9724 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9725 },
9726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9731 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9732 { } /* end */
9733};
9734
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009735/* additional init verbs for Benq laptops */
9736static struct hda_verb alc262_EAPD_verbs[] = {
9737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9738 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9739 {}
9740};
9741
Kailang Yang83c34212007-07-05 11:43:05 +02009742static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9743 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9745
9746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9747 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9748 {}
9749};
9750
Tobin Davisf651b502007-10-26 12:40:47 +02009751/* Samsung Q1 Ultra Vista model setup */
9752static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009753 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9754 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9757 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009758 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009759 { } /* end */
9760};
9761
9762static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009763 /* output mixer */
9764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9767 /* speaker */
9768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9772 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9777 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9778 /* internal mic */
9779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9780 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9781 /* ADC, choose mic */
9782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009792 {}
9793};
9794
Tobin Davisf651b502007-10-26 12:40:47 +02009795/* mute/unmute internal speaker according to the hp jack and mute state */
9796static void alc262_ultra_automute(struct hda_codec *codec)
9797{
9798 struct alc_spec *spec = codec->spec;
9799 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009800
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009801 mute = 0;
9802 /* auto-mute only when HP is used as HP */
9803 if (!spec->cur_mux[0]) {
9804 unsigned int present;
9805 /* need to execute and sync at first */
9806 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9807 present = snd_hda_codec_read(codec, 0x15, 0,
9808 AC_VERB_GET_PIN_SENSE, 0);
9809 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9810 if (spec->jack_present)
9811 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009812 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009813 /* mute/unmute internal speaker */
9814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9815 HDA_AMP_MUTE, mute);
9816 /* mute/unmute HP */
9817 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9818 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009819}
9820
9821/* unsolicited event for HP jack sensing */
9822static void alc262_ultra_unsol_event(struct hda_codec *codec,
9823 unsigned int res)
9824{
9825 if ((res >> 26) != ALC880_HP_EVENT)
9826 return;
9827 alc262_ultra_automute(codec);
9828}
9829
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009830static struct hda_input_mux alc262_ultra_capture_source = {
9831 .num_items = 2,
9832 .items = {
9833 { "Mic", 0x1 },
9834 { "Headphone", 0x7 },
9835 },
9836};
9837
9838static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9839 struct snd_ctl_elem_value *ucontrol)
9840{
9841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9842 struct alc_spec *spec = codec->spec;
9843 int ret;
9844
9845 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9846 if (!ret)
9847 return 0;
9848 /* reprogram the HP pin as mic or HP according to the input source */
9849 snd_hda_codec_write_cache(codec, 0x15, 0,
9850 AC_VERB_SET_PIN_WIDGET_CONTROL,
9851 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9852 alc262_ultra_automute(codec); /* mute/unmute HP */
9853 return ret;
9854}
9855
9856static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9857 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9858 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9859 {
9860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9861 .name = "Capture Source",
9862 .info = alc882_mux_enum_info,
9863 .get = alc882_mux_enum_get,
9864 .put = alc262_ultra_mux_enum_put,
9865 },
9866 { } /* end */
9867};
9868
Kailang Yangdf694da2005-12-05 19:42:22 +01009869/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009870static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9871 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009872{
9873 hda_nid_t nid;
9874 int err;
9875
9876 spec->multiout.num_dacs = 1; /* only use one dac */
9877 spec->multiout.dac_nids = spec->private_dac_nids;
9878 spec->multiout.dac_nids[0] = 2;
9879
9880 nid = cfg->line_out_pins[0];
9881 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009882 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9883 "Front Playback Volume",
9884 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009886 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009887 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9888 "Front Playback Switch",
9889 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009891 return err;
9892 }
9893
Takashi Iwai82bc9552006-03-21 11:24:42 +01009894 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009895 if (nid) {
9896 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009897 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9898 "Speaker Playback Volume",
9899 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9900 HDA_OUTPUT));
9901 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009902 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009903 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9904 "Speaker Playback Switch",
9905 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9906 HDA_OUTPUT));
9907 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009908 return err;
9909 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009910 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9911 "Speaker Playback Switch",
9912 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9913 HDA_OUTPUT));
9914 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009915 return err;
9916 }
9917 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009918 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009919 if (nid) {
9920 /* spec->multiout.hp_nid = 2; */
9921 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009922 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9923 "Headphone Playback Volume",
9924 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9925 HDA_OUTPUT));
9926 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009927 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009928 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9929 "Headphone Playback Switch",
9930 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9931 HDA_OUTPUT));
9932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009933 return err;
9934 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009935 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9936 "Headphone Playback Switch",
9937 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9938 HDA_OUTPUT));
9939 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009940 return err;
9941 }
9942 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009943 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009944}
9945
9946/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009947#define alc262_auto_create_analog_input_ctls \
9948 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009949
9950/*
9951 * generic initialization of ADC, input mixers and output mixers
9952 */
9953static struct hda_verb alc262_volume_init_verbs[] = {
9954 /*
9955 * Unmute ADC0-2 and set the default input to mic-in
9956 */
9957 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9959 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9960 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9961 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9962 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9963
Takashi Iwaicb53c622007-08-10 17:21:45 +02009964 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009965 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009966 * Note: PASD motherboards uses the Line In 2 as the input for
9967 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009968 */
9969 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009975
9976 /*
9977 * Set up output mixers (0x0c - 0x0f)
9978 */
9979 /* set vol=0 to output mixers */
9980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9981 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009983
Kailang Yangdf694da2005-12-05 19:42:22 +01009984 /* set up input amps for analog loopback */
9985 /* Amp Indices: DAC = 0, mixer = 1 */
9986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9988 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9990 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9992
9993 /* FIXME: use matrix-type input source selection */
9994 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9995 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9996 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10000 /* Input mixer2 */
10001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10005 /* Input mixer3 */
10006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10010
10011 { }
10012};
10013
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010014static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10015 /*
10016 * Unmute ADC0-2 and set the default input to mic-in
10017 */
10018 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10022 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10023 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10024
Takashi Iwaicb53c622007-08-10 17:21:45 +020010025 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010026 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010027 * Note: PASD motherboards uses the Line In 2 as the input for
10028 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010029 */
10030 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010038
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010039 /*
10040 * Set up output mixers (0x0c - 0x0e)
10041 */
10042 /* set vol=0 to output mixers */
10043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10044 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10046
10047 /* set up input amps for analog loopback */
10048 /* Amp Indices: DAC = 0, mixer = 1 */
10049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10055
Takashi Iwaice875f02008-01-28 18:17:43 +010010056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10058 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10059
10060 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10062
10063 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10065
10066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10067 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10069 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10071
10072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10075 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10076 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10077 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10078
10079
10080 /* FIXME: use matrix-type input source selection */
10081 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10082 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10087 /* Input mixer2 */
10088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10090 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10092 /* Input mixer3 */
10093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10097
Takashi Iwaice875f02008-01-28 18:17:43 +010010098 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10099
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010100 { }
10101};
10102
Kailang Yangcd7509a2007-01-26 18:33:17 +010010103static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10104 /*
10105 * Unmute ADC0-2 and set the default input to mic-in
10106 */
10107 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10109 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10110 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10111 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10112 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10113
Takashi Iwaicb53c622007-08-10 17:21:45 +020010114 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010115 * mixer widget
10116 * Note: PASD motherboards uses the Line In 2 as the input for front
10117 * panel mic (mic 2)
10118 */
10119 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010128 /*
10129 * Set up output mixers (0x0c - 0x0e)
10130 */
10131 /* set vol=0 to output mixers */
10132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10135
10136 /* set up input amps for analog loopback */
10137 /* Amp Indices: DAC = 0, mixer = 1 */
10138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10144
10145
10146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10150 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10151 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10152 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10153
10154 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10156
10157 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10158 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10159
10160 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10163 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10164 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10165 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10166
10167 /* FIXME: use matrix-type input source selection */
10168 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10169 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10175 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10177 /* Input mixer2 */
10178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10183 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10185 /* Input mixer3 */
10186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10191 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10193
Takashi Iwaice875f02008-01-28 18:17:43 +010010194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10195
Kailang Yangcd7509a2007-01-26 18:33:17 +010010196 { }
10197};
10198
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010199static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10200
10201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10203 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10204
10205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10209
10210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10212 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10213 {}
10214};
10215
10216
Takashi Iwaicb53c622007-08-10 17:21:45 +020010217#ifdef CONFIG_SND_HDA_POWER_SAVE
10218#define alc262_loopbacks alc880_loopbacks
10219#endif
10220
Kailang Yangdf694da2005-12-05 19:42:22 +010010221/* pcm configuration: identiacal with ALC880 */
10222#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10223#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10224#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10225#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10226
10227/*
10228 * BIOS auto configuration
10229 */
10230static int alc262_parse_auto_config(struct hda_codec *codec)
10231{
10232 struct alc_spec *spec = codec->spec;
10233 int err;
10234 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010236 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10237 alc262_ignore);
10238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010239 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010240 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010241 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010242 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10243 if (err < 0)
10244 return err;
10245 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10246 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010247 return err;
10248
10249 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10250
10251 if (spec->autocfg.dig_out_pin)
10252 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10253 if (spec->autocfg.dig_in_pin)
10254 spec->dig_in_nid = ALC262_DIGIN_NID;
10255
10256 if (spec->kctl_alloc)
10257 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10258
10259 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010260 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010261 spec->input_mux = &spec->private_imux;
10262
Takashi Iwai776e1842007-08-29 15:07:11 +020010263 err = alc_auto_add_mic_boost(codec);
10264 if (err < 0)
10265 return err;
10266
Kailang Yangdf694da2005-12-05 19:42:22 +010010267 return 1;
10268}
10269
10270#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10271#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10272#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010273#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010274
10275
10276/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010277static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010278{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010279 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010280 alc262_auto_init_multi_out(codec);
10281 alc262_auto_init_hp_out(codec);
10282 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010283 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010284 if (spec->unsol_event)
10285 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010286}
10287
10288/*
10289 * configuration and preset
10290 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010291static const char *alc262_models[ALC262_MODEL_LAST] = {
10292 [ALC262_BASIC] = "basic",
10293 [ALC262_HIPPO] = "hippo",
10294 [ALC262_HIPPO_1] = "hippo_1",
10295 [ALC262_FUJITSU] = "fujitsu",
10296 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010297 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010298 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010299 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010300 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010301 [ALC262_BENQ_T31] = "benq-t31",
10302 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010303 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010304 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010305 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010306 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010307 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010308 [ALC262_AUTO] = "auto",
10309};
10310
10311static struct snd_pci_quirk alc262_cfg_tbl[] = {
10312 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010313 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010314 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010315 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010316 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10317 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010318 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010319 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010320 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010321 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010322 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010323 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010324 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010325 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010326 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010327 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010328 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010329 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010330 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10331 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10332 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010333 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10334 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010335 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010336 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010337 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010338 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10339 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10340 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010341 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010342 ALC262_TOSHIBA_RX1),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010343 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010344 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010345 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010346 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010347 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010348 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010349 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010350 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010351 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010352 {}
10353};
10354
10355static struct alc_config_preset alc262_presets[] = {
10356 [ALC262_BASIC] = {
10357 .mixers = { alc262_base_mixer },
10358 .init_verbs = { alc262_init_verbs },
10359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10360 .dac_nids = alc262_dac_nids,
10361 .hp_nid = 0x03,
10362 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10363 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010364 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010365 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010366 [ALC262_HIPPO] = {
10367 .mixers = { alc262_base_mixer },
10368 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10369 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10370 .dac_nids = alc262_dac_nids,
10371 .hp_nid = 0x03,
10372 .dig_out_nid = ALC262_DIGOUT_NID,
10373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10374 .channel_mode = alc262_modes,
10375 .input_mux = &alc262_capture_source,
10376 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010377 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010378 },
10379 [ALC262_HIPPO_1] = {
10380 .mixers = { alc262_hippo1_mixer },
10381 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10382 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10383 .dac_nids = alc262_dac_nids,
10384 .hp_nid = 0x02,
10385 .dig_out_nid = ALC262_DIGOUT_NID,
10386 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10387 .channel_mode = alc262_modes,
10388 .input_mux = &alc262_capture_source,
10389 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010390 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010391 },
Takashi Iwai834be882006-03-01 14:16:17 +010010392 [ALC262_FUJITSU] = {
10393 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010394 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10395 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10397 .dac_nids = alc262_dac_nids,
10398 .hp_nid = 0x03,
10399 .dig_out_nid = ALC262_DIGOUT_NID,
10400 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10401 .channel_mode = alc262_modes,
10402 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010403 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010404 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010405 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010406 [ALC262_HP_BPC] = {
10407 .mixers = { alc262_HP_BPC_mixer },
10408 .init_verbs = { alc262_HP_BPC_init_verbs },
10409 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10410 .dac_nids = alc262_dac_nids,
10411 .hp_nid = 0x03,
10412 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10413 .channel_mode = alc262_modes,
10414 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010415 .unsol_event = alc262_hp_bpc_unsol_event,
10416 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010417 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010418 [ALC262_HP_BPC_D7000_WF] = {
10419 .mixers = { alc262_HP_BPC_WildWest_mixer },
10420 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10421 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10422 .dac_nids = alc262_dac_nids,
10423 .hp_nid = 0x03,
10424 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10425 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010426 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010427 .unsol_event = alc262_hp_wildwest_unsol_event,
10428 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010429 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010430 [ALC262_HP_BPC_D7000_WL] = {
10431 .mixers = { alc262_HP_BPC_WildWest_mixer,
10432 alc262_HP_BPC_WildWest_option_mixer },
10433 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10434 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10435 .dac_nids = alc262_dac_nids,
10436 .hp_nid = 0x03,
10437 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10438 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010439 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010440 .unsol_event = alc262_hp_wildwest_unsol_event,
10441 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010442 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010443 [ALC262_HP_TC_T5735] = {
10444 .mixers = { alc262_hp_t5735_mixer },
10445 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10446 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10447 .dac_nids = alc262_dac_nids,
10448 .hp_nid = 0x03,
10449 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10450 .channel_mode = alc262_modes,
10451 .input_mux = &alc262_capture_source,
10452 .unsol_event = alc262_hp_t5735_unsol_event,
10453 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010454 },
10455 [ALC262_HP_RP5700] = {
10456 .mixers = { alc262_hp_rp5700_mixer },
10457 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10459 .dac_nids = alc262_dac_nids,
10460 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10461 .channel_mode = alc262_modes,
10462 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010463 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010464 [ALC262_BENQ_ED8] = {
10465 .mixers = { alc262_base_mixer },
10466 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10467 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10468 .dac_nids = alc262_dac_nids,
10469 .hp_nid = 0x03,
10470 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10471 .channel_mode = alc262_modes,
10472 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010473 },
Kailang Yang272a5272007-05-14 11:00:38 +020010474 [ALC262_SONY_ASSAMD] = {
10475 .mixers = { alc262_sony_mixer },
10476 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10477 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10478 .dac_nids = alc262_dac_nids,
10479 .hp_nid = 0x02,
10480 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10481 .channel_mode = alc262_modes,
10482 .input_mux = &alc262_capture_source,
10483 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010484 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010485 },
10486 [ALC262_BENQ_T31] = {
10487 .mixers = { alc262_benq_t31_mixer },
10488 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_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 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010496 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010497 },
Tobin Davisf651b502007-10-26 12:40:47 +020010498 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010499 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10500 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010501 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10502 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010503 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10504 .channel_mode = alc262_modes,
10505 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010506 .adc_nids = alc262_adc_nids, /* ADC0 */
10507 .capsrc_nids = alc262_capsrc_nids,
10508 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010509 .unsol_event = alc262_ultra_unsol_event,
10510 .init_hook = alc262_ultra_automute,
10511 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010512 [ALC262_LENOVO_3000] = {
10513 .mixers = { alc262_lenovo_3000_mixer },
10514 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10515 alc262_lenovo_3000_unsol_verbs },
10516 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10517 .dac_nids = alc262_dac_nids,
10518 .hp_nid = 0x03,
10519 .dig_out_nid = ALC262_DIGOUT_NID,
10520 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10521 .channel_mode = alc262_modes,
10522 .input_mux = &alc262_fujitsu_capture_source,
10523 .unsol_event = alc262_lenovo_3000_unsol_event,
10524 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010525 [ALC262_NEC] = {
10526 .mixers = { alc262_nec_mixer },
10527 .init_verbs = { alc262_nec_verbs },
10528 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10529 .dac_nids = alc262_dac_nids,
10530 .hp_nid = 0x03,
10531 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10532 .channel_mode = alc262_modes,
10533 .input_mux = &alc262_capture_source,
10534 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010535 [ALC262_TOSHIBA_S06] = {
10536 .mixers = { alc262_toshiba_s06_mixer },
10537 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10538 alc262_eapd_verbs },
10539 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10540 .capsrc_nids = alc262_dmic_capsrc_nids,
10541 .dac_nids = alc262_dac_nids,
10542 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10543 .dig_out_nid = ALC262_DIGOUT_NID,
10544 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10545 .channel_mode = alc262_modes,
10546 .input_mux = &alc262_dmic_capture_source,
10547 .unsol_event = alc262_toshiba_s06_unsol_event,
10548 .init_hook = alc262_toshiba_s06_init_hook,
10549 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010550 [ALC262_TOSHIBA_RX1] = {
10551 .mixers = { alc262_toshiba_rx1_mixer },
10552 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10553 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10554 .dac_nids = alc262_dac_nids,
10555 .hp_nid = 0x03,
10556 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10557 .channel_mode = alc262_modes,
10558 .input_mux = &alc262_capture_source,
10559 .unsol_event = alc262_hippo_unsol_event,
10560 .init_hook = alc262_hippo_automute,
10561 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010562};
10563
10564static int patch_alc262(struct hda_codec *codec)
10565{
10566 struct alc_spec *spec;
10567 int board_config;
10568 int err;
10569
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010570 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010571 if (spec == NULL)
10572 return -ENOMEM;
10573
10574 codec->spec = spec;
10575#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010576 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10577 * under-run
10578 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010579 {
10580 int tmp;
10581 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10582 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10583 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10584 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10585 }
10586#endif
10587
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010588 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10589
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010590 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10591 alc262_models,
10592 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010593
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010594 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010595 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10596 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010597 board_config = ALC262_AUTO;
10598 }
10599
10600 if (board_config == ALC262_AUTO) {
10601 /* automatic parse from the BIOS config */
10602 err = alc262_parse_auto_config(codec);
10603 if (err < 0) {
10604 alc_free(codec);
10605 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010606 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010607 printk(KERN_INFO
10608 "hda_codec: Cannot set up configuration "
10609 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010610 board_config = ALC262_BASIC;
10611 }
10612 }
10613
10614 if (board_config != ALC262_AUTO)
10615 setup_preset(spec, &alc262_presets[board_config]);
10616
10617 spec->stream_name_analog = "ALC262 Analog";
10618 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10619 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010620
Kailang Yangdf694da2005-12-05 19:42:22 +010010621 spec->stream_name_digital = "ALC262 Digital";
10622 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10623 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10624
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010625 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010626 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010627 unsigned int wcap = get_wcaps(codec, 0x07);
10628
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010629 /* get type */
10630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010631 if (wcap != AC_WID_AUD_IN) {
10632 spec->adc_nids = alc262_adc_nids_alt;
10633 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010634 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010635 spec->mixers[spec->num_mixers] =
10636 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010637 spec->num_mixers++;
10638 } else {
10639 spec->adc_nids = alc262_adc_nids;
10640 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010641 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010642 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10643 spec->num_mixers++;
10644 }
10645 }
10646
Takashi Iwai2134ea42008-01-10 16:53:55 +010010647 spec->vmaster_nid = 0x0c;
10648
Kailang Yangdf694da2005-12-05 19:42:22 +010010649 codec->patch_ops = alc_patch_ops;
10650 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010651 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010652#ifdef CONFIG_SND_HDA_POWER_SAVE
10653 if (!spec->loopback.amplist)
10654 spec->loopback.amplist = alc262_loopbacks;
10655#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010656
Kailang Yangdf694da2005-12-05 19:42:22 +010010657 return 0;
10658}
10659
Kailang Yangdf694da2005-12-05 19:42:22 +010010660/*
Kailang Yanga361d842007-06-05 12:30:55 +020010661 * ALC268 channel source setting (2 channel)
10662 */
10663#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10664#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010665
Kailang Yanga361d842007-06-05 12:30:55 +020010666static hda_nid_t alc268_dac_nids[2] = {
10667 /* front, hp */
10668 0x02, 0x03
10669};
10670
10671static hda_nid_t alc268_adc_nids[2] = {
10672 /* ADC0-1 */
10673 0x08, 0x07
10674};
10675
10676static hda_nid_t alc268_adc_nids_alt[1] = {
10677 /* ADC0 */
10678 0x08
10679};
10680
Takashi Iwaie1406342008-02-11 18:32:32 +010010681static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10682
Kailang Yanga361d842007-06-05 12:30:55 +020010683static struct snd_kcontrol_new alc268_base_mixer[] = {
10684 /* output mixer control */
10685 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10686 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10687 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010689 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10690 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10691 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010692 { }
10693};
10694
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010695/* bind Beep switches of both NID 0x0f and 0x10 */
10696static struct hda_bind_ctls alc268_bind_beep_sw = {
10697 .ops = &snd_hda_bind_sw,
10698 .values = {
10699 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10700 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10701 0
10702 },
10703};
10704
10705static struct snd_kcontrol_new alc268_beep_mixer[] = {
10706 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10707 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10708 { }
10709};
10710
Kailang Yangd1a991a2007-08-15 16:21:59 +020010711static struct hda_verb alc268_eapd_verbs[] = {
10712 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10713 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10714 { }
10715};
10716
Takashi Iwaid2738092007-08-16 14:59:45 +020010717/* Toshiba specific */
10718#define alc268_toshiba_automute alc262_hippo_automute
10719
10720static struct hda_verb alc268_toshiba_verbs[] = {
10721 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10722 { } /* end */
10723};
10724
Kailang Yang8ef355d2008-08-26 13:10:22 +020010725static struct hda_input_mux alc268_acer_lc_capture_source = {
10726 .num_items = 2,
10727 .items = {
10728 { "i-Mic", 0x6 },
10729 { "E-Mic", 0x0 },
10730 },
10731};
10732
Takashi Iwaid2738092007-08-16 14:59:45 +020010733/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010734/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010735static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10736 .ops = &snd_hda_bind_vol,
10737 .values = {
10738 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10739 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10740 0
10741 },
10742};
10743
Takashi Iwai889c4392007-08-23 18:56:52 +020010744/* mute/unmute internal speaker according to the hp jack and mute state */
10745static void alc268_acer_automute(struct hda_codec *codec, int force)
10746{
10747 struct alc_spec *spec = codec->spec;
10748 unsigned int mute;
10749
10750 if (force || !spec->sense_updated) {
10751 unsigned int present;
10752 present = snd_hda_codec_read(codec, 0x14, 0,
10753 AC_VERB_GET_PIN_SENSE, 0);
10754 spec->jack_present = (present & 0x80000000) != 0;
10755 spec->sense_updated = 1;
10756 }
10757 if (spec->jack_present)
10758 mute = HDA_AMP_MUTE; /* mute internal speaker */
10759 else /* unmute internal speaker if necessary */
10760 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10761 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10762 HDA_AMP_MUTE, mute);
10763}
10764
10765
10766/* bind hp and internal speaker mute (with plug check) */
10767static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10768 struct snd_ctl_elem_value *ucontrol)
10769{
10770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10771 long *valp = ucontrol->value.integer.value;
10772 int change;
10773
10774 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10775 HDA_AMP_MUTE,
10776 valp[0] ? 0 : HDA_AMP_MUTE);
10777 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10778 HDA_AMP_MUTE,
10779 valp[1] ? 0 : HDA_AMP_MUTE);
10780 if (change)
10781 alc268_acer_automute(codec, 0);
10782 return change;
10783}
Takashi Iwaid2738092007-08-16 14:59:45 +020010784
Kailang Yang8ef355d2008-08-26 13:10:22 +020010785static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10786 /* output mixer control */
10787 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10788 {
10789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10790 .name = "Master Playback Switch",
10791 .info = snd_hda_mixer_amp_switch_info,
10792 .get = snd_hda_mixer_amp_switch_get,
10793 .put = alc268_acer_master_sw_put,
10794 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10795 },
10796 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10797 { }
10798};
10799
Takashi Iwaid2738092007-08-16 14:59:45 +020010800static struct snd_kcontrol_new alc268_acer_mixer[] = {
10801 /* output mixer control */
10802 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10803 {
10804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10805 .name = "Master Playback Switch",
10806 .info = snd_hda_mixer_amp_switch_info,
10807 .get = snd_hda_mixer_amp_switch_get,
10808 .put = alc268_acer_master_sw_put,
10809 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10810 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10812 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10813 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010814 { }
10815};
10816
Kailang Yang8ef355d2008-08-26 13:10:22 +020010817static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10818 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10821 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10822 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10824 { }
10825};
10826
Takashi Iwaid2738092007-08-16 14:59:45 +020010827static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010828 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10829 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010834 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10835 { }
10836};
10837
10838/* unsolicited event for HP jack sensing */
10839static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10840 unsigned int res)
10841{
Takashi Iwai889c4392007-08-23 18:56:52 +020010842 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010843 return;
10844 alc268_toshiba_automute(codec);
10845}
10846
10847static void alc268_acer_unsol_event(struct hda_codec *codec,
10848 unsigned int res)
10849{
Takashi Iwai889c4392007-08-23 18:56:52 +020010850 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010851 return;
10852 alc268_acer_automute(codec, 1);
10853}
10854
Takashi Iwai889c4392007-08-23 18:56:52 +020010855static void alc268_acer_init_hook(struct hda_codec *codec)
10856{
10857 alc268_acer_automute(codec, 1);
10858}
10859
Kailang Yang8ef355d2008-08-26 13:10:22 +020010860/* toggle speaker-output according to the hp-jack state */
10861static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10862{
10863 unsigned int present;
10864 unsigned char bits;
10865
10866 present = snd_hda_codec_read(codec, 0x15, 0,
10867 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10868 bits = present ? AMP_IN_MUTE(0) : 0;
10869 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10870 AMP_IN_MUTE(0), bits);
10871 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10872 AMP_IN_MUTE(0), bits);
10873}
10874
10875
10876static void alc268_acer_mic_automute(struct hda_codec *codec)
10877{
10878 unsigned int present;
10879
10880 present = snd_hda_codec_read(codec, 0x18, 0,
10881 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10882 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10883 present ? 0x0 : 0x6);
10884}
10885
10886static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10887 unsigned int res)
10888{
10889 if ((res >> 26) == ALC880_HP_EVENT)
10890 alc268_aspire_one_speaker_automute(codec);
10891 if ((res >> 26) == ALC880_MIC_EVENT)
10892 alc268_acer_mic_automute(codec);
10893}
10894
10895static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10896{
10897 alc268_aspire_one_speaker_automute(codec);
10898 alc268_acer_mic_automute(codec);
10899}
10900
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010901static struct snd_kcontrol_new alc268_dell_mixer[] = {
10902 /* output mixer control */
10903 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10904 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10908 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10909 { }
10910};
10911
10912static struct hda_verb alc268_dell_verbs[] = {
10913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10916 { }
10917};
10918
10919/* mute/unmute internal speaker according to the hp jack and mute state */
10920static void alc268_dell_automute(struct hda_codec *codec)
10921{
10922 unsigned int present;
10923 unsigned int mute;
10924
10925 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10926 if (present & 0x80000000)
10927 mute = HDA_AMP_MUTE;
10928 else
10929 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10930 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10931 HDA_AMP_MUTE, mute);
10932}
10933
10934static void alc268_dell_unsol_event(struct hda_codec *codec,
10935 unsigned int res)
10936{
10937 if ((res >> 26) != ALC880_HP_EVENT)
10938 return;
10939 alc268_dell_automute(codec);
10940}
10941
10942#define alc268_dell_init_hook alc268_dell_automute
10943
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010944static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10946 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10949 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10950 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10951 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10952 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10953 { }
10954};
10955
10956static struct hda_verb alc267_quanta_il1_verbs[] = {
10957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10958 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10959 { }
10960};
10961
10962static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10963{
10964 unsigned int present;
10965
10966 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10967 & AC_PINSENSE_PRESENCE;
10968 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10969 present ? 0 : PIN_OUT);
10970}
10971
10972static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10973{
10974 unsigned int present;
10975
10976 present = snd_hda_codec_read(codec, 0x18, 0,
10977 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10978 snd_hda_codec_write(codec, 0x23, 0,
10979 AC_VERB_SET_CONNECT_SEL,
10980 present ? 0x00 : 0x01);
10981}
10982
10983static void alc267_quanta_il1_automute(struct hda_codec *codec)
10984{
10985 alc267_quanta_il1_hp_automute(codec);
10986 alc267_quanta_il1_mic_automute(codec);
10987}
10988
10989static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10990 unsigned int res)
10991{
10992 switch (res >> 26) {
10993 case ALC880_HP_EVENT:
10994 alc267_quanta_il1_hp_automute(codec);
10995 break;
10996 case ALC880_MIC_EVENT:
10997 alc267_quanta_il1_mic_automute(codec);
10998 break;
10999 }
11000}
11001
Kailang Yanga361d842007-06-05 12:30:55 +020011002/*
11003 * generic initialization of ADC, input mixers and output mixers
11004 */
11005static struct hda_verb alc268_base_init_verbs[] = {
11006 /* Unmute DAC0-1 and set vol = 0 */
11007 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11008 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11009 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11010 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11011 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11012 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11013
11014 /*
11015 * Set up output mixers (0x0c - 0x0e)
11016 */
11017 /* set vol=0 to output mixers */
11018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11020 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11021 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11022
11023 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025
11026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11032 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11033 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11034
11035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11038 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11040 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11041 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011042
11043 /* set PCBEEP vol = 0, mute connections */
11044 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11046 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011047
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011048 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011049
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011050 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11052 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011054
Kailang Yanga361d842007-06-05 12:30:55 +020011055 { }
11056};
11057
11058/*
11059 * generic initialization of ADC, input mixers and output mixers
11060 */
11061static struct hda_verb alc268_volume_init_verbs[] = {
11062 /* set output DAC */
11063 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11065 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11067
11068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11069 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11071 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11072 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11073
11074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11078 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11079
11080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11082 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11083 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11084
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011085 /* set PCBEEP vol = 0, mute connections */
11086 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11088 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011089
11090 { }
11091};
11092
11093#define alc268_mux_enum_info alc_mux_enum_info
11094#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011095#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020011096
11097static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11098 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11099 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11100 {
11101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11102 /* The multiple "Capture Source" controls confuse alsamixer
11103 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011104 */
11105 /* .name = "Capture Source", */
11106 .name = "Input Source",
11107 .count = 1,
11108 .info = alc268_mux_enum_info,
11109 .get = alc268_mux_enum_get,
11110 .put = alc268_mux_enum_put,
11111 },
11112 { } /* end */
11113};
11114
11115static struct snd_kcontrol_new alc268_capture_mixer[] = {
11116 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11117 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11118 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11119 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11120 {
11121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11122 /* The multiple "Capture Source" controls confuse alsamixer
11123 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011124 */
11125 /* .name = "Capture Source", */
11126 .name = "Input Source",
11127 .count = 2,
11128 .info = alc268_mux_enum_info,
11129 .get = alc268_mux_enum_get,
11130 .put = alc268_mux_enum_put,
11131 },
11132 { } /* end */
11133};
11134
11135static struct hda_input_mux alc268_capture_source = {
11136 .num_items = 4,
11137 .items = {
11138 { "Mic", 0x0 },
11139 { "Front Mic", 0x1 },
11140 { "Line", 0x2 },
11141 { "CD", 0x3 },
11142 },
11143};
11144
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011145static struct hda_input_mux alc268_acer_capture_source = {
11146 .num_items = 3,
11147 .items = {
11148 { "Mic", 0x0 },
11149 { "Internal Mic", 0x6 },
11150 { "Line", 0x2 },
11151 },
11152};
11153
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011154#ifdef CONFIG_SND_DEBUG
11155static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011156 /* Volume widgets */
11157 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11159 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11160 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11161 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11162 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11163 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11164 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11165 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11166 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11167 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11168 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11169 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011170 /* The below appears problematic on some hardwares */
11171 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011172 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11173 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11174 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11175 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11176
11177 /* Modes for retasking pin widgets */
11178 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11179 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11180 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11181 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11182
11183 /* Controls for GPIO pins, assuming they are configured as outputs */
11184 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11185 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11186 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11187 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11188
11189 /* Switches to allow the digital SPDIF output pin to be enabled.
11190 * The ALC268 does not have an SPDIF input.
11191 */
11192 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11193
11194 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11195 * this output to turn on an external amplifier.
11196 */
11197 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11198 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11199
11200 { } /* end */
11201};
11202#endif
11203
Kailang Yanga361d842007-06-05 12:30:55 +020011204/* create input playback/capture controls for the given pin */
11205static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11206 const char *ctlname, int idx)
11207{
11208 char name[32];
11209 int err;
11210
11211 sprintf(name, "%s Playback Volume", ctlname);
11212 if (nid == 0x14) {
11213 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11214 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11215 HDA_OUTPUT));
11216 if (err < 0)
11217 return err;
11218 } else if (nid == 0x15) {
11219 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11220 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11221 HDA_OUTPUT));
11222 if (err < 0)
11223 return err;
11224 } else
11225 return -1;
11226 sprintf(name, "%s Playback Switch", ctlname);
11227 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11228 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11229 if (err < 0)
11230 return err;
11231 return 0;
11232}
11233
11234/* add playback controls from the parsed DAC table */
11235static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11236 const struct auto_pin_cfg *cfg)
11237{
11238 hda_nid_t nid;
11239 int err;
11240
11241 spec->multiout.num_dacs = 2; /* only use one dac */
11242 spec->multiout.dac_nids = spec->private_dac_nids;
11243 spec->multiout.dac_nids[0] = 2;
11244 spec->multiout.dac_nids[1] = 3;
11245
11246 nid = cfg->line_out_pins[0];
11247 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011248 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011249
11250 nid = cfg->speaker_pins[0];
11251 if (nid == 0x1d) {
11252 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11253 "Speaker Playback Volume",
11254 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11255 if (err < 0)
11256 return err;
11257 }
11258 nid = cfg->hp_pins[0];
11259 if (nid)
11260 alc268_new_analog_output(spec, nid, "Headphone", 0);
11261
11262 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11263 if (nid == 0x16) {
11264 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11265 "Mono Playback Switch",
11266 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11267 if (err < 0)
11268 return err;
11269 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011270 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011271}
11272
11273/* create playback/capture controls for input pins */
11274static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11275 const struct auto_pin_cfg *cfg)
11276{
11277 struct hda_input_mux *imux = &spec->private_imux;
11278 int i, idx1;
11279
11280 for (i = 0; i < AUTO_PIN_LAST; i++) {
11281 switch(cfg->input_pins[i]) {
11282 case 0x18:
11283 idx1 = 0; /* Mic 1 */
11284 break;
11285 case 0x19:
11286 idx1 = 1; /* Mic 2 */
11287 break;
11288 case 0x1a:
11289 idx1 = 2; /* Line In */
11290 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011291 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011292 idx1 = 3; /* CD */
11293 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011294 case 0x12:
11295 case 0x13:
11296 idx1 = 6; /* digital mics */
11297 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011298 default:
11299 continue;
11300 }
11301 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11302 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011303 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011304 }
11305 return 0;
11306}
11307
11308static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11309{
11310 struct alc_spec *spec = codec->spec;
11311 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11312 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11313 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11314 unsigned int dac_vol1, dac_vol2;
11315
11316 if (speaker_nid) {
11317 snd_hda_codec_write(codec, speaker_nid, 0,
11318 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11319 snd_hda_codec_write(codec, 0x0f, 0,
11320 AC_VERB_SET_AMP_GAIN_MUTE,
11321 AMP_IN_UNMUTE(1));
11322 snd_hda_codec_write(codec, 0x10, 0,
11323 AC_VERB_SET_AMP_GAIN_MUTE,
11324 AMP_IN_UNMUTE(1));
11325 } else {
11326 snd_hda_codec_write(codec, 0x0f, 0,
11327 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11328 snd_hda_codec_write(codec, 0x10, 0,
11329 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11330 }
11331
11332 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011333 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011334 dac_vol2 = AMP_OUT_ZERO;
11335 else if (line_nid == 0x15)
11336 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011337 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011338 dac_vol2 = AMP_OUT_ZERO;
11339 else if (hp_nid == 0x15)
11340 dac_vol1 = AMP_OUT_ZERO;
11341 if (line_nid != 0x16 || hp_nid != 0x16 ||
11342 spec->autocfg.line_out_pins[1] != 0x16 ||
11343 spec->autocfg.line_out_pins[2] != 0x16)
11344 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11345
11346 snd_hda_codec_write(codec, 0x02, 0,
11347 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11348 snd_hda_codec_write(codec, 0x03, 0,
11349 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11350}
11351
11352/* pcm configuration: identiacal with ALC880 */
11353#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11354#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011355#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011356#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11357
11358/*
11359 * BIOS auto configuration
11360 */
11361static int alc268_parse_auto_config(struct hda_codec *codec)
11362{
11363 struct alc_spec *spec = codec->spec;
11364 int err;
11365 static hda_nid_t alc268_ignore[] = { 0 };
11366
11367 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11368 alc268_ignore);
11369 if (err < 0)
11370 return err;
11371 if (!spec->autocfg.line_outs)
11372 return 0; /* can't find valid BIOS pin config */
11373
11374 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11375 if (err < 0)
11376 return err;
11377 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11378 if (err < 0)
11379 return err;
11380
11381 spec->multiout.max_channels = 2;
11382
11383 /* digital only support output */
11384 if (spec->autocfg.dig_out_pin)
11385 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11386
11387 if (spec->kctl_alloc)
11388 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11389
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011390 if (spec->autocfg.speaker_pins[0] != 0x1d)
11391 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11392
Kailang Yanga361d842007-06-05 12:30:55 +020011393 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11394 spec->num_mux_defs = 1;
11395 spec->input_mux = &spec->private_imux;
11396
Takashi Iwai776e1842007-08-29 15:07:11 +020011397 err = alc_auto_add_mic_boost(codec);
11398 if (err < 0)
11399 return err;
11400
Kailang Yanga361d842007-06-05 12:30:55 +020011401 return 1;
11402}
11403
11404#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11405#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11406#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11407
11408/* init callback for auto-configuration model -- overriding the default init */
11409static void alc268_auto_init(struct hda_codec *codec)
11410{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011411 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011412 alc268_auto_init_multi_out(codec);
11413 alc268_auto_init_hp_out(codec);
11414 alc268_auto_init_mono_speaker_out(codec);
11415 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011416 if (spec->unsol_event)
11417 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011418}
11419
11420/*
11421 * configuration and preset
11422 */
11423static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011424 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011425 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011426 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011427 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011428 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011429 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011430 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011431#ifdef CONFIG_SND_DEBUG
11432 [ALC268_TEST] = "test",
11433#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011434 [ALC268_AUTO] = "auto",
11435};
11436
11437static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011438 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011439 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011440 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011441 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011442 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011443 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11444 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011445 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011446 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011447 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011448 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011449 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011450 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011451 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011452 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011453 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011454 {}
11455};
11456
11457static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011458 [ALC267_QUANTA_IL1] = {
11459 .mixers = { alc267_quanta_il1_mixer },
11460 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11461 alc267_quanta_il1_verbs },
11462 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11463 .dac_nids = alc268_dac_nids,
11464 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11465 .adc_nids = alc268_adc_nids_alt,
11466 .hp_nid = 0x03,
11467 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11468 .channel_mode = alc268_modes,
11469 .input_mux = &alc268_capture_source,
11470 .unsol_event = alc267_quanta_il1_unsol_event,
11471 .init_hook = alc267_quanta_il1_automute,
11472 },
Kailang Yanga361d842007-06-05 12:30:55 +020011473 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011474 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11475 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011476 .init_verbs = { alc268_base_init_verbs },
11477 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11478 .dac_nids = alc268_dac_nids,
11479 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11480 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011481 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011482 .hp_nid = 0x03,
11483 .dig_out_nid = ALC268_DIGOUT_NID,
11484 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11485 .channel_mode = alc268_modes,
11486 .input_mux = &alc268_capture_source,
11487 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011488 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011489 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11490 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011491 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11492 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011493 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11494 .dac_nids = alc268_dac_nids,
11495 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11496 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011497 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011498 .hp_nid = 0x03,
11499 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11500 .channel_mode = alc268_modes,
11501 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011502 .unsol_event = alc268_toshiba_unsol_event,
11503 .init_hook = alc268_toshiba_automute,
11504 },
11505 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011506 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11507 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011508 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11509 alc268_acer_verbs },
11510 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11511 .dac_nids = alc268_dac_nids,
11512 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11513 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011514 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011515 .hp_nid = 0x02,
11516 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11517 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011518 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011519 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011520 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011521 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011522 [ALC268_ACER_ASPIRE_ONE] = {
11523 .mixers = { alc268_acer_aspire_one_mixer,
11524 alc268_capture_alt_mixer },
11525 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11526 alc268_acer_aspire_one_verbs },
11527 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11528 .dac_nids = alc268_dac_nids,
11529 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11530 .adc_nids = alc268_adc_nids_alt,
11531 .capsrc_nids = alc268_capsrc_nids,
11532 .hp_nid = 0x03,
11533 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11534 .channel_mode = alc268_modes,
11535 .input_mux = &alc268_acer_lc_capture_source,
11536 .unsol_event = alc268_acer_lc_unsol_event,
11537 .init_hook = alc268_acer_lc_init_hook,
11538 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011539 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011540 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011541 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11542 alc268_dell_verbs },
11543 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11544 .dac_nids = alc268_dac_nids,
11545 .hp_nid = 0x02,
11546 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11547 .channel_mode = alc268_modes,
11548 .unsol_event = alc268_dell_unsol_event,
11549 .init_hook = alc268_dell_init_hook,
11550 .input_mux = &alc268_capture_source,
11551 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011552 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011553 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11554 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011555 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11556 alc268_toshiba_verbs },
11557 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11558 .dac_nids = alc268_dac_nids,
11559 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11560 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011561 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011562 .hp_nid = 0x03,
11563 .dig_out_nid = ALC268_DIGOUT_NID,
11564 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11565 .channel_mode = alc268_modes,
11566 .input_mux = &alc268_capture_source,
11567 .unsol_event = alc268_toshiba_unsol_event,
11568 .init_hook = alc268_toshiba_automute
11569 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011570#ifdef CONFIG_SND_DEBUG
11571 [ALC268_TEST] = {
11572 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11573 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11574 alc268_volume_init_verbs },
11575 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11576 .dac_nids = alc268_dac_nids,
11577 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11578 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011579 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011580 .hp_nid = 0x03,
11581 .dig_out_nid = ALC268_DIGOUT_NID,
11582 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11583 .channel_mode = alc268_modes,
11584 .input_mux = &alc268_capture_source,
11585 },
11586#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011587};
11588
11589static int patch_alc268(struct hda_codec *codec)
11590{
11591 struct alc_spec *spec;
11592 int board_config;
11593 int err;
11594
11595 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11596 if (spec == NULL)
11597 return -ENOMEM;
11598
11599 codec->spec = spec;
11600
11601 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11602 alc268_models,
11603 alc268_cfg_tbl);
11604
11605 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11606 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11607 "trying auto-probe from BIOS...\n");
11608 board_config = ALC268_AUTO;
11609 }
11610
11611 if (board_config == ALC268_AUTO) {
11612 /* automatic parse from the BIOS config */
11613 err = alc268_parse_auto_config(codec);
11614 if (err < 0) {
11615 alc_free(codec);
11616 return err;
11617 } else if (!err) {
11618 printk(KERN_INFO
11619 "hda_codec: Cannot set up configuration "
11620 "from BIOS. Using base mode...\n");
11621 board_config = ALC268_3ST;
11622 }
11623 }
11624
11625 if (board_config != ALC268_AUTO)
11626 setup_preset(spec, &alc268_presets[board_config]);
11627
Kailang Yang2f893282008-05-27 12:14:47 +020011628 if (codec->vendor_id == 0x10ec0267) {
11629 spec->stream_name_analog = "ALC267 Analog";
11630 spec->stream_name_digital = "ALC267 Digital";
11631 } else {
11632 spec->stream_name_analog = "ALC268 Analog";
11633 spec->stream_name_digital = "ALC268 Digital";
11634 }
11635
Kailang Yanga361d842007-06-05 12:30:55 +020011636 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11637 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011638 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011639
Kailang Yanga361d842007-06-05 12:30:55 +020011640 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11641
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011642 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11643 /* override the amp caps for beep generator */
11644 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11645 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11646 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11647 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11648 (0 << AC_AMPCAP_MUTE_SHIFT));
11649
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011650 if (!spec->adc_nids && spec->input_mux) {
11651 /* check whether NID 0x07 is valid */
11652 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011653 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011654
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011655 /* get type */
11656 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011657 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011658 spec->adc_nids = alc268_adc_nids_alt;
11659 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11660 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011661 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011662 spec->num_mixers++;
11663 } else {
11664 spec->adc_nids = alc268_adc_nids;
11665 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11666 spec->mixers[spec->num_mixers] =
11667 alc268_capture_mixer;
11668 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011669 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011670 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011671 /* set default input source */
11672 for (i = 0; i < spec->num_adc_nids; i++)
11673 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11674 0, AC_VERB_SET_CONNECT_SEL,
11675 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011676 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011677
11678 spec->vmaster_nid = 0x02;
11679
Kailang Yanga361d842007-06-05 12:30:55 +020011680 codec->patch_ops = alc_patch_ops;
11681 if (board_config == ALC268_AUTO)
11682 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011683
Kailang Yanga361d842007-06-05 12:30:55 +020011684 return 0;
11685}
11686
11687/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011688 * ALC269 channel source setting (2 channel)
11689 */
11690#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11691
11692#define alc269_dac_nids alc260_dac_nids
11693
11694static hda_nid_t alc269_adc_nids[1] = {
11695 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011696 0x08,
11697};
11698
Takashi Iwaie01bf502008-08-21 16:25:07 +020011699static hda_nid_t alc269_capsrc_nids[1] = {
11700 0x23,
11701};
11702
11703/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11704 * not a mux!
11705 */
11706
Kailang Yangf53281e2008-07-18 12:36:43 +020011707static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11708 .num_items = 2,
11709 .items = {
11710 { "i-Mic", 0x5 },
11711 { "e-Mic", 0x0 },
11712 },
11713};
11714
11715static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11716 .num_items = 2,
11717 .items = {
11718 { "i-Mic", 0x1 },
11719 { "e-Mic", 0x0 },
11720 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011721};
11722
11723#define alc269_modes alc260_modes
11724#define alc269_capture_source alc880_lg_lw_capture_source
11725
11726static struct snd_kcontrol_new alc269_base_mixer[] = {
11727 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11728 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11729 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11730 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011733 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11734 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011735 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11736 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11737 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11738 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11740 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11741 { } /* end */
11742};
11743
Kailang Yang60db6b52008-08-26 13:13:00 +020011744static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11745 /* output mixer control */
11746 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11747 {
11748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11749 .name = "Master Playback Switch",
11750 .info = snd_hda_mixer_amp_switch_info,
11751 .get = snd_hda_mixer_amp_switch_get,
11752 .put = alc268_acer_master_sw_put,
11753 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11754 },
11755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11759 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11760 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11761 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11762 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11763 { }
11764};
11765
Kailang Yangf53281e2008-07-18 12:36:43 +020011766/* bind volumes of both NID 0x0c and 0x0d */
11767static struct hda_bind_ctls alc269_epc_bind_vol = {
11768 .ops = &snd_hda_bind_vol,
11769 .values = {
11770 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11771 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11772 0
11773 },
11774};
11775
11776static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11777 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11778 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11779 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11780 { } /* end */
11781};
11782
Kailang Yangf6a92242007-12-13 16:52:54 +010011783/* capture mixer elements */
11784static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011785 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11786 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011787 {
11788 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11789 /* The multiple "Capture Source" controls confuse alsamixer
11790 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011791 */
11792 /* .name = "Capture Source", */
11793 .name = "Input Source",
11794 .count = 1,
11795 .info = alc_mux_enum_info,
11796 .get = alc_mux_enum_get,
11797 .put = alc_mux_enum_put,
11798 },
11799 { } /* end */
11800};
11801
Kailang Yangf53281e2008-07-18 12:36:43 +020011802/* capture mixer elements */
11803static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11806 { } /* end */
11807};
11808
Takashi Iwai2005af22008-08-20 18:38:26 +020011809/* beep control */
11810static struct snd_kcontrol_new alc269_beep_mixer[] = {
11811 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11812 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11813 { } /* end */
11814};
11815
Kailang Yang60db6b52008-08-26 13:13:00 +020011816static struct hda_verb alc269_quanta_fl1_verbs[] = {
11817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11818 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11821 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11822 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11823 { }
11824};
11825
11826/* toggle speaker-output according to the hp-jack state */
11827static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11828{
11829 unsigned int present;
11830 unsigned char bits;
11831
11832 present = snd_hda_codec_read(codec, 0x15, 0,
11833 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11834 bits = present ? AMP_IN_MUTE(0) : 0;
11835 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11836 AMP_IN_MUTE(0), bits);
11837 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11838 AMP_IN_MUTE(0), bits);
11839
11840 snd_hda_codec_write(codec, 0x20, 0,
11841 AC_VERB_SET_COEF_INDEX, 0x0c);
11842 snd_hda_codec_write(codec, 0x20, 0,
11843 AC_VERB_SET_PROC_COEF, 0x680);
11844
11845 snd_hda_codec_write(codec, 0x20, 0,
11846 AC_VERB_SET_COEF_INDEX, 0x0c);
11847 snd_hda_codec_write(codec, 0x20, 0,
11848 AC_VERB_SET_PROC_COEF, 0x480);
11849}
11850
11851static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11852{
11853 unsigned int present;
11854
11855 present = snd_hda_codec_read(codec, 0x18, 0,
11856 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11857 snd_hda_codec_write(codec, 0x23, 0,
11858 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11859}
11860
11861static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11862 unsigned int res)
11863{
11864 if ((res >> 26) == ALC880_HP_EVENT)
11865 alc269_quanta_fl1_speaker_automute(codec);
11866 if ((res >> 26) == ALC880_MIC_EVENT)
11867 alc269_quanta_fl1_mic_automute(codec);
11868}
11869
11870static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11871{
11872 alc269_quanta_fl1_speaker_automute(codec);
11873 alc269_quanta_fl1_mic_automute(codec);
11874}
11875
11876static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11878 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11879 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11883 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11884 {}
11885};
11886
11887static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11888 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11889 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11890 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11891 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11892 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11893 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11894 {}
11895};
11896
11897/* toggle speaker-output according to the hp-jack state */
11898static void alc269_speaker_automute(struct hda_codec *codec)
11899{
11900 unsigned int present;
11901 unsigned char bits;
11902
11903 present = snd_hda_codec_read(codec, 0x15, 0,
11904 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11905 bits = present ? AMP_IN_MUTE(0) : 0;
11906 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11907 AMP_IN_MUTE(0), bits);
11908 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11909 AMP_IN_MUTE(0), bits);
11910}
11911
11912static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11913{
11914 unsigned int present;
11915
11916 present = snd_hda_codec_read(codec, 0x18, 0,
11917 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11918 snd_hda_codec_write(codec, 0x23, 0,
11919 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11920}
11921
11922static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11923{
11924 unsigned int present;
11925
11926 present = snd_hda_codec_read(codec, 0x18, 0,
11927 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11928 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11929 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11930 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11931 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11932}
11933
11934/* unsolicited event for HP jack sensing */
11935static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11936 unsigned int res)
11937{
11938 if ((res >> 26) == ALC880_HP_EVENT)
11939 alc269_speaker_automute(codec);
11940
11941 if ((res >> 26) == ALC880_MIC_EVENT)
11942 alc269_eeepc_dmic_automute(codec);
11943}
11944
11945static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11946{
11947 alc269_speaker_automute(codec);
11948 alc269_eeepc_dmic_automute(codec);
11949}
11950
11951/* unsolicited event for HP jack sensing */
11952static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11953 unsigned int res)
11954{
11955 if ((res >> 26) == ALC880_HP_EVENT)
11956 alc269_speaker_automute(codec);
11957
11958 if ((res >> 26) == ALC880_MIC_EVENT)
11959 alc269_eeepc_amic_automute(codec);
11960}
11961
11962static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11963{
11964 alc269_speaker_automute(codec);
11965 alc269_eeepc_amic_automute(codec);
11966}
11967
Kailang Yangf6a92242007-12-13 16:52:54 +010011968/*
11969 * generic initialization of ADC, input mixers and output mixers
11970 */
11971static struct hda_verb alc269_init_verbs[] = {
11972 /*
11973 * Unmute ADC0 and set the default input to mic-in
11974 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011976
11977 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11978 * analog-loopback mixer widget
11979 * Note: PASD motherboards uses the Line In 2 as the input for
11980 * front panel mic (mic 2)
11981 */
11982 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11988
11989 /*
11990 * Set up output mixers (0x0c - 0x0e)
11991 */
11992 /* set vol=0 to output mixers */
11993 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11994 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11995
11996 /* set up input amps for analog loopback */
11997 /* Amp Indices: DAC = 0, mixer = 1 */
11998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12004
12005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12007 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12008 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12009 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12011 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12012
12013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12020
12021 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12023
12024 /* FIXME: use matrix-type input source selection */
12025 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12026 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12031
12032 /* set EAPD */
12033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12034 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12035 { }
12036};
12037
12038/* add playback controls from the parsed DAC table */
12039static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12040 const struct auto_pin_cfg *cfg)
12041{
12042 hda_nid_t nid;
12043 int err;
12044
12045 spec->multiout.num_dacs = 1; /* only use one dac */
12046 spec->multiout.dac_nids = spec->private_dac_nids;
12047 spec->multiout.dac_nids[0] = 2;
12048
12049 nid = cfg->line_out_pins[0];
12050 if (nid) {
12051 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12052 "Front Playback Volume",
12053 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12054 if (err < 0)
12055 return err;
12056 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12057 "Front Playback Switch",
12058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12059 if (err < 0)
12060 return err;
12061 }
12062
12063 nid = cfg->speaker_pins[0];
12064 if (nid) {
12065 if (!cfg->line_out_pins[0]) {
12066 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12067 "Speaker Playback Volume",
12068 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12069 HDA_OUTPUT));
12070 if (err < 0)
12071 return err;
12072 }
12073 if (nid == 0x16) {
12074 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12075 "Speaker Playback Switch",
12076 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12077 HDA_OUTPUT));
12078 if (err < 0)
12079 return err;
12080 } else {
12081 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12082 "Speaker Playback Switch",
12083 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12084 HDA_OUTPUT));
12085 if (err < 0)
12086 return err;
12087 }
12088 }
12089 nid = cfg->hp_pins[0];
12090 if (nid) {
12091 /* spec->multiout.hp_nid = 2; */
12092 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12093 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12094 "Headphone Playback Volume",
12095 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12096 HDA_OUTPUT));
12097 if (err < 0)
12098 return err;
12099 }
12100 if (nid == 0x16) {
12101 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12102 "Headphone Playback Switch",
12103 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12104 HDA_OUTPUT));
12105 if (err < 0)
12106 return err;
12107 } else {
12108 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12109 "Headphone Playback Switch",
12110 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12111 HDA_OUTPUT));
12112 if (err < 0)
12113 return err;
12114 }
12115 }
12116 return 0;
12117}
12118
12119#define alc269_auto_create_analog_input_ctls \
12120 alc880_auto_create_analog_input_ctls
12121
12122#ifdef CONFIG_SND_HDA_POWER_SAVE
12123#define alc269_loopbacks alc880_loopbacks
12124#endif
12125
12126/* pcm configuration: identiacal with ALC880 */
12127#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12128#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12129#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12130#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12131
12132/*
12133 * BIOS auto configuration
12134 */
12135static int alc269_parse_auto_config(struct hda_codec *codec)
12136{
12137 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012138 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012139 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12140
12141 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12142 alc269_ignore);
12143 if (err < 0)
12144 return err;
12145
12146 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12147 if (err < 0)
12148 return err;
12149 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12150 if (err < 0)
12151 return err;
12152
12153 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12154
12155 if (spec->autocfg.dig_out_pin)
12156 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12157
12158 if (spec->kctl_alloc)
12159 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12160
Takashi Iwai2005af22008-08-20 18:38:26 +020012161 /* create a beep mixer control if the pin 0x1d isn't assigned */
12162 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12163 if (spec->autocfg.input_pins[i] == 0x1d)
12164 break;
12165 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12166 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
12167
Kailang Yangf6a92242007-12-13 16:52:54 +010012168 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
12169 spec->num_mux_defs = 1;
12170 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012171 /* set default input source */
12172 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12173 0, AC_VERB_SET_CONNECT_SEL,
12174 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012175
12176 err = alc_auto_add_mic_boost(codec);
12177 if (err < 0)
12178 return err;
12179
Kailang Yangf53281e2008-07-18 12:36:43 +020012180 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
12181 spec->num_mixers++;
12182
Kailang Yangf6a92242007-12-13 16:52:54 +010012183 return 1;
12184}
12185
12186#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12187#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12188#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12189
12190
12191/* init callback for auto-configuration model -- overriding the default init */
12192static void alc269_auto_init(struct hda_codec *codec)
12193{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012194 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012195 alc269_auto_init_multi_out(codec);
12196 alc269_auto_init_hp_out(codec);
12197 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012198 if (spec->unsol_event)
12199 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012200}
12201
12202/*
12203 * configuration and preset
12204 */
12205static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012206 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012207 [ALC269_QUANTA_FL1] = "quanta",
12208 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12209 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901"
Kailang Yangf6a92242007-12-13 16:52:54 +010012210};
12211
12212static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012213 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012214 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12215 ALC269_ASUS_EEEPC_P703),
12216 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12217 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012218 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12219 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010012220 {}
12221};
12222
12223static struct alc_config_preset alc269_presets[] = {
12224 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020012225 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012226 .init_verbs = { alc269_init_verbs },
12227 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12228 .dac_nids = alc269_dac_nids,
12229 .hp_nid = 0x03,
12230 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12231 .channel_mode = alc269_modes,
12232 .input_mux = &alc269_capture_source,
12233 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012234 [ALC269_QUANTA_FL1] = {
12235 .mixers = { alc269_quanta_fl1_mixer },
12236 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12237 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12238 .dac_nids = alc269_dac_nids,
12239 .hp_nid = 0x03,
12240 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12241 .channel_mode = alc269_modes,
12242 .input_mux = &alc269_capture_source,
12243 .unsol_event = alc269_quanta_fl1_unsol_event,
12244 .init_hook = alc269_quanta_fl1_init_hook,
12245 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012246 [ALC269_ASUS_EEEPC_P703] = {
12247 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
12248 .init_verbs = { alc269_init_verbs,
12249 alc269_eeepc_amic_init_verbs },
12250 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12251 .dac_nids = alc269_dac_nids,
12252 .hp_nid = 0x03,
12253 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12254 .channel_mode = alc269_modes,
12255 .input_mux = &alc269_eeepc_amic_capture_source,
12256 .unsol_event = alc269_eeepc_amic_unsol_event,
12257 .init_hook = alc269_eeepc_amic_inithook,
12258 },
12259 [ALC269_ASUS_EEEPC_P901] = {
12260 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
12261 .init_verbs = { alc269_init_verbs,
12262 alc269_eeepc_dmic_init_verbs },
12263 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12264 .dac_nids = alc269_dac_nids,
12265 .hp_nid = 0x03,
12266 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12267 .channel_mode = alc269_modes,
12268 .input_mux = &alc269_eeepc_dmic_capture_source,
12269 .unsol_event = alc269_eeepc_dmic_unsol_event,
12270 .init_hook = alc269_eeepc_dmic_inithook,
12271 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012272};
12273
12274static int patch_alc269(struct hda_codec *codec)
12275{
12276 struct alc_spec *spec;
12277 int board_config;
12278 int err;
12279
12280 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12281 if (spec == NULL)
12282 return -ENOMEM;
12283
12284 codec->spec = spec;
12285
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012286 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12287
Kailang Yangf6a92242007-12-13 16:52:54 +010012288 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12289 alc269_models,
12290 alc269_cfg_tbl);
12291
12292 if (board_config < 0) {
12293 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12294 "trying auto-probe from BIOS...\n");
12295 board_config = ALC269_AUTO;
12296 }
12297
12298 if (board_config == ALC269_AUTO) {
12299 /* automatic parse from the BIOS config */
12300 err = alc269_parse_auto_config(codec);
12301 if (err < 0) {
12302 alc_free(codec);
12303 return err;
12304 } else if (!err) {
12305 printk(KERN_INFO
12306 "hda_codec: Cannot set up configuration "
12307 "from BIOS. Using base mode...\n");
12308 board_config = ALC269_BASIC;
12309 }
12310 }
12311
12312 if (board_config != ALC269_AUTO)
12313 setup_preset(spec, &alc269_presets[board_config]);
12314
12315 spec->stream_name_analog = "ALC269 Analog";
12316 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12317 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12318
12319 spec->stream_name_digital = "ALC269 Digital";
12320 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12321 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12322
12323 spec->adc_nids = alc269_adc_nids;
12324 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012325 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010012326
12327 codec->patch_ops = alc_patch_ops;
12328 if (board_config == ALC269_AUTO)
12329 spec->init_hook = alc269_auto_init;
12330#ifdef CONFIG_SND_HDA_POWER_SAVE
12331 if (!spec->loopback.amplist)
12332 spec->loopback.amplist = alc269_loopbacks;
12333#endif
12334
12335 return 0;
12336}
12337
12338/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012339 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12340 */
12341
12342/*
12343 * set the path ways for 2 channel output
12344 * need to set the codec line out and mic 1 pin widgets to inputs
12345 */
12346static struct hda_verb alc861_threestack_ch2_init[] = {
12347 /* set pin widget 1Ah (line in) for input */
12348 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012349 /* set pin widget 18h (mic1/2) for input, for mic also enable
12350 * the vref
12351 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012352 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12353
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012354 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12355#if 0
12356 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12357 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12358#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012359 { } /* end */
12360};
12361/*
12362 * 6ch mode
12363 * need to set the codec line out and mic 1 pin widgets to outputs
12364 */
12365static struct hda_verb alc861_threestack_ch6_init[] = {
12366 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12367 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12368 /* set pin widget 18h (mic1) for output (CLFE)*/
12369 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12370
12371 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012372 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012373
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12375#if 0
12376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12378#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012379 { } /* end */
12380};
12381
12382static struct hda_channel_mode alc861_threestack_modes[2] = {
12383 { 2, alc861_threestack_ch2_init },
12384 { 6, alc861_threestack_ch6_init },
12385};
Takashi Iwai22309c32006-08-09 16:57:28 +020012386/* Set mic1 as input and unmute the mixer */
12387static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12388 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12389 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12390 { } /* end */
12391};
12392/* Set mic1 as output and mute mixer */
12393static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12394 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12395 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12396 { } /* end */
12397};
12398
12399static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12400 { 2, alc861_uniwill_m31_ch2_init },
12401 { 4, alc861_uniwill_m31_ch4_init },
12402};
Kailang Yangdf694da2005-12-05 19:42:22 +010012403
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012404/* Set mic1 and line-in as input and unmute the mixer */
12405static struct hda_verb alc861_asus_ch2_init[] = {
12406 /* set pin widget 1Ah (line in) for input */
12407 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012408 /* set pin widget 18h (mic1/2) for input, for mic also enable
12409 * the vref
12410 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012411 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12412
12413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12414#if 0
12415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12416 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12417#endif
12418 { } /* end */
12419};
12420/* Set mic1 nad line-in as output and mute mixer */
12421static struct hda_verb alc861_asus_ch6_init[] = {
12422 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12423 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12424 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12425 /* set pin widget 18h (mic1) for output (CLFE)*/
12426 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12427 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12428 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12429 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12430
12431 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12432#if 0
12433 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12435#endif
12436 { } /* end */
12437};
12438
12439static struct hda_channel_mode alc861_asus_modes[2] = {
12440 { 2, alc861_asus_ch2_init },
12441 { 6, alc861_asus_ch6_init },
12442};
12443
Kailang Yangdf694da2005-12-05 19:42:22 +010012444/* patch-ALC861 */
12445
12446static struct snd_kcontrol_new alc861_base_mixer[] = {
12447 /* output mixer control */
12448 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12449 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12450 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12451 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12452 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12453
12454 /*Input mixer control */
12455 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12456 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12457 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12458 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12459 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12460 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12462 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012465
Kailang Yangdf694da2005-12-05 19:42:22 +010012466 /* Capture mixer control */
12467 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12468 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12469 {
12470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12471 .name = "Capture Source",
12472 .count = 1,
12473 .info = alc_mux_enum_info,
12474 .get = alc_mux_enum_get,
12475 .put = alc_mux_enum_put,
12476 },
12477 { } /* end */
12478};
12479
12480static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12481 /* output mixer control */
12482 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12483 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12484 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12485 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12486 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12487
12488 /* Input mixer control */
12489 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12490 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12491 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12492 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12493 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12494 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12496 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12497 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012499
Kailang Yangdf694da2005-12-05 19:42:22 +010012500 /* Capture mixer control */
12501 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12502 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12503 {
12504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12505 .name = "Capture Source",
12506 .count = 1,
12507 .info = alc_mux_enum_info,
12508 .get = alc_mux_enum_get,
12509 .put = alc_mux_enum_put,
12510 },
12511 {
12512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12513 .name = "Channel Mode",
12514 .info = alc_ch_mode_info,
12515 .get = alc_ch_mode_get,
12516 .put = alc_ch_mode_put,
12517 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12518 },
12519 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012520};
12521
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012522static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012523 /* output mixer control */
12524 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12526 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012527
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012528 /*Capture mixer control */
12529 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12530 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12531 {
12532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12533 .name = "Capture Source",
12534 .count = 1,
12535 .info = alc_mux_enum_info,
12536 .get = alc_mux_enum_get,
12537 .put = alc_mux_enum_put,
12538 },
12539
12540 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012541};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012542
Takashi Iwai22309c32006-08-09 16:57:28 +020012543static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12544 /* output mixer control */
12545 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12546 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12547 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12548 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12549 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12550
12551 /* Input mixer control */
12552 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12553 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12554 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12555 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12556 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12557 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12559 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012562
Takashi Iwai22309c32006-08-09 16:57:28 +020012563 /* Capture mixer control */
12564 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12565 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12566 {
12567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12568 .name = "Capture Source",
12569 .count = 1,
12570 .info = alc_mux_enum_info,
12571 .get = alc_mux_enum_get,
12572 .put = alc_mux_enum_put,
12573 },
12574 {
12575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12576 .name = "Channel Mode",
12577 .info = alc_ch_mode_info,
12578 .get = alc_ch_mode_get,
12579 .put = alc_ch_mode_put,
12580 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12581 },
12582 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012583};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012584
12585static struct snd_kcontrol_new alc861_asus_mixer[] = {
12586 /* output mixer control */
12587 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12588 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12589 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12590 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12591 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12592
12593 /* Input mixer control */
12594 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12595 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12596 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12597 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12598 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12599 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12601 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12604
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012605 /* Capture mixer control */
12606 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12607 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12608 {
12609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12610 .name = "Capture Source",
12611 .count = 1,
12612 .info = alc_mux_enum_info,
12613 .get = alc_mux_enum_get,
12614 .put = alc_mux_enum_put,
12615 },
12616 {
12617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12618 .name = "Channel Mode",
12619 .info = alc_ch_mode_info,
12620 .get = alc_ch_mode_get,
12621 .put = alc_ch_mode_put,
12622 .private_value = ARRAY_SIZE(alc861_asus_modes),
12623 },
12624 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012625};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012626
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012627/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012628static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012629 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12630 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12631 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12632 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12633 { }
12634};
12635
Kailang Yangdf694da2005-12-05 19:42:22 +010012636/*
12637 * generic initialization of ADC, input mixers and output mixers
12638 */
12639static struct hda_verb alc861_base_init_verbs[] = {
12640 /*
12641 * Unmute ADC0 and set the default input to mic-in
12642 */
12643 /* port-A for surround (rear panel) */
12644 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12645 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12646 /* port-B for mic-in (rear panel) with vref */
12647 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12648 /* port-C for line-in (rear panel) */
12649 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12650 /* port-D for Front */
12651 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12652 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12653 /* port-E for HP out (front panel) */
12654 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12655 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012656 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012657 /* port-F for mic-in (front panel) with vref */
12658 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12659 /* port-G for CLFE (rear panel) */
12660 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12661 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12662 /* port-H for side (rear panel) */
12663 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12664 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12665 /* CD-in */
12666 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12667 /* route front mic to ADC1*/
12668 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012670
Kailang Yangdf694da2005-12-05 19:42:22 +010012671 /* Unmute DAC0~3 & spdif out*/
12672 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12673 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12674 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12675 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012677
Kailang Yangdf694da2005-12-05 19:42:22 +010012678 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12679 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12680 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12681 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12682 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012683
Kailang Yangdf694da2005-12-05 19:42:22 +010012684 /* Unmute Stereo Mixer 15 */
12685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012689
12690 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12692 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12693 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012698 /* hp used DAC 3 (Front) */
12699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012700 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12701
12702 { }
12703};
12704
12705static struct hda_verb alc861_threestack_init_verbs[] = {
12706 /*
12707 * Unmute ADC0 and set the default input to mic-in
12708 */
12709 /* port-A for surround (rear panel) */
12710 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12711 /* port-B for mic-in (rear panel) with vref */
12712 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12713 /* port-C for line-in (rear panel) */
12714 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12715 /* port-D for Front */
12716 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12717 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12718 /* port-E for HP out (front panel) */
12719 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12720 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012721 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012722 /* port-F for mic-in (front panel) with vref */
12723 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12724 /* port-G for CLFE (rear panel) */
12725 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12726 /* port-H for side (rear panel) */
12727 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12728 /* CD-in */
12729 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12730 /* route front mic to ADC1*/
12731 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12733 /* Unmute DAC0~3 & spdif out*/
12734 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12735 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12736 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12737 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012739
Kailang Yangdf694da2005-12-05 19:42:22 +010012740 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12741 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12742 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12743 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12744 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012745
Kailang Yangdf694da2005-12-05 19:42:22 +010012746 /* Unmute Stereo Mixer 15 */
12747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012751
12752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12755 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012760 /* hp used DAC 3 (Front) */
12761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12763 { }
12764};
Takashi Iwai22309c32006-08-09 16:57:28 +020012765
12766static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12767 /*
12768 * Unmute ADC0 and set the default input to mic-in
12769 */
12770 /* port-A for surround (rear panel) */
12771 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12772 /* port-B for mic-in (rear panel) with vref */
12773 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12774 /* port-C for line-in (rear panel) */
12775 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12776 /* port-D for Front */
12777 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12778 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12779 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012780 /* this has to be set to VREF80 */
12781 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012782 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012784 /* port-F for mic-in (front panel) with vref */
12785 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12786 /* port-G for CLFE (rear panel) */
12787 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12788 /* port-H for side (rear panel) */
12789 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12790 /* CD-in */
12791 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12792 /* route front mic to ADC1*/
12793 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12795 /* Unmute DAC0~3 & spdif out*/
12796 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12797 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12798 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12799 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012801
Takashi Iwai22309c32006-08-09 16:57:28 +020012802 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12803 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12804 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12805 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12806 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012807
Takashi Iwai22309c32006-08-09 16:57:28 +020012808 /* Unmute Stereo Mixer 15 */
12809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012813
12814 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12817 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12818 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12819 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12820 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012822 /* hp used DAC 3 (Front) */
12823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012824 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12825 { }
12826};
12827
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012828static struct hda_verb alc861_asus_init_verbs[] = {
12829 /*
12830 * Unmute ADC0 and set the default input to mic-in
12831 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012832 /* port-A for surround (rear panel)
12833 * according to codec#0 this is the HP jack
12834 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012835 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12836 /* route front PCM to HP */
12837 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12838 /* port-B for mic-in (rear panel) with vref */
12839 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12840 /* port-C for line-in (rear panel) */
12841 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12842 /* port-D for Front */
12843 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12844 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12845 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012846 /* this has to be set to VREF80 */
12847 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012848 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012849 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012850 /* port-F for mic-in (front panel) with vref */
12851 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12852 /* port-G for CLFE (rear panel) */
12853 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12854 /* port-H for side (rear panel) */
12855 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12856 /* CD-in */
12857 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12858 /* route front mic to ADC1*/
12859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12861 /* Unmute DAC0~3 & spdif out*/
12862 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12863 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12864 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12865 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12867 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12868 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12869 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12870 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12871 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012872
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012873 /* Unmute Stereo Mixer 15 */
12874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012878
12879 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12882 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12886 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012887 /* hp used DAC 3 (Front) */
12888 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012889 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12890 { }
12891};
12892
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012893/* additional init verbs for ASUS laptops */
12894static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12895 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12896 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12897 { }
12898};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012899
Kailang Yangdf694da2005-12-05 19:42:22 +010012900/*
12901 * generic initialization of ADC, input mixers and output mixers
12902 */
12903static struct hda_verb alc861_auto_init_verbs[] = {
12904 /*
12905 * Unmute ADC0 and set the default input to mic-in
12906 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012907 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012909
Kailang Yangdf694da2005-12-05 19:42:22 +010012910 /* Unmute DAC0~3 & spdif out*/
12911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12913 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12914 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012916
Kailang Yangdf694da2005-12-05 19:42:22 +010012917 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12918 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12919 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12920 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12921 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012922
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 /* Unmute Stereo Mixer 15 */
12924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12928
12929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12930 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12932 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12937
12938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012942 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012947 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012948
12949 { }
12950};
12951
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012952static struct hda_verb alc861_toshiba_init_verbs[] = {
12953 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012954
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012955 { }
12956};
12957
12958/* toggle speaker-output according to the hp-jack state */
12959static void alc861_toshiba_automute(struct hda_codec *codec)
12960{
12961 unsigned int present;
12962
12963 present = snd_hda_codec_read(codec, 0x0f, 0,
12964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012965 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12966 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12967 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12968 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012969}
12970
12971static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12972 unsigned int res)
12973{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012974 if ((res >> 26) == ALC880_HP_EVENT)
12975 alc861_toshiba_automute(codec);
12976}
12977
Kailang Yangdf694da2005-12-05 19:42:22 +010012978/* pcm configuration: identiacal with ALC880 */
12979#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12980#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12981#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12982#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12983
12984
12985#define ALC861_DIGOUT_NID 0x07
12986
12987static struct hda_channel_mode alc861_8ch_modes[1] = {
12988 { 8, NULL }
12989};
12990
12991static hda_nid_t alc861_dac_nids[4] = {
12992 /* front, surround, clfe, side */
12993 0x03, 0x06, 0x05, 0x04
12994};
12995
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012996static hda_nid_t alc660_dac_nids[3] = {
12997 /* front, clfe, surround */
12998 0x03, 0x05, 0x06
12999};
13000
Kailang Yangdf694da2005-12-05 19:42:22 +010013001static hda_nid_t alc861_adc_nids[1] = {
13002 /* ADC0-2 */
13003 0x08,
13004};
13005
13006static struct hda_input_mux alc861_capture_source = {
13007 .num_items = 5,
13008 .items = {
13009 { "Mic", 0x0 },
13010 { "Front Mic", 0x3 },
13011 { "Line", 0x1 },
13012 { "CD", 0x4 },
13013 { "Mixer", 0x5 },
13014 },
13015};
13016
13017/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013018static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13019 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013020{
13021 int i;
13022 hda_nid_t nid;
13023
13024 spec->multiout.dac_nids = spec->private_dac_nids;
13025 for (i = 0; i < cfg->line_outs; i++) {
13026 nid = cfg->line_out_pins[i];
13027 if (nid) {
13028 if (i >= ARRAY_SIZE(alc861_dac_nids))
13029 continue;
13030 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13031 }
13032 }
13033 spec->multiout.num_dacs = cfg->line_outs;
13034 return 0;
13035}
13036
13037/* add playback controls from the parsed DAC table */
13038static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13039 const struct auto_pin_cfg *cfg)
13040{
13041 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013042 static const char *chname[4] = {
13043 "Front", "Surround", NULL /*CLFE*/, "Side"
13044 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013045 hda_nid_t nid;
13046 int i, idx, err;
13047
13048 for (i = 0; i < cfg->line_outs; i++) {
13049 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013050 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013051 continue;
13052 if (nid == 0x05) {
13053 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013054 err = add_control(spec, ALC_CTL_BIND_MUTE,
13055 "Center Playback Switch",
13056 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13057 HDA_OUTPUT));
13058 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013059 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013060 err = add_control(spec, ALC_CTL_BIND_MUTE,
13061 "LFE Playback Switch",
13062 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13063 HDA_OUTPUT));
13064 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013065 return err;
13066 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013067 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13068 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013069 if (nid == alc861_dac_nids[idx])
13070 break;
13071 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013072 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13073 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13074 HDA_OUTPUT));
13075 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013076 return err;
13077 }
13078 }
13079 return 0;
13080}
13081
13082static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13083{
13084 int err;
13085 hda_nid_t nid;
13086
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013087 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013088 return 0;
13089
13090 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13091 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013092 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13093 "Headphone Playback Switch",
13094 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13095 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013096 return err;
13097 spec->multiout.hp_nid = nid;
13098 }
13099 return 0;
13100}
13101
13102/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013103static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13104 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013105{
Kailang Yangdf694da2005-12-05 19:42:22 +010013106 struct hda_input_mux *imux = &spec->private_imux;
13107 int i, err, idx, idx1;
13108
13109 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013110 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013111 case 0x0c:
13112 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013113 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013114 break;
13115 case 0x0f:
13116 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013117 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013118 break;
13119 case 0x0d:
13120 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013121 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013122 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013123 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013124 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013125 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013126 break;
13127 case 0x11:
13128 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013129 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013130 break;
13131 default:
13132 continue;
13133 }
13134
Takashi Iwai4a471b72005-12-07 13:56:29 +010013135 err = new_analog_input(spec, cfg->input_pins[i],
13136 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013137 if (err < 0)
13138 return err;
13139
Takashi Iwai4a471b72005-12-07 13:56:29 +010013140 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013141 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013142 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013143 }
13144 return 0;
13145}
13146
13147static struct snd_kcontrol_new alc861_capture_mixer[] = {
13148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13150
13151 {
13152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13153 /* The multiple "Capture Source" controls confuse alsamixer
13154 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010013155 */
13156 /* .name = "Capture Source", */
13157 .name = "Input Source",
13158 .count = 1,
13159 .info = alc_mux_enum_info,
13160 .get = alc_mux_enum_get,
13161 .put = alc_mux_enum_put,
13162 },
13163 { } /* end */
13164};
13165
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013166static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13167 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013168 int pin_type, int dac_idx)
13169{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013170 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13171 pin_type);
13172 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13173 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013174}
13175
13176static void alc861_auto_init_multi_out(struct hda_codec *codec)
13177{
13178 struct alc_spec *spec = codec->spec;
13179 int i;
13180
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013181 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013182 for (i = 0; i < spec->autocfg.line_outs; i++) {
13183 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013184 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013185 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013186 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013187 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013188 }
13189}
13190
13191static void alc861_auto_init_hp_out(struct hda_codec *codec)
13192{
13193 struct alc_spec *spec = codec->spec;
13194 hda_nid_t pin;
13195
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013196 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013197 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013198 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13199 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013200 pin = spec->autocfg.speaker_pins[0];
13201 if (pin)
13202 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013203}
13204
13205static void alc861_auto_init_analog_input(struct hda_codec *codec)
13206{
13207 struct alc_spec *spec = codec->spec;
13208 int i;
13209
13210 for (i = 0; i < AUTO_PIN_LAST; i++) {
13211 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013212 if (nid >= 0x0c && nid <= 0x11) {
13213 snd_hda_codec_write(codec, nid, 0,
13214 AC_VERB_SET_PIN_WIDGET_CONTROL,
13215 i <= AUTO_PIN_FRONT_MIC ?
13216 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013217 }
13218 }
13219}
13220
13221/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222/* return 1 if successful, 0 if the proper config is not found,
13223 * or a negative error code
13224 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013225static int alc861_parse_auto_config(struct hda_codec *codec)
13226{
13227 struct alc_spec *spec = codec->spec;
13228 int err;
13229 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013231 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13232 alc861_ignore);
13233 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013234 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013235 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013236 return 0; /* can't find valid BIOS pin config */
13237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013238 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13239 if (err < 0)
13240 return err;
13241 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13242 if (err < 0)
13243 return err;
13244 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13245 if (err < 0)
13246 return err;
13247 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13248 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013249 return err;
13250
13251 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13252
13253 if (spec->autocfg.dig_out_pin)
13254 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13255
13256 if (spec->kctl_alloc)
13257 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13258
13259 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
13260
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013261 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013262 spec->input_mux = &spec->private_imux;
13263
13264 spec->adc_nids = alc861_adc_nids;
13265 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13266 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
13267 spec->num_mixers++;
13268
13269 return 1;
13270}
13271
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013272/* additional initialization for auto-configuration model */
13273static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013275 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013276 alc861_auto_init_multi_out(codec);
13277 alc861_auto_init_hp_out(codec);
13278 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013279 if (spec->unsol_event)
13280 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013281}
13282
Takashi Iwaicb53c622007-08-10 17:21:45 +020013283#ifdef CONFIG_SND_HDA_POWER_SAVE
13284static struct hda_amp_list alc861_loopbacks[] = {
13285 { 0x15, HDA_INPUT, 0 },
13286 { 0x15, HDA_INPUT, 1 },
13287 { 0x15, HDA_INPUT, 2 },
13288 { 0x15, HDA_INPUT, 3 },
13289 { } /* end */
13290};
13291#endif
13292
Kailang Yangdf694da2005-12-05 19:42:22 +010013293
13294/*
13295 * configuration and preset
13296 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013297static const char *alc861_models[ALC861_MODEL_LAST] = {
13298 [ALC861_3ST] = "3stack",
13299 [ALC660_3ST] = "3stack-660",
13300 [ALC861_3ST_DIG] = "3stack-dig",
13301 [ALC861_6ST_DIG] = "6stack-dig",
13302 [ALC861_UNIWILL_M31] = "uniwill-m31",
13303 [ALC861_TOSHIBA] = "toshiba",
13304 [ALC861_ASUS] = "asus",
13305 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13306 [ALC861_AUTO] = "auto",
13307};
13308
13309static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013310 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013311 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13312 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13313 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013314 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013315 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013316 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013317 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13318 * Any other models that need this preset?
13319 */
13320 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013321 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13322 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013323 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13324 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13325 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13326 /* FIXME: the below seems conflict */
13327 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13328 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13329 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013330 {}
13331};
13332
13333static struct alc_config_preset alc861_presets[] = {
13334 [ALC861_3ST] = {
13335 .mixers = { alc861_3ST_mixer },
13336 .init_verbs = { alc861_threestack_init_verbs },
13337 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13338 .dac_nids = alc861_dac_nids,
13339 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13340 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013341 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013342 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13343 .adc_nids = alc861_adc_nids,
13344 .input_mux = &alc861_capture_source,
13345 },
13346 [ALC861_3ST_DIG] = {
13347 .mixers = { alc861_base_mixer },
13348 .init_verbs = { alc861_threestack_init_verbs },
13349 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13350 .dac_nids = alc861_dac_nids,
13351 .dig_out_nid = ALC861_DIGOUT_NID,
13352 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13353 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013354 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013355 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13356 .adc_nids = alc861_adc_nids,
13357 .input_mux = &alc861_capture_source,
13358 },
13359 [ALC861_6ST_DIG] = {
13360 .mixers = { alc861_base_mixer },
13361 .init_verbs = { alc861_base_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_8ch_modes),
13366 .channel_mode = alc861_8ch_modes,
13367 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13368 .adc_nids = alc861_adc_nids,
13369 .input_mux = &alc861_capture_source,
13370 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013371 [ALC660_3ST] = {
13372 .mixers = { alc861_3ST_mixer },
13373 .init_verbs = { alc861_threestack_init_verbs },
13374 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13375 .dac_nids = alc660_dac_nids,
13376 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13377 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013378 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013379 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13380 .adc_nids = alc861_adc_nids,
13381 .input_mux = &alc861_capture_source,
13382 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013383 [ALC861_UNIWILL_M31] = {
13384 .mixers = { alc861_uniwill_m31_mixer },
13385 .init_verbs = { alc861_uniwill_m31_init_verbs },
13386 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13387 .dac_nids = alc861_dac_nids,
13388 .dig_out_nid = ALC861_DIGOUT_NID,
13389 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13390 .channel_mode = alc861_uniwill_m31_modes,
13391 .need_dac_fix = 1,
13392 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13393 .adc_nids = alc861_adc_nids,
13394 .input_mux = &alc861_capture_source,
13395 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013396 [ALC861_TOSHIBA] = {
13397 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013398 .init_verbs = { alc861_base_init_verbs,
13399 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013400 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13401 .dac_nids = alc861_dac_nids,
13402 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13403 .channel_mode = alc883_3ST_2ch_modes,
13404 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13405 .adc_nids = alc861_adc_nids,
13406 .input_mux = &alc861_capture_source,
13407 .unsol_event = alc861_toshiba_unsol_event,
13408 .init_hook = alc861_toshiba_automute,
13409 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013410 [ALC861_ASUS] = {
13411 .mixers = { alc861_asus_mixer },
13412 .init_verbs = { alc861_asus_init_verbs },
13413 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13414 .dac_nids = alc861_dac_nids,
13415 .dig_out_nid = ALC861_DIGOUT_NID,
13416 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13417 .channel_mode = alc861_asus_modes,
13418 .need_dac_fix = 1,
13419 .hp_nid = 0x06,
13420 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13421 .adc_nids = alc861_adc_nids,
13422 .input_mux = &alc861_capture_source,
13423 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013424 [ALC861_ASUS_LAPTOP] = {
13425 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13426 .init_verbs = { alc861_asus_init_verbs,
13427 alc861_asus_laptop_init_verbs },
13428 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13429 .dac_nids = alc861_dac_nids,
13430 .dig_out_nid = ALC861_DIGOUT_NID,
13431 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13432 .channel_mode = alc883_3ST_2ch_modes,
13433 .need_dac_fix = 1,
13434 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13435 .adc_nids = alc861_adc_nids,
13436 .input_mux = &alc861_capture_source,
13437 },
13438};
Kailang Yangdf694da2005-12-05 19:42:22 +010013439
13440
13441static int patch_alc861(struct hda_codec *codec)
13442{
13443 struct alc_spec *spec;
13444 int board_config;
13445 int err;
13446
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013447 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013448 if (spec == NULL)
13449 return -ENOMEM;
13450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013451 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013452
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013453 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13454 alc861_models,
13455 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013456
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013457 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013458 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13459 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013460 board_config = ALC861_AUTO;
13461 }
13462
13463 if (board_config == ALC861_AUTO) {
13464 /* automatic parse from the BIOS config */
13465 err = alc861_parse_auto_config(codec);
13466 if (err < 0) {
13467 alc_free(codec);
13468 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013469 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013470 printk(KERN_INFO
13471 "hda_codec: Cannot set up configuration "
13472 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013473 board_config = ALC861_3ST_DIG;
13474 }
13475 }
13476
13477 if (board_config != ALC861_AUTO)
13478 setup_preset(spec, &alc861_presets[board_config]);
13479
13480 spec->stream_name_analog = "ALC861 Analog";
13481 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13482 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13483
13484 spec->stream_name_digital = "ALC861 Digital";
13485 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13486 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13487
Takashi Iwai2134ea42008-01-10 16:53:55 +010013488 spec->vmaster_nid = 0x03;
13489
Kailang Yangdf694da2005-12-05 19:42:22 +010013490 codec->patch_ops = alc_patch_ops;
13491 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013492 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013493#ifdef CONFIG_SND_HDA_POWER_SAVE
13494 if (!spec->loopback.amplist)
13495 spec->loopback.amplist = alc861_loopbacks;
13496#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013497
Kailang Yangdf694da2005-12-05 19:42:22 +010013498 return 0;
13499}
13500
13501/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013502 * ALC861-VD support
13503 *
13504 * Based on ALC882
13505 *
13506 * In addition, an independent DAC
13507 */
13508#define ALC861VD_DIGOUT_NID 0x06
13509
13510static hda_nid_t alc861vd_dac_nids[4] = {
13511 /* front, surr, clfe, side surr */
13512 0x02, 0x03, 0x04, 0x05
13513};
13514
13515/* dac_nids for ALC660vd are in a different order - according to
13516 * Realtek's driver.
13517 * This should probably tesult in a different mixer for 6stack models
13518 * of ALC660vd codecs, but for now there is only 3stack mixer
13519 * - and it is the same as in 861vd.
13520 * adc_nids in ALC660vd are (is) the same as in 861vd
13521 */
13522static hda_nid_t alc660vd_dac_nids[3] = {
13523 /* front, rear, clfe, rear_surr */
13524 0x02, 0x04, 0x03
13525};
13526
13527static hda_nid_t alc861vd_adc_nids[1] = {
13528 /* ADC0 */
13529 0x09,
13530};
13531
Takashi Iwaie1406342008-02-11 18:32:32 +010013532static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13533
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013534/* input MUX */
13535/* FIXME: should be a matrix-type input source selection */
13536static struct hda_input_mux alc861vd_capture_source = {
13537 .num_items = 4,
13538 .items = {
13539 { "Mic", 0x0 },
13540 { "Front Mic", 0x1 },
13541 { "Line", 0x2 },
13542 { "CD", 0x4 },
13543 },
13544};
13545
Kailang Yang272a5272007-05-14 11:00:38 +020013546static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013547 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013548 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013549 { "Ext Mic", 0x0 },
13550 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013551 },
13552};
13553
Kailang Yangd1a991a2007-08-15 16:21:59 +020013554static struct hda_input_mux alc861vd_hp_capture_source = {
13555 .num_items = 2,
13556 .items = {
13557 { "Front Mic", 0x0 },
13558 { "ATAPI Mic", 0x1 },
13559 },
13560};
13561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013562#define alc861vd_mux_enum_info alc_mux_enum_info
13563#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013564/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13565#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013566
13567/*
13568 * 2ch mode
13569 */
13570static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13571 { 2, NULL }
13572};
13573
13574/*
13575 * 6ch mode
13576 */
13577static struct hda_verb alc861vd_6stack_ch6_init[] = {
13578 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13579 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13580 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13581 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13582 { } /* end */
13583};
13584
13585/*
13586 * 8ch mode
13587 */
13588static struct hda_verb alc861vd_6stack_ch8_init[] = {
13589 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13590 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13591 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13592 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13593 { } /* end */
13594};
13595
13596static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13597 { 6, alc861vd_6stack_ch6_init },
13598 { 8, alc861vd_6stack_ch8_init },
13599};
13600
13601static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13602 {
13603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13604 .name = "Channel Mode",
13605 .info = alc_ch_mode_info,
13606 .get = alc_ch_mode_get,
13607 .put = alc_ch_mode_put,
13608 },
13609 { } /* end */
13610};
13611
13612static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13613 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13614 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13615
13616 {
13617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13618 /* The multiple "Capture Source" controls confuse alsamixer
13619 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013620 */
13621 /* .name = "Capture Source", */
13622 .name = "Input Source",
13623 .count = 1,
13624 .info = alc861vd_mux_enum_info,
13625 .get = alc861vd_mux_enum_get,
13626 .put = alc861vd_mux_enum_put,
13627 },
13628 { } /* end */
13629};
13630
13631/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13632 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13633 */
13634static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13635 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13636 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13637
13638 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13639 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13640
13641 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13642 HDA_OUTPUT),
13643 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13644 HDA_OUTPUT),
13645 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13646 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13647
13648 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13649 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13650
13651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13652
13653 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13656
13657 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13658 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13659 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13660
13661 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13662 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13663
13664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13666
13667 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13668 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13669
13670 { } /* end */
13671};
13672
13673static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13674 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13676
13677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13678
13679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13682
13683 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13686
13687 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13688 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13689
13690 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13691 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13692
13693 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13694 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13695
13696 { } /* end */
13697};
13698
Kailang Yangbdd148a2007-05-08 15:19:08 +020013699static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13700 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13701 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13702 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13703
13704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13705
13706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13709
13710 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13711 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13712 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13713
13714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13716
13717 { } /* end */
13718};
13719
Tobin Davisb419f342008-03-07 11:57:51 +010013720/* Pin assignment: Speaker=0x14, HP = 0x15,
13721 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013722 */
13723static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013724 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13725 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13727 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013728 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13729 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13730 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13731 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13732 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13733 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13734 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13735 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013736 { } /* end */
13737};
13738
Kailang Yangd1a991a2007-08-15 16:21:59 +020013739/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13740 * Front Mic=0x18, ATAPI Mic = 0x19,
13741 */
13742static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13743 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13744 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13745 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13746 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13747 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13748 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13749 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13750 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013751
Kailang Yangd1a991a2007-08-15 16:21:59 +020013752 { } /* end */
13753};
13754
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013755/*
13756 * generic initialization of ADC, input mixers and output mixers
13757 */
13758static struct hda_verb alc861vd_volume_init_verbs[] = {
13759 /*
13760 * Unmute ADC0 and set the default input to mic-in
13761 */
13762 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13764
13765 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13766 * the analog-loopback mixer widget
13767 */
13768 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013774
13775 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013780
13781 /*
13782 * Set up output mixers (0x02 - 0x05)
13783 */
13784 /* set vol=0 to output mixers */
13785 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13786 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13787 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13788 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13789
13790 /* set up input amps for analog loopback */
13791 /* Amp Indices: DAC = 0, mixer = 1 */
13792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13800
13801 { }
13802};
13803
13804/*
13805 * 3-stack pin configuration:
13806 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13807 */
13808static struct hda_verb alc861vd_3stack_init_verbs[] = {
13809 /*
13810 * Set pin mode and muting
13811 */
13812 /* set front pin widgets 0x14 for output */
13813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13814 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13815 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13816
13817 /* Mic (rear) pin: input vref at 80% */
13818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13819 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13820 /* Front Mic pin: input vref at 80% */
13821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13823 /* Line In pin: input */
13824 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13825 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13826 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13829 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13830 /* CD pin widget for input */
13831 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13832
13833 { }
13834};
13835
13836/*
13837 * 6-stack pin configuration:
13838 */
13839static struct hda_verb alc861vd_6stack_init_verbs[] = {
13840 /*
13841 * Set pin mode and muting
13842 */
13843 /* set front pin widgets 0x14 for output */
13844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13846 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13847
13848 /* Rear Pin: output 1 (0x0d) */
13849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13852 /* CLFE Pin: output 2 (0x0e) */
13853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13855 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13856 /* Side Pin: output 3 (0x0f) */
13857 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13859 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13860
13861 /* Mic (rear) pin: input vref at 80% */
13862 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13864 /* Front Mic pin: input vref at 80% */
13865 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13866 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13867 /* Line In pin: input */
13868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13870 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13872 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13873 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13874 /* CD pin widget for input */
13875 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13876
13877 { }
13878};
13879
Kailang Yangbdd148a2007-05-08 15:19:08 +020013880static struct hda_verb alc861vd_eapd_verbs[] = {
13881 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13882 { }
13883};
13884
Kailang Yangf9423e72008-05-27 12:32:25 +020013885static struct hda_verb alc660vd_eapd_verbs[] = {
13886 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13887 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13888 { }
13889};
13890
Kailang Yangbdd148a2007-05-08 15:19:08 +020013891static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013897 {}
13898};
13899
13900/* toggle speaker-output according to the hp-jack state */
13901static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13902{
13903 unsigned int present;
13904 unsigned char bits;
13905
13906 present = snd_hda_codec_read(codec, 0x1b, 0,
13907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013908 bits = present ? HDA_AMP_MUTE : 0;
13909 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13910 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013911}
13912
13913static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13914{
13915 unsigned int present;
13916 unsigned char bits;
13917
13918 present = snd_hda_codec_read(codec, 0x18, 0,
13919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013920 bits = present ? HDA_AMP_MUTE : 0;
13921 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13922 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013923}
13924
13925static void alc861vd_lenovo_automute(struct hda_codec *codec)
13926{
13927 alc861vd_lenovo_hp_automute(codec);
13928 alc861vd_lenovo_mic_automute(codec);
13929}
13930
13931static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13932 unsigned int res)
13933{
13934 switch (res >> 26) {
13935 case ALC880_HP_EVENT:
13936 alc861vd_lenovo_hp_automute(codec);
13937 break;
13938 case ALC880_MIC_EVENT:
13939 alc861vd_lenovo_mic_automute(codec);
13940 break;
13941 }
13942}
13943
Kailang Yang272a5272007-05-14 11:00:38 +020013944static struct hda_verb alc861vd_dallas_verbs[] = {
13945 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13946 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13947 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13948 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13949
13950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13955 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13957 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013958
Kailang Yang272a5272007-05-14 11:00:38 +020013959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13963 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13965 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13966 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13967
13968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13975 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13976
13977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13981
13982 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013983 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13985
13986 { } /* end */
13987};
13988
13989/* toggle speaker-output according to the hp-jack state */
13990static void alc861vd_dallas_automute(struct hda_codec *codec)
13991{
13992 unsigned int present;
13993
13994 present = snd_hda_codec_read(codec, 0x15, 0,
13995 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013996 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13997 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013998}
13999
14000static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14001{
14002 if ((res >> 26) == ALC880_HP_EVENT)
14003 alc861vd_dallas_automute(codec);
14004}
14005
Takashi Iwaicb53c622007-08-10 17:21:45 +020014006#ifdef CONFIG_SND_HDA_POWER_SAVE
14007#define alc861vd_loopbacks alc880_loopbacks
14008#endif
14009
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014010/* pcm configuration: identiacal with ALC880 */
14011#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14012#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14013#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14014#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14015
14016/*
14017 * configuration and preset
14018 */
14019static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14020 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014021 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014022 [ALC861VD_3ST] = "3stack",
14023 [ALC861VD_3ST_DIG] = "3stack-digout",
14024 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014025 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014026 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014027 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014028 [ALC861VD_AUTO] = "auto",
14029};
14030
14031static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014032 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14033 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014034 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014035 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020014036 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020014037 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014038 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014039 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014040 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014041 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014042 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014043 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014044 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014045 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14046 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014047 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014048 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014049 {}
14050};
14051
14052static struct alc_config_preset alc861vd_presets[] = {
14053 [ALC660VD_3ST] = {
14054 .mixers = { alc861vd_3st_mixer },
14055 .init_verbs = { alc861vd_volume_init_verbs,
14056 alc861vd_3stack_init_verbs },
14057 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14058 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014059 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14060 .channel_mode = alc861vd_3stack_2ch_modes,
14061 .input_mux = &alc861vd_capture_source,
14062 },
Mike Crash6963f842007-06-25 12:12:51 +020014063 [ALC660VD_3ST_DIG] = {
14064 .mixers = { alc861vd_3st_mixer },
14065 .init_verbs = { alc861vd_volume_init_verbs,
14066 alc861vd_3stack_init_verbs },
14067 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14068 .dac_nids = alc660vd_dac_nids,
14069 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014070 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14071 .channel_mode = alc861vd_3stack_2ch_modes,
14072 .input_mux = &alc861vd_capture_source,
14073 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014074 [ALC861VD_3ST] = {
14075 .mixers = { alc861vd_3st_mixer },
14076 .init_verbs = { alc861vd_volume_init_verbs,
14077 alc861vd_3stack_init_verbs },
14078 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14079 .dac_nids = alc861vd_dac_nids,
14080 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14081 .channel_mode = alc861vd_3stack_2ch_modes,
14082 .input_mux = &alc861vd_capture_source,
14083 },
14084 [ALC861VD_3ST_DIG] = {
14085 .mixers = { alc861vd_3st_mixer },
14086 .init_verbs = { alc861vd_volume_init_verbs,
14087 alc861vd_3stack_init_verbs },
14088 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14089 .dac_nids = alc861vd_dac_nids,
14090 .dig_out_nid = ALC861VD_DIGOUT_NID,
14091 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14092 .channel_mode = alc861vd_3stack_2ch_modes,
14093 .input_mux = &alc861vd_capture_source,
14094 },
14095 [ALC861VD_6ST_DIG] = {
14096 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14097 .init_verbs = { alc861vd_volume_init_verbs,
14098 alc861vd_6stack_init_verbs },
14099 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14100 .dac_nids = alc861vd_dac_nids,
14101 .dig_out_nid = ALC861VD_DIGOUT_NID,
14102 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14103 .channel_mode = alc861vd_6stack_modes,
14104 .input_mux = &alc861vd_capture_source,
14105 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014106 [ALC861VD_LENOVO] = {
14107 .mixers = { alc861vd_lenovo_mixer },
14108 .init_verbs = { alc861vd_volume_init_verbs,
14109 alc861vd_3stack_init_verbs,
14110 alc861vd_eapd_verbs,
14111 alc861vd_lenovo_unsol_verbs },
14112 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14113 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014114 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14115 .channel_mode = alc861vd_3stack_2ch_modes,
14116 .input_mux = &alc861vd_capture_source,
14117 .unsol_event = alc861vd_lenovo_unsol_event,
14118 .init_hook = alc861vd_lenovo_automute,
14119 },
Kailang Yang272a5272007-05-14 11:00:38 +020014120 [ALC861VD_DALLAS] = {
14121 .mixers = { alc861vd_dallas_mixer },
14122 .init_verbs = { alc861vd_dallas_verbs },
14123 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14124 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014125 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14126 .channel_mode = alc861vd_3stack_2ch_modes,
14127 .input_mux = &alc861vd_dallas_capture_source,
14128 .unsol_event = alc861vd_dallas_unsol_event,
14129 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014130 },
14131 [ALC861VD_HP] = {
14132 .mixers = { alc861vd_hp_mixer },
14133 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14134 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14135 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014136 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014137 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14138 .channel_mode = alc861vd_3stack_2ch_modes,
14139 .input_mux = &alc861vd_hp_capture_source,
14140 .unsol_event = alc861vd_dallas_unsol_event,
14141 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014142 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014143};
14144
14145/*
14146 * BIOS auto configuration
14147 */
14148static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14149 hda_nid_t nid, int pin_type, int dac_idx)
14150{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014151 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014152}
14153
14154static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14155{
14156 struct alc_spec *spec = codec->spec;
14157 int i;
14158
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014159 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014160 for (i = 0; i <= HDA_SIDE; i++) {
14161 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014162 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014163 if (nid)
14164 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014165 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014166 }
14167}
14168
14169
14170static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14171{
14172 struct alc_spec *spec = codec->spec;
14173 hda_nid_t pin;
14174
14175 pin = spec->autocfg.hp_pins[0];
14176 if (pin) /* connect to front and use dac 0 */
14177 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014178 pin = spec->autocfg.speaker_pins[0];
14179 if (pin)
14180 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014181}
14182
14183#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14184#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14185
14186static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14187{
14188 struct alc_spec *spec = codec->spec;
14189 int i;
14190
14191 for (i = 0; i < AUTO_PIN_LAST; i++) {
14192 hda_nid_t nid = spec->autocfg.input_pins[i];
14193 if (alc861vd_is_input_pin(nid)) {
14194 snd_hda_codec_write(codec, nid, 0,
14195 AC_VERB_SET_PIN_WIDGET_CONTROL,
14196 i <= AUTO_PIN_FRONT_MIC ?
14197 PIN_VREF80 : PIN_IN);
14198 if (nid != ALC861VD_PIN_CD_NID)
14199 snd_hda_codec_write(codec, nid, 0,
14200 AC_VERB_SET_AMP_GAIN_MUTE,
14201 AMP_OUT_MUTE);
14202 }
14203 }
14204}
14205
Takashi Iwaif511b012008-08-15 16:46:42 +020014206#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14207
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014208#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14209#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14210
14211/* add playback controls from the parsed DAC table */
14212/* Based on ALC880 version. But ALC861VD has separate,
14213 * different NIDs for mute/unmute switch and volume control */
14214static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14215 const struct auto_pin_cfg *cfg)
14216{
14217 char name[32];
14218 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14219 hda_nid_t nid_v, nid_s;
14220 int i, err;
14221
14222 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014223 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014224 continue;
14225 nid_v = alc861vd_idx_to_mixer_vol(
14226 alc880_dac_to_idx(
14227 spec->multiout.dac_nids[i]));
14228 nid_s = alc861vd_idx_to_mixer_switch(
14229 alc880_dac_to_idx(
14230 spec->multiout.dac_nids[i]));
14231
14232 if (i == 2) {
14233 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014234 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14235 "Center Playback Volume",
14236 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14237 HDA_OUTPUT));
14238 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014239 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014240 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14241 "LFE Playback Volume",
14242 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14243 HDA_OUTPUT));
14244 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014245 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014246 err = add_control(spec, ALC_CTL_BIND_MUTE,
14247 "Center Playback Switch",
14248 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14249 HDA_INPUT));
14250 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014251 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014252 err = add_control(spec, ALC_CTL_BIND_MUTE,
14253 "LFE Playback Switch",
14254 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14255 HDA_INPUT));
14256 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014257 return err;
14258 } else {
14259 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014260 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14261 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14262 HDA_OUTPUT));
14263 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014264 return err;
14265 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014266 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014267 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 HDA_INPUT));
14269 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014270 return err;
14271 }
14272 }
14273 return 0;
14274}
14275
14276/* add playback controls for speaker and HP outputs */
14277/* Based on ALC880 version. But ALC861VD has separate,
14278 * different NIDs for mute/unmute switch and volume control */
14279static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14280 hda_nid_t pin, const char *pfx)
14281{
14282 hda_nid_t nid_v, nid_s;
14283 int err;
14284 char name[32];
14285
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014287 return 0;
14288
14289 if (alc880_is_fixed_pin(pin)) {
14290 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14291 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014292 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014293 spec->multiout.hp_nid = nid_v;
14294 else
14295 spec->multiout.extra_out_nid[0] = nid_v;
14296 /* control HP volume/switch on the output mixer amp */
14297 nid_v = alc861vd_idx_to_mixer_vol(
14298 alc880_fixed_pin_idx(pin));
14299 nid_s = alc861vd_idx_to_mixer_switch(
14300 alc880_fixed_pin_idx(pin));
14301
14302 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14304 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14305 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014306 return err;
14307 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014308 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14309 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14310 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014311 return err;
14312 } else if (alc880_is_multi_pin(pin)) {
14313 /* set manual connection */
14314 /* we have only a switch on HP-out PIN */
14315 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014316 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14317 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14318 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014319 return err;
14320 }
14321 return 0;
14322}
14323
14324/* parse the BIOS configuration and set up the alc_spec
14325 * return 1 if successful, 0 if the proper config is not found,
14326 * or a negative error code
14327 * Based on ALC880 version - had to change it to override
14328 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14329static int alc861vd_parse_auto_config(struct hda_codec *codec)
14330{
14331 struct alc_spec *spec = codec->spec;
14332 int err;
14333 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14334
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014335 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14336 alc861vd_ignore);
14337 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014338 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014339 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014340 return 0; /* can't find valid BIOS pin config */
14341
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014342 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14343 if (err < 0)
14344 return err;
14345 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14346 if (err < 0)
14347 return err;
14348 err = alc861vd_auto_create_extra_out(spec,
14349 spec->autocfg.speaker_pins[0],
14350 "Speaker");
14351 if (err < 0)
14352 return err;
14353 err = alc861vd_auto_create_extra_out(spec,
14354 spec->autocfg.hp_pins[0],
14355 "Headphone");
14356 if (err < 0)
14357 return err;
14358 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14359 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014360 return err;
14361
14362 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14363
14364 if (spec->autocfg.dig_out_pin)
14365 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14366
14367 if (spec->kctl_alloc)
14368 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14369
14370 spec->init_verbs[spec->num_init_verbs++]
14371 = alc861vd_volume_init_verbs;
14372
14373 spec->num_mux_defs = 1;
14374 spec->input_mux = &spec->private_imux;
14375
Takashi Iwai776e1842007-08-29 15:07:11 +020014376 err = alc_auto_add_mic_boost(codec);
14377 if (err < 0)
14378 return err;
14379
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014380 return 1;
14381}
14382
14383/* additional initialization for auto-configuration model */
14384static void alc861vd_auto_init(struct hda_codec *codec)
14385{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014386 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014387 alc861vd_auto_init_multi_out(codec);
14388 alc861vd_auto_init_hp_out(codec);
14389 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014390 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014391 if (spec->unsol_event)
14392 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014393}
14394
14395static int patch_alc861vd(struct hda_codec *codec)
14396{
14397 struct alc_spec *spec;
14398 int err, board_config;
14399
14400 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14401 if (spec == NULL)
14402 return -ENOMEM;
14403
14404 codec->spec = spec;
14405
14406 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14407 alc861vd_models,
14408 alc861vd_cfg_tbl);
14409
14410 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14411 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14412 "ALC861VD, trying auto-probe from BIOS...\n");
14413 board_config = ALC861VD_AUTO;
14414 }
14415
14416 if (board_config == ALC861VD_AUTO) {
14417 /* automatic parse from the BIOS config */
14418 err = alc861vd_parse_auto_config(codec);
14419 if (err < 0) {
14420 alc_free(codec);
14421 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014422 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014423 printk(KERN_INFO
14424 "hda_codec: Cannot set up configuration "
14425 "from BIOS. Using base mode...\n");
14426 board_config = ALC861VD_3ST;
14427 }
14428 }
14429
14430 if (board_config != ALC861VD_AUTO)
14431 setup_preset(spec, &alc861vd_presets[board_config]);
14432
Kailang Yang2f893282008-05-27 12:14:47 +020014433 if (codec->vendor_id == 0x10ec0660) {
14434 spec->stream_name_analog = "ALC660-VD Analog";
14435 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014436 /* always turn on EAPD */
14437 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020014438 } else {
14439 spec->stream_name_analog = "ALC861VD Analog";
14440 spec->stream_name_digital = "ALC861VD Digital";
14441 }
14442
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014443 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14444 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14445
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014446 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14447 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14448
14449 spec->adc_nids = alc861vd_adc_nids;
14450 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014451 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014452
14453 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
14454 spec->num_mixers++;
14455
Takashi Iwai2134ea42008-01-10 16:53:55 +010014456 spec->vmaster_nid = 0x02;
14457
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014458 codec->patch_ops = alc_patch_ops;
14459
14460 if (board_config == ALC861VD_AUTO)
14461 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014462#ifdef CONFIG_SND_HDA_POWER_SAVE
14463 if (!spec->loopback.amplist)
14464 spec->loopback.amplist = alc861vd_loopbacks;
14465#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014466
14467 return 0;
14468}
14469
14470/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014471 * ALC662 support
14472 *
14473 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14474 * configuration. Each pin widget can choose any input DACs and a mixer.
14475 * Each ADC is connected from a mixer of all inputs. This makes possible
14476 * 6-channel independent captures.
14477 *
14478 * In addition, an independent DAC for the multi-playback (not used in this
14479 * driver yet).
14480 */
14481#define ALC662_DIGOUT_NID 0x06
14482#define ALC662_DIGIN_NID 0x0a
14483
14484static hda_nid_t alc662_dac_nids[4] = {
14485 /* front, rear, clfe, rear_surr */
14486 0x02, 0x03, 0x04
14487};
14488
14489static hda_nid_t alc662_adc_nids[1] = {
14490 /* ADC1-2 */
14491 0x09,
14492};
Takashi Iwaie1406342008-02-11 18:32:32 +010014493
Kailang Yang77a261b2008-02-19 11:38:05 +010014494static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014495
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014496/* input MUX */
14497/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014498static struct hda_input_mux alc662_capture_source = {
14499 .num_items = 4,
14500 .items = {
14501 { "Mic", 0x0 },
14502 { "Front Mic", 0x1 },
14503 { "Line", 0x2 },
14504 { "CD", 0x4 },
14505 },
14506};
14507
14508static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14509 .num_items = 2,
14510 .items = {
14511 { "Mic", 0x1 },
14512 { "Line", 0x2 },
14513 },
14514};
Kailang Yang291702f2007-10-16 14:28:03 +020014515
14516static struct hda_input_mux alc662_eeepc_capture_source = {
14517 .num_items = 2,
14518 .items = {
14519 { "i-Mic", 0x1 },
14520 { "e-Mic", 0x0 },
14521 },
14522};
14523
Kailang Yang6dda9f42008-05-27 12:05:31 +020014524static struct hda_input_mux alc663_capture_source = {
14525 .num_items = 3,
14526 .items = {
14527 { "Mic", 0x0 },
14528 { "Front Mic", 0x1 },
14529 { "Line", 0x2 },
14530 },
14531};
14532
14533static struct hda_input_mux alc663_m51va_capture_source = {
14534 .num_items = 2,
14535 .items = {
14536 { "Ext-Mic", 0x0 },
14537 { "D-Mic", 0x9 },
14538 },
14539};
14540
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014541#define alc662_mux_enum_info alc_mux_enum_info
14542#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014543#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014544
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014545/*
14546 * 2ch mode
14547 */
14548static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14549 { 2, NULL }
14550};
14551
14552/*
14553 * 2ch mode
14554 */
14555static struct hda_verb alc662_3ST_ch2_init[] = {
14556 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14557 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14558 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14559 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14560 { } /* end */
14561};
14562
14563/*
14564 * 6ch mode
14565 */
14566static struct hda_verb alc662_3ST_ch6_init[] = {
14567 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14568 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14569 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14570 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14571 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14572 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14573 { } /* end */
14574};
14575
14576static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14577 { 2, alc662_3ST_ch2_init },
14578 { 6, alc662_3ST_ch6_init },
14579};
14580
14581/*
14582 * 2ch mode
14583 */
14584static struct hda_verb alc662_sixstack_ch6_init[] = {
14585 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14586 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14587 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14588 { } /* end */
14589};
14590
14591/*
14592 * 6ch mode
14593 */
14594static struct hda_verb alc662_sixstack_ch8_init[] = {
14595 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14596 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14598 { } /* end */
14599};
14600
14601static struct hda_channel_mode alc662_5stack_modes[2] = {
14602 { 2, alc662_sixstack_ch6_init },
14603 { 6, alc662_sixstack_ch8_init },
14604};
14605
14606/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14607 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14608 */
14609
14610static struct snd_kcontrol_new alc662_base_mixer[] = {
14611 /* output mixer control */
14612 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014613 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014614 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014615 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014616 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14617 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014618 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14619 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14621
14622 /*Input mixer control */
14623 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14624 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14625 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14626 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14627 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14628 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14629 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014631 { } /* end */
14632};
14633
14634static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14635 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014636 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14638 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14639 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14644 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14645 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14646 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14647 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014648 { } /* end */
14649};
14650
14651static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14652 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014653 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014654 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014655 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014656 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14657 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014658 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14659 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14661 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14662 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14668 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14669 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14670 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014671 { } /* end */
14672};
14673
14674static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14675 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14676 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014677 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14678 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14680 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14681 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014684 { } /* end */
14685};
14686
Kailang Yang291702f2007-10-16 14:28:03 +020014687static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014688 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014689
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014690 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14691 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014692
14693 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14694 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14695 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14696
14697 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14698 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14699 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14700 { } /* end */
14701};
14702
Kailang Yang8c427222008-01-10 13:03:59 +010014703static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014704 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14705 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014706 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14707 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14709 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14710 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14711 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014712 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014713 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14718 { } /* end */
14719};
14720
Kailang Yangf1d4e282008-08-26 14:03:29 +020014721static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14722 .ops = &snd_hda_bind_vol,
14723 .values = {
14724 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14725 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14726 0
14727 },
14728};
14729
14730static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14731 .ops = &snd_hda_bind_sw,
14732 .values = {
14733 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14734 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14735 0
14736 },
14737};
14738
Kailang Yang6dda9f42008-05-27 12:05:31 +020014739static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014740 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14741 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14744 { } /* end */
14745};
14746
14747static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14748 .ops = &snd_hda_bind_sw,
14749 .values = {
14750 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14751 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14752 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14753 0
14754 },
14755};
14756
14757static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14758 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14759 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14762 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14763 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14764
14765 { } /* end */
14766};
14767
14768static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14769 .ops = &snd_hda_bind_sw,
14770 .values = {
14771 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14772 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14773 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14774 0
14775 },
14776};
14777
14778static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14779 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14780 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14783 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14784 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14785 { } /* end */
14786};
14787
14788static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014789 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14790 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14794 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14795 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14796 { } /* end */
14797};
14798
14799static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14800 .ops = &snd_hda_bind_vol,
14801 .values = {
14802 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14803 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14804 0
14805 },
14806};
14807
14808static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14809 .ops = &snd_hda_bind_sw,
14810 .values = {
14811 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14812 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14813 0
14814 },
14815};
14816
14817static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14818 HDA_BIND_VOL("Master Playback Volume",
14819 &alc663_asus_two_bind_master_vol),
14820 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14821 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014822 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014825 { } /* end */
14826};
14827
14828static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14829 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14830 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14831 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014835 { } /* end */
14836};
14837
14838static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14840 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14841 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14842 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14844
14845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14847 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14848 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14849 { } /* end */
14850};
14851
14852static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14853 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14854 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14856
14857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14859 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14860 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14863 { } /* end */
14864};
14865
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014866static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14867 {
14868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14869 .name = "Channel Mode",
14870 .info = alc_ch_mode_info,
14871 .get = alc_ch_mode_get,
14872 .put = alc_ch_mode_put,
14873 },
14874 { } /* end */
14875};
14876
14877static struct hda_verb alc662_init_verbs[] = {
14878 /* ADC: mute amp left and right */
14879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14880 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14881 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14882
Takashi Iwaicb53c622007-08-10 17:21:45 +020014883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014888
Kailang Yangb60dd392007-09-20 12:50:29 +020014889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014895
14896 /* Front Pin: output 0 (0x0c) */
14897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14899
14900 /* Rear Pin: output 1 (0x0d) */
14901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14903
14904 /* CLFE Pin: output 2 (0x0e) */
14905 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14906 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14907
14908 /* Mic (rear) pin: input vref at 80% */
14909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14911 /* Front Mic pin: input vref at 80% */
14912 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14914 /* Line In pin: input */
14915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14917 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14920 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14921 /* CD pin widget for input */
14922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14923
14924 /* FIXME: use matrix-type input source selection */
14925 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14926 /* Input mixer */
14927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014931
14932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014936
14937 /* always trun on EAPD */
14938 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14939 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14940
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014941 { }
14942};
14943
14944static struct hda_verb alc662_sue_init_verbs[] = {
14945 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14946 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014947 {}
14948};
14949
14950static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14952 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14953 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014954};
14955
Kailang Yang8c427222008-01-10 13:03:59 +010014956/* Set Unsolicited Event*/
14957static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14959 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14960 {}
14961};
14962
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014963/*
14964 * generic initialization of ADC, input mixers and output mixers
14965 */
14966static struct hda_verb alc662_auto_init_verbs[] = {
14967 /*
14968 * Unmute ADC and set the default input to mic-in
14969 */
14970 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14972
14973 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14974 * mixer widget
14975 * Note: PASD motherboards uses the Line In 2 as the input for front
14976 * panel mic (mic 2)
14977 */
14978 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014984
14985 /*
14986 * Set up output mixers (0x0c - 0x0f)
14987 */
14988 /* set vol=0 to output mixers */
14989 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14990 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14991 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14992
14993 /* set up input amps for analog loopback */
14994 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015001
15002
15003 /* FIXME: use matrix-type input source selection */
15004 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15005 /* Input mixer */
15006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015008 { }
15009};
15010
Takashi Iwai24fb9172008-09-02 14:48:20 +020015011/* additional verbs for ALC663 */
15012static struct hda_verb alc663_auto_init_verbs[] = {
15013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15014 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15015 { }
15016};
15017
Kailang Yang6dda9f42008-05-27 12:05:31 +020015018static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15020 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015021 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15022 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015023 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015026 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15027 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15028 {}
15029};
15030
Kailang Yangf1d4e282008-08-26 14:03:29 +020015031static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15032 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15033 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15034 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15037 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15038 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15039 {}
15040};
15041
15042static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15043 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15046 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15049 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15050 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15051 {}
15052};
15053
15054static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15060 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15061 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15062 {}
15063};
15064
15065static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15067 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15068 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15069 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15075 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15076 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15078 {}
15079};
15080
15081static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15082 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15088 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15091 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15092 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15094 {}
15095};
15096
Kailang Yang6dda9f42008-05-27 12:05:31 +020015097static struct hda_verb alc663_g71v_init_verbs[] = {
15098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15099 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15100 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15101
15102 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15103 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15104 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15105
15106 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15107 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15108 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15109 {}
15110};
15111
15112static struct hda_verb alc663_g50v_init_verbs[] = {
15113 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15114 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15115 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15116
15117 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15118 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15119 {}
15120};
15121
Kailang Yangf1d4e282008-08-26 14:03:29 +020015122static struct hda_verb alc662_ecs_init_verbs[] = {
15123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15125 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15126 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15127 {}
15128};
15129
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015130/* capture mixer elements */
15131static struct snd_kcontrol_new alc662_capture_mixer[] = {
15132 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15133 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15134 {
15135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15136 /* The multiple "Capture Source" controls confuse alsamixer
15137 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015138 */
15139 /* .name = "Capture Source", */
15140 .name = "Input Source",
15141 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010015142 .info = alc662_mux_enum_info,
15143 .get = alc662_mux_enum_get,
15144 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015145 },
15146 { } /* end */
15147};
15148
Kailang Yangf1d4e282008-08-26 14:03:29 +020015149static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15150 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15151 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15152 { } /* end */
15153};
15154
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015155static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15156{
15157 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015158 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015159
15160 present = snd_hda_codec_read(codec, 0x14, 0,
15161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015162 bits = present ? HDA_AMP_MUTE : 0;
15163 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15164 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015165}
15166
15167static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15168{
15169 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015170 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015171
15172 present = snd_hda_codec_read(codec, 0x1b, 0,
15173 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015174 bits = present ? HDA_AMP_MUTE : 0;
15175 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15176 HDA_AMP_MUTE, bits);
15177 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15178 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015179}
15180
15181static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15182 unsigned int res)
15183{
15184 if ((res >> 26) == ALC880_HP_EVENT)
15185 alc662_lenovo_101e_all_automute(codec);
15186 if ((res >> 26) == ALC880_FRONT_EVENT)
15187 alc662_lenovo_101e_ispeaker_automute(codec);
15188}
15189
Kailang Yang291702f2007-10-16 14:28:03 +020015190static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15191{
15192 unsigned int present;
15193
15194 present = snd_hda_codec_read(codec, 0x18, 0,
15195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15196 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15197 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15198 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15199 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15200 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15201 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15202 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15203 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15204}
15205
15206/* unsolicited event for HP jack sensing */
15207static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15208 unsigned int res)
15209{
15210 if ((res >> 26) == ALC880_HP_EVENT)
15211 alc262_hippo1_automute( codec );
15212
15213 if ((res >> 26) == ALC880_MIC_EVENT)
15214 alc662_eeepc_mic_automute(codec);
15215}
15216
15217static void alc662_eeepc_inithook(struct hda_codec *codec)
15218{
15219 alc262_hippo1_automute( codec );
15220 alc662_eeepc_mic_automute(codec);
15221}
15222
Kailang Yang8c427222008-01-10 13:03:59 +010015223static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15224{
15225 unsigned int mute;
15226 unsigned int present;
15227
15228 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15229 present = snd_hda_codec_read(codec, 0x14, 0,
15230 AC_VERB_GET_PIN_SENSE, 0);
15231 present = (present & 0x80000000) != 0;
15232 if (present) {
15233 /* mute internal speaker */
15234 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015235 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015236 } else {
15237 /* unmute internal speaker if necessary */
15238 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15239 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015240 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015241 }
15242}
15243
15244/* unsolicited event for HP jack sensing */
15245static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15246 unsigned int res)
15247{
15248 if ((res >> 26) == ALC880_HP_EVENT)
15249 alc662_eeepc_ep20_automute(codec);
15250}
15251
15252static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15253{
15254 alc662_eeepc_ep20_automute(codec);
15255}
15256
Kailang Yang6dda9f42008-05-27 12:05:31 +020015257static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15258{
15259 unsigned int present;
15260 unsigned char bits;
15261
15262 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015263 AC_VERB_GET_PIN_SENSE, 0)
15264 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015265 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015266 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15267 AMP_IN_MUTE(0), bits);
15268 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15269 AMP_IN_MUTE(0), bits);
15270}
15271
15272static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15273{
15274 unsigned int present;
15275 unsigned char bits;
15276
15277 present = snd_hda_codec_read(codec, 0x21, 0,
15278 AC_VERB_GET_PIN_SENSE, 0)
15279 & AC_PINSENSE_PRESENCE;
15280 bits = present ? HDA_AMP_MUTE : 0;
15281 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15282 AMP_IN_MUTE(0), bits);
15283 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15284 AMP_IN_MUTE(0), bits);
15285 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15286 AMP_IN_MUTE(0), bits);
15287 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15288 AMP_IN_MUTE(0), bits);
15289}
15290
15291static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15292{
15293 unsigned int present;
15294 unsigned char bits;
15295
15296 present = snd_hda_codec_read(codec, 0x15, 0,
15297 AC_VERB_GET_PIN_SENSE, 0)
15298 & AC_PINSENSE_PRESENCE;
15299 bits = present ? HDA_AMP_MUTE : 0;
15300 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15301 AMP_IN_MUTE(0), bits);
15302 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15303 AMP_IN_MUTE(0), bits);
15304 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15305 AMP_IN_MUTE(0), bits);
15306 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15307 AMP_IN_MUTE(0), bits);
15308}
15309
15310static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15311{
15312 unsigned int present;
15313 unsigned char bits;
15314
15315 present = snd_hda_codec_read(codec, 0x1b, 0,
15316 AC_VERB_GET_PIN_SENSE, 0)
15317 & AC_PINSENSE_PRESENCE;
15318 bits = present ? 0 : PIN_OUT;
15319 snd_hda_codec_write(codec, 0x14, 0,
15320 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15321}
15322
15323static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15324{
15325 unsigned int present1, present2;
15326
15327 present1 = snd_hda_codec_read(codec, 0x21, 0,
15328 AC_VERB_GET_PIN_SENSE, 0)
15329 & AC_PINSENSE_PRESENCE;
15330 present2 = snd_hda_codec_read(codec, 0x15, 0,
15331 AC_VERB_GET_PIN_SENSE, 0)
15332 & AC_PINSENSE_PRESENCE;
15333
15334 if (present1 || present2) {
15335 snd_hda_codec_write_cache(codec, 0x14, 0,
15336 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15337 } else {
15338 snd_hda_codec_write_cache(codec, 0x14, 0,
15339 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15340 }
15341}
15342
15343static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15344{
15345 unsigned int present1, present2;
15346
15347 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15348 AC_VERB_GET_PIN_SENSE, 0)
15349 & AC_PINSENSE_PRESENCE;
15350 present2 = snd_hda_codec_read(codec, 0x15, 0,
15351 AC_VERB_GET_PIN_SENSE, 0)
15352 & AC_PINSENSE_PRESENCE;
15353
15354 if (present1 || present2) {
15355 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15356 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15357 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15358 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15359 } else {
15360 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15361 AMP_IN_MUTE(0), 0);
15362 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15363 AMP_IN_MUTE(0), 0);
15364 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015365}
15366
15367static void alc663_m51va_mic_automute(struct hda_codec *codec)
15368{
15369 unsigned int present;
15370
15371 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015372 AC_VERB_GET_PIN_SENSE, 0)
15373 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015374 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015375 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015376 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015377 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015378 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015379 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015380 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015381 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015382}
15383
15384static void alc663_m51va_unsol_event(struct hda_codec *codec,
15385 unsigned int res)
15386{
15387 switch (res >> 26) {
15388 case ALC880_HP_EVENT:
15389 alc663_m51va_speaker_automute(codec);
15390 break;
15391 case ALC880_MIC_EVENT:
15392 alc663_m51va_mic_automute(codec);
15393 break;
15394 }
15395}
15396
15397static void alc663_m51va_inithook(struct hda_codec *codec)
15398{
15399 alc663_m51va_speaker_automute(codec);
15400 alc663_m51va_mic_automute(codec);
15401}
15402
Kailang Yangf1d4e282008-08-26 14:03:29 +020015403/* ***************** Mode1 ******************************/
15404static void alc663_mode1_unsol_event(struct hda_codec *codec,
15405 unsigned int res)
15406{
15407 switch (res >> 26) {
15408 case ALC880_HP_EVENT:
15409 alc663_m51va_speaker_automute(codec);
15410 break;
15411 case ALC880_MIC_EVENT:
15412 alc662_eeepc_mic_automute(codec);
15413 break;
15414 }
15415}
15416
15417static void alc663_mode1_inithook(struct hda_codec *codec)
15418{
15419 alc663_m51va_speaker_automute(codec);
15420 alc662_eeepc_mic_automute(codec);
15421}
15422/* ***************** Mode2 ******************************/
15423static void alc662_mode2_unsol_event(struct hda_codec *codec,
15424 unsigned int res)
15425{
15426 switch (res >> 26) {
15427 case ALC880_HP_EVENT:
15428 alc662_f5z_speaker_automute(codec);
15429 break;
15430 case ALC880_MIC_EVENT:
15431 alc662_eeepc_mic_automute(codec);
15432 break;
15433 }
15434}
15435
15436static void alc662_mode2_inithook(struct hda_codec *codec)
15437{
15438 alc662_f5z_speaker_automute(codec);
15439 alc662_eeepc_mic_automute(codec);
15440}
15441/* ***************** Mode3 ******************************/
15442static void alc663_mode3_unsol_event(struct hda_codec *codec,
15443 unsigned int res)
15444{
15445 switch (res >> 26) {
15446 case ALC880_HP_EVENT:
15447 alc663_two_hp_m1_speaker_automute(codec);
15448 break;
15449 case ALC880_MIC_EVENT:
15450 alc662_eeepc_mic_automute(codec);
15451 break;
15452 }
15453}
15454
15455static void alc663_mode3_inithook(struct hda_codec *codec)
15456{
15457 alc663_two_hp_m1_speaker_automute(codec);
15458 alc662_eeepc_mic_automute(codec);
15459}
15460/* ***************** Mode4 ******************************/
15461static void alc663_mode4_unsol_event(struct hda_codec *codec,
15462 unsigned int res)
15463{
15464 switch (res >> 26) {
15465 case ALC880_HP_EVENT:
15466 alc663_21jd_two_speaker_automute(codec);
15467 break;
15468 case ALC880_MIC_EVENT:
15469 alc662_eeepc_mic_automute(codec);
15470 break;
15471 }
15472}
15473
15474static void alc663_mode4_inithook(struct hda_codec *codec)
15475{
15476 alc663_21jd_two_speaker_automute(codec);
15477 alc662_eeepc_mic_automute(codec);
15478}
15479/* ***************** Mode5 ******************************/
15480static void alc663_mode5_unsol_event(struct hda_codec *codec,
15481 unsigned int res)
15482{
15483 switch (res >> 26) {
15484 case ALC880_HP_EVENT:
15485 alc663_15jd_two_speaker_automute(codec);
15486 break;
15487 case ALC880_MIC_EVENT:
15488 alc662_eeepc_mic_automute(codec);
15489 break;
15490 }
15491}
15492
15493static void alc663_mode5_inithook(struct hda_codec *codec)
15494{
15495 alc663_15jd_two_speaker_automute(codec);
15496 alc662_eeepc_mic_automute(codec);
15497}
15498/* ***************** Mode6 ******************************/
15499static void alc663_mode6_unsol_event(struct hda_codec *codec,
15500 unsigned int res)
15501{
15502 switch (res >> 26) {
15503 case ALC880_HP_EVENT:
15504 alc663_two_hp_m2_speaker_automute(codec);
15505 break;
15506 case ALC880_MIC_EVENT:
15507 alc662_eeepc_mic_automute(codec);
15508 break;
15509 }
15510}
15511
15512static void alc663_mode6_inithook(struct hda_codec *codec)
15513{
15514 alc663_two_hp_m2_speaker_automute(codec);
15515 alc662_eeepc_mic_automute(codec);
15516}
15517
Kailang Yang6dda9f42008-05-27 12:05:31 +020015518static void alc663_g71v_hp_automute(struct hda_codec *codec)
15519{
15520 unsigned int present;
15521 unsigned char bits;
15522
15523 present = snd_hda_codec_read(codec, 0x21, 0,
15524 AC_VERB_GET_PIN_SENSE, 0)
15525 & AC_PINSENSE_PRESENCE;
15526 bits = present ? HDA_AMP_MUTE : 0;
15527 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15528 HDA_AMP_MUTE, bits);
15529 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15530 HDA_AMP_MUTE, bits);
15531}
15532
15533static void alc663_g71v_front_automute(struct hda_codec *codec)
15534{
15535 unsigned int present;
15536 unsigned char bits;
15537
15538 present = snd_hda_codec_read(codec, 0x15, 0,
15539 AC_VERB_GET_PIN_SENSE, 0)
15540 & AC_PINSENSE_PRESENCE;
15541 bits = present ? HDA_AMP_MUTE : 0;
15542 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15543 HDA_AMP_MUTE, bits);
15544}
15545
15546static void alc663_g71v_unsol_event(struct hda_codec *codec,
15547 unsigned int res)
15548{
15549 switch (res >> 26) {
15550 case ALC880_HP_EVENT:
15551 alc663_g71v_hp_automute(codec);
15552 break;
15553 case ALC880_FRONT_EVENT:
15554 alc663_g71v_front_automute(codec);
15555 break;
15556 case ALC880_MIC_EVENT:
15557 alc662_eeepc_mic_automute(codec);
15558 break;
15559 }
15560}
15561
15562static void alc663_g71v_inithook(struct hda_codec *codec)
15563{
15564 alc663_g71v_front_automute(codec);
15565 alc663_g71v_hp_automute(codec);
15566 alc662_eeepc_mic_automute(codec);
15567}
15568
15569static void alc663_g50v_unsol_event(struct hda_codec *codec,
15570 unsigned int res)
15571{
15572 switch (res >> 26) {
15573 case ALC880_HP_EVENT:
15574 alc663_m51va_speaker_automute(codec);
15575 break;
15576 case ALC880_MIC_EVENT:
15577 alc662_eeepc_mic_automute(codec);
15578 break;
15579 }
15580}
15581
15582static void alc663_g50v_inithook(struct hda_codec *codec)
15583{
15584 alc663_m51va_speaker_automute(codec);
15585 alc662_eeepc_mic_automute(codec);
15586}
15587
Kailang Yangf1d4e282008-08-26 14:03:29 +020015588/* bind hp and internal speaker mute (with plug check) */
15589static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15590 struct snd_ctl_elem_value *ucontrol)
15591{
15592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15593 long *valp = ucontrol->value.integer.value;
15594 int change;
15595
15596 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15597 HDA_AMP_MUTE,
15598 valp[0] ? 0 : HDA_AMP_MUTE);
15599 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15600 HDA_AMP_MUTE,
15601 valp[1] ? 0 : HDA_AMP_MUTE);
15602 if (change)
15603 alc262_hippo1_automute(codec);
15604 return change;
15605}
15606
15607static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15608 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15609 {
15610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15611 .name = "Master Playback Switch",
15612 .info = snd_hda_mixer_amp_switch_info,
15613 .get = snd_hda_mixer_amp_switch_get,
15614 .put = alc662_ecs_master_sw_put,
15615 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15616 },
15617
15618 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15619 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15620 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15621
15622 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15623 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15624 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15625 { } /* end */
15626};
15627
Takashi Iwaicb53c622007-08-10 17:21:45 +020015628#ifdef CONFIG_SND_HDA_POWER_SAVE
15629#define alc662_loopbacks alc880_loopbacks
15630#endif
15631
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015632
15633/* pcm configuration: identiacal with ALC880 */
15634#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15635#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15636#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15637#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15638
15639/*
15640 * configuration and preset
15641 */
15642static const char *alc662_models[ALC662_MODEL_LAST] = {
15643 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15644 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15645 [ALC662_3ST_6ch] = "3stack-6ch",
15646 [ALC662_5ST_DIG] = "6stack-dig",
15647 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015648 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015649 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015650 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015651 [ALC663_ASUS_M51VA] = "m51va",
15652 [ALC663_ASUS_G71V] = "g71v",
15653 [ALC663_ASUS_H13] = "h13",
15654 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015655 [ALC663_ASUS_MODE1] = "asus-mode1",
15656 [ALC662_ASUS_MODE2] = "asus-mode2",
15657 [ALC663_ASUS_MODE3] = "asus-mode3",
15658 [ALC663_ASUS_MODE4] = "asus-mode4",
15659 [ALC663_ASUS_MODE5] = "asus-mode5",
15660 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661 [ALC662_AUTO] = "auto",
15662};
15663
15664static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015665 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
15666 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015667 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015668 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015669 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015670 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15671 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15672 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15673 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15674 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15675 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15676 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15677 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15678 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15679 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15680 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15681 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15682 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15683 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15684 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15685 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15686 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15687 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15688 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15689 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15690 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15691 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15692 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15693 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15694 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15695 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15696 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15697 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15698 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15699 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15700 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015701 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015702 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15703 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015704 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15705 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15706 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015707 {}
15708};
15709
15710static struct alc_config_preset alc662_presets[] = {
15711 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015712 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015713 .init_verbs = { alc662_init_verbs },
15714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15715 .dac_nids = alc662_dac_nids,
15716 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015717 .dig_in_nid = ALC662_DIGIN_NID,
15718 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15719 .channel_mode = alc662_3ST_2ch_modes,
15720 .input_mux = &alc662_capture_source,
15721 },
15722 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015723 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15724 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015725 .init_verbs = { alc662_init_verbs },
15726 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15727 .dac_nids = alc662_dac_nids,
15728 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015729 .dig_in_nid = ALC662_DIGIN_NID,
15730 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15731 .channel_mode = alc662_3ST_6ch_modes,
15732 .need_dac_fix = 1,
15733 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015734 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015735 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015736 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15737 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738 .init_verbs = { alc662_init_verbs },
15739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15740 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015741 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15742 .channel_mode = alc662_3ST_6ch_modes,
15743 .need_dac_fix = 1,
15744 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015745 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015746 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015747 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
15748 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015749 .init_verbs = { alc662_init_verbs },
15750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15751 .dac_nids = alc662_dac_nids,
15752 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015753 .dig_in_nid = ALC662_DIGIN_NID,
15754 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15755 .channel_mode = alc662_5stack_modes,
15756 .input_mux = &alc662_capture_source,
15757 },
15758 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015759 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015760 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15761 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15762 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015763 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15764 .channel_mode = alc662_3ST_2ch_modes,
15765 .input_mux = &alc662_lenovo_101e_capture_source,
15766 .unsol_event = alc662_lenovo_101e_unsol_event,
15767 .init_hook = alc662_lenovo_101e_all_automute,
15768 },
Kailang Yang291702f2007-10-16 14:28:03 +020015769 [ALC662_ASUS_EEEPC_P701] = {
15770 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
15771 .init_verbs = { alc662_init_verbs,
15772 alc662_eeepc_sue_init_verbs },
15773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15774 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15776 .channel_mode = alc662_3ST_2ch_modes,
15777 .input_mux = &alc662_eeepc_capture_source,
15778 .unsol_event = alc662_eeepc_unsol_event,
15779 .init_hook = alc662_eeepc_inithook,
15780 },
Kailang Yang8c427222008-01-10 13:03:59 +010015781 [ALC662_ASUS_EEEPC_EP20] = {
15782 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
15783 alc662_chmode_mixer },
15784 .init_verbs = { alc662_init_verbs,
15785 alc662_eeepc_ep20_sue_init_verbs },
15786 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15787 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015788 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15789 .channel_mode = alc662_3ST_6ch_modes,
15790 .input_mux = &alc662_lenovo_101e_capture_source,
15791 .unsol_event = alc662_eeepc_ep20_unsol_event,
15792 .init_hook = alc662_eeepc_ep20_inithook,
15793 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015794 [ALC662_ECS] = {
15795 .mixers = { alc662_ecs_mixer, alc662_capture_mixer },
15796 .init_verbs = { alc662_init_verbs,
15797 alc662_ecs_init_verbs },
15798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15799 .dac_nids = alc662_dac_nids,
15800 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15801 .channel_mode = alc662_3ST_2ch_modes,
15802 .input_mux = &alc662_eeepc_capture_source,
15803 .unsol_event = alc662_eeepc_unsol_event,
15804 .init_hook = alc662_eeepc_inithook,
15805 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015806 [ALC663_ASUS_M51VA] = {
15807 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15808 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15809 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15810 .dac_nids = alc662_dac_nids,
15811 .dig_out_nid = ALC662_DIGOUT_NID,
15812 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15813 .channel_mode = alc662_3ST_2ch_modes,
15814 .input_mux = &alc663_m51va_capture_source,
15815 .unsol_event = alc663_m51va_unsol_event,
15816 .init_hook = alc663_m51va_inithook,
15817 },
15818 [ALC663_ASUS_G71V] = {
15819 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
15820 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15822 .dac_nids = alc662_dac_nids,
15823 .dig_out_nid = ALC662_DIGOUT_NID,
15824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15825 .channel_mode = alc662_3ST_2ch_modes,
15826 .input_mux = &alc662_eeepc_capture_source,
15827 .unsol_event = alc663_g71v_unsol_event,
15828 .init_hook = alc663_g71v_inithook,
15829 },
15830 [ALC663_ASUS_H13] = {
15831 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15832 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15834 .dac_nids = alc662_dac_nids,
15835 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15836 .channel_mode = alc662_3ST_2ch_modes,
15837 .input_mux = &alc663_m51va_capture_source,
15838 .unsol_event = alc663_m51va_unsol_event,
15839 .init_hook = alc663_m51va_inithook,
15840 },
15841 [ALC663_ASUS_G50V] = {
15842 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
15843 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15845 .dac_nids = alc662_dac_nids,
15846 .dig_out_nid = ALC662_DIGOUT_NID,
15847 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15848 .channel_mode = alc662_3ST_6ch_modes,
15849 .input_mux = &alc663_capture_source,
15850 .unsol_event = alc663_g50v_unsol_event,
15851 .init_hook = alc663_g50v_inithook,
15852 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015853 [ALC663_ASUS_MODE1] = {
15854 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer },
15855 .init_verbs = { alc662_init_verbs,
15856 alc663_21jd_amic_init_verbs },
15857 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15858 .hp_nid = 0x03,
15859 .dac_nids = alc662_dac_nids,
15860 .dig_out_nid = ALC662_DIGOUT_NID,
15861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15862 .channel_mode = alc662_3ST_2ch_modes,
15863 .input_mux = &alc662_eeepc_capture_source,
15864 .unsol_event = alc663_mode1_unsol_event,
15865 .init_hook = alc663_mode1_inithook,
15866 },
15867 [ALC662_ASUS_MODE2] = {
15868 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer },
15869 .init_verbs = { alc662_init_verbs,
15870 alc662_1bjd_amic_init_verbs },
15871 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15872 .dac_nids = alc662_dac_nids,
15873 .dig_out_nid = ALC662_DIGOUT_NID,
15874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15875 .channel_mode = alc662_3ST_2ch_modes,
15876 .input_mux = &alc662_eeepc_capture_source,
15877 .unsol_event = alc662_mode2_unsol_event,
15878 .init_hook = alc662_mode2_inithook,
15879 },
15880 [ALC663_ASUS_MODE3] = {
15881 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer },
15882 .init_verbs = { alc662_init_verbs,
15883 alc663_two_hp_amic_m1_init_verbs },
15884 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15885 .hp_nid = 0x03,
15886 .dac_nids = alc662_dac_nids,
15887 .dig_out_nid = ALC662_DIGOUT_NID,
15888 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15889 .channel_mode = alc662_3ST_2ch_modes,
15890 .input_mux = &alc662_eeepc_capture_source,
15891 .unsol_event = alc663_mode3_unsol_event,
15892 .init_hook = alc663_mode3_inithook,
15893 },
15894 [ALC663_ASUS_MODE4] = {
15895 .mixers = { alc663_asus_21jd_clfe_mixer,
15896 alc662_auto_capture_mixer},
15897 .init_verbs = { alc662_init_verbs,
15898 alc663_21jd_amic_init_verbs},
15899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15900 .hp_nid = 0x03,
15901 .dac_nids = alc662_dac_nids,
15902 .dig_out_nid = ALC662_DIGOUT_NID,
15903 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15904 .channel_mode = alc662_3ST_2ch_modes,
15905 .input_mux = &alc662_eeepc_capture_source,
15906 .unsol_event = alc663_mode4_unsol_event,
15907 .init_hook = alc663_mode4_inithook,
15908 },
15909 [ALC663_ASUS_MODE5] = {
15910 .mixers = { alc663_asus_15jd_clfe_mixer,
15911 alc662_auto_capture_mixer },
15912 .init_verbs = { alc662_init_verbs,
15913 alc663_15jd_amic_init_verbs },
15914 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15915 .hp_nid = 0x03,
15916 .dac_nids = alc662_dac_nids,
15917 .dig_out_nid = ALC662_DIGOUT_NID,
15918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15919 .channel_mode = alc662_3ST_2ch_modes,
15920 .input_mux = &alc662_eeepc_capture_source,
15921 .unsol_event = alc663_mode5_unsol_event,
15922 .init_hook = alc663_mode5_inithook,
15923 },
15924 [ALC663_ASUS_MODE6] = {
15925 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer },
15926 .init_verbs = { alc662_init_verbs,
15927 alc663_two_hp_amic_m2_init_verbs },
15928 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15929 .hp_nid = 0x03,
15930 .dac_nids = alc662_dac_nids,
15931 .dig_out_nid = ALC662_DIGOUT_NID,
15932 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15933 .channel_mode = alc662_3ST_2ch_modes,
15934 .input_mux = &alc662_eeepc_capture_source,
15935 .unsol_event = alc663_mode6_unsol_event,
15936 .init_hook = alc663_mode6_inithook,
15937 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015938};
15939
15940
15941/*
15942 * BIOS auto configuration
15943 */
15944
15945/* add playback controls from the parsed DAC table */
15946static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15947 const struct auto_pin_cfg *cfg)
15948{
15949 char name[32];
15950 static const char *chname[4] = {
15951 "Front", "Surround", NULL /*CLFE*/, "Side"
15952 };
15953 hda_nid_t nid;
15954 int i, err;
15955
15956 for (i = 0; i < cfg->line_outs; i++) {
15957 if (!spec->multiout.dac_nids[i])
15958 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015959 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015960 if (i == 2) {
15961 /* Center/LFE */
15962 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15963 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015964 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15965 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015966 if (err < 0)
15967 return err;
15968 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15969 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015970 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15971 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015972 if (err < 0)
15973 return err;
15974 err = add_control(spec, ALC_CTL_BIND_MUTE,
15975 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015976 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
15977 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015978 if (err < 0)
15979 return err;
15980 err = add_control(spec, ALC_CTL_BIND_MUTE,
15981 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
15983 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015984 if (err < 0)
15985 return err;
15986 } else {
15987 sprintf(name, "%s Playback Volume", chname[i]);
15988 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015989 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15990 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015991 if (err < 0)
15992 return err;
15993 sprintf(name, "%s Playback Switch", chname[i]);
15994 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015995 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
15996 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015997 if (err < 0)
15998 return err;
15999 }
16000 }
16001 return 0;
16002}
16003
16004/* add playback controls for speaker and HP outputs */
16005static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16006 const char *pfx)
16007{
16008 hda_nid_t nid;
16009 int err;
16010 char name[32];
16011
16012 if (!pin)
16013 return 0;
16014
Takashi Iwai24fb9172008-09-02 14:48:20 +020016015 if (pin == 0x17) {
16016 /* ALC663 has a mono output pin on 0x17 */
16017 sprintf(name, "%s Playback Switch", pfx);
16018 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16019 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16020 return err;
16021 }
16022
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016023 if (alc880_is_fixed_pin(pin)) {
16024 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16025 /* printk("DAC nid=%x\n",nid); */
16026 /* specify the DAC as the extra output */
16027 if (!spec->multiout.hp_nid)
16028 spec->multiout.hp_nid = nid;
16029 else
16030 spec->multiout.extra_out_nid[0] = nid;
16031 /* control HP volume/switch on the output mixer amp */
16032 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16033 sprintf(name, "%s Playback Volume", pfx);
16034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16035 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16036 if (err < 0)
16037 return err;
16038 sprintf(name, "%s Playback Switch", pfx);
16039 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16040 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16041 if (err < 0)
16042 return err;
16043 } else if (alc880_is_multi_pin(pin)) {
16044 /* set manual connection */
16045 /* we have only a switch on HP-out PIN */
16046 sprintf(name, "%s Playback Switch", pfx);
16047 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16048 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16049 if (err < 0)
16050 return err;
16051 }
16052 return 0;
16053}
16054
16055/* create playback/capture controls for input pins */
16056static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16057 const struct auto_pin_cfg *cfg)
16058{
16059 struct hda_input_mux *imux = &spec->private_imux;
16060 int i, err, idx;
16061
16062 for (i = 0; i < AUTO_PIN_LAST; i++) {
16063 if (alc880_is_input_pin(cfg->input_pins[i])) {
16064 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16065 err = new_analog_input(spec, cfg->input_pins[i],
16066 auto_pin_cfg_labels[i],
16067 idx, 0x0b);
16068 if (err < 0)
16069 return err;
16070 imux->items[imux->num_items].label =
16071 auto_pin_cfg_labels[i];
16072 imux->items[imux->num_items].index =
16073 alc880_input_pin_idx(cfg->input_pins[i]);
16074 imux->num_items++;
16075 }
16076 }
16077 return 0;
16078}
16079
16080static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16081 hda_nid_t nid, int pin_type,
16082 int dac_idx)
16083{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016084 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016085 /* need the manual connection? */
16086 if (alc880_is_multi_pin(nid)) {
16087 struct alc_spec *spec = codec->spec;
16088 int idx = alc880_multi_pin_idx(nid);
16089 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16090 AC_VERB_SET_CONNECT_SEL,
16091 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16092 }
16093}
16094
16095static void alc662_auto_init_multi_out(struct hda_codec *codec)
16096{
16097 struct alc_spec *spec = codec->spec;
16098 int i;
16099
Kailang Yang8c427222008-01-10 13:03:59 +010016100 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016101 for (i = 0; i <= HDA_SIDE; i++) {
16102 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016103 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016104 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016105 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016106 i);
16107 }
16108}
16109
16110static void alc662_auto_init_hp_out(struct hda_codec *codec)
16111{
16112 struct alc_spec *spec = codec->spec;
16113 hda_nid_t pin;
16114
16115 pin = spec->autocfg.hp_pins[0];
16116 if (pin) /* connect to front */
16117 /* use dac 0 */
16118 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016119 pin = spec->autocfg.speaker_pins[0];
16120 if (pin)
16121 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016122}
16123
16124#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16125#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16126
16127static void alc662_auto_init_analog_input(struct hda_codec *codec)
16128{
16129 struct alc_spec *spec = codec->spec;
16130 int i;
16131
16132 for (i = 0; i < AUTO_PIN_LAST; i++) {
16133 hda_nid_t nid = spec->autocfg.input_pins[i];
16134 if (alc662_is_input_pin(nid)) {
16135 snd_hda_codec_write(codec, nid, 0,
16136 AC_VERB_SET_PIN_WIDGET_CONTROL,
16137 (i <= AUTO_PIN_FRONT_MIC ?
16138 PIN_VREF80 : PIN_IN));
16139 if (nid != ALC662_PIN_CD_NID)
16140 snd_hda_codec_write(codec, nid, 0,
16141 AC_VERB_SET_AMP_GAIN_MUTE,
16142 AMP_OUT_MUTE);
16143 }
16144 }
16145}
16146
Takashi Iwaif511b012008-08-15 16:46:42 +020016147#define alc662_auto_init_input_src alc882_auto_init_input_src
16148
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016149static int alc662_parse_auto_config(struct hda_codec *codec)
16150{
16151 struct alc_spec *spec = codec->spec;
16152 int err;
16153 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16154
16155 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16156 alc662_ignore);
16157 if (err < 0)
16158 return err;
16159 if (!spec->autocfg.line_outs)
16160 return 0; /* can't find valid BIOS pin config */
16161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016162 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16163 if (err < 0)
16164 return err;
16165 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16166 if (err < 0)
16167 return err;
16168 err = alc662_auto_create_extra_out(spec,
16169 spec->autocfg.speaker_pins[0],
16170 "Speaker");
16171 if (err < 0)
16172 return err;
16173 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16174 "Headphone");
16175 if (err < 0)
16176 return err;
16177 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16178 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016179 return err;
16180
16181 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16182
16183 if (spec->autocfg.dig_out_pin)
16184 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16185
16186 if (spec->kctl_alloc)
16187 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
16188
16189 spec->num_mux_defs = 1;
16190 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016191
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016192 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020016193 if (codec->vendor_id == 0x10ec0663)
16194 spec->init_verbs[spec->num_init_verbs++] =
16195 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020016196
16197 err = alc_auto_add_mic_boost(codec);
16198 if (err < 0)
16199 return err;
16200
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016201 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16202 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016203 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016204}
16205
16206/* additional initialization for auto-configuration model */
16207static void alc662_auto_init(struct hda_codec *codec)
16208{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016209 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016210 alc662_auto_init_multi_out(codec);
16211 alc662_auto_init_hp_out(codec);
16212 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016213 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016214 if (spec->unsol_event)
16215 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016216}
16217
16218static int patch_alc662(struct hda_codec *codec)
16219{
16220 struct alc_spec *spec;
16221 int err, board_config;
16222
16223 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16224 if (!spec)
16225 return -ENOMEM;
16226
16227 codec->spec = spec;
16228
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016229 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16230
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016231 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16232 alc662_models,
16233 alc662_cfg_tbl);
16234 if (board_config < 0) {
16235 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16236 "trying auto-probe from BIOS...\n");
16237 board_config = ALC662_AUTO;
16238 }
16239
16240 if (board_config == ALC662_AUTO) {
16241 /* automatic parse from the BIOS config */
16242 err = alc662_parse_auto_config(codec);
16243 if (err < 0) {
16244 alc_free(codec);
16245 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016246 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016247 printk(KERN_INFO
16248 "hda_codec: Cannot set up configuration "
16249 "from BIOS. Using base mode...\n");
16250 board_config = ALC662_3ST_2ch_DIG;
16251 }
16252 }
16253
16254 if (board_config != ALC662_AUTO)
16255 setup_preset(spec, &alc662_presets[board_config]);
16256
Kailang Yang6dda9f42008-05-27 12:05:31 +020016257 if (codec->vendor_id == 0x10ec0663) {
16258 spec->stream_name_analog = "ALC663 Analog";
16259 spec->stream_name_digital = "ALC663 Digital";
16260 } else {
16261 spec->stream_name_analog = "ALC662 Analog";
16262 spec->stream_name_digital = "ALC662 Digital";
16263 }
16264
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016265 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16266 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16267
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016268 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16269 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16270
Takashi Iwaie1406342008-02-11 18:32:32 +010016271 spec->adc_nids = alc662_adc_nids;
16272 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16273 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016274
Takashi Iwai2134ea42008-01-10 16:53:55 +010016275 spec->vmaster_nid = 0x02;
16276
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016277 codec->patch_ops = alc_patch_ops;
16278 if (board_config == ALC662_AUTO)
16279 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016280#ifdef CONFIG_SND_HDA_POWER_SAVE
16281 if (!spec->loopback.amplist)
16282 spec->loopback.amplist = alc662_loopbacks;
16283#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016284
16285 return 0;
16286}
16287
16288/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016289 * patch entries
16290 */
16291struct hda_codec_preset snd_hda_preset_realtek[] = {
16292 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016293 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016294 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016295 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016296 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016297 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016298 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016299 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16300 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16301 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016302 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16303 .patch = patch_alc883 },
16304 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16305 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016306 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016307 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016308 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016309 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020016310 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016311 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016312 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016313 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016314 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016315 {} /* terminator */
16316};