blob: 4eceab9bd10985427d041a48c9401fae9cc271a4 [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 Avdoninbab282b2006-08-22 13:31:58 +0200213 ALC883_ACER,
Tobin Davis2880a8672007-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;
Takashi Iwaie044c392008-10-27 16:56:24 +0100310
311#ifdef SND_HDA_NEEDS_RESUME
312#define ALC_MAX_PINS 16
313 unsigned int num_pins;
314 hda_nid_t pin_nids[ALC_MAX_PINS];
315 unsigned int pin_cfgs[ALC_MAX_PINS];
316#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100317};
318
319/*
320 * configuration template - to be copied to the spec instance
321 */
322struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200323 struct snd_kcontrol_new *mixers[5]; /* should be identical size
324 * with spec
325 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100326 const struct hda_verb *init_verbs[5];
327 unsigned int num_dacs;
328 hda_nid_t *dac_nids;
329 hda_nid_t dig_out_nid; /* optional */
330 hda_nid_t hp_nid; /* optional */
331 unsigned int num_adc_nids;
332 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100333 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100334 hda_nid_t dig_in_nid;
335 unsigned int num_channel_mode;
336 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200337 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200338 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100339 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100340 void (*unsol_event)(struct hda_codec *, unsigned int);
341 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200342#ifdef CONFIG_SND_HDA_POWER_SAVE
343 struct hda_amp_list *loopbacks;
344#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345};
346
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
348/*
349 * input MUX handling
350 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200351static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353{
354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
355 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200356 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
357 if (mux_idx >= spec->num_mux_defs)
358 mux_idx = 0;
359 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
361
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200362static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 struct alc_spec *spec = codec->spec;
367 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
368
369 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
370 return 0;
371}
372
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375{
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct alc_spec *spec = codec->spec;
378 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100380 hda_nid_t nid = spec->capsrc_nids ?
381 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200382 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100383 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384}
385
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387/*
388 * channel mode setting
389 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
394 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100395 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
396 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397}
398
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200399static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
400 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401{
402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
403 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100404 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405 spec->num_channel_mode,
406 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200409static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
410 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200414 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
415 spec->num_channel_mode,
416 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200417 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200418 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
419 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420}
421
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200424 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100425 * being part of a format specifier. Maximum allowed length of a value is
426 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100427 *
428 * Note: some retasking pin complexes seem to ignore requests for input
429 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
430 * are requested. Therefore order this list so that this behaviour will not
431 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200432 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
433 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200434 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100436 "Mic 50pc bias", "Mic 80pc bias",
437 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438};
439static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100440 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100441};
442/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200443 * in the pin being assumed to be exclusively an input or an output pin. In
444 * addition, "input" pins may or may not process the mic bias option
445 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
446 * accept requests for bias as of chip versions up to March 2006) and/or
447 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100448 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200449#define ALC_PIN_DIR_IN 0x00
450#define ALC_PIN_DIR_OUT 0x01
451#define ALC_PIN_DIR_INOUT 0x02
452#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
453#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100454
Kailang Yangea1fb292008-08-26 12:58:38 +0200455/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 * For each direction the minimum and maximum values are given.
457 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200458static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 { 0, 2 }, /* ALC_PIN_DIR_IN */
460 { 3, 4 }, /* ALC_PIN_DIR_OUT */
461 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200462 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
463 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100464};
465#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
466#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
467#define alc_pin_mode_n_items(_dir) \
468 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 unsigned int item_num = uinfo->value.enumerated.item;
474 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
475
476 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200477 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
479
480 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
481 item_num = alc_pin_mode_min(dir);
482 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200483 return 0;
484}
485
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200486static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200488{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200493 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
495 AC_VERB_GET_PIN_WIDGET_CONTROL,
496 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200497
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498 /* Find enumerated value for current pinctl setting */
499 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200500 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200502 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 return 0;
504}
505
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200506static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508{
509 signed int change;
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 hda_nid_t nid = kcontrol->private_value & 0xffff;
512 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
513 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_PIN_WIDGET_CONTROL,
516 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200518 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 val = alc_pin_mode_min(dir);
520
521 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100522 if (change) {
523 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200524 snd_hda_codec_write_cache(codec, nid, 0,
525 AC_VERB_SET_PIN_WIDGET_CONTROL,
526 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100527
Kailang Yangea1fb292008-08-26 12:58:38 +0200528 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100529 * for the requested pin mode. Enum values of 2 or less are
530 * input modes.
531 *
532 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533 * reduces noise slightly (particularly on input) so we'll
534 * do it. However, having both input and output buffers
535 * enabled simultaneously doesn't seem to be problematic if
536 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100537 */
538 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200539 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
540 HDA_AMP_MUTE, HDA_AMP_MUTE);
541 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
542 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100543 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200544 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
545 HDA_AMP_MUTE, HDA_AMP_MUTE);
546 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
547 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100548 }
549 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550 return change;
551}
552
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 .info = alc_pin_mode_info, \
556 .get = alc_pin_mode_get, \
557 .put = alc_pin_mode_put, \
558 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100559
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100560/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
561 * together using a mask with more than one bit set. This control is
562 * currently used only by the ALC260 test model. At this stage they are not
563 * needed for any "production" models.
564 */
565#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200566#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200567
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100570{
571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 hda_nid_t nid = kcontrol->private_value & 0xffff;
573 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
574 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575 unsigned int val = snd_hda_codec_read(codec, nid, 0,
576 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100577
578 *valp = (val & mask) != 0;
579 return 0;
580}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
582 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100583{
584 signed int change;
585 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
586 hda_nid_t nid = kcontrol->private_value & 0xffff;
587 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
588 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
590 AC_VERB_GET_GPIO_DATA,
591 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100592
593 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200594 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
595 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100596 gpio_data &= ~mask;
597 else
598 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200599 snd_hda_codec_write_cache(codec, nid, 0,
600 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100601
602 return change;
603}
604#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
605 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
606 .info = alc_gpio_data_info, \
607 .get = alc_gpio_data_get, \
608 .put = alc_gpio_data_put, \
609 .private_value = nid | (mask<<16) }
610#endif /* CONFIG_SND_DEBUG */
611
Jonathan Woithe92621f12006-02-28 11:47:47 +0100612/* A switch control to allow the enabling of the digital IO pins on the
613 * ALC260. This is incredibly simplistic; the intention of this control is
614 * to provide something in the test model allowing digital outputs to be
615 * identified if present. If models are found which can utilise these
616 * outputs a more complete mixer control can be devised for those models if
617 * necessary.
618 */
619#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200620#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200621
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 hda_nid_t nid = kcontrol->private_value & 0xffff;
627 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
628 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200629 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100630 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100631
632 *valp = (val & mask) != 0;
633 return 0;
634}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100637{
638 signed int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100644 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100646
647 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200648 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100649 if (val==0)
650 ctrl_data &= ~mask;
651 else
652 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200653 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
654 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100655
656 return change;
657}
658#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
659 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
660 .info = alc_spdif_ctrl_info, \
661 .get = alc_spdif_ctrl_get, \
662 .put = alc_spdif_ctrl_put, \
663 .private_value = nid | (mask<<16) }
664#endif /* CONFIG_SND_DEBUG */
665
Jonathan Woithef8225f62008-01-08 12:16:54 +0100666/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
667 * Again, this is only used in the ALC26x test models to help identify when
668 * the EAPD line must be asserted for features to work.
669 */
670#ifdef CONFIG_SND_DEBUG
671#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
672
673static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 hda_nid_t nid = kcontrol->private_value & 0xffff;
678 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
679 long *valp = ucontrol->value.integer.value;
680 unsigned int val = snd_hda_codec_read(codec, nid, 0,
681 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
682
683 *valp = (val & mask) != 0;
684 return 0;
685}
686
687static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
689{
690 int change;
691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
692 hda_nid_t nid = kcontrol->private_value & 0xffff;
693 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
694 long val = *ucontrol->value.integer.value;
695 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
696 AC_VERB_GET_EAPD_BTLENABLE,
697 0x00);
698
699 /* Set/unset the masked control bit(s) as needed */
700 change = (!val ? 0 : mask) != (ctrl_data & mask);
701 if (!val)
702 ctrl_data &= ~mask;
703 else
704 ctrl_data |= mask;
705 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
706 ctrl_data);
707
708 return change;
709}
710
711#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
712 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
713 .info = alc_eapd_ctrl_info, \
714 .get = alc_eapd_ctrl_get, \
715 .put = alc_eapd_ctrl_put, \
716 .private_value = nid | (mask<<16) }
717#endif /* CONFIG_SND_DEBUG */
718
Kailang Yangdf694da2005-12-05 19:42:22 +0100719/*
720 * set up from the preset table
721 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722static void setup_preset(struct alc_spec *spec,
723 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100724{
725 int i;
726
727 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
728 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
730 i++)
731 spec->init_verbs[spec->num_init_verbs++] =
732 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200733
Kailang Yangdf694da2005-12-05 19:42:22 +0100734 spec->channel_mode = preset->channel_mode;
735 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200736 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100737
738 spec->multiout.max_channels = spec->channel_mode[0].channels;
739
740 spec->multiout.num_dacs = preset->num_dacs;
741 spec->multiout.dac_nids = preset->dac_nids;
742 spec->multiout.dig_out_nid = preset->dig_out_nid;
743 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200744
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200745 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200746 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200747 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100748 spec->input_mux = preset->input_mux;
749
750 spec->num_adc_nids = preset->num_adc_nids;
751 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100752 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100753 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100754
755 spec->unsol_event = preset->unsol_event;
756 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200757#ifdef CONFIG_SND_HDA_POWER_SAVE
758 spec->loopback.amplist = preset->loopbacks;
759#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100760}
761
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200762/* Enable GPIO mask and set output */
763static struct hda_verb alc_gpio1_init_verbs[] = {
764 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
766 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
767 { }
768};
769
770static struct hda_verb alc_gpio2_init_verbs[] = {
771 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
772 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
773 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
774 { }
775};
776
Kailang Yangbdd148a2007-05-08 15:19:08 +0200777static struct hda_verb alc_gpio3_init_verbs[] = {
778 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
779 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
780 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
781 { }
782};
783
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200784/*
785 * Fix hardware PLL issue
786 * On some codecs, the analog PLL gating control must be off while
787 * the default value is 1.
788 */
789static void alc_fix_pll(struct hda_codec *codec)
790{
791 struct alc_spec *spec = codec->spec;
792 unsigned int val;
793
794 if (!spec->pll_nid)
795 return;
796 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
797 spec->pll_coef_idx);
798 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
799 AC_VERB_GET_PROC_COEF, 0);
800 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
801 spec->pll_coef_idx);
802 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
803 val & ~(1 << spec->pll_coef_bit));
804}
805
806static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
807 unsigned int coef_idx, unsigned int coef_bit)
808{
809 struct alc_spec *spec = codec->spec;
810 spec->pll_nid = nid;
811 spec->pll_coef_idx = coef_idx;
812 spec->pll_coef_bit = coef_bit;
813 alc_fix_pll(codec);
814}
815
Kailang Yangc9b58002007-10-16 14:30:01 +0200816static void alc_sku_automute(struct hda_codec *codec)
817{
818 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200819 unsigned int present;
820 unsigned int hp_nid = spec->autocfg.hp_pins[0];
821 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
822
823 /* need to execute and sync at first */
824 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
825 present = snd_hda_codec_read(codec, hp_nid, 0,
826 AC_VERB_GET_PIN_SENSE, 0);
827 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100828 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
829 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200830}
831
Kailang Yang7fb0d782008-10-15 11:12:35 +0200832static void alc_mic_automute(struct hda_codec *codec)
833{
834 struct alc_spec *spec = codec->spec;
835 unsigned int present;
836 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
837 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
838 unsigned int mix_nid = spec->capsrc_nids[0];
839 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
840
841 capsrc_idx_mic = mic_nid - 0x18;
842 capsrc_idx_fmic = fmic_nid - 0x18;
843 present = snd_hda_codec_read(codec, mic_nid, 0,
844 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
845 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
846 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
847 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
848 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
849 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
851}
852
Kailang Yangc9b58002007-10-16 14:30:01 +0200853/* unsolicited event for HP jack sensing */
854static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
855{
856 if (codec->vendor_id == 0x10ec0880)
857 res >>= 28;
858 else
859 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200860 if (res == ALC880_HP_EVENT)
861 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200862
Kailang Yang7fb0d782008-10-15 11:12:35 +0200863 if (res == ALC880_MIC_EVENT)
864 alc_mic_automute(codec);
865}
866
867static void alc_inithook(struct hda_codec *codec)
868{
Kailang Yangc9b58002007-10-16 14:30:01 +0200869 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200870 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200871}
872
Kailang Yangf9423e72008-05-27 12:32:25 +0200873/* additional initialization for ALC888 variants */
874static void alc888_coef_init(struct hda_codec *codec)
875{
876 unsigned int tmp;
877
878 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
879 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
880 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
881 if ((tmp & 0xf0) == 2)
882 /* alc888S-VC */
883 snd_hda_codec_read(codec, 0x20, 0,
884 AC_VERB_SET_PROC_COEF, 0x830);
885 else
886 /* alc888-VB */
887 snd_hda_codec_read(codec, 0x20, 0,
888 AC_VERB_SET_PROC_COEF, 0x3030);
889}
890
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200891/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
892 * 31 ~ 16 : Manufacture ID
893 * 15 ~ 8 : SKU ID
894 * 7 ~ 0 : Assembly ID
895 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
896 */
897static void alc_subsystem_id(struct hda_codec *codec,
898 unsigned int porta, unsigned int porte,
899 unsigned int portd)
900{
Kailang Yangc9b58002007-10-16 14:30:01 +0200901 unsigned int ass, tmp, i;
902 unsigned nid;
903 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200904
Kailang Yangc9b58002007-10-16 14:30:01 +0200905 ass = codec->subsystem_id & 0xffff;
906 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
907 goto do_sku;
908
Kailang Yangea1fb292008-08-26 12:58:38 +0200909 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200910 * 31~30 : port conetcivity
911 * 29~21 : reserve
912 * 20 : PCBEEP input
913 * 19~16 : Check sum (15:1)
914 * 15~1 : Custom
915 * 0 : override
916 */
917 nid = 0x1d;
918 if (codec->vendor_id == 0x10ec0260)
919 nid = 0x17;
920 ass = snd_hda_codec_read(codec, nid, 0,
921 AC_VERB_GET_CONFIG_DEFAULT, 0);
922 if (!(ass & 1) && !(ass & 0x100000))
923 return;
924 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200925 return;
926
Kailang Yangc9b58002007-10-16 14:30:01 +0200927 /* check sum */
928 tmp = 0;
929 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100930 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200931 tmp++;
932 }
933 if (((ass >> 16) & 0xf) != tmp)
934 return;
935do_sku:
936 /*
937 * 0 : override
938 * 1 : Swap Jack
939 * 2 : 0 --> Desktop, 1 --> Laptop
940 * 3~5 : External Amplifier control
941 * 7~6 : Reserved
942 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200943 tmp = (ass & 0x38) >> 3; /* external Amp control */
944 switch (tmp) {
945 case 1:
946 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
947 break;
948 case 3:
949 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
950 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200951 case 7:
952 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
953 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200954 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200955 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200956 case 0x10ec0260:
957 snd_hda_codec_write(codec, 0x0f, 0,
958 AC_VERB_SET_EAPD_BTLENABLE, 2);
959 snd_hda_codec_write(codec, 0x10, 0,
960 AC_VERB_SET_EAPD_BTLENABLE, 2);
961 break;
962 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200963 case 0x10ec0267:
964 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200965 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200966 case 0x10ec0660:
967 case 0x10ec0662:
968 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200969 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200970 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200971 snd_hda_codec_write(codec, 0x14, 0,
972 AC_VERB_SET_EAPD_BTLENABLE, 2);
973 snd_hda_codec_write(codec, 0x15, 0,
974 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200975 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200976 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200977 switch (codec->vendor_id) {
978 case 0x10ec0260:
979 snd_hda_codec_write(codec, 0x1a, 0,
980 AC_VERB_SET_COEF_INDEX, 7);
981 tmp = snd_hda_codec_read(codec, 0x1a, 0,
982 AC_VERB_GET_PROC_COEF, 0);
983 snd_hda_codec_write(codec, 0x1a, 0,
984 AC_VERB_SET_COEF_INDEX, 7);
985 snd_hda_codec_write(codec, 0x1a, 0,
986 AC_VERB_SET_PROC_COEF,
987 tmp | 0x2010);
988 break;
989 case 0x10ec0262:
990 case 0x10ec0880:
991 case 0x10ec0882:
992 case 0x10ec0883:
993 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200994 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200995 snd_hda_codec_write(codec, 0x20, 0,
996 AC_VERB_SET_COEF_INDEX, 7);
997 tmp = snd_hda_codec_read(codec, 0x20, 0,
998 AC_VERB_GET_PROC_COEF, 0);
999 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001000 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001001 snd_hda_codec_write(codec, 0x20, 0,
1002 AC_VERB_SET_PROC_COEF,
1003 tmp | 0x2010);
1004 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001005 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001006 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001007 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001008 case 0x10ec0267:
1009 case 0x10ec0268:
1010 snd_hda_codec_write(codec, 0x20, 0,
1011 AC_VERB_SET_COEF_INDEX, 7);
1012 tmp = snd_hda_codec_read(codec, 0x20, 0,
1013 AC_VERB_GET_PROC_COEF, 0);
1014 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001015 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001016 snd_hda_codec_write(codec, 0x20, 0,
1017 AC_VERB_SET_PROC_COEF,
1018 tmp | 0x3000);
1019 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001020 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001021 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001022 break;
1023 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001024
Kailang Yang8c427222008-01-10 13:03:59 +01001025 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001026 * when the external headphone out jack is plugged"
1027 */
Kailang Yang8c427222008-01-10 13:03:59 +01001028 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001029 return;
1030 /*
1031 * 10~8 : Jack location
1032 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1033 * 14~13: Resvered
1034 * 15 : 1 --> enable the function "Mute internal speaker
1035 * when the external headphone out jack is plugged"
1036 */
1037 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001038 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001039 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001040 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001041 else
1042 return;
1043 }
1044
1045 if (!spec->autocfg.hp_pins[0]) {
1046 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1047 if (tmp == 0)
1048 spec->autocfg.hp_pins[0] = porta;
1049 else if (tmp == 1)
1050 spec->autocfg.hp_pins[0] = porte;
1051 else if (tmp == 2)
1052 spec->autocfg.hp_pins[0] = portd;
1053 else
1054 return;
1055 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056 if (spec->autocfg.hp_pins[0])
1057 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1058 AC_VERB_SET_UNSOLICITED_ENABLE,
1059 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001060
Kailang Yang7fb0d782008-10-15 11:12:35 +02001061 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1062 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1063 snd_hda_codec_write(codec,
1064 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1065 AC_VERB_SET_UNSOLICITED_ENABLE,
1066 AC_USRSP_EN | ALC880_MIC_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001067
Kailang Yangc9b58002007-10-16 14:30:01 +02001068 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001069}
1070
Takashi Iwai41e41f12005-06-08 14:48:49 +02001071/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001072 * Fix-up pin default configurations
1073 */
1074
1075struct alc_pincfg {
1076 hda_nid_t nid;
1077 u32 val;
1078};
1079
1080static void alc_fix_pincfg(struct hda_codec *codec,
1081 const struct snd_pci_quirk *quirk,
1082 const struct alc_pincfg **pinfix)
1083{
1084 const struct alc_pincfg *cfg;
1085
1086 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1087 if (!quirk)
1088 return;
1089
1090 cfg = pinfix[quirk->value];
1091 for (; cfg->nid; cfg++) {
1092 int i;
1093 u32 val = cfg->val;
1094 for (i = 0; i < 4; i++) {
1095 snd_hda_codec_write(codec, cfg->nid, 0,
1096 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1097 val & 0xff);
1098 val >>= 8;
1099 }
1100 }
1101}
1102
1103/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001104 * ALC880 3-stack model
1105 *
1106 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001107 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1108 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 */
1110
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001111static hda_nid_t alc880_dac_nids[4] = {
1112 /* front, rear, clfe, rear_surr */
1113 0x02, 0x05, 0x04, 0x03
1114};
1115
1116static hda_nid_t alc880_adc_nids[3] = {
1117 /* ADC0-2 */
1118 0x07, 0x08, 0x09,
1119};
1120
1121/* The datasheet says the node 0x07 is connected from inputs,
1122 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001123 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001125static hda_nid_t alc880_adc_nids_alt[2] = {
1126 /* ADC1-2 */
1127 0x08, 0x09,
1128};
1129
1130#define ALC880_DIGOUT_NID 0x06
1131#define ALC880_DIGIN_NID 0x0a
1132
1133static struct hda_input_mux alc880_capture_source = {
1134 .num_items = 4,
1135 .items = {
1136 { "Mic", 0x0 },
1137 { "Front Mic", 0x3 },
1138 { "Line", 0x2 },
1139 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001141};
1142
1143/* channel source setting (2/6 channel selection for 3-stack) */
1144/* 2ch mode */
1145static struct hda_verb alc880_threestack_ch2_init[] = {
1146 /* set line-in to input, mute it */
1147 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1148 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1149 /* set mic-in to input vref 80%, mute it */
1150 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1151 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 { } /* end */
1153};
1154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155/* 6ch mode */
1156static struct hda_verb alc880_threestack_ch6_init[] = {
1157 /* set line-in to output, unmute it */
1158 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1159 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1160 /* set mic-in to output, unmute it */
1161 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1162 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1163 { } /* end */
1164};
1165
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001166static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001167 { 2, alc880_threestack_ch2_init },
1168 { 6, alc880_threestack_ch6_init },
1169};
1170
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001171static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001174 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001175 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001176 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001178 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1179 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1186 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1188 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1189 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001191 {
1192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1193 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001194 .info = alc_ch_mode_info,
1195 .get = alc_ch_mode_get,
1196 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001197 },
1198 { } /* end */
1199};
1200
1201/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001202static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001203 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1204 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1205 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1206 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1207 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1208 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1209 {
1210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1211 /* The multiple "Capture Source" controls confuse alsamixer
1212 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001213 */
1214 /* .name = "Capture Source", */
1215 .name = "Input Source",
1216 .count = 3,
1217 .info = alc_mux_enum_info,
1218 .get = alc_mux_enum_get,
1219 .put = alc_mux_enum_put,
1220 },
1221 { } /* end */
1222};
1223
1224/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001225static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001226 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1227 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1228 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1229 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 {
1231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1232 /* The multiple "Capture Source" controls confuse alsamixer
1233 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 */
1235 /* .name = "Capture Source", */
1236 .name = "Input Source",
1237 .count = 2,
1238 .info = alc_mux_enum_info,
1239 .get = alc_mux_enum_get,
1240 .put = alc_mux_enum_put,
1241 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 { } /* end */
1243};
1244
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245
1246
1247/*
1248 * ALC880 5-stack model
1249 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001250 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1251 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001252 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1253 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1254 */
1255
1256/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001257static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001258 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001259 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 { } /* end */
1261};
1262
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263/* channel source setting (6/8 channel selection for 5-stack) */
1264/* 6ch mode */
1265static struct hda_verb alc880_fivestack_ch6_init[] = {
1266 /* set line-in to input, mute it */
1267 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1268 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001269 { } /* end */
1270};
1271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272/* 8ch mode */
1273static struct hda_verb alc880_fivestack_ch8_init[] = {
1274 /* set line-in to output, unmute it */
1275 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1276 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1277 { } /* end */
1278};
1279
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001280static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281 { 6, alc880_fivestack_ch6_init },
1282 { 8, alc880_fivestack_ch8_init },
1283};
1284
1285
1286/*
1287 * ALC880 6-stack model
1288 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001289 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1290 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1292 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1293 */
1294
1295static hda_nid_t alc880_6st_dac_nids[4] = {
1296 /* front, rear, clfe, rear_surr */
1297 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001298};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299
1300static struct hda_input_mux alc880_6stack_capture_source = {
1301 .num_items = 4,
1302 .items = {
1303 { "Mic", 0x0 },
1304 { "Front Mic", 0x1 },
1305 { "Line", 0x2 },
1306 { "CD", 0x4 },
1307 },
1308};
1309
1310/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001311static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001312 { 8, NULL },
1313};
1314
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001315static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001318 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001319 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001320 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001322 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1323 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001324 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001325 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001326 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1327 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1334 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1335 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001336 {
1337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1338 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001339 .info = alc_ch_mode_info,
1340 .get = alc_ch_mode_get,
1341 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001342 },
1343 { } /* end */
1344};
1345
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001346
1347/*
1348 * ALC880 W810 model
1349 *
1350 * W810 has rear IO for:
1351 * Front (DAC 02)
1352 * Surround (DAC 03)
1353 * Center/LFE (DAC 04)
1354 * Digital out (06)
1355 *
1356 * The system also has a pair of internal speakers, and a headphone jack.
1357 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001358 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001359 * There is a variable resistor to control the speaker or headphone
1360 * volume. This is a hardware-only device without a software API.
1361 *
1362 * Plugging headphones in will disable the internal speakers. This is
1363 * implemented in hardware, not via the driver using jack sense. In
1364 * a similar fashion, plugging into the rear socket marked "front" will
1365 * disable both the speakers and headphones.
1366 *
1367 * For input, there's a microphone jack, and an "audio in" jack.
1368 * These may not do anything useful with this driver yet, because I
1369 * haven't setup any initialization verbs for these yet...
1370 */
1371
1372static hda_nid_t alc880_w810_dac_nids[3] = {
1373 /* front, rear/surround, clfe */
1374 0x02, 0x03, 0x04
1375};
1376
1377/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001378static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001379 { 6, NULL }
1380};
1381
1382/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001383static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001384 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001385 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001386 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001387 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001388 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001390 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1391 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1393 { } /* end */
1394};
1395
1396
1397/*
1398 * Z710V model
1399 *
1400 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001401 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1402 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001403 */
1404
1405static hda_nid_t alc880_z71v_dac_nids[1] = {
1406 0x02
1407};
1408#define ALC880_Z71V_HP_DAC 0x03
1409
1410/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001411static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001412 { 2, NULL }
1413};
1414
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001415static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001417 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001419 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1424 { } /* end */
1425};
1426
1427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428/*
1429 * ALC880 F1734 model
1430 *
1431 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1432 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1433 */
1434
1435static hda_nid_t alc880_f1734_dac_nids[1] = {
1436 0x03
1437};
1438#define ALC880_F1734_HP_DAC 0x02
1439
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001440static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001441 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001442 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001443 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 { } /* end */
1450};
1451
Takashi Iwai937b4162008-02-11 14:52:36 +01001452static struct hda_input_mux alc880_f1734_capture_source = {
1453 .num_items = 2,
1454 .items = {
1455 { "Mic", 0x1 },
1456 { "CD", 0x4 },
1457 },
1458};
1459
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001461/*
1462 * ALC880 ASUS model
1463 *
1464 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1465 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1466 * Mic = 0x18, Line = 0x1a
1467 */
1468
1469#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1470#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1471
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001472static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001473 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001474 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001475 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001476 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001477 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1478 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001479 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1480 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001481 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1482 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1484 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001487 {
1488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1489 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001490 .info = alc_ch_mode_info,
1491 .get = alc_ch_mode_get,
1492 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001493 },
1494 { } /* end */
1495};
1496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001497/*
1498 * ALC880 ASUS W1V model
1499 *
1500 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1501 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1502 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1503 */
1504
1505/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001506static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001507 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1508 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001509 { } /* end */
1510};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001511
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001512/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001513static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001514 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1515 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1516 { } /* end */
1517};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001518
Kailang Yangdf694da2005-12-05 19:42:22 +01001519/* TCL S700 */
1520static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1521 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1522 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1525 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1528 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1529 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1530 {
1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1532 /* The multiple "Capture Source" controls confuse alsamixer
1533 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001534 */
1535 /* .name = "Capture Source", */
1536 .name = "Input Source",
1537 .count = 1,
1538 .info = alc_mux_enum_info,
1539 .get = alc_mux_enum_get,
1540 .put = alc_mux_enum_put,
1541 },
1542 { } /* end */
1543};
1544
Kailang Yangccc656c2006-10-17 12:32:26 +02001545/* Uniwill */
1546static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001547 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1548 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1549 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1550 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1552 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1553 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1554 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1561 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1562 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1563 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1564 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1565 {
1566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1567 .name = "Channel Mode",
1568 .info = alc_ch_mode_info,
1569 .get = alc_ch_mode_get,
1570 .put = alc_ch_mode_put,
1571 },
1572 { } /* end */
1573};
1574
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001575static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1576 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1577 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1578 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1579 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1582 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1583 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1584 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1585 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1586 { } /* end */
1587};
1588
Kailang Yangccc656c2006-10-17 12:32:26 +02001589static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001590 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1591 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1592 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1593 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1596 { } /* end */
1597};
1598
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001600 * virtual master controls
1601 */
1602
1603/*
1604 * slave controls for virtual master
1605 */
1606static const char *alc_slave_vols[] = {
1607 "Front Playback Volume",
1608 "Surround Playback Volume",
1609 "Center Playback Volume",
1610 "LFE Playback Volume",
1611 "Side Playback Volume",
1612 "Headphone Playback Volume",
1613 "Speaker Playback Volume",
1614 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001615 "Line-Out Playback Volume",
1616 NULL,
1617};
1618
1619static const char *alc_slave_sws[] = {
1620 "Front Playback Switch",
1621 "Surround Playback Switch",
1622 "Center Playback Switch",
1623 "LFE Playback Switch",
1624 "Side Playback Switch",
1625 "Headphone Playback Switch",
1626 "Speaker Playback Switch",
1627 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001628 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001629 NULL,
1630};
1631
1632/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001633 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 */
1635static int alc_build_controls(struct hda_codec *codec)
1636{
1637 struct alc_spec *spec = codec->spec;
1638 int err;
1639 int i;
1640
1641 for (i = 0; i < spec->num_mixers; i++) {
1642 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1643 if (err < 0)
1644 return err;
1645 }
1646
1647 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001648 err = snd_hda_create_spdif_out_ctls(codec,
1649 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 if (err < 0)
1651 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001652 err = snd_hda_create_spdif_share_sw(codec,
1653 &spec->multiout);
1654 if (err < 0)
1655 return err;
1656 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 }
1658 if (spec->dig_in_nid) {
1659 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1660 if (err < 0)
1661 return err;
1662 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001663
1664 /* if we have no master control, let's create it */
1665 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001666 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001667 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001668 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001669 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001670 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001671 if (err < 0)
1672 return err;
1673 }
1674 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1675 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1676 NULL, alc_slave_sws);
1677 if (err < 0)
1678 return err;
1679 }
1680
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681 return 0;
1682}
1683
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001684
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685/*
1686 * initialize the codec volumes, etc
1687 */
1688
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001689/*
1690 * generic initialization of ADC, input mixers and output mixers
1691 */
1692static struct hda_verb alc880_volume_init_verbs[] = {
1693 /*
1694 * Unmute ADC0-2 and set the default input to mic-in
1695 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001696 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001698 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001700 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001703 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1704 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001705 * Note: PASD motherboards uses the Line In 2 as the input for front
1706 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001708 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 /*
1718 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001720 /* set vol=0 to output mixers */
1721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1725 /* set up input amps for analog loopback */
1726 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1730 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001733 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1734 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735
1736 { }
1737};
1738
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739/*
1740 * 3-stack pin configuration:
1741 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1742 */
1743static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1744 /*
1745 * preset connection lists of input pins
1746 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1747 */
1748 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1749 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1750 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1751
1752 /*
1753 * Set pin mode and muting
1754 */
1755 /* set front pin widgets 0x14 for output */
1756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1758 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1761 /* Mic2 (as headphone out) for HP output */
1762 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1764 /* Line In pin widget for input */
1765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1767 /* Line2 (as front mic) pin widget for input and vref at 80% */
1768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1769 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1770 /* CD pin widget for input */
1771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1772
1773 { }
1774};
1775
1776/*
1777 * 5-stack pin configuration:
1778 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1779 * line-in/side = 0x1a, f-mic = 0x1b
1780 */
1781static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1782 /*
1783 * preset connection lists of input pins
1784 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1785 */
1786 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1787 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1788
1789 /*
1790 * Set pin mode and muting
1791 */
1792 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1796 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 /* unmute pins for output (no gain on this amp) */
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1802
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1806 /* Mic2 (as headphone out) for HP output */
1807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001809 /* Line In pin widget for input */
1810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 /* Line2 (as front mic) pin widget for input and vref at 80% */
1813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1814 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1815 /* CD pin widget for input */
1816 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817
1818 { }
1819};
1820
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001821/*
1822 * W810 pin configuration:
1823 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1824 */
1825static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826 /* hphone/speaker input selector: front DAC */
1827 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835
1836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 { }
1840};
1841
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001842/*
1843 * Z71V pin configuration:
1844 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1845 */
1846static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001847 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001851
Takashi Iwai16ded522005-06-10 19:58:24 +02001852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001855 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001856
1857 { }
1858};
1859
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001860/*
1861 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001862 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1863 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001864 */
1865static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1866 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1867
Takashi Iwai16ded522005-06-10 19:58:24 +02001868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001869 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001872 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001873 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001874 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1876
Takashi Iwai16ded522005-06-10 19:58:24 +02001877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001881 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001883 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001884 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001885 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001886
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001887 { }
1888};
Takashi Iwai16ded522005-06-10 19:58:24 +02001889
Kailang Yangccc656c2006-10-17 12:32:26 +02001890/*
1891 * Uniwill pin configuration:
1892 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1893 * line = 0x1a
1894 */
1895static struct hda_verb alc880_uniwill_init_verbs[] = {
1896 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1897
1898 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1904 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1905 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1912
1913 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1917 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1918 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1919 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1920 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1921 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1922
1923 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1925
1926 { }
1927};
1928
1929/*
1930* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001931* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001932 */
1933static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1934 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1935
1936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1940 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1941 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1948
1949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1951 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1952 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1955
1956 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1957 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1958
1959 { }
1960};
1961
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001962static struct hda_verb alc880_beep_init_verbs[] = {
1963 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1964 { }
1965};
1966
Kailang Yangccc656c2006-10-17 12:32:26 +02001967/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001968static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001969{
1970 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001971 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001972
1973 present = snd_hda_codec_read(codec, 0x14, 0,
1974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001975 bits = present ? HDA_AMP_MUTE : 0;
1976 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1977 HDA_AMP_MUTE, bits);
1978 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1979 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001980}
1981
1982/* auto-toggle front mic */
1983static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1984{
1985 unsigned int present;
1986 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001987
1988 present = snd_hda_codec_read(codec, 0x18, 0,
1989 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001990 bits = present ? HDA_AMP_MUTE : 0;
1991 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001992}
1993
1994static void alc880_uniwill_automute(struct hda_codec *codec)
1995{
1996 alc880_uniwill_hp_automute(codec);
1997 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001998}
1999
2000static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2001 unsigned int res)
2002{
2003 /* Looks like the unsol event is incompatible with the standard
2004 * definition. 4bit tag is placed at 28 bit!
2005 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002006 switch (res >> 28) {
2007 case ALC880_HP_EVENT:
2008 alc880_uniwill_hp_automute(codec);
2009 break;
2010 case ALC880_MIC_EVENT:
2011 alc880_uniwill_mic_automute(codec);
2012 break;
2013 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002014}
2015
2016static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2017{
2018 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002019 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002020
2021 present = snd_hda_codec_read(codec, 0x14, 0,
2022 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002023 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002024 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002025}
2026
2027static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2028{
2029 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002030
Kailang Yangccc656c2006-10-17 12:32:26 +02002031 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002032 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2033 present &= HDA_AMP_VOLMASK;
2034 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2035 HDA_AMP_VOLMASK, present);
2036 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2037 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002038}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002039
Kailang Yangccc656c2006-10-17 12:32:26 +02002040static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2041 unsigned int res)
2042{
2043 /* Looks like the unsol event is incompatible with the standard
2044 * definition. 4bit tag is placed at 28 bit!
2045 */
2046 if ((res >> 28) == ALC880_HP_EVENT)
2047 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002048 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002049 alc880_uniwill_p53_dcvol_automute(codec);
2050}
2051
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002052/*
2053 * F1734 pin configuration:
2054 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2055 */
2056static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002058 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2059 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2060 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2062
2063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2067
2068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2076 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002077
Takashi Iwai937b4162008-02-11 14:52:36 +01002078 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2079 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2080
Takashi Iwai16ded522005-06-10 19:58:24 +02002081 { }
2082};
2083
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002084/*
2085 * ASUS pin configuration:
2086 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2087 */
2088static struct hda_verb alc880_pin_asus_init_verbs[] = {
2089 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2090 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2091 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2092 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2093
2094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2095 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2100 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2102
2103 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2105 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002112
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002113 { }
2114};
2115
2116/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002117#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2118#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002119
Kailang Yangdf694da2005-12-05 19:42:22 +01002120/* Clevo m520g init */
2121static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2122 /* headphone output */
2123 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2124 /* line-out */
2125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2126 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 /* Line-in */
2128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2129 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2130 /* CD */
2131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2132 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* Mic1 (rear panel) */
2134 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2136 /* Mic2 (front panel) */
2137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2139 /* headphone */
2140 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2142 /* change to EAPD mode */
2143 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2144 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2145
2146 { }
2147};
2148
2149static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002150 /* change to EAPD mode */
2151 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2152 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2153
Kailang Yangdf694da2005-12-05 19:42:22 +01002154 /* Headphone output */
2155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2156 /* Front output*/
2157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2158 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2159
2160 /* Line In pin widget for input */
2161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2162 /* CD pin widget for input */
2163 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2164 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2166
2167 /* change to EAPD mode */
2168 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2169 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2170
2171 { }
2172};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173
2174/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002175 * LG m1 express dual
2176 *
2177 * Pin assignment:
2178 * Rear Line-In/Out (blue): 0x14
2179 * Build-in Mic-In: 0x15
2180 * Speaker-out: 0x17
2181 * HP-Out (green): 0x1b
2182 * Mic-In/Out (red): 0x19
2183 * SPDIF-Out: 0x1e
2184 */
2185
2186/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2187static hda_nid_t alc880_lg_dac_nids[3] = {
2188 0x05, 0x02, 0x03
2189};
2190
2191/* seems analog CD is not working */
2192static struct hda_input_mux alc880_lg_capture_source = {
2193 .num_items = 3,
2194 .items = {
2195 { "Mic", 0x1 },
2196 { "Line", 0x5 },
2197 { "Internal Mic", 0x6 },
2198 },
2199};
2200
2201/* 2,4,6 channel modes */
2202static struct hda_verb alc880_lg_ch2_init[] = {
2203 /* set line-in and mic-in to input */
2204 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2205 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2206 { }
2207};
2208
2209static struct hda_verb alc880_lg_ch4_init[] = {
2210 /* set line-in to out and mic-in to input */
2211 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2212 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2213 { }
2214};
2215
2216static struct hda_verb alc880_lg_ch6_init[] = {
2217 /* set line-in and mic-in to output */
2218 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2219 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2220 { }
2221};
2222
2223static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2224 { 2, alc880_lg_ch2_init },
2225 { 4, alc880_lg_ch4_init },
2226 { 6, alc880_lg_ch6_init },
2227};
2228
2229static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002230 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2231 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002232 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2233 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2234 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2235 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2236 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2237 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2243 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2244 {
2245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2246 .name = "Channel Mode",
2247 .info = alc_ch_mode_info,
2248 .get = alc_ch_mode_get,
2249 .put = alc_ch_mode_put,
2250 },
2251 { } /* end */
2252};
2253
2254static struct hda_verb alc880_lg_init_verbs[] = {
2255 /* set capture source to mic-in */
2256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2259 /* mute all amp mixer inputs */
2260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002263 /* line-in to input */
2264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2266 /* built-in mic */
2267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2269 /* speaker-out */
2270 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2271 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 /* mic-in to input */
2273 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2274 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2275 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276 /* HP-out */
2277 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280 /* jack sense */
2281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2282 { }
2283};
2284
2285/* toggle speaker-output according to the hp-jack state */
2286static void alc880_lg_automute(struct hda_codec *codec)
2287{
2288 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002289 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002290
2291 present = snd_hda_codec_read(codec, 0x1b, 0,
2292 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002293 bits = present ? HDA_AMP_MUTE : 0;
2294 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2295 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002296}
2297
2298static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2299{
2300 /* Looks like the unsol event is incompatible with the standard
2301 * definition. 4bit tag is placed at 28 bit!
2302 */
2303 if ((res >> 28) == 0x01)
2304 alc880_lg_automute(codec);
2305}
2306
2307/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002308 * LG LW20
2309 *
2310 * Pin assignment:
2311 * Speaker-out: 0x14
2312 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002313 * Built-in Mic-In: 0x19
2314 * Line-In: 0x1b
2315 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002316 * SPDIF-Out: 0x1e
2317 */
2318
Takashi Iwaid6815182006-03-23 16:06:23 +01002319static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002320 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002321 .items = {
2322 { "Mic", 0x0 },
2323 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002324 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002325 },
2326};
2327
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002328#define alc880_lg_lw_modes alc880_threestack_modes
2329
Takashi Iwaid6815182006-03-23 16:06:23 +01002330static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2336 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2337 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2338 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2340 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002341 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2342 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2343 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2344 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002345 {
2346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2347 .name = "Channel Mode",
2348 .info = alc_ch_mode_info,
2349 .get = alc_ch_mode_get,
2350 .put = alc_ch_mode_put,
2351 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002352 { } /* end */
2353};
2354
2355static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002356 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2357 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2358 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2359
Takashi Iwaid6815182006-03-23 16:06:23 +01002360 /* set capture source to mic-in */
2361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002365 /* speaker-out */
2366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2367 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2368 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2370 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2371 /* mic-in to input */
2372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2374 /* built-in mic */
2375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2377 /* jack sense */
2378 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2379 { }
2380};
2381
2382/* toggle speaker-output according to the hp-jack state */
2383static void alc880_lg_lw_automute(struct hda_codec *codec)
2384{
2385 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002386 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002387
2388 present = snd_hda_codec_read(codec, 0x1b, 0,
2389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002390 bits = present ? HDA_AMP_MUTE : 0;
2391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2392 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002393}
2394
2395static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2396{
2397 /* Looks like the unsol event is incompatible with the standard
2398 * definition. 4bit tag is placed at 28 bit!
2399 */
2400 if ((res >> 28) == 0x01)
2401 alc880_lg_lw_automute(codec);
2402}
2403
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002404static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2405 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2406 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2409 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2410 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2411 { } /* end */
2412};
2413
2414static struct hda_input_mux alc880_medion_rim_capture_source = {
2415 .num_items = 2,
2416 .items = {
2417 { "Mic", 0x0 },
2418 { "Internal Mic", 0x1 },
2419 },
2420};
2421
2422static struct hda_verb alc880_medion_rim_init_verbs[] = {
2423 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2424
2425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2427
2428 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2431 /* Mic2 (as headphone out) for HP output */
2432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2434 /* Internal Speaker */
2435 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2436 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2437
2438 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2439 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2440
2441 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2442 { }
2443};
2444
2445/* toggle speaker-output according to the hp-jack state */
2446static void alc880_medion_rim_automute(struct hda_codec *codec)
2447{
2448 unsigned int present;
2449 unsigned char bits;
2450
2451 present = snd_hda_codec_read(codec, 0x14, 0,
2452 AC_VERB_GET_PIN_SENSE, 0)
2453 & AC_PINSENSE_PRESENCE;
2454 bits = present ? HDA_AMP_MUTE : 0;
2455 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2456 HDA_AMP_MUTE, bits);
2457 if (present)
2458 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2459 else
2460 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2461}
2462
2463static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2464 unsigned int res)
2465{
2466 /* Looks like the unsol event is incompatible with the standard
2467 * definition. 4bit tag is placed at 28 bit!
2468 */
2469 if ((res >> 28) == ALC880_HP_EVENT)
2470 alc880_medion_rim_automute(codec);
2471}
2472
Takashi Iwaicb53c622007-08-10 17:21:45 +02002473#ifdef CONFIG_SND_HDA_POWER_SAVE
2474static struct hda_amp_list alc880_loopbacks[] = {
2475 { 0x0b, HDA_INPUT, 0 },
2476 { 0x0b, HDA_INPUT, 1 },
2477 { 0x0b, HDA_INPUT, 2 },
2478 { 0x0b, HDA_INPUT, 3 },
2479 { 0x0b, HDA_INPUT, 4 },
2480 { } /* end */
2481};
2482
2483static struct hda_amp_list alc880_lg_loopbacks[] = {
2484 { 0x0b, HDA_INPUT, 1 },
2485 { 0x0b, HDA_INPUT, 6 },
2486 { 0x0b, HDA_INPUT, 7 },
2487 { } /* end */
2488};
2489#endif
2490
Takashi Iwaid6815182006-03-23 16:06:23 +01002491/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002492 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002494
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495static int alc_init(struct hda_codec *codec)
2496{
2497 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 unsigned int i;
2499
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002500 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002501 if (codec->vendor_id == 0x10ec0888)
2502 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 for (i = 0; i < spec->num_init_verbs; i++)
2505 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002506
2507 if (spec->init_hook)
2508 spec->init_hook(codec);
2509
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 return 0;
2511}
2512
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002513static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2514{
2515 struct alc_spec *spec = codec->spec;
2516
2517 if (spec->unsol_event)
2518 spec->unsol_event(codec, res);
2519}
2520
Takashi Iwaicb53c622007-08-10 17:21:45 +02002521#ifdef CONFIG_SND_HDA_POWER_SAVE
2522static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2523{
2524 struct alc_spec *spec = codec->spec;
2525 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2526}
2527#endif
2528
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529/*
2530 * Analog playback callbacks
2531 */
2532static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2533 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002534 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535{
2536 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002537 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2538 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539}
2540
2541static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2542 struct hda_codec *codec,
2543 unsigned int stream_tag,
2544 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002545 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546{
2547 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002548 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2549 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550}
2551
2552static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2553 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002554 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555{
2556 struct alc_spec *spec = codec->spec;
2557 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2558}
2559
2560/*
2561 * Digital out
2562 */
2563static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2564 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002565 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566{
2567 struct alc_spec *spec = codec->spec;
2568 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2569}
2570
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002571static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2572 struct hda_codec *codec,
2573 unsigned int stream_tag,
2574 unsigned int format,
2575 struct snd_pcm_substream *substream)
2576{
2577 struct alc_spec *spec = codec->spec;
2578 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2579 stream_tag, format, substream);
2580}
2581
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2583 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002584 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585{
2586 struct alc_spec *spec = codec->spec;
2587 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2588}
2589
2590/*
2591 * Analog capture
2592 */
Takashi Iwai63300792008-01-24 15:31:36 +01002593static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 struct hda_codec *codec,
2595 unsigned int stream_tag,
2596 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002597 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598{
2599 struct alc_spec *spec = codec->spec;
2600
Takashi Iwai63300792008-01-24 15:31:36 +01002601 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 stream_tag, 0, format);
2603 return 0;
2604}
2605
Takashi Iwai63300792008-01-24 15:31:36 +01002606static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002608 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609{
2610 struct alc_spec *spec = codec->spec;
2611
Takashi Iwai888afa12008-03-18 09:57:50 +01002612 snd_hda_codec_cleanup_stream(codec,
2613 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 return 0;
2615}
2616
2617
2618/*
2619 */
2620static struct hda_pcm_stream alc880_pcm_analog_playback = {
2621 .substreams = 1,
2622 .channels_min = 2,
2623 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 .ops = {
2626 .open = alc880_playback_pcm_open,
2627 .prepare = alc880_playback_pcm_prepare,
2628 .cleanup = alc880_playback_pcm_cleanup
2629 },
2630};
2631
2632static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002633 .substreams = 1,
2634 .channels_min = 2,
2635 .channels_max = 2,
2636 /* NID is set in alc_build_pcms */
2637};
2638
2639static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2640 .substreams = 1,
2641 .channels_min = 2,
2642 .channels_max = 2,
2643 /* NID is set in alc_build_pcms */
2644};
2645
2646static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2647 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 .channels_min = 2,
2649 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002652 .prepare = alc880_alt_capture_pcm_prepare,
2653 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 },
2655};
2656
2657static struct hda_pcm_stream alc880_pcm_digital_playback = {
2658 .substreams = 1,
2659 .channels_min = 2,
2660 .channels_max = 2,
2661 /* NID is set in alc_build_pcms */
2662 .ops = {
2663 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002664 .close = alc880_dig_playback_pcm_close,
2665 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 },
2667};
2668
2669static struct hda_pcm_stream alc880_pcm_digital_capture = {
2670 .substreams = 1,
2671 .channels_min = 2,
2672 .channels_max = 2,
2673 /* NID is set in alc_build_pcms */
2674};
2675
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002676/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002677static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002678 .substreams = 0,
2679 .channels_min = 0,
2680 .channels_max = 0,
2681};
2682
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683static int alc_build_pcms(struct hda_codec *codec)
2684{
2685 struct alc_spec *spec = codec->spec;
2686 struct hda_pcm *info = spec->pcm_rec;
2687 int i;
2688
2689 codec->num_pcms = 1;
2690 codec->pcm_info = info;
2691
2692 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002693 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002694 if (snd_BUG_ON(!spec->multiout.dac_nids))
2695 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002696 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2697 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2698 }
2699 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002700 if (snd_BUG_ON(!spec->adc_nids))
2701 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002702 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2703 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2704 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705
Takashi Iwai4a471b72005-12-07 13:56:29 +01002706 if (spec->channel_mode) {
2707 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2708 for (i = 0; i < spec->num_channel_mode; i++) {
2709 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2710 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2711 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 }
2713 }
2714
Takashi Iwaie08a0072006-09-07 17:52:14 +02002715 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002717 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002718 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002720 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002721 if (spec->multiout.dig_out_nid &&
2722 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2724 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2725 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002726 if (spec->dig_in_nid &&
2727 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2729 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2730 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002731 /* FIXME: do we need this for all Realtek codec models? */
2732 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733 }
2734
Takashi Iwaie08a0072006-09-07 17:52:14 +02002735 /* If the use of more than one ADC is requested for the current
2736 * model, configure a second analog capture-only PCM.
2737 */
2738 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002739 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2740 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002741 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002742 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002743 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002744 if (spec->alt_dac_nid) {
2745 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2746 *spec->stream_analog_alt_playback;
2747 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2748 spec->alt_dac_nid;
2749 } else {
2750 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2751 alc_pcm_null_stream;
2752 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2753 }
2754 if (spec->num_adc_nids > 1) {
2755 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2756 *spec->stream_analog_alt_capture;
2757 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2758 spec->adc_nids[1];
2759 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2760 spec->num_adc_nids - 1;
2761 } else {
2762 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2763 alc_pcm_null_stream;
2764 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002765 }
2766 }
2767
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 return 0;
2769}
2770
2771static void alc_free(struct hda_codec *codec)
2772{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773 struct alc_spec *spec = codec->spec;
2774 unsigned int i;
2775
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002776 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 return;
2778
2779 if (spec->kctl_alloc) {
2780 for (i = 0; i < spec->num_kctl_used; i++)
2781 kfree(spec->kctl_alloc[i].name);
2782 kfree(spec->kctl_alloc);
2783 }
2784 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002785 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002786}
2787
Takashi Iwaie044c392008-10-27 16:56:24 +01002788#ifdef SND_HDA_NEEDS_RESUME
2789static void store_pin_configs(struct hda_codec *codec)
2790{
2791 struct alc_spec *spec = codec->spec;
2792 hda_nid_t nid, end_nid;
2793
2794 end_nid = codec->start_nid + codec->num_nodes;
2795 for (nid = codec->start_nid; nid < end_nid; nid++) {
2796 unsigned int wid_caps = get_wcaps(codec, nid);
2797 unsigned int wid_type =
2798 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2799 if (wid_type != AC_WID_PIN)
2800 continue;
2801 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
2802 break;
2803 spec->pin_nids[spec->num_pins] = nid;
2804 spec->pin_cfgs[spec->num_pins] =
2805 snd_hda_codec_read(codec, nid, 0,
2806 AC_VERB_GET_CONFIG_DEFAULT, 0);
2807 spec->num_pins++;
2808 }
2809}
2810
2811static void resume_pin_configs(struct hda_codec *codec)
2812{
2813 struct alc_spec *spec = codec->spec;
2814 int i;
2815
2816 for (i = 0; i < spec->num_pins; i++) {
2817 hda_nid_t pin_nid = spec->pin_nids[i];
2818 unsigned int pin_config = spec->pin_cfgs[i];
2819 snd_hda_codec_write(codec, pin_nid, 0,
2820 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2821 pin_config & 0x000000ff);
2822 snd_hda_codec_write(codec, pin_nid, 0,
2823 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2824 (pin_config & 0x0000ff00) >> 8);
2825 snd_hda_codec_write(codec, pin_nid, 0,
2826 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2827 (pin_config & 0x00ff0000) >> 16);
2828 snd_hda_codec_write(codec, pin_nid, 0,
2829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2830 pin_config >> 24);
2831 }
2832}
2833
2834static int alc_resume(struct hda_codec *codec)
2835{
2836 resume_pin_configs(codec);
2837 codec->patch_ops.init(codec);
2838 snd_hda_codec_resume_amp(codec);
2839 snd_hda_codec_resume_cache(codec);
2840 return 0;
2841}
2842#else
2843#define store_pin_configs(codec)
2844#endif
2845
Linus Torvalds1da177e2005-04-16 15:20:36 -07002846/*
2847 */
2848static struct hda_codec_ops alc_patch_ops = {
2849 .build_controls = alc_build_controls,
2850 .build_pcms = alc_build_pcms,
2851 .init = alc_init,
2852 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002853 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01002854#ifdef SND_HDA_NEEDS_RESUME
2855 .resume = alc_resume,
2856#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02002857#ifdef CONFIG_SND_HDA_POWER_SAVE
2858 .check_power_status = alc_check_power_status,
2859#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860};
2861
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002862
2863/*
2864 * Test configuration for debugging
2865 *
2866 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2867 * enum controls.
2868 */
2869#ifdef CONFIG_SND_DEBUG
2870static hda_nid_t alc880_test_dac_nids[4] = {
2871 0x02, 0x03, 0x04, 0x05
2872};
2873
2874static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002875 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002876 .items = {
2877 { "In-1", 0x0 },
2878 { "In-2", 0x1 },
2879 { "In-3", 0x2 },
2880 { "In-4", 0x3 },
2881 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002882 { "Front", 0x5 },
2883 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002884 },
2885};
2886
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002887static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002888 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002889 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002890 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002891 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002892};
2893
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002894static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2895 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002896{
2897 static char *texts[] = {
2898 "N/A", "Line Out", "HP Out",
2899 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2900 };
2901 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2902 uinfo->count = 1;
2903 uinfo->value.enumerated.items = 8;
2904 if (uinfo->value.enumerated.item >= 8)
2905 uinfo->value.enumerated.item = 7;
2906 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2907 return 0;
2908}
2909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002910static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2911 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002912{
2913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2914 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2915 unsigned int pin_ctl, item = 0;
2916
2917 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2918 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2919 if (pin_ctl & AC_PINCTL_OUT_EN) {
2920 if (pin_ctl & AC_PINCTL_HP_EN)
2921 item = 2;
2922 else
2923 item = 1;
2924 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2925 switch (pin_ctl & AC_PINCTL_VREFEN) {
2926 case AC_PINCTL_VREF_HIZ: item = 3; break;
2927 case AC_PINCTL_VREF_50: item = 4; break;
2928 case AC_PINCTL_VREF_GRD: item = 5; break;
2929 case AC_PINCTL_VREF_80: item = 6; break;
2930 case AC_PINCTL_VREF_100: item = 7; break;
2931 }
2932 }
2933 ucontrol->value.enumerated.item[0] = item;
2934 return 0;
2935}
2936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002937static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2938 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002939{
2940 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2941 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2942 static unsigned int ctls[] = {
2943 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2944 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2949 };
2950 unsigned int old_ctl, new_ctl;
2951
2952 old_ctl = snd_hda_codec_read(codec, nid, 0,
2953 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2954 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2955 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002956 int val;
2957 snd_hda_codec_write_cache(codec, nid, 0,
2958 AC_VERB_SET_PIN_WIDGET_CONTROL,
2959 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002960 val = ucontrol->value.enumerated.item[0] >= 3 ?
2961 HDA_AMP_MUTE : 0;
2962 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2963 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002964 return 1;
2965 }
2966 return 0;
2967}
2968
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002969static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2970 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002971{
2972 static char *texts[] = {
2973 "Front", "Surround", "CLFE", "Side"
2974 };
2975 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2976 uinfo->count = 1;
2977 uinfo->value.enumerated.items = 4;
2978 if (uinfo->value.enumerated.item >= 4)
2979 uinfo->value.enumerated.item = 3;
2980 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2981 return 0;
2982}
2983
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002984static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2985 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002986{
2987 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2988 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2989 unsigned int sel;
2990
2991 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2992 ucontrol->value.enumerated.item[0] = sel & 3;
2993 return 0;
2994}
2995
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002996static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2997 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002998{
2999 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3000 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3001 unsigned int sel;
3002
3003 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3004 if (ucontrol->value.enumerated.item[0] != sel) {
3005 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003006 snd_hda_codec_write_cache(codec, nid, 0,
3007 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003008 return 1;
3009 }
3010 return 0;
3011}
3012
3013#define PIN_CTL_TEST(xname,nid) { \
3014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3015 .name = xname, \
3016 .info = alc_test_pin_ctl_info, \
3017 .get = alc_test_pin_ctl_get, \
3018 .put = alc_test_pin_ctl_put, \
3019 .private_value = nid \
3020 }
3021
3022#define PIN_SRC_TEST(xname,nid) { \
3023 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3024 .name = xname, \
3025 .info = alc_test_pin_src_info, \
3026 .get = alc_test_pin_src_get, \
3027 .put = alc_test_pin_src_put, \
3028 .private_value = nid \
3029 }
3030
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003031static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3034 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3035 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003036 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3037 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3038 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3039 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003040 PIN_CTL_TEST("Front Pin Mode", 0x14),
3041 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3042 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3043 PIN_CTL_TEST("Side Pin Mode", 0x17),
3044 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3045 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3046 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3047 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3048 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3049 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3050 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3051 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3052 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3053 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3054 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3055 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3056 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3057 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3058 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3059 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003062 {
3063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3064 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003065 .info = alc_ch_mode_info,
3066 .get = alc_ch_mode_get,
3067 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003068 },
3069 { } /* end */
3070};
3071
3072static struct hda_verb alc880_test_init_verbs[] = {
3073 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003082 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003087 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3090 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3091 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003092 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003093 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003097 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003098 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3099 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3101 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3102 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003103 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003104 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3105 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3107 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003108 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003110 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003112 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003113 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003114 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003115 /* Analog input/passthru */
3116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003121 { }
3122};
3123#endif
3124
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125/*
3126 */
3127
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003128static const char *alc880_models[ALC880_MODEL_LAST] = {
3129 [ALC880_3ST] = "3stack",
3130 [ALC880_TCL_S700] = "tcl",
3131 [ALC880_3ST_DIG] = "3stack-digout",
3132 [ALC880_CLEVO] = "clevo",
3133 [ALC880_5ST] = "5stack",
3134 [ALC880_5ST_DIG] = "5stack-digout",
3135 [ALC880_W810] = "w810",
3136 [ALC880_Z71V] = "z71v",
3137 [ALC880_6ST] = "6stack",
3138 [ALC880_6ST_DIG] = "6stack-digout",
3139 [ALC880_ASUS] = "asus",
3140 [ALC880_ASUS_W1V] = "asus-w1v",
3141 [ALC880_ASUS_DIG] = "asus-dig",
3142 [ALC880_ASUS_DIG2] = "asus-dig2",
3143 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003144 [ALC880_UNIWILL_P53] = "uniwill-p53",
3145 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003146 [ALC880_F1734] = "F1734",
3147 [ALC880_LG] = "lg",
3148 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003149 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003150#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003151 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003152#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003153 [ALC880_AUTO] = "auto",
3154};
3155
3156static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003157 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003158 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3159 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3160 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3161 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3162 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3163 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3164 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3165 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003166 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3167 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003168 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3169 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3170 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3171 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3172 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3173 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3174 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3175 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3176 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3177 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003178 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003179 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3180 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3181 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003182 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003183 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003184 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3185 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003186 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3187 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003188 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3189 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3190 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3191 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003192 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3193 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003194 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003195 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003196 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003197 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003198 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3199 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003200 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003201 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003202 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003203 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003204 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003205 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003206 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003207 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003208 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003209 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3210 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003211 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003212 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3213 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3214 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3215 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003216 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3217 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003218 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003219 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003220 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3221 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003222 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3223 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3224 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003225 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3226 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3227 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228 {}
3229};
3230
Takashi Iwai16ded522005-06-10 19:58:24 +02003231/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003232 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003233 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003234static struct alc_config_preset alc880_presets[] = {
3235 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003239 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3242 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003243 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003244 .input_mux = &alc880_capture_source,
3245 },
3246 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003248 .init_verbs = { alc880_volume_init_verbs,
3249 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003250 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003251 .dac_nids = alc880_dac_nids,
3252 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003253 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3254 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003255 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 .input_mux = &alc880_capture_source,
3257 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003258 [ALC880_TCL_S700] = {
3259 .mixers = { alc880_tcl_s700_mixer },
3260 .init_verbs = { alc880_volume_init_verbs,
3261 alc880_pin_tcl_S700_init_verbs,
3262 alc880_gpio2_init_verbs },
3263 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3264 .dac_nids = alc880_dac_nids,
3265 .hp_nid = 0x03,
3266 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3267 .channel_mode = alc880_2_jack_modes,
3268 .input_mux = &alc880_capture_source,
3269 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003270 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003271 .mixers = { alc880_three_stack_mixer,
3272 alc880_five_stack_mixer},
3273 .init_verbs = { alc880_volume_init_verbs,
3274 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003275 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3276 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003277 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3278 .channel_mode = alc880_fivestack_modes,
3279 .input_mux = &alc880_capture_source,
3280 },
3281 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003282 .mixers = { alc880_three_stack_mixer,
3283 alc880_five_stack_mixer },
3284 .init_verbs = { alc880_volume_init_verbs,
3285 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003286 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3287 .dac_nids = alc880_dac_nids,
3288 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003289 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3290 .channel_mode = alc880_fivestack_modes,
3291 .input_mux = &alc880_capture_source,
3292 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003293 [ALC880_6ST] = {
3294 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003295 .init_verbs = { alc880_volume_init_verbs,
3296 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003297 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3298 .dac_nids = alc880_6st_dac_nids,
3299 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3300 .channel_mode = alc880_sixstack_modes,
3301 .input_mux = &alc880_6stack_capture_source,
3302 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003303 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003304 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003305 .init_verbs = { alc880_volume_init_verbs,
3306 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003307 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3308 .dac_nids = alc880_6st_dac_nids,
3309 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003310 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3311 .channel_mode = alc880_sixstack_modes,
3312 .input_mux = &alc880_6stack_capture_source,
3313 },
3314 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003316 .init_verbs = { alc880_volume_init_verbs,
3317 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003318 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003319 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3320 .dac_nids = alc880_w810_dac_nids,
3321 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003322 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3323 .channel_mode = alc880_w810_modes,
3324 .input_mux = &alc880_capture_source,
3325 },
3326 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003328 .init_verbs = { alc880_volume_init_verbs,
3329 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003330 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3331 .dac_nids = alc880_z71v_dac_nids,
3332 .dig_out_nid = ALC880_DIGOUT_NID,
3333 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003334 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3335 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003336 .input_mux = &alc880_capture_source,
3337 },
3338 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003339 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003340 .init_verbs = { alc880_volume_init_verbs,
3341 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003342 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3343 .dac_nids = alc880_f1734_dac_nids,
3344 .hp_nid = 0x02,
3345 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3346 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003347 .input_mux = &alc880_f1734_capture_source,
3348 .unsol_event = alc880_uniwill_p53_unsol_event,
3349 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003350 },
3351 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003353 .init_verbs = { alc880_volume_init_verbs,
3354 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 alc880_gpio1_init_verbs },
3356 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3357 .dac_nids = alc880_asus_dac_nids,
3358 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3359 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003360 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003361 .input_mux = &alc880_capture_source,
3362 },
3363 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003365 .init_verbs = { alc880_volume_init_verbs,
3366 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003367 alc880_gpio1_init_verbs },
3368 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3369 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003370 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003371 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3372 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003373 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003374 .input_mux = &alc880_capture_source,
3375 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003376 [ALC880_ASUS_DIG2] = {
3377 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 .init_verbs = { alc880_volume_init_verbs,
3379 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003380 alc880_gpio2_init_verbs }, /* use GPIO2 */
3381 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3382 .dac_nids = alc880_asus_dac_nids,
3383 .dig_out_nid = ALC880_DIGOUT_NID,
3384 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3385 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003386 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003387 .input_mux = &alc880_capture_source,
3388 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003389 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003391 .init_verbs = { alc880_volume_init_verbs,
3392 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003393 alc880_gpio1_init_verbs },
3394 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3395 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003396 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003397 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3398 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003399 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003400 .input_mux = &alc880_capture_source,
3401 },
3402 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003403 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003404 .init_verbs = { alc880_volume_init_verbs,
3405 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3407 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003408 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3410 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003411 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003412 .input_mux = &alc880_capture_source,
3413 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003414 [ALC880_UNIWILL] = {
3415 .mixers = { alc880_uniwill_mixer },
3416 .init_verbs = { alc880_volume_init_verbs,
3417 alc880_uniwill_init_verbs },
3418 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3419 .dac_nids = alc880_asus_dac_nids,
3420 .dig_out_nid = ALC880_DIGOUT_NID,
3421 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3422 .channel_mode = alc880_threestack_modes,
3423 .need_dac_fix = 1,
3424 .input_mux = &alc880_capture_source,
3425 .unsol_event = alc880_uniwill_unsol_event,
3426 .init_hook = alc880_uniwill_automute,
3427 },
3428 [ALC880_UNIWILL_P53] = {
3429 .mixers = { alc880_uniwill_p53_mixer },
3430 .init_verbs = { alc880_volume_init_verbs,
3431 alc880_uniwill_p53_init_verbs },
3432 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3433 .dac_nids = alc880_asus_dac_nids,
3434 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003435 .channel_mode = alc880_threestack_modes,
3436 .input_mux = &alc880_capture_source,
3437 .unsol_event = alc880_uniwill_p53_unsol_event,
3438 .init_hook = alc880_uniwill_p53_hp_automute,
3439 },
3440 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003441 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003442 alc880_pcbeep_mixer, },
3443 .init_verbs = { alc880_volume_init_verbs,
3444 alc880_uniwill_p53_init_verbs,
3445 alc880_beep_init_verbs },
3446 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3447 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003448 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003449 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3450 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003451 .input_mux = &alc880_capture_source,
3452 .unsol_event = alc880_uniwill_p53_unsol_event,
3453 .init_hook = alc880_uniwill_p53_hp_automute,
3454 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003455 [ALC880_CLEVO] = {
3456 .mixers = { alc880_three_stack_mixer },
3457 .init_verbs = { alc880_volume_init_verbs,
3458 alc880_pin_clevo_init_verbs },
3459 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3460 .dac_nids = alc880_dac_nids,
3461 .hp_nid = 0x03,
3462 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3463 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003464 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003465 .input_mux = &alc880_capture_source,
3466 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003467 [ALC880_LG] = {
3468 .mixers = { alc880_lg_mixer },
3469 .init_verbs = { alc880_volume_init_verbs,
3470 alc880_lg_init_verbs },
3471 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3472 .dac_nids = alc880_lg_dac_nids,
3473 .dig_out_nid = ALC880_DIGOUT_NID,
3474 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3475 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003476 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003477 .input_mux = &alc880_lg_capture_source,
3478 .unsol_event = alc880_lg_unsol_event,
3479 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003480#ifdef CONFIG_SND_HDA_POWER_SAVE
3481 .loopbacks = alc880_lg_loopbacks,
3482#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003483 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003484 [ALC880_LG_LW] = {
3485 .mixers = { alc880_lg_lw_mixer },
3486 .init_verbs = { alc880_volume_init_verbs,
3487 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003488 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003489 .dac_nids = alc880_dac_nids,
3490 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003491 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3492 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003493 .input_mux = &alc880_lg_lw_capture_source,
3494 .unsol_event = alc880_lg_lw_unsol_event,
3495 .init_hook = alc880_lg_lw_automute,
3496 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003497 [ALC880_MEDION_RIM] = {
3498 .mixers = { alc880_medion_rim_mixer },
3499 .init_verbs = { alc880_volume_init_verbs,
3500 alc880_medion_rim_init_verbs,
3501 alc_gpio2_init_verbs },
3502 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3503 .dac_nids = alc880_dac_nids,
3504 .dig_out_nid = ALC880_DIGOUT_NID,
3505 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3506 .channel_mode = alc880_2_jack_modes,
3507 .input_mux = &alc880_medion_rim_capture_source,
3508 .unsol_event = alc880_medion_rim_unsol_event,
3509 .init_hook = alc880_medion_rim_automute,
3510 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003511#ifdef CONFIG_SND_DEBUG
3512 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 .mixers = { alc880_test_mixer },
3514 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003515 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3516 .dac_nids = alc880_test_dac_nids,
3517 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003518 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3519 .channel_mode = alc880_test_modes,
3520 .input_mux = &alc880_test_capture_source,
3521 },
3522#endif
3523};
3524
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525/*
3526 * Automatic parse of I/O pins from the BIOS configuration
3527 */
3528
3529#define NUM_CONTROL_ALLOC 32
3530#define NUM_VERB_ALLOC 32
3531
3532enum {
3533 ALC_CTL_WIDGET_VOL,
3534 ALC_CTL_WIDGET_MUTE,
3535 ALC_CTL_BIND_MUTE,
3536};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003537static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3539 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003540 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003541};
3542
3543/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003544static int add_control(struct alc_spec *spec, int type, const char *name,
3545 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003546{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003547 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548
3549 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3550 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3551
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003552 /* array + terminator */
3553 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3554 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003555 return -ENOMEM;
3556 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003557 memcpy(knew, spec->kctl_alloc,
3558 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559 kfree(spec->kctl_alloc);
3560 }
3561 spec->kctl_alloc = knew;
3562 spec->num_kctl_alloc = num;
3563 }
3564
3565 knew = &spec->kctl_alloc[spec->num_kctl_used];
3566 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003567 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003568 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 return -ENOMEM;
3570 knew->private_value = val;
3571 spec->num_kctl_used++;
3572 return 0;
3573}
3574
3575#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3576#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3577#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3578#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3579#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3580#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3581#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3582#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3583#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3584#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3585#define ALC880_PIN_CD_NID 0x1c
3586
3587/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003588static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3589 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590{
3591 hda_nid_t nid;
3592 int assigned[4];
3593 int i, j;
3594
3595 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003596 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597
3598 /* check the pins hardwired to audio widget */
3599 for (i = 0; i < cfg->line_outs; i++) {
3600 nid = cfg->line_out_pins[i];
3601 if (alc880_is_fixed_pin(nid)) {
3602 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003603 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003604 assigned[idx] = 1;
3605 }
3606 }
3607 /* left pins can be connect to any audio widget */
3608 for (i = 0; i < cfg->line_outs; i++) {
3609 nid = cfg->line_out_pins[i];
3610 if (alc880_is_fixed_pin(nid))
3611 continue;
3612 /* search for an empty channel */
3613 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003614 if (!assigned[j]) {
3615 spec->multiout.dac_nids[i] =
3616 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003617 assigned[j] = 1;
3618 break;
3619 }
3620 }
3621 }
3622 spec->multiout.num_dacs = cfg->line_outs;
3623 return 0;
3624}
3625
3626/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003627static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3628 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629{
3630 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003631 static const char *chname[4] = {
3632 "Front", "Surround", NULL /*CLFE*/, "Side"
3633 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003634 hda_nid_t nid;
3635 int i, err;
3636
3637 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003638 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003639 continue;
3640 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3641 if (i == 2) {
3642 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003643 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3644 "Center Playback Volume",
3645 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3646 HDA_OUTPUT));
3647 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003648 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003649 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3650 "LFE Playback Volume",
3651 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3652 HDA_OUTPUT));
3653 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003654 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003655 err = add_control(spec, ALC_CTL_BIND_MUTE,
3656 "Center Playback Switch",
3657 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3658 HDA_INPUT));
3659 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003660 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003661 err = add_control(spec, ALC_CTL_BIND_MUTE,
3662 "LFE Playback Switch",
3663 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3664 HDA_INPUT));
3665 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666 return err;
3667 } else {
3668 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003669 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3670 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3671 HDA_OUTPUT));
3672 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003673 return err;
3674 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003675 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3676 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3677 HDA_INPUT));
3678 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003679 return err;
3680 }
3681 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003682 return 0;
3683}
3684
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003685/* add playback controls for speaker and HP outputs */
3686static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3687 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688{
3689 hda_nid_t nid;
3690 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003691 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003692
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003694 return 0;
3695
3696 if (alc880_is_fixed_pin(pin)) {
3697 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003698 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003699 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003700 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003701 else
3702 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003703 /* control HP volume/switch on the output mixer amp */
3704 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003705 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003706 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3707 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3708 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003710 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003711 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3712 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3713 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 return err;
3715 } else if (alc880_is_multi_pin(pin)) {
3716 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003718 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003719 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3720 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3721 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722 return err;
3723 }
3724 return 0;
3725}
3726
3727/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003728static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3729 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003730 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003731{
3732 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003733 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003734
3735 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003736 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3737 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3738 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739 return err;
3740 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003741 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3742 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3743 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 return err;
3745 return 0;
3746}
3747
3748/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003749static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3750 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003753 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003754
3755 for (i = 0; i < AUTO_PIN_LAST; i++) {
3756 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003757 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003758 err = new_analog_input(spec, cfg->input_pins[i],
3759 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003760 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 if (err < 0)
3762 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003763 imux->items[imux->num_items].label =
3764 auto_pin_cfg_labels[i];
3765 imux->items[imux->num_items].index =
3766 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003767 imux->num_items++;
3768 }
3769 }
3770 return 0;
3771}
3772
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003773static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3774 unsigned int pin_type)
3775{
3776 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3777 pin_type);
3778 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3780 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003781}
3782
Kailang Yangdf694da2005-12-05 19:42:22 +01003783static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3784 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 int dac_idx)
3786{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003787 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 /* need the manual connection? */
3789 if (alc880_is_multi_pin(nid)) {
3790 struct alc_spec *spec = codec->spec;
3791 int idx = alc880_multi_pin_idx(nid);
3792 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3793 AC_VERB_SET_CONNECT_SEL,
3794 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3795 }
3796}
3797
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003798static int get_pin_type(int line_out_type)
3799{
3800 if (line_out_type == AUTO_PIN_HP_OUT)
3801 return PIN_HP;
3802 else
3803 return PIN_OUT;
3804}
3805
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806static void alc880_auto_init_multi_out(struct hda_codec *codec)
3807{
3808 struct alc_spec *spec = codec->spec;
3809 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003810
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003811 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812 for (i = 0; i < spec->autocfg.line_outs; i++) {
3813 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003814 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3815 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003816 }
3817}
3818
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003819static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003820{
3821 struct alc_spec *spec = codec->spec;
3822 hda_nid_t pin;
3823
Takashi Iwai82bc9552006-03-21 11:24:42 +01003824 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003825 if (pin) /* connect to front */
3826 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003827 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 if (pin) /* connect to front */
3829 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3830}
3831
3832static void alc880_auto_init_analog_input(struct hda_codec *codec)
3833{
3834 struct alc_spec *spec = codec->spec;
3835 int i;
3836
3837 for (i = 0; i < AUTO_PIN_LAST; i++) {
3838 hda_nid_t nid = spec->autocfg.input_pins[i];
3839 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003840 snd_hda_codec_write(codec, nid, 0,
3841 AC_VERB_SET_PIN_WIDGET_CONTROL,
3842 i <= AUTO_PIN_FRONT_MIC ?
3843 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003845 snd_hda_codec_write(codec, nid, 0,
3846 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003847 AMP_OUT_MUTE);
3848 }
3849 }
3850}
3851
3852/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003853/* return 1 if successful, 0 if the proper config is not found,
3854 * or a negative error code
3855 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856static int alc880_parse_auto_config(struct hda_codec *codec)
3857{
3858 struct alc_spec *spec = codec->spec;
3859 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003860 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003862 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3863 alc880_ignore);
3864 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003865 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003866 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003867 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003868
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003869 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3870 if (err < 0)
3871 return err;
3872 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3873 if (err < 0)
3874 return err;
3875 err = alc880_auto_create_extra_out(spec,
3876 spec->autocfg.speaker_pins[0],
3877 "Speaker");
3878 if (err < 0)
3879 return err;
3880 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3881 "Headphone");
3882 if (err < 0)
3883 return err;
3884 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3885 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003886 return err;
3887
3888 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3889
3890 if (spec->autocfg.dig_out_pin)
3891 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3892 if (spec->autocfg.dig_in_pin)
3893 spec->dig_in_nid = ALC880_DIGIN_NID;
3894
3895 if (spec->kctl_alloc)
3896 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3897
3898 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3899
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003900 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003901 spec->input_mux = &spec->private_imux;
3902
Takashi Iwaie044c392008-10-27 16:56:24 +01003903 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003904 return 1;
3905}
3906
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003907/* additional initialization for auto-configuration model */
3908static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003909{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003910 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003912 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003913 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003914 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02003915 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003916}
3917
3918/*
3919 * OK, here we have finally the patch for ALC880
3920 */
3921
Linus Torvalds1da177e2005-04-16 15:20:36 -07003922static int patch_alc880(struct hda_codec *codec)
3923{
3924 struct alc_spec *spec;
3925 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003926 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003927
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003929 if (spec == NULL)
3930 return -ENOMEM;
3931
3932 codec->spec = spec;
3933
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003934 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3935 alc880_models,
3936 alc880_cfg_tbl);
3937 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003938 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3939 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003940 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003941 }
3942
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003943 if (board_config == ALC880_AUTO) {
3944 /* automatic parse from the BIOS config */
3945 err = alc880_parse_auto_config(codec);
3946 if (err < 0) {
3947 alc_free(codec);
3948 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003949 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003950 printk(KERN_INFO
3951 "hda_codec: Cannot set up configuration "
3952 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003953 board_config = ALC880_3ST;
3954 }
3955 }
3956
Kailang Yangdf694da2005-12-05 19:42:22 +01003957 if (board_config != ALC880_AUTO)
3958 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959
3960 spec->stream_name_analog = "ALC880 Analog";
3961 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3962 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003963 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964
3965 spec->stream_name_digital = "ALC880 Digital";
3966 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3967 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3968
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003969 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003971 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972 /* get type */
3973 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974 if (wcap != AC_WID_AUD_IN) {
3975 spec->adc_nids = alc880_adc_nids_alt;
3976 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003977 spec->mixers[spec->num_mixers] =
3978 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003979 spec->num_mixers++;
3980 } else {
3981 spec->adc_nids = alc880_adc_nids;
3982 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3983 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3984 spec->num_mixers++;
3985 }
3986 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987
Takashi Iwai2134ea42008-01-10 16:53:55 +01003988 spec->vmaster_nid = 0x0c;
3989
Linus Torvalds1da177e2005-04-16 15:20:36 -07003990 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003992 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003993#ifdef CONFIG_SND_HDA_POWER_SAVE
3994 if (!spec->loopback.amplist)
3995 spec->loopback.amplist = alc880_loopbacks;
3996#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003997
3998 return 0;
3999}
4000
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001
Linus Torvalds1da177e2005-04-16 15:20:36 -07004002/*
4003 * ALC260 support
4004 */
4005
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006static hda_nid_t alc260_dac_nids[1] = {
4007 /* front */
4008 0x02,
4009};
4010
4011static hda_nid_t alc260_adc_nids[1] = {
4012 /* ADC0 */
4013 0x04,
4014};
4015
Kailang Yangdf694da2005-12-05 19:42:22 +01004016static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 /* ADC1 */
4018 0x05,
4019};
4020
Kailang Yangdf694da2005-12-05 19:42:22 +01004021static hda_nid_t alc260_hp_adc_nids[2] = {
4022 /* ADC1, 0 */
4023 0x05, 0x04
4024};
4025
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004026/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4027 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4028 */
4029static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004030 /* ADC0, ADC1 */
4031 0x04, 0x05
4032};
4033
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004034#define ALC260_DIGOUT_NID 0x03
4035#define ALC260_DIGIN_NID 0x06
4036
4037static struct hda_input_mux alc260_capture_source = {
4038 .num_items = 4,
4039 .items = {
4040 { "Mic", 0x0 },
4041 { "Front Mic", 0x1 },
4042 { "Line", 0x2 },
4043 { "CD", 0x4 },
4044 },
4045};
4046
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004047/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004048 * headphone jack and the internal CD lines since these are the only pins at
4049 * which audio can appear. For flexibility, also allow the option of
4050 * recording the mixer output on the second ADC (ADC0 doesn't have a
4051 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004052 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004053static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4054 {
4055 .num_items = 3,
4056 .items = {
4057 { "Mic/Line", 0x0 },
4058 { "CD", 0x4 },
4059 { "Headphone", 0x2 },
4060 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004061 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004062 {
4063 .num_items = 4,
4064 .items = {
4065 { "Mic/Line", 0x0 },
4066 { "CD", 0x4 },
4067 { "Headphone", 0x2 },
4068 { "Mixer", 0x5 },
4069 },
4070 },
4071
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004072};
4073
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004074/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4075 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004076 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004077static struct hda_input_mux alc260_acer_capture_sources[2] = {
4078 {
4079 .num_items = 4,
4080 .items = {
4081 { "Mic", 0x0 },
4082 { "Line", 0x2 },
4083 { "CD", 0x4 },
4084 { "Headphone", 0x5 },
4085 },
4086 },
4087 {
4088 .num_items = 5,
4089 .items = {
4090 { "Mic", 0x0 },
4091 { "Line", 0x2 },
4092 { "CD", 0x4 },
4093 { "Headphone", 0x6 },
4094 { "Mixer", 0x5 },
4095 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004096 },
4097};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098/*
4099 * This is just place-holder, so there's something for alc_build_pcms to look
4100 * at when it calculates the maximum number of channels. ALC260 has no mixer
4101 * element which allows changing the channel mode, so the verb list is
4102 * never used.
4103 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004104static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004105 { 2, NULL },
4106};
4107
Kailang Yangdf694da2005-12-05 19:42:22 +01004108
4109/* Mixer combinations
4110 *
4111 * basic: base_output + input + pc_beep + capture
4112 * HP: base_output + input + capture_alt
4113 * HP_3013: hp_3013 + input + capture
4114 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004115 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004116 */
4117
4118static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004119 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004120 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004121 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4122 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4123 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4124 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4125 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126};
Kailang Yangdf694da2005-12-05 19:42:22 +01004127
4128static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4130 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4131 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4132 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4134 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4135 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4136 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004137 { } /* end */
4138};
4139
Kailang Yangdf694da2005-12-05 19:42:22 +01004140static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4141 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4142 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4143 { } /* end */
4144};
4145
Takashi Iwaibec15c32008-01-28 18:16:30 +01004146/* update HP, line and mono out pins according to the master switch */
4147static void alc260_hp_master_update(struct hda_codec *codec,
4148 hda_nid_t hp, hda_nid_t line,
4149 hda_nid_t mono)
4150{
4151 struct alc_spec *spec = codec->spec;
4152 unsigned int val = spec->master_sw ? PIN_HP : 0;
4153 /* change HP and line-out pins */
4154 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4155 val);
4156 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4157 val);
4158 /* mono (speaker) depending on the HP jack sense */
4159 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4160 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4161 val);
4162}
4163
4164static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4165 struct snd_ctl_elem_value *ucontrol)
4166{
4167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4168 struct alc_spec *spec = codec->spec;
4169 *ucontrol->value.integer.value = spec->master_sw;
4170 return 0;
4171}
4172
4173static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4174 struct snd_ctl_elem_value *ucontrol)
4175{
4176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4177 struct alc_spec *spec = codec->spec;
4178 int val = !!*ucontrol->value.integer.value;
4179 hda_nid_t hp, line, mono;
4180
4181 if (val == spec->master_sw)
4182 return 0;
4183 spec->master_sw = val;
4184 hp = (kcontrol->private_value >> 16) & 0xff;
4185 line = (kcontrol->private_value >> 8) & 0xff;
4186 mono = kcontrol->private_value & 0xff;
4187 alc260_hp_master_update(codec, hp, line, mono);
4188 return 1;
4189}
4190
4191static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4192 {
4193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4194 .name = "Master Playback Switch",
4195 .info = snd_ctl_boolean_mono_info,
4196 .get = alc260_hp_master_sw_get,
4197 .put = alc260_hp_master_sw_put,
4198 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4199 },
4200 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4201 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4203 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4204 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4205 HDA_OUTPUT),
4206 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4207 { } /* end */
4208};
4209
4210static struct hda_verb alc260_hp_unsol_verbs[] = {
4211 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4212 {},
4213};
4214
4215static void alc260_hp_automute(struct hda_codec *codec)
4216{
4217 struct alc_spec *spec = codec->spec;
4218 unsigned int present;
4219
4220 present = snd_hda_codec_read(codec, 0x10, 0,
4221 AC_VERB_GET_PIN_SENSE, 0);
4222 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4223 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4224}
4225
4226static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4227{
4228 if ((res >> 26) == ALC880_HP_EVENT)
4229 alc260_hp_automute(codec);
4230}
4231
Kailang Yangdf694da2005-12-05 19:42:22 +01004232static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004233 {
4234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4235 .name = "Master Playback Switch",
4236 .info = snd_ctl_boolean_mono_info,
4237 .get = alc260_hp_master_sw_get,
4238 .put = alc260_hp_master_sw_put,
4239 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4240 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004241 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4242 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4243 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4244 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004247 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4248 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004249 { } /* end */
4250};
4251
Kailang Yang3f878302008-08-26 13:02:23 +02004252static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4253 .ops = &snd_hda_bind_vol,
4254 .values = {
4255 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4256 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4257 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4258 0
4259 },
4260};
4261
4262static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4263 .ops = &snd_hda_bind_sw,
4264 .values = {
4265 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4266 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4267 0
4268 },
4269};
4270
4271static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4272 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4273 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4274 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4276 { } /* end */
4277};
4278
Takashi Iwaibec15c32008-01-28 18:16:30 +01004279static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4280 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4281 {},
4282};
4283
4284static void alc260_hp_3013_automute(struct hda_codec *codec)
4285{
4286 struct alc_spec *spec = codec->spec;
4287 unsigned int present;
4288
4289 present = snd_hda_codec_read(codec, 0x15, 0,
4290 AC_VERB_GET_PIN_SENSE, 0);
4291 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4292 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4293}
4294
4295static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4296 unsigned int res)
4297{
4298 if ((res >> 26) == ALC880_HP_EVENT)
4299 alc260_hp_3013_automute(codec);
4300}
4301
Kailang Yang3f878302008-08-26 13:02:23 +02004302static void alc260_hp_3012_automute(struct hda_codec *codec)
4303{
4304 unsigned int present, bits;
4305
4306 present = snd_hda_codec_read(codec, 0x10, 0,
4307 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4308
4309 bits = present ? 0 : PIN_OUT;
4310 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4311 bits);
4312 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4313 bits);
4314 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4315 bits);
4316}
4317
4318static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4319 unsigned int res)
4320{
4321 if ((res >> 26) == ALC880_HP_EVENT)
4322 alc260_hp_3012_automute(codec);
4323}
4324
4325/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004326 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4327 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004328static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004330 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004331 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004332 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4333 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4334 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4335 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004336 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004337 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4338 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004339 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4340 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004341 { } /* end */
4342};
4343
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004344/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4345 * versions of the ALC260 don't act on requests to enable mic bias from NID
4346 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4347 * datasheet doesn't mention this restriction. At this stage it's not clear
4348 * whether this behaviour is intentional or is a hardware bug in chip
4349 * revisions available in early 2006. Therefore for now allow the
4350 * "Headphone Jack Mode" control to span all choices, but if it turns out
4351 * that the lack of mic bias for this NID is intentional we could change the
4352 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4353 *
4354 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4355 * don't appear to make the mic bias available from the "line" jack, even
4356 * though the NID used for this jack (0x14) can supply it. The theory is
4357 * that perhaps Acer have included blocking capacitors between the ALC260
4358 * and the output jack. If this turns out to be the case for all such
4359 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4360 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004361 *
4362 * The C20x Tablet series have a mono internal speaker which is controlled
4363 * via the chip's Mono sum widget and pin complex, so include the necessary
4364 * controls for such models. On models without a "mono speaker" the control
4365 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004366 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004367static struct snd_kcontrol_new alc260_acer_mixer[] = {
4368 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4369 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004370 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004371 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004372 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004373 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004374 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004375 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4376 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4378 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4379 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4380 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4381 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4382 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4383 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4384 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4385 { } /* end */
4386};
4387
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004388/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4389 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4390 */
4391static struct snd_kcontrol_new alc260_will_mixer[] = {
4392 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4393 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4395 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4396 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4397 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4398 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4399 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4400 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4401 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4402 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4403 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4404 { } /* end */
4405};
4406
4407/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4408 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4409 */
4410static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4411 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4412 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4414 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4415 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4416 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4417 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4418 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4419 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4420 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4421 { } /* end */
4422};
4423
Kailang Yangdf694da2005-12-05 19:42:22 +01004424/* capture mixer elements */
4425static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004426 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4427 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004428 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4429 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004430 {
4431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004432 /* The multiple "Capture Source" controls confuse alsamixer
4433 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004434 */
4435 /* .name = "Capture Source", */
4436 .name = "Input Source",
4437 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004438 .info = alc_mux_enum_info,
4439 .get = alc_mux_enum_get,
4440 .put = alc_mux_enum_put,
4441 },
4442 { } /* end */
4443};
4444
Kailang Yangdf694da2005-12-05 19:42:22 +01004445static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4446 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4447 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4448 {
4449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4450 /* The multiple "Capture Source" controls confuse alsamixer
4451 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004452 */
4453 /* .name = "Capture Source", */
4454 .name = "Input Source",
4455 .count = 1,
4456 .info = alc_mux_enum_info,
4457 .get = alc_mux_enum_get,
4458 .put = alc_mux_enum_put,
4459 },
4460 { } /* end */
4461};
4462
4463/*
4464 * initialization verbs
4465 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004466static struct hda_verb alc260_init_verbs[] = {
4467 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004469 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004471 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004473 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004474 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004475 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004477 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004478 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004479 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004480 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004481 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004482 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004483 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4485 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004487 /* set connection select to line in (default select for this ADC) */
4488 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004489 /* mute capture amp left and right */
4490 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 /* set connection select to line in (default select for this ADC) */
4492 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004493 /* set vol=0 Line-Out mixer amp left and right */
4494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4495 /* unmute pin widget amp left and right (no gain on this amp) */
4496 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4497 /* set vol=0 HP mixer amp left and right */
4498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4499 /* unmute pin widget amp left and right (no gain on this amp) */
4500 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4501 /* set vol=0 Mono mixer amp left and right */
4502 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4503 /* unmute pin widget amp left and right (no gain on this amp) */
4504 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4505 /* unmute LINE-2 out pin */
4506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004507 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4508 * Line In 2 = 0x03
4509 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004510 /* mute analog inputs */
4511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4514 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4515 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004516 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004517 /* mute Front out path */
4518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4519 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4520 /* mute Headphone out path */
4521 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4523 /* mute Mono out path */
4524 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4525 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004526 { }
4527};
4528
Takashi Iwai474167d2006-05-17 17:17:43 +02004529#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004530static struct hda_verb alc260_hp_init_verbs[] = {
4531 /* Headphone and output */
4532 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4533 /* mono output */
4534 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4535 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4536 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4537 /* Mic2 (front panel) pin widget for input and vref at 80% */
4538 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4539 /* Line In pin widget for input */
4540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4541 /* Line-2 pin widget for output */
4542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4543 /* CD pin widget for input */
4544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4545 /* unmute amp left and right */
4546 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4547 /* set connection select to line in (default select for this ADC) */
4548 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4549 /* unmute Line-Out mixer amp left and right (volume = 0) */
4550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4551 /* mute pin widget amp left and right (no gain on this amp) */
4552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4553 /* unmute HP mixer amp left and right (volume = 0) */
4554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4555 /* mute pin widget amp left and right (no gain on this amp) */
4556 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004557 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4558 * Line In 2 = 0x03
4559 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004560 /* mute analog inputs */
4561 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004566 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4567 /* Unmute Front out path */
4568 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4570 /* Unmute Headphone out path */
4571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4573 /* Unmute Mono out path */
4574 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4575 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4576 { }
4577};
Takashi Iwai474167d2006-05-17 17:17:43 +02004578#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004579
4580static struct hda_verb alc260_hp_3013_init_verbs[] = {
4581 /* Line out and output */
4582 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4583 /* mono output */
4584 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4585 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4587 /* Mic2 (front panel) pin widget for input and vref at 80% */
4588 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4589 /* Line In pin widget for input */
4590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4591 /* Headphone pin widget for output */
4592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4593 /* CD pin widget for input */
4594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4595 /* unmute amp left and right */
4596 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4597 /* set connection select to line in (default select for this ADC) */
4598 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4599 /* unmute Line-Out mixer amp left and right (volume = 0) */
4600 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4601 /* mute pin widget amp left and right (no gain on this amp) */
4602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4603 /* unmute HP mixer amp left and right (volume = 0) */
4604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4605 /* mute pin widget amp left and right (no gain on this amp) */
4606 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004607 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4608 * Line In 2 = 0x03
4609 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004610 /* mute analog inputs */
4611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004616 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4617 /* Unmute Front out path */
4618 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4620 /* Unmute Headphone out path */
4621 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4622 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4623 /* Unmute Mono out path */
4624 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4625 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4626 { }
4627};
4628
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004629/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004630 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4631 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004632 */
4633static struct hda_verb alc260_fujitsu_init_verbs[] = {
4634 /* Disable all GPIOs */
4635 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4636 /* Internal speaker is connected to headphone pin */
4637 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4638 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004640 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4641 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4642 /* Ensure all other unused pins are disabled and muted. */
4643 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004645 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004646 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004647 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004648 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004651
Jonathan Woithef7ace402006-02-28 11:46:14 +01004652 /* Disable digital (SPDIF) pins */
4653 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4654 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004655
Kailang Yangea1fb292008-08-26 12:58:38 +02004656 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004657 * when acting as an output.
4658 */
4659 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4660
4661 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4665 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4668 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004671
Jonathan Woithef7ace402006-02-28 11:46:14 +01004672 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4673 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4674 /* Unmute Line1 pin widget output buffer since it starts as an output.
4675 * If the pin mode is changed by the user the pin mode control will
4676 * take care of enabling the pin's input/output buffers as needed.
4677 * Therefore there's no need to enable the input buffer at this
4678 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004679 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004681 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004682 * mixer ctrl)
4683 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004684 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004685
Jonathan Woithef7ace402006-02-28 11:46:14 +01004686 /* Mute capture amp left and right */
4687 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004688 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004689 * in (on mic1 pin)
4690 */
4691 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004692
Jonathan Woithef7ace402006-02-28 11:46:14 +01004693 /* Do the same for the second ADC: mute capture input amp and
4694 * set ADC connection to line in (on mic1 pin)
4695 */
4696 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4697 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004698
Jonathan Woithef7ace402006-02-28 11:46:14 +01004699 /* Mute all inputs to mixer widget (even unconnected ones) */
4700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004708
4709 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004710};
4711
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004712/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4713 * similar laptops (adapted from Fujitsu init verbs).
4714 */
4715static struct hda_verb alc260_acer_init_verbs[] = {
4716 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4717 * the headphone jack. Turn this on and rely on the standard mute
4718 * methods whenever the user wants to turn these outputs off.
4719 */
4720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4722 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4723 /* Internal speaker/Headphone jack is connected to Line-out pin */
4724 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4725 /* Internal microphone/Mic jack is connected to Mic1 pin */
4726 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4727 /* Line In jack is connected to Line1 pin */
4728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004729 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4730 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004731 /* Ensure all other unused pins are disabled and muted. */
4732 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4733 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004734 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4735 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4738 /* Disable digital (SPDIF) pins */
4739 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4740 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4741
Kailang Yangea1fb292008-08-26 12:58:38 +02004742 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004743 * bus when acting as outputs.
4744 */
4745 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4746 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4747
4748 /* Start with output sum widgets muted and their output gains at min */
4749 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4755 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4756 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4757 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004759 /* Unmute Line-out pin widget amp left and right
4760 * (no equiv mixer ctrl)
4761 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004762 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004763 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4764 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004765 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4766 * inputs. If the pin mode is changed by the user the pin mode control
4767 * will take care of enabling the pin's input/output buffers as needed.
4768 * Therefore there's no need to enable the input buffer at this
4769 * stage.
4770 */
4771 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4773
4774 /* Mute capture amp left and right */
4775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4776 /* Set ADC connection select to match default mixer setting - mic
4777 * (on mic1 pin)
4778 */
4779 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4780
4781 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004782 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004783 */
4784 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004785 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004786
4787 /* Mute all inputs to mixer widget (even unconnected ones) */
4788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4796
4797 { }
4798};
4799
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004800static struct hda_verb alc260_will_verbs[] = {
4801 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4802 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4803 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4804 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4805 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4806 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4807 {}
4808};
4809
4810static struct hda_verb alc260_replacer_672v_verbs[] = {
4811 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4812 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4813 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4814
4815 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4816 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4817 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4818
4819 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4820 {}
4821};
4822
4823/* toggle speaker-output according to the hp-jack state */
4824static void alc260_replacer_672v_automute(struct hda_codec *codec)
4825{
4826 unsigned int present;
4827
4828 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4829 present = snd_hda_codec_read(codec, 0x0f, 0,
4830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4831 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004832 snd_hda_codec_write_cache(codec, 0x01, 0,
4833 AC_VERB_SET_GPIO_DATA, 1);
4834 snd_hda_codec_write_cache(codec, 0x0f, 0,
4835 AC_VERB_SET_PIN_WIDGET_CONTROL,
4836 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004837 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004838 snd_hda_codec_write_cache(codec, 0x01, 0,
4839 AC_VERB_SET_GPIO_DATA, 0);
4840 snd_hda_codec_write_cache(codec, 0x0f, 0,
4841 AC_VERB_SET_PIN_WIDGET_CONTROL,
4842 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004843 }
4844}
4845
4846static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4847 unsigned int res)
4848{
4849 if ((res >> 26) == ALC880_HP_EVENT)
4850 alc260_replacer_672v_automute(codec);
4851}
4852
Kailang Yang3f878302008-08-26 13:02:23 +02004853static struct hda_verb alc260_hp_dc7600_verbs[] = {
4854 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4856 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4857 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4858 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4860 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4861 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4862 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4864 {}
4865};
4866
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004867/* Test configuration for debugging, modelled after the ALC880 test
4868 * configuration.
4869 */
4870#ifdef CONFIG_SND_DEBUG
4871static hda_nid_t alc260_test_dac_nids[1] = {
4872 0x02,
4873};
4874static hda_nid_t alc260_test_adc_nids[2] = {
4875 0x04, 0x05,
4876};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004877/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004878 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004879 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004880 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004881static struct hda_input_mux alc260_test_capture_sources[2] = {
4882 {
4883 .num_items = 7,
4884 .items = {
4885 { "MIC1 pin", 0x0 },
4886 { "MIC2 pin", 0x1 },
4887 { "LINE1 pin", 0x2 },
4888 { "LINE2 pin", 0x3 },
4889 { "CD pin", 0x4 },
4890 { "LINE-OUT pin", 0x5 },
4891 { "HP-OUT pin", 0x6 },
4892 },
4893 },
4894 {
4895 .num_items = 8,
4896 .items = {
4897 { "MIC1 pin", 0x0 },
4898 { "MIC2 pin", 0x1 },
4899 { "LINE1 pin", 0x2 },
4900 { "LINE2 pin", 0x3 },
4901 { "CD pin", 0x4 },
4902 { "Mixer", 0x5 },
4903 { "LINE-OUT pin", 0x6 },
4904 { "HP-OUT pin", 0x7 },
4905 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004906 },
4907};
4908static struct snd_kcontrol_new alc260_test_mixer[] = {
4909 /* Output driver widgets */
4910 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4911 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4912 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4913 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4914 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4915 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4916
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004917 /* Modes for retasking pin widgets
4918 * Note: the ALC260 doesn't seem to act on requests to enable mic
4919 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4920 * mention this restriction. At this stage it's not clear whether
4921 * this behaviour is intentional or is a hardware bug in chip
4922 * revisions available at least up until early 2006. Therefore for
4923 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4924 * choices, but if it turns out that the lack of mic bias for these
4925 * NIDs is intentional we could change their modes from
4926 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4927 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004928 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4929 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4930 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4931 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4932 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4933 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4934
4935 /* Loopback mixer controls */
4936 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4937 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4938 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4939 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4940 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4941 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4942 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4943 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4944 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4945 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4946 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4947 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4948 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4949 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4950 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4951 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004952
4953 /* Controls for GPIO pins, assuming they are configured as outputs */
4954 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4955 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4956 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4957 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4958
Jonathan Woithe92621f12006-02-28 11:47:47 +01004959 /* Switches to allow the digital IO pins to be enabled. The datasheet
4960 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004961 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004962 */
4963 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4964 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4965
Jonathan Woithef8225f62008-01-08 12:16:54 +01004966 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4967 * this output to turn on an external amplifier.
4968 */
4969 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4970 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4971
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004972 { } /* end */
4973};
4974static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004975 /* Enable all GPIOs as outputs with an initial value of 0 */
4976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4977 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4978 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4979
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004980 /* Enable retasking pins as output, initially without power amp */
4981 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4982 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4985 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4986 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4987
Jonathan Woithe92621f12006-02-28 11:47:47 +01004988 /* Disable digital (SPDIF) pins initially, but users can enable
4989 * them via a mixer switch. In the case of SPDIF-out, this initverb
4990 * payload also sets the generation to 0, output to be in "consumer"
4991 * PCM format, copyright asserted, no pre-emphasis and no validity
4992 * control.
4993 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004994 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4995 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4996
Kailang Yangea1fb292008-08-26 12:58:38 +02004997 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004998 * OUT1 sum bus when acting as an output.
4999 */
5000 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5001 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5002 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5003 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5004
5005 /* Start with output sum widgets muted and their output gains at min */
5006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5012 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5013 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5015
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005016 /* Unmute retasking pin widget output buffers since the default
5017 * state appears to be output. As the pin mode is changed by the
5018 * user the pin mode control will take care of enabling the pin's
5019 * input/output buffers as needed.
5020 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005021 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5022 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5023 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5025 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5026 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5027 /* Also unmute the mono-out pin widget */
5028 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5029
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005030 /* Mute capture amp left and right */
5031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005032 /* Set ADC connection select to match default mixer setting (mic1
5033 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005034 */
5035 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5036
5037 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005038 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005039 */
5040 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5041 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5042
5043 /* Mute all inputs to mixer widget (even unconnected ones) */
5044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5052
5053 { }
5054};
5055#endif
5056
Takashi Iwai63300792008-01-24 15:31:36 +01005057#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5058#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005059
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005060#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5061#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5062
Kailang Yangdf694da2005-12-05 19:42:22 +01005063/*
5064 * for BIOS auto-configuration
5065 */
5066
5067static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005068 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005069{
5070 hda_nid_t nid_vol;
5071 unsigned long vol_val, sw_val;
5072 char name[32];
5073 int err;
5074
5075 if (nid >= 0x0f && nid < 0x11) {
5076 nid_vol = nid - 0x7;
5077 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5078 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5079 } else if (nid == 0x11) {
5080 nid_vol = nid - 0x7;
5081 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5082 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5083 } else if (nid >= 0x12 && nid <= 0x15) {
5084 nid_vol = 0x08;
5085 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5086 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5087 } else
5088 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005089
Takashi Iwai863b4512008-10-21 17:01:47 +02005090 if (!(*vol_bits & (1 << nid_vol))) {
5091 /* first control for the volume widget */
5092 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5093 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5094 if (err < 0)
5095 return err;
5096 *vol_bits |= (1 << nid_vol);
5097 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005098 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5100 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005101 return err;
5102 return 1;
5103}
5104
5105/* add playback controls from the parsed DAC table */
5106static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5107 const struct auto_pin_cfg *cfg)
5108{
5109 hda_nid_t nid;
5110 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005111 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005112
5113 spec->multiout.num_dacs = 1;
5114 spec->multiout.dac_nids = spec->private_dac_nids;
5115 spec->multiout.dac_nids[0] = 0x02;
5116
5117 nid = cfg->line_out_pins[0];
5118 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005119 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005120 if (err < 0)
5121 return err;
5122 }
5123
Takashi Iwai82bc9552006-03-21 11:24:42 +01005124 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005125 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005126 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005127 if (err < 0)
5128 return err;
5129 }
5130
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005131 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005132 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005133 err = alc260_add_playback_controls(spec, nid, "Headphone",
5134 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005135 if (err < 0)
5136 return err;
5137 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005138 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005139}
5140
5141/* create playback/capture controls for input pins */
5142static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5143 const struct auto_pin_cfg *cfg)
5144{
Kailang Yangdf694da2005-12-05 19:42:22 +01005145 struct hda_input_mux *imux = &spec->private_imux;
5146 int i, err, idx;
5147
5148 for (i = 0; i < AUTO_PIN_LAST; i++) {
5149 if (cfg->input_pins[i] >= 0x12) {
5150 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005151 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005152 auto_pin_cfg_labels[i], idx,
5153 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005154 if (err < 0)
5155 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005156 imux->items[imux->num_items].label =
5157 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005158 imux->items[imux->num_items].index = idx;
5159 imux->num_items++;
5160 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005161 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005162 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005163 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005164 auto_pin_cfg_labels[i], idx,
5165 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005166 if (err < 0)
5167 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 imux->items[imux->num_items].label =
5169 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 imux->items[imux->num_items].index = idx;
5171 imux->num_items++;
5172 }
5173 }
5174 return 0;
5175}
5176
5177static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5178 hda_nid_t nid, int pin_type,
5179 int sel_idx)
5180{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005181 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005182 /* need the manual connection? */
5183 if (nid >= 0x12) {
5184 int idx = nid - 0x12;
5185 snd_hda_codec_write(codec, idx + 0x0b, 0,
5186 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005187 }
5188}
5189
5190static void alc260_auto_init_multi_out(struct hda_codec *codec)
5191{
5192 struct alc_spec *spec = codec->spec;
5193 hda_nid_t nid;
5194
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005195 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005196 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005197 if (nid) {
5198 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5199 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5200 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005201
Takashi Iwai82bc9552006-03-21 11:24:42 +01005202 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005203 if (nid)
5204 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5205
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005206 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005208 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005209}
Kailang Yangdf694da2005-12-05 19:42:22 +01005210
5211#define ALC260_PIN_CD_NID 0x16
5212static void alc260_auto_init_analog_input(struct hda_codec *codec)
5213{
5214 struct alc_spec *spec = codec->spec;
5215 int i;
5216
5217 for (i = 0; i < AUTO_PIN_LAST; i++) {
5218 hda_nid_t nid = spec->autocfg.input_pins[i];
5219 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005220 snd_hda_codec_write(codec, nid, 0,
5221 AC_VERB_SET_PIN_WIDGET_CONTROL,
5222 i <= AUTO_PIN_FRONT_MIC ?
5223 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005224 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005225 snd_hda_codec_write(codec, nid, 0,
5226 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005227 AMP_OUT_MUTE);
5228 }
5229 }
5230}
5231
5232/*
5233 * generic initialization of ADC, input mixers and output mixers
5234 */
5235static struct hda_verb alc260_volume_init_verbs[] = {
5236 /*
5237 * Unmute ADC0-1 and set the default input to mic-in
5238 */
5239 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5240 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5241 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005243
Kailang Yangdf694da2005-12-05 19:42:22 +01005244 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5245 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005246 * Note: PASD motherboards uses the Line In 2 as the input for
5247 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005248 */
5249 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005250 /* mute analog inputs */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005256
5257 /*
5258 * Set up output mixers (0x08 - 0x0a)
5259 */
5260 /* set vol=0 to output mixers */
5261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5263 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5264 /* set up input amps for analog loopback */
5265 /* Amp Indices: DAC = 0, mixer = 1 */
5266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5270 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005272
Kailang Yangdf694da2005-12-05 19:42:22 +01005273 { }
5274};
5275
5276static int alc260_parse_auto_config(struct hda_codec *codec)
5277{
5278 struct alc_spec *spec = codec->spec;
5279 unsigned int wcap;
5280 int err;
5281 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005283 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5284 alc260_ignore);
5285 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005286 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005287 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5288 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005289 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005290 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005291 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005292 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5293 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005294 return err;
5295
5296 spec->multiout.max_channels = 2;
5297
5298 if (spec->autocfg.dig_out_pin)
5299 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5300 if (spec->kctl_alloc)
5301 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5302
5303 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5304
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005305 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005306 spec->input_mux = &spec->private_imux;
5307
5308 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005309 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005310 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005311 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005312 spec->adc_nids = alc260_adc_nids_alt;
5313 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5314 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005315 } else {
5316 spec->adc_nids = alc260_adc_nids;
5317 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5318 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005319 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005320 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005321
Takashi Iwaie044c392008-10-27 16:56:24 +01005322 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 return 1;
5324}
5325
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005326/* additional initialization for auto-configuration model */
5327static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005328{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005329 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005330 alc260_auto_init_multi_out(codec);
5331 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005332 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005333 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005334}
5335
Takashi Iwaicb53c622007-08-10 17:21:45 +02005336#ifdef CONFIG_SND_HDA_POWER_SAVE
5337static struct hda_amp_list alc260_loopbacks[] = {
5338 { 0x07, HDA_INPUT, 0 },
5339 { 0x07, HDA_INPUT, 1 },
5340 { 0x07, HDA_INPUT, 2 },
5341 { 0x07, HDA_INPUT, 3 },
5342 { 0x07, HDA_INPUT, 4 },
5343 { } /* end */
5344};
5345#endif
5346
Kailang Yangdf694da2005-12-05 19:42:22 +01005347/*
5348 * ALC260 configurations
5349 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005350static const char *alc260_models[ALC260_MODEL_LAST] = {
5351 [ALC260_BASIC] = "basic",
5352 [ALC260_HP] = "hp",
5353 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005354 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005355 [ALC260_FUJITSU_S702X] = "fujitsu",
5356 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005357 [ALC260_WILL] = "will",
5358 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005359#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005360 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005361#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005362 [ALC260_AUTO] = "auto",
5363};
5364
5365static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005366 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005367 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005368 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005369 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005370 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005371 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005372 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005373 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5374 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5375 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5376 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5377 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5378 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5379 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5380 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5381 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005382 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005383 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005384 {}
5385};
5386
Kailang Yangdf694da2005-12-05 19:42:22 +01005387static struct alc_config_preset alc260_presets[] = {
5388 [ALC260_BASIC] = {
5389 .mixers = { alc260_base_output_mixer,
5390 alc260_input_mixer,
5391 alc260_pc_beep_mixer,
5392 alc260_capture_mixer },
5393 .init_verbs = { alc260_init_verbs },
5394 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5395 .dac_nids = alc260_dac_nids,
5396 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5397 .adc_nids = alc260_adc_nids,
5398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5399 .channel_mode = alc260_modes,
5400 .input_mux = &alc260_capture_source,
5401 },
5402 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005403 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005404 alc260_input_mixer,
5405 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005406 .init_verbs = { alc260_init_verbs,
5407 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005408 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5409 .dac_nids = alc260_dac_nids,
5410 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5411 .adc_nids = alc260_hp_adc_nids,
5412 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5413 .channel_mode = alc260_modes,
5414 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005415 .unsol_event = alc260_hp_unsol_event,
5416 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 },
Kailang Yang3f878302008-08-26 13:02:23 +02005418 [ALC260_HP_DC7600] = {
5419 .mixers = { alc260_hp_dc7600_mixer,
5420 alc260_input_mixer,
5421 alc260_capture_alt_mixer },
5422 .init_verbs = { alc260_init_verbs,
5423 alc260_hp_dc7600_verbs },
5424 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5425 .dac_nids = alc260_dac_nids,
5426 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5427 .adc_nids = alc260_hp_adc_nids,
5428 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5429 .channel_mode = alc260_modes,
5430 .input_mux = &alc260_capture_source,
5431 .unsol_event = alc260_hp_3012_unsol_event,
5432 .init_hook = alc260_hp_3012_automute,
5433 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005434 [ALC260_HP_3013] = {
5435 .mixers = { alc260_hp_3013_mixer,
5436 alc260_input_mixer,
5437 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005438 .init_verbs = { alc260_hp_3013_init_verbs,
5439 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005440 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5441 .dac_nids = alc260_dac_nids,
5442 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5443 .adc_nids = alc260_hp_adc_nids,
5444 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5445 .channel_mode = alc260_modes,
5446 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005447 .unsol_event = alc260_hp_3013_unsol_event,
5448 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005449 },
5450 [ALC260_FUJITSU_S702X] = {
5451 .mixers = { alc260_fujitsu_mixer,
5452 alc260_capture_mixer },
5453 .init_verbs = { alc260_fujitsu_init_verbs },
5454 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5455 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005456 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5457 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005458 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5459 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005460 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5461 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005462 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005463 [ALC260_ACER] = {
5464 .mixers = { alc260_acer_mixer,
5465 alc260_capture_mixer },
5466 .init_verbs = { alc260_acer_init_verbs },
5467 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5468 .dac_nids = alc260_dac_nids,
5469 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5470 .adc_nids = alc260_dual_adc_nids,
5471 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5472 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005473 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5474 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005475 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005476 [ALC260_WILL] = {
5477 .mixers = { alc260_will_mixer,
5478 alc260_capture_mixer },
5479 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5480 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5481 .dac_nids = alc260_dac_nids,
5482 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5483 .adc_nids = alc260_adc_nids,
5484 .dig_out_nid = ALC260_DIGOUT_NID,
5485 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5486 .channel_mode = alc260_modes,
5487 .input_mux = &alc260_capture_source,
5488 },
5489 [ALC260_REPLACER_672V] = {
5490 .mixers = { alc260_replacer_672v_mixer,
5491 alc260_capture_mixer },
5492 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5493 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5494 .dac_nids = alc260_dac_nids,
5495 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5496 .adc_nids = alc260_adc_nids,
5497 .dig_out_nid = ALC260_DIGOUT_NID,
5498 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5499 .channel_mode = alc260_modes,
5500 .input_mux = &alc260_capture_source,
5501 .unsol_event = alc260_replacer_672v_unsol_event,
5502 .init_hook = alc260_replacer_672v_automute,
5503 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005504#ifdef CONFIG_SND_DEBUG
5505 [ALC260_TEST] = {
5506 .mixers = { alc260_test_mixer,
5507 alc260_capture_mixer },
5508 .init_verbs = { alc260_test_init_verbs },
5509 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5510 .dac_nids = alc260_test_dac_nids,
5511 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5512 .adc_nids = alc260_test_adc_nids,
5513 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5514 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005515 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5516 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005517 },
5518#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005519};
5520
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521static int patch_alc260(struct hda_codec *codec)
5522{
5523 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005524 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005525
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005526 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527 if (spec == NULL)
5528 return -ENOMEM;
5529
5530 codec->spec = spec;
5531
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005532 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5533 alc260_models,
5534 alc260_cfg_tbl);
5535 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005536 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5537 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005538 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005539 }
5540
Kailang Yangdf694da2005-12-05 19:42:22 +01005541 if (board_config == ALC260_AUTO) {
5542 /* automatic parse from the BIOS config */
5543 err = alc260_parse_auto_config(codec);
5544 if (err < 0) {
5545 alc_free(codec);
5546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005547 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005548 printk(KERN_INFO
5549 "hda_codec: Cannot set up configuration "
5550 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005551 board_config = ALC260_BASIC;
5552 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005553 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005554
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 if (board_config != ALC260_AUTO)
5556 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557
5558 spec->stream_name_analog = "ALC260 Analog";
5559 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5560 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5561
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005562 spec->stream_name_digital = "ALC260 Digital";
5563 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5564 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5565
Takashi Iwai2134ea42008-01-10 16:53:55 +01005566 spec->vmaster_nid = 0x08;
5567
Linus Torvalds1da177e2005-04-16 15:20:36 -07005568 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005570 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005571#ifdef CONFIG_SND_HDA_POWER_SAVE
5572 if (!spec->loopback.amplist)
5573 spec->loopback.amplist = alc260_loopbacks;
5574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005575
5576 return 0;
5577}
5578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005579
Linus Torvalds1da177e2005-04-16 15:20:36 -07005580/*
5581 * ALC882 support
5582 *
5583 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5584 * configuration. Each pin widget can choose any input DACs and a mixer.
5585 * Each ADC is connected from a mixer of all inputs. This makes possible
5586 * 6-channel independent captures.
5587 *
5588 * In addition, an independent DAC for the multi-playback (not used in this
5589 * driver yet).
5590 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005591#define ALC882_DIGOUT_NID 0x06
5592#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005593
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005594static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005595 { 8, NULL }
5596};
5597
5598static hda_nid_t alc882_dac_nids[4] = {
5599 /* front, rear, clfe, rear_surr */
5600 0x02, 0x03, 0x04, 0x05
5601};
5602
Kailang Yangdf694da2005-12-05 19:42:22 +01005603/* identical with ALC880 */
5604#define alc882_adc_nids alc880_adc_nids
5605#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005606
Takashi Iwaie1406342008-02-11 18:32:32 +01005607static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5608static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5609
Linus Torvalds1da177e2005-04-16 15:20:36 -07005610/* input MUX */
5611/* FIXME: should be a matrix-type input source selection */
5612
5613static struct hda_input_mux alc882_capture_source = {
5614 .num_items = 4,
5615 .items = {
5616 { "Mic", 0x0 },
5617 { "Front Mic", 0x1 },
5618 { "Line", 0x2 },
5619 { "CD", 0x4 },
5620 },
5621};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005622#define alc882_mux_enum_info alc_mux_enum_info
5623#define alc882_mux_enum_get alc_mux_enum_get
5624
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005625static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5626 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005627{
5628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5629 struct alc_spec *spec = codec->spec;
5630 const struct hda_input_mux *imux = spec->input_mux;
5631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005632 hda_nid_t nid = spec->capsrc_nids ?
5633 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005634 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5635 unsigned int i, idx;
5636
5637 idx = ucontrol->value.enumerated.item[0];
5638 if (idx >= imux->num_items)
5639 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005640 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005641 return 0;
5642 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005643 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5644 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005645 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005646 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005647 }
5648 *cur_val = idx;
5649 return 1;
5650}
5651
Kailang Yangdf694da2005-12-05 19:42:22 +01005652/*
Kailang Yang272a5272007-05-14 11:00:38 +02005653 * 2ch mode
5654 */
5655static struct hda_verb alc882_3ST_ch2_init[] = {
5656 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5657 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5658 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5659 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5660 { } /* end */
5661};
5662
5663/*
5664 * 6ch mode
5665 */
5666static struct hda_verb alc882_3ST_ch6_init[] = {
5667 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5668 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5669 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5670 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5671 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5672 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5673 { } /* end */
5674};
5675
5676static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5677 { 2, alc882_3ST_ch2_init },
5678 { 6, alc882_3ST_ch6_init },
5679};
5680
5681/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 * 6ch mode
5683 */
5684static struct hda_verb alc882_sixstack_ch6_init[] = {
5685 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5686 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5687 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5688 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5689 { } /* end */
5690};
5691
5692/*
5693 * 8ch mode
5694 */
5695static struct hda_verb alc882_sixstack_ch8_init[] = {
5696 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5697 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5698 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5699 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5700 { } /* end */
5701};
5702
5703static struct hda_channel_mode alc882_sixstack_modes[2] = {
5704 { 6, alc882_sixstack_ch6_init },
5705 { 8, alc882_sixstack_ch8_init },
5706};
5707
Takashi Iwai87350ad2007-08-16 18:19:38 +02005708/*
5709 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5710 */
5711
5712/*
5713 * 2ch mode
5714 */
5715static struct hda_verb alc885_mbp_ch2_init[] = {
5716 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5717 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5719 { } /* end */
5720};
5721
5722/*
5723 * 6ch mode
5724 */
5725static struct hda_verb alc885_mbp_ch6_init[] = {
5726 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5727 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5728 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5729 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5730 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5731 { } /* end */
5732};
5733
5734static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5735 { 2, alc885_mbp_ch2_init },
5736 { 6, alc885_mbp_ch6_init },
5737};
5738
5739
Linus Torvalds1da177e2005-04-16 15:20:36 -07005740/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5741 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5742 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005743static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005744 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005745 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005746 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005747 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005748 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5749 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005750 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5751 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005752 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005753 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5762 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005763 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005764 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5765 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5766 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005767 { } /* end */
5768};
5769
Takashi Iwai87350ad2007-08-16 18:19:38 +02005770static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5772 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5773 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5774 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5776 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5778 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005779 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5781 { } /* end */
5782};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005783static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5784 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5785 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5788 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5789 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5791 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5793 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5794 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5795 { } /* end */
5796};
5797
Kailang Yang272a5272007-05-14 11:00:38 +02005798static struct snd_kcontrol_new alc882_targa_mixer[] = {
5799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5800 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005812 { } /* end */
5813};
5814
5815/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5816 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5817 */
5818static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5820 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5822 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5823 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5824 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5825 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5826 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5827 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5828 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005831 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005832 { } /* end */
5833};
5834
Takashi Iwai914759b2007-09-06 14:52:04 +02005835static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5838 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5841 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5842 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5844 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5846 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5847 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5848 { } /* end */
5849};
5850
Kailang Yangdf694da2005-12-05 19:42:22 +01005851static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5852 {
5853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5854 .name = "Channel Mode",
5855 .info = alc_ch_mode_info,
5856 .get = alc_ch_mode_get,
5857 .put = alc_ch_mode_put,
5858 },
5859 { } /* end */
5860};
5861
Linus Torvalds1da177e2005-04-16 15:20:36 -07005862static struct hda_verb alc882_init_verbs[] = {
5863 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005867 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005871 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5873 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5874 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005875 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005876 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5878 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005879
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005880 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005884 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005887 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005888 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005889 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005892 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005893 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005895 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005896 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005897 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005898 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5899 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005900 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005901 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5902 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005903 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5905 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5906 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5907 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5908 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005909 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005910 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005911
5912 /* FIXME: use matrix-type input source selection */
5913 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5914 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005919 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005920 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5921 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005924 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5929 /* ADC1: mute amp left and right */
5930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005931 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005932 /* ADC2: mute amp left and right */
5933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005934 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005935 /* ADC3: mute amp left and right */
5936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005937 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005938
5939 { }
5940};
5941
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005942static struct hda_verb alc882_eapd_verbs[] = {
5943 /* change to EAPD mode */
5944 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005945 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005946 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005947};
5948
Tobin Davis9102cd12006-12-15 10:02:12 +01005949/* Mac Pro test */
5950static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5956 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5957 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5958 { } /* end */
5959};
5960
5961static struct hda_verb alc882_macpro_init_verbs[] = {
5962 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5966 /* Front Pin: output 0 (0x0c) */
5967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5968 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5969 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5970 /* Front Mic pin: input vref at 80% */
5971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5973 /* Speaker: output */
5974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5976 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5977 /* Headphone output (output 0 - 0x0c) */
5978 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5980 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5981
5982 /* FIXME: use matrix-type input source selection */
5983 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5984 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5989 /* Input mixer2 */
5990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5994 /* Input mixer3 */
5995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5999 /* ADC1: mute amp left and right */
6000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6001 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6002 /* ADC2: mute amp left and right */
6003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6004 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6005 /* ADC3: mute amp left and right */
6006 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6007 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6008
6009 { }
6010};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006011
Takashi Iwai87350ad2007-08-16 18:19:38 +02006012/* Macbook Pro rev3 */
6013static struct hda_verb alc885_mbp3_init_verbs[] = {
6014 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6018 /* Rear mixer */
6019 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6022 /* Front Pin: output 0 (0x0c) */
6023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6025 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6026 /* HP Pin: output 0 (0x0d) */
6027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6030 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6031 /* Mic (rear) pin: input vref at 80% */
6032 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6034 /* Front Mic pin: input vref at 80% */
6035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6037 /* Line In pin: use output 1 when in LineOut mode */
6038 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6040 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6041
6042 /* FIXME: use matrix-type input source selection */
6043 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6044 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6049 /* Input mixer2 */
6050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6054 /* Input mixer3 */
6055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6059 /* ADC1: mute amp left and right */
6060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6061 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6062 /* ADC2: mute amp left and right */
6063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6064 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6065 /* ADC3: mute amp left and right */
6066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6067 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6068
6069 { }
6070};
6071
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006072/* iMac 24 mixer. */
6073static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6074 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6075 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6076 { } /* end */
6077};
6078
6079/* iMac 24 init verbs. */
6080static struct hda_verb alc885_imac24_init_verbs[] = {
6081 /* Internal speakers: output 0 (0x0c) */
6082 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6083 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6084 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6085 /* Internal speakers: output 0 (0x0c) */
6086 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6088 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6089 /* Headphone: output 0 (0x0c) */
6090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6091 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6092 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6093 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6094 /* Front Mic: input vref at 80% */
6095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6097 { }
6098};
6099
6100/* Toggle speaker-output according to the hp-jack state */
6101static void alc885_imac24_automute(struct hda_codec *codec)
6102{
6103 unsigned int present;
6104
6105 present = snd_hda_codec_read(codec, 0x14, 0,
6106 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006107 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6108 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6109 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6110 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006111}
6112
6113/* Processes unsolicited events. */
6114static void alc885_imac24_unsol_event(struct hda_codec *codec,
6115 unsigned int res)
6116{
6117 /* Headphone insertion or removal. */
6118 if ((res >> 26) == ALC880_HP_EVENT)
6119 alc885_imac24_automute(codec);
6120}
6121
Takashi Iwai87350ad2007-08-16 18:19:38 +02006122static void alc885_mbp3_automute(struct hda_codec *codec)
6123{
6124 unsigned int present;
6125
6126 present = snd_hda_codec_read(codec, 0x15, 0,
6127 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6128 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6129 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6130 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6131 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6132
6133}
6134static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6135 unsigned int res)
6136{
6137 /* Headphone insertion or removal. */
6138 if ((res >> 26) == ALC880_HP_EVENT)
6139 alc885_mbp3_automute(codec);
6140}
6141
6142
Kailang Yang272a5272007-05-14 11:00:38 +02006143static struct hda_verb alc882_targa_verbs[] = {
6144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6146
6147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006149
Kailang Yang272a5272007-05-14 11:00:38 +02006150 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6151 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6152 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6153
6154 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6155 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6156 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6157 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6158 { } /* end */
6159};
6160
6161/* toggle speaker-output according to the hp-jack state */
6162static void alc882_targa_automute(struct hda_codec *codec)
6163{
6164 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006165
Kailang Yang272a5272007-05-14 11:00:38 +02006166 present = snd_hda_codec_read(codec, 0x14, 0,
6167 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006168 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6169 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006170 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6171 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006172}
6173
6174static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6175{
6176 /* Looks like the unsol event is incompatible with the standard
6177 * definition. 4bit tag is placed at 26 bit!
6178 */
6179 if (((res >> 26) == ALC880_HP_EVENT)) {
6180 alc882_targa_automute(codec);
6181 }
6182}
6183
6184static struct hda_verb alc882_asus_a7j_verbs[] = {
6185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6187
6188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006191
Kailang Yang272a5272007-05-14 11:00:38 +02006192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6193 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6194 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6195
6196 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6197 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6198 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6199 { } /* end */
6200};
6201
Takashi Iwai914759b2007-09-06 14:52:04 +02006202static struct hda_verb alc882_asus_a7m_verbs[] = {
6203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6205
6206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6208 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006209
Takashi Iwai914759b2007-09-06 14:52:04 +02006210 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6212 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6213
6214 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6215 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6216 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6217 { } /* end */
6218};
6219
Tobin Davis9102cd12006-12-15 10:02:12 +01006220static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6221{
6222 unsigned int gpiostate, gpiomask, gpiodir;
6223
6224 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6225 AC_VERB_GET_GPIO_DATA, 0);
6226
6227 if (!muted)
6228 gpiostate |= (1 << pin);
6229 else
6230 gpiostate &= ~(1 << pin);
6231
6232 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6233 AC_VERB_GET_GPIO_MASK, 0);
6234 gpiomask |= (1 << pin);
6235
6236 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6237 AC_VERB_GET_GPIO_DIRECTION, 0);
6238 gpiodir |= (1 << pin);
6239
6240
6241 snd_hda_codec_write(codec, codec->afg, 0,
6242 AC_VERB_SET_GPIO_MASK, gpiomask);
6243 snd_hda_codec_write(codec, codec->afg, 0,
6244 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6245
6246 msleep(1);
6247
6248 snd_hda_codec_write(codec, codec->afg, 0,
6249 AC_VERB_SET_GPIO_DATA, gpiostate);
6250}
6251
Takashi Iwai7debbe52007-08-16 15:01:03 +02006252/* set up GPIO at initialization */
6253static void alc885_macpro_init_hook(struct hda_codec *codec)
6254{
6255 alc882_gpio_mute(codec, 0, 0);
6256 alc882_gpio_mute(codec, 1, 0);
6257}
6258
6259/* set up GPIO and update auto-muting at initialization */
6260static void alc885_imac24_init_hook(struct hda_codec *codec)
6261{
6262 alc885_macpro_init_hook(codec);
6263 alc885_imac24_automute(codec);
6264}
6265
Kailang Yangdf694da2005-12-05 19:42:22 +01006266/*
6267 * generic initialization of ADC, input mixers and output mixers
6268 */
6269static struct hda_verb alc882_auto_init_verbs[] = {
6270 /*
6271 * Unmute ADC0-2 and set the default input to mic-in
6272 */
6273 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6275 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6278 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279
Takashi Iwaicb53c622007-08-10 17:21:45 +02006280 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006281 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006282 * Note: PASD motherboards uses the Line In 2 as the input for
6283 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006284 */
6285 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006291
6292 /*
6293 * Set up output mixers (0x0c - 0x0f)
6294 */
6295 /* set vol=0 to output mixers */
6296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 /* set up input amps for analog loopback */
6301 /* Amp Indices: DAC = 0, mixer = 1 */
6302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6310 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6312
6313 /* FIXME: use matrix-type input source selection */
6314 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6315 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6320 /* Input mixer2 */
6321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6325 /* Input mixer3 */
6326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6330
6331 { }
6332};
6333
6334/* capture mixer elements */
6335static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6338 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6339 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6340 {
6341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6342 /* The multiple "Capture Source" controls confuse alsamixer
6343 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 */
6345 /* .name = "Capture Source", */
6346 .name = "Input Source",
6347 .count = 2,
6348 .info = alc882_mux_enum_info,
6349 .get = alc882_mux_enum_get,
6350 .put = alc882_mux_enum_put,
6351 },
6352 { } /* end */
6353};
6354
6355static struct snd_kcontrol_new alc882_capture_mixer[] = {
6356 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6358 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6359 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6360 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6361 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6362 {
6363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6364 /* The multiple "Capture Source" controls confuse alsamixer
6365 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006366 */
6367 /* .name = "Capture Source", */
6368 .name = "Input Source",
6369 .count = 3,
6370 .info = alc882_mux_enum_info,
6371 .get = alc882_mux_enum_get,
6372 .put = alc882_mux_enum_put,
6373 },
6374 { } /* end */
6375};
6376
Takashi Iwaicb53c622007-08-10 17:21:45 +02006377#ifdef CONFIG_SND_HDA_POWER_SAVE
6378#define alc882_loopbacks alc880_loopbacks
6379#endif
6380
Kailang Yangdf694da2005-12-05 19:42:22 +01006381/* pcm configuration: identiacal with ALC880 */
6382#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6383#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6384#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6385#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6386
6387/*
6388 * configuration and preset
6389 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006390static const char *alc882_models[ALC882_MODEL_LAST] = {
6391 [ALC882_3ST_DIG] = "3stack-dig",
6392 [ALC882_6ST_DIG] = "6stack-dig",
6393 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006394 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006395 [ALC882_TARGA] = "targa",
6396 [ALC882_ASUS_A7J] = "asus-a7j",
6397 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006398 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006399 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006400 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006401 [ALC882_AUTO] = "auto",
6402};
6403
6404static struct snd_pci_quirk alc882_cfg_tbl[] = {
6405 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006407 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006408 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006410 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006411 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006412 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006413 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006414 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6415 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6416 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006417 {}
6418};
6419
6420static struct alc_config_preset alc882_presets[] = {
6421 [ALC882_3ST_DIG] = {
6422 .mixers = { alc882_base_mixer },
6423 .init_verbs = { alc882_init_verbs },
6424 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6425 .dac_nids = alc882_dac_nids,
6426 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 .dig_in_nid = ALC882_DIGIN_NID,
6428 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6429 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006430 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006431 .input_mux = &alc882_capture_source,
6432 },
6433 [ALC882_6ST_DIG] = {
6434 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6435 .init_verbs = { alc882_init_verbs },
6436 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6437 .dac_nids = alc882_dac_nids,
6438 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006439 .dig_in_nid = ALC882_DIGIN_NID,
6440 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6441 .channel_mode = alc882_sixstack_modes,
6442 .input_mux = &alc882_capture_source,
6443 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006444 [ALC882_ARIMA] = {
6445 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6446 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6447 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6448 .dac_nids = alc882_dac_nids,
6449 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6450 .channel_mode = alc882_sixstack_modes,
6451 .input_mux = &alc882_capture_source,
6452 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006453 [ALC882_W2JC] = {
6454 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6455 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6456 alc880_gpio1_init_verbs },
6457 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6458 .dac_nids = alc882_dac_nids,
6459 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6460 .channel_mode = alc880_threestack_modes,
6461 .need_dac_fix = 1,
6462 .input_mux = &alc882_capture_source,
6463 .dig_out_nid = ALC882_DIGOUT_NID,
6464 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006465 [ALC885_MBP3] = {
6466 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6467 .init_verbs = { alc885_mbp3_init_verbs,
6468 alc880_gpio1_init_verbs },
6469 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6470 .dac_nids = alc882_dac_nids,
6471 .channel_mode = alc885_mbp_6ch_modes,
6472 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6473 .input_mux = &alc882_capture_source,
6474 .dig_out_nid = ALC882_DIGOUT_NID,
6475 .dig_in_nid = ALC882_DIGIN_NID,
6476 .unsol_event = alc885_mbp3_unsol_event,
6477 .init_hook = alc885_mbp3_automute,
6478 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006479 [ALC885_MACPRO] = {
6480 .mixers = { alc882_macpro_mixer },
6481 .init_verbs = { alc882_macpro_init_verbs },
6482 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6483 .dac_nids = alc882_dac_nids,
6484 .dig_out_nid = ALC882_DIGOUT_NID,
6485 .dig_in_nid = ALC882_DIGIN_NID,
6486 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6487 .channel_mode = alc882_ch_modes,
6488 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006489 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006490 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006491 [ALC885_IMAC24] = {
6492 .mixers = { alc885_imac24_mixer },
6493 .init_verbs = { alc885_imac24_init_verbs },
6494 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6495 .dac_nids = alc882_dac_nids,
6496 .dig_out_nid = ALC882_DIGOUT_NID,
6497 .dig_in_nid = ALC882_DIGIN_NID,
6498 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6499 .channel_mode = alc882_ch_modes,
6500 .input_mux = &alc882_capture_source,
6501 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006502 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006503 },
Kailang Yang272a5272007-05-14 11:00:38 +02006504 [ALC882_TARGA] = {
6505 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6506 alc882_capture_mixer },
6507 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6508 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6509 .dac_nids = alc882_dac_nids,
6510 .dig_out_nid = ALC882_DIGOUT_NID,
6511 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6512 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006513 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006514 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6515 .channel_mode = alc882_3ST_6ch_modes,
6516 .need_dac_fix = 1,
6517 .input_mux = &alc882_capture_source,
6518 .unsol_event = alc882_targa_unsol_event,
6519 .init_hook = alc882_targa_automute,
6520 },
6521 [ALC882_ASUS_A7J] = {
6522 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6523 alc882_capture_mixer },
6524 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6525 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6526 .dac_nids = alc882_dac_nids,
6527 .dig_out_nid = ALC882_DIGOUT_NID,
6528 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6529 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006530 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006531 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6532 .channel_mode = alc882_3ST_6ch_modes,
6533 .need_dac_fix = 1,
6534 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006535 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006536 [ALC882_ASUS_A7M] = {
6537 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6538 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6539 alc880_gpio1_init_verbs,
6540 alc882_asus_a7m_verbs },
6541 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6542 .dac_nids = alc882_dac_nids,
6543 .dig_out_nid = ALC882_DIGOUT_NID,
6544 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6545 .channel_mode = alc880_threestack_modes,
6546 .need_dac_fix = 1,
6547 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006548 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006549};
6550
6551
6552/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006553 * Pin config fixes
6554 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006555enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006556 PINFIX_ABIT_AW9D_MAX
6557};
6558
6559static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6560 { 0x15, 0x01080104 }, /* side */
6561 { 0x16, 0x01011012 }, /* rear */
6562 { 0x17, 0x01016011 }, /* clfe */
6563 { }
6564};
6565
6566static const struct alc_pincfg *alc882_pin_fixes[] = {
6567 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6568};
6569
6570static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6571 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6572 {}
6573};
6574
6575/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006576 * BIOS auto configuration
6577 */
6578static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6579 hda_nid_t nid, int pin_type,
6580 int dac_idx)
6581{
6582 /* set as output */
6583 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006584 int idx;
6585
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006586 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006587 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6588 idx = 4;
6589 else
6590 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006591 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6592
6593}
6594
6595static void alc882_auto_init_multi_out(struct hda_codec *codec)
6596{
6597 struct alc_spec *spec = codec->spec;
6598 int i;
6599
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006600 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006601 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006602 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006603 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006604 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006605 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006606 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006607 }
6608}
6609
6610static void alc882_auto_init_hp_out(struct hda_codec *codec)
6611{
6612 struct alc_spec *spec = codec->spec;
6613 hda_nid_t pin;
6614
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006615 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006616 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006617 /* use dac 0 */
6618 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006619 pin = spec->autocfg.speaker_pins[0];
6620 if (pin)
6621 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006622}
6623
6624#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6625#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6626
6627static void alc882_auto_init_analog_input(struct hda_codec *codec)
6628{
6629 struct alc_spec *spec = codec->spec;
6630 int i;
6631
6632 for (i = 0; i < AUTO_PIN_LAST; i++) {
6633 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006634 unsigned int vref;
6635 if (!nid)
6636 continue;
6637 vref = PIN_IN;
6638 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006639 unsigned int pincap;
6640 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6641 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006642 AC_PINCAP_VREF_80)
6643 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006644 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006645 snd_hda_codec_write(codec, nid, 0,
6646 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6647 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6648 snd_hda_codec_write(codec, nid, 0,
6649 AC_VERB_SET_AMP_GAIN_MUTE,
6650 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006651 }
6652}
6653
Takashi Iwaif511b012008-08-15 16:46:42 +02006654static void alc882_auto_init_input_src(struct hda_codec *codec)
6655{
6656 struct alc_spec *spec = codec->spec;
6657 const struct hda_input_mux *imux = spec->input_mux;
6658 int c;
6659
6660 for (c = 0; c < spec->num_adc_nids; c++) {
6661 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6662 hda_nid_t nid = spec->capsrc_nids[c];
6663 int conns, mute, idx, item;
6664
6665 conns = snd_hda_get_connections(codec, nid, conn_list,
6666 ARRAY_SIZE(conn_list));
6667 if (conns < 0)
6668 continue;
6669 for (idx = 0; idx < conns; idx++) {
6670 /* if the current connection is the selected one,
6671 * unmute it as default - otherwise mute it
6672 */
6673 mute = AMP_IN_MUTE(idx);
6674 for (item = 0; item < imux->num_items; item++) {
6675 if (imux->items[item].index == idx) {
6676 if (spec->cur_mux[c] == item)
6677 mute = AMP_IN_UNMUTE(idx);
6678 break;
6679 }
6680 }
6681 snd_hda_codec_write(codec, nid, 0,
6682 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6683 }
6684 }
6685}
6686
Takashi Iwai776e1842007-08-29 15:07:11 +02006687/* add mic boosts if needed */
6688static int alc_auto_add_mic_boost(struct hda_codec *codec)
6689{
6690 struct alc_spec *spec = codec->spec;
6691 int err;
6692 hda_nid_t nid;
6693
6694 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006695 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006696 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6697 "Mic Boost",
6698 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6699 if (err < 0)
6700 return err;
6701 }
6702 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006703 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006704 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6705 "Front Mic Boost",
6706 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6707 if (err < 0)
6708 return err;
6709 }
6710 return 0;
6711}
6712
Kailang Yangdf694da2005-12-05 19:42:22 +01006713/* almost identical with ALC880 parser... */
6714static int alc882_parse_auto_config(struct hda_codec *codec)
6715{
6716 struct alc_spec *spec = codec->spec;
6717 int err = alc880_parse_auto_config(codec);
6718
6719 if (err < 0)
6720 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006721 else if (!err)
6722 return 0; /* no config found */
6723
6724 err = alc_auto_add_mic_boost(codec);
6725 if (err < 0)
6726 return err;
6727
6728 /* hack - override the init verbs */
6729 spec->init_verbs[0] = alc882_auto_init_verbs;
6730
6731 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006732}
6733
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006734/* additional initialization for auto-configuration model */
6735static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006736{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006737 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006738 alc882_auto_init_multi_out(codec);
6739 alc882_auto_init_hp_out(codec);
6740 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006741 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006742 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006743 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006744}
6745
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006746static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6747
Linus Torvalds1da177e2005-04-16 15:20:36 -07006748static int patch_alc882(struct hda_codec *codec)
6749{
6750 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006751 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006752
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006753 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006754 if (spec == NULL)
6755 return -ENOMEM;
6756
Linus Torvalds1da177e2005-04-16 15:20:36 -07006757 codec->spec = spec;
6758
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006759 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6760 alc882_models,
6761 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006762
Kailang Yangdf694da2005-12-05 19:42:22 +01006763 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006764 /* Pick up systems that don't supply PCI SSID */
6765 switch (codec->subsystem_id) {
6766 case 0x106b0c00: /* Mac Pro */
6767 board_config = ALC885_MACPRO;
6768 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006769 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006770 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006771 board_config = ALC885_IMAC24;
6772 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006773 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006774 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006775 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006776 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777 board_config = ALC885_MBP3;
6778 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006779 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006780 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006781 if (codec->revision_id == 0x100101 ||
6782 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006783 alc_free(codec);
6784 return patch_alc883(codec);
6785 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006786 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6787 "trying auto-probe from BIOS...\n");
6788 board_config = ALC882_AUTO;
6789 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006790 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006791
Takashi Iwaif95474e2007-07-10 00:47:43 +02006792 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6793
Kailang Yangdf694da2005-12-05 19:42:22 +01006794 if (board_config == ALC882_AUTO) {
6795 /* automatic parse from the BIOS config */
6796 err = alc882_parse_auto_config(codec);
6797 if (err < 0) {
6798 alc_free(codec);
6799 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006800 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006801 printk(KERN_INFO
6802 "hda_codec: Cannot set up configuration "
6803 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006804 board_config = ALC882_3ST_DIG;
6805 }
6806 }
6807
6808 if (board_config != ALC882_AUTO)
6809 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006810
Kailang Yang2f893282008-05-27 12:14:47 +02006811 if (codec->vendor_id == 0x10ec0885) {
6812 spec->stream_name_analog = "ALC885 Analog";
6813 spec->stream_name_digital = "ALC885 Digital";
6814 } else {
6815 spec->stream_name_analog = "ALC882 Analog";
6816 spec->stream_name_digital = "ALC882 Digital";
6817 }
6818
Kailang Yangdf694da2005-12-05 19:42:22 +01006819 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6820 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006821 /* FIXME: setup DAC5 */
6822 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6823 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006824
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6826 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006827
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006828 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006829 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006830 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006831 /* get type */
6832 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006833 if (wcap != AC_WID_AUD_IN) {
6834 spec->adc_nids = alc882_adc_nids_alt;
6835 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006836 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006837 spec->mixers[spec->num_mixers] =
6838 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006839 spec->num_mixers++;
6840 } else {
6841 spec->adc_nids = alc882_adc_nids;
6842 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006843 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006844 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6845 spec->num_mixers++;
6846 }
6847 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006848
Takashi Iwai2134ea42008-01-10 16:53:55 +01006849 spec->vmaster_nid = 0x0c;
6850
Linus Torvalds1da177e2005-04-16 15:20:36 -07006851 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006852 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006853 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006854#ifdef CONFIG_SND_HDA_POWER_SAVE
6855 if (!spec->loopback.amplist)
6856 spec->loopback.amplist = alc882_loopbacks;
6857#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006858
6859 return 0;
6860}
6861
6862/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006863 * ALC883 support
6864 *
6865 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6866 * configuration. Each pin widget can choose any input DACs and a mixer.
6867 * Each ADC is connected from a mixer of all inputs. This makes possible
6868 * 6-channel independent captures.
6869 *
6870 * In addition, an independent DAC for the multi-playback (not used in this
6871 * driver yet).
6872 */
6873#define ALC883_DIGOUT_NID 0x06
6874#define ALC883_DIGIN_NID 0x0a
6875
6876static hda_nid_t alc883_dac_nids[4] = {
6877 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006878 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006879};
6880
6881static hda_nid_t alc883_adc_nids[2] = {
6882 /* ADC1-2 */
6883 0x08, 0x09,
6884};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006885
Takashi Iwaie1406342008-02-11 18:32:32 +01006886static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6887
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006888/* input MUX */
6889/* FIXME: should be a matrix-type input source selection */
6890
6891static struct hda_input_mux alc883_capture_source = {
6892 .num_items = 4,
6893 .items = {
6894 { "Mic", 0x0 },
6895 { "Front Mic", 0x1 },
6896 { "Line", 0x2 },
6897 { "CD", 0x4 },
6898 },
6899};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006900
Jiang zhe17bba1b2008-06-04 12:11:07 +02006901static struct hda_input_mux alc883_3stack_6ch_intel = {
6902 .num_items = 4,
6903 .items = {
6904 { "Mic", 0x1 },
6905 { "Front Mic", 0x0 },
6906 { "Line", 0x2 },
6907 { "CD", 0x4 },
6908 },
6909};
6910
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006911static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6912 .num_items = 2,
6913 .items = {
6914 { "Mic", 0x1 },
6915 { "Line", 0x2 },
6916 },
6917};
6918
Kailang Yang272a5272007-05-14 11:00:38 +02006919static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6920 .num_items = 4,
6921 .items = {
6922 { "Mic", 0x0 },
6923 { "iMic", 0x1 },
6924 { "Line", 0x2 },
6925 { "CD", 0x4 },
6926 },
6927};
6928
Jiang zhefb97dc62008-03-06 11:07:11 +01006929static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6930 .num_items = 2,
6931 .items = {
6932 { "Mic", 0x0 },
6933 { "Int Mic", 0x1 },
6934 },
6935};
6936
Kailang Yange2757d52008-08-26 13:17:46 +02006937static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6938 .num_items = 3,
6939 .items = {
6940 { "Mic", 0x0 },
6941 { "Front Mic", 0x1 },
6942 { "Line", 0x4 },
6943 },
6944};
6945
6946static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6947 .num_items = 2,
6948 .items = {
6949 { "Mic", 0x0 },
6950 { "Line", 0x2 },
6951 },
6952};
6953
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006954#define alc883_mux_enum_info alc_mux_enum_info
6955#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006956/* ALC883 has the ALC882-type input selection */
6957#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006958
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006959/*
6960 * 2ch mode
6961 */
6962static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6963 { 2, NULL }
6964};
6965
6966/*
6967 * 2ch mode
6968 */
6969static struct hda_verb alc883_3ST_ch2_init[] = {
6970 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6971 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6972 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6973 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6974 { } /* end */
6975};
6976
6977/*
Tobin Davisb2011312007-09-17 12:45:11 +02006978 * 4ch mode
6979 */
6980static struct hda_verb alc883_3ST_ch4_init[] = {
6981 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6982 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6983 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6985 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6986 { } /* end */
6987};
6988
6989/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006990 * 6ch mode
6991 */
6992static struct hda_verb alc883_3ST_ch6_init[] = {
6993 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6994 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6995 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6996 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6997 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6998 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6999 { } /* end */
7000};
7001
Tobin Davisb2011312007-09-17 12:45:11 +02007002static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007003 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007004 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007005 { 6, alc883_3ST_ch6_init },
7006};
7007
7008/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007009 * 2ch mode
7010 */
7011static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7012 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7013 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7014 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7015 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7016 { } /* end */
7017};
7018
7019/*
7020 * 4ch mode
7021 */
7022static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7023 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7024 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7025 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7026 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7027 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7028 { } /* end */
7029};
7030
7031/*
7032 * 6ch mode
7033 */
7034static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7035 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7036 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7037 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7038 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7039 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7040 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7041 { } /* end */
7042};
7043
7044static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7045 { 2, alc883_3ST_ch2_intel_init },
7046 { 4, alc883_3ST_ch4_intel_init },
7047 { 6, alc883_3ST_ch6_intel_init },
7048};
7049
7050/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007051 * 6ch mode
7052 */
7053static struct hda_verb alc883_sixstack_ch6_init[] = {
7054 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7055 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7056 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7057 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7058 { } /* end */
7059};
7060
7061/*
7062 * 8ch mode
7063 */
7064static struct hda_verb alc883_sixstack_ch8_init[] = {
7065 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7066 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7067 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7069 { } /* end */
7070};
7071
7072static struct hda_channel_mode alc883_sixstack_modes[2] = {
7073 { 6, alc883_sixstack_ch6_init },
7074 { 8, alc883_sixstack_ch8_init },
7075};
7076
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007077static struct hda_verb alc883_medion_eapd_verbs[] = {
7078 /* eanable EAPD on medion laptop */
7079 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7080 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7081 { }
7082};
7083
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007084/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7085 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7086 */
7087
7088static struct snd_kcontrol_new alc883_base_mixer[] = {
7089 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7090 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7091 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7092 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7093 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7094 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7095 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7096 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7098 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007105 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7107 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007108 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007109 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7110 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7111 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7113 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7114 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7115 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7116 {
7117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7118 /* .name = "Capture Source", */
7119 .name = "Input Source",
7120 .count = 2,
7121 .info = alc883_mux_enum_info,
7122 .get = alc883_mux_enum_get,
7123 .put = alc883_mux_enum_put,
7124 },
7125 { } /* end */
7126};
7127
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007128static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7133 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7134 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7140 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7143 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7144 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7145 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7146 {
7147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7148 /* .name = "Capture Source", */
7149 .name = "Input Source",
7150 .count = 2,
7151 .info = alc883_mux_enum_info,
7152 .get = alc883_mux_enum_get,
7153 .put = alc883_mux_enum_put,
7154 },
7155 { } /* end */
7156};
7157
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007158static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007159 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7160 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7162 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7167 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7168 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7169 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7170 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7171 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7172 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7173 {
7174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7175 /* .name = "Capture Source", */
7176 .name = "Input Source",
7177 .count = 2,
7178 .info = alc883_mux_enum_info,
7179 .get = alc883_mux_enum_get,
7180 .put = alc883_mux_enum_put,
7181 },
7182 { } /* end */
7183};
7184
Jiang zhefb97dc62008-03-06 11:07:11 +01007185static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7186 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7187 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7189 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7193 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7194 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7195 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7196 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7197 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7198 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7199 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7200 {
7201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7202 /* .name = "Capture Source", */
7203 .name = "Input Source",
7204 .count = 2,
7205 .info = alc883_mux_enum_info,
7206 .get = alc883_mux_enum_get,
7207 .put = alc883_mux_enum_put,
7208 },
7209 { } /* end */
7210};
7211
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007212static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7214 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7217 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7219 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007221 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7223 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007224 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007225 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7226 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7227 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7229 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7230 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7231 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7232 {
7233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7234 /* .name = "Capture Source", */
7235 .name = "Input Source",
7236 .count = 2,
7237 .info = alc883_mux_enum_info,
7238 .get = alc883_mux_enum_get,
7239 .put = alc883_mux_enum_put,
7240 },
7241 { } /* end */
7242};
7243
7244static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7246 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7247 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7248 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7249 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7250 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7251 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7252 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7254 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7255 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007263 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7264 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7265 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7266 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7267 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007268 {
7269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7270 /* .name = "Capture Source", */
7271 .name = "Input Source",
Kailang Yange2757d52008-08-26 13:17:46 +02007272 .count = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007273 .info = alc883_mux_enum_info,
7274 .get = alc883_mux_enum_get,
7275 .put = alc883_mux_enum_put,
7276 },
7277 { } /* end */
7278};
7279
Jiang zhe17bba1b2008-06-04 12:11:07 +02007280static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7281 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7282 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7284 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7285 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7286 HDA_OUTPUT),
7287 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7288 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7289 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7291 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7292 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7294 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7296 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7298 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7299 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7301 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7302 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7304 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7305 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7306 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7307 {
7308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7309 /* .name = "Capture Source", */
7310 .name = "Input Source",
7311 .count = 2,
7312 .info = alc883_mux_enum_info,
7313 .get = alc883_mux_enum_get,
7314 .put = alc883_mux_enum_put,
7315 },
7316 { } /* end */
7317};
7318
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007319static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007320 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007321 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007322 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007323 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007324 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7325 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007326 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7327 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7332 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007334 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7336 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007337 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7339 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7340 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7341 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7342 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7343
7344 {
7345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7346 /* .name = "Capture Source", */
7347 .name = "Input Source",
7348 .count = 1,
7349 .info = alc883_mux_enum_info,
7350 .get = alc883_mux_enum_get,
7351 .put = alc883_mux_enum_put,
7352 },
7353 { } /* end */
7354};
7355
Kailang Yangccc656c2006-10-17 12:32:26 +02007356static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7357 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7359 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7361 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7363 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7364 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7365 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7366 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7367 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007371 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7373 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7374 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7375 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7376 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7377 {
7378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7379 /* .name = "Capture Source", */
7380 .name = "Input Source",
7381 .count = 2,
7382 .info = alc883_mux_enum_info,
7383 .get = alc883_mux_enum_get,
7384 .put = alc883_mux_enum_put,
7385 },
7386 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007387};
Kailang Yangccc656c2006-10-17 12:32:26 +02007388
7389static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7390 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7392 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7393 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7394 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007398 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7399 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7400 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007401 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7402 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7403 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7404 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7405 {
7406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7407 /* .name = "Capture Source", */
7408 .name = "Input Source",
7409 .count = 2,
7410 .info = alc883_mux_enum_info,
7411 .get = alc883_mux_enum_get,
7412 .put = alc883_mux_enum_put,
7413 },
7414 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007415};
Kailang Yangccc656c2006-10-17 12:32:26 +02007416
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007417static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7418 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7419 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007420 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7421 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7427 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7428 {
7429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7430 /* .name = "Capture Source", */
7431 .name = "Input Source",
7432 .count = 1,
7433 .info = alc883_mux_enum_info,
7434 .get = alc883_mux_enum_get,
7435 .put = alc883_mux_enum_put,
7436 },
7437 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007438};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007439
Kailang Yang272a5272007-05-14 11:00:38 +02007440static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7441 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7442 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7448 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7449 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7451 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7452 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7453 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7454 {
7455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7456 /* .name = "Capture Source", */
7457 .name = "Input Source",
7458 .count = 2,
7459 .info = alc883_mux_enum_info,
7460 .get = alc883_mux_enum_get,
7461 .put = alc883_mux_enum_put,
7462 },
7463 { } /* end */
7464};
7465
7466static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7467 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7469 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7477 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7478 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7479 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7480 {
7481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7482 /* .name = "Capture Source", */
7483 .name = "Input Source",
7484 .count = 2,
7485 .info = alc883_mux_enum_info,
7486 .get = alc883_mux_enum_get,
7487 .put = alc883_mux_enum_put,
7488 },
7489 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007490};
Kailang Yang272a5272007-05-14 11:00:38 +02007491
Tobin Davis2880a8672007-08-07 11:50:26 +02007492static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7494 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7499 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7500 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02007501 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7502 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7503 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7504 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7505 {
7506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7507 /* .name = "Capture Source", */
7508 .name = "Input Source",
7509 .count = 2,
7510 .info = alc883_mux_enum_info,
7511 .get = alc883_mux_enum_get,
7512 .put = alc883_mux_enum_put,
7513 },
7514 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007515};
Tobin Davis2880a8672007-08-07 11:50:26 +02007516
Kailang Yange2757d52008-08-26 13:17:46 +02007517static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7518 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7519 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7520 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7521 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7522 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7523 0x0d, 1, 0x0, HDA_OUTPUT),
7524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7526 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7527 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7528 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7530 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7531 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7532 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7533 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7534 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7539 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7540 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7541 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7542 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7543 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7544 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7545 {
7546 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7547 /* .name = "Capture Source", */
7548 .name = "Input Source",
7549 .count = 2,
7550 .info = alc883_mux_enum_info,
7551 .get = alc883_mux_enum_get,
7552 .put = alc883_mux_enum_put,
7553 },
7554 { } /* end */
7555};
7556
7557static struct hda_bind_ctls alc883_bind_cap_vol = {
7558 .ops = &snd_hda_bind_vol,
7559 .values = {
7560 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7561 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7562 0
7563 },
7564};
7565
7566static struct hda_bind_ctls alc883_bind_cap_switch = {
7567 .ops = &snd_hda_bind_sw,
7568 .values = {
7569 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7570 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7571 0
7572 },
7573};
7574
7575static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7577 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7584 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7585 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7586 {
7587 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7588 /* .name = "Capture Source", */
7589 .name = "Input Source",
7590 .count = 1,
7591 .info = alc883_mux_enum_info,
7592 .get = alc883_mux_enum_get,
7593 .put = alc883_mux_enum_put,
7594 },
7595 { } /* end */
7596};
7597
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007598static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7599 {
7600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7601 .name = "Channel Mode",
7602 .info = alc_ch_mode_info,
7603 .get = alc_ch_mode_get,
7604 .put = alc_ch_mode_put,
7605 },
7606 { } /* end */
7607};
7608
7609static struct hda_verb alc883_init_verbs[] = {
7610 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007612 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7613 /* ADC2: mute amp left and right */
7614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7615 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7616 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7620 /* Rear mixer */
7621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7624 /* CLFE mixer */
7625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7628 /* Side mixer */
7629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7630 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7632
Takashi Iwaicb53c622007-08-10 17:21:45 +02007633 /* mute analog input loopbacks */
7634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007639
7640 /* Front Pin: output 0 (0x0c) */
7641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7643 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7644 /* Rear Pin: output 1 (0x0d) */
7645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7648 /* CLFE Pin: output 2 (0x0e) */
7649 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7651 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7652 /* Side Pin: output 3 (0x0f) */
7653 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7655 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7656 /* Mic (rear) pin: input vref at 80% */
7657 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7658 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7659 /* Front Mic pin: input vref at 80% */
7660 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7661 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7662 /* Line In pin: input */
7663 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7665 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7667 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7668 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 /* CD pin widget for input */
7670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7671
7672 /* FIXME: use matrix-type input source selection */
7673 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7674 /* Input mixer2 */
7675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007679 /* Input mixer3 */
7680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007684 { }
7685};
7686
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007687/* toggle speaker-output according to the hp-jack state */
7688static void alc883_mitac_hp_automute(struct hda_codec *codec)
7689{
7690 unsigned int present;
7691
7692 present = snd_hda_codec_read(codec, 0x15, 0,
7693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7694 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7696 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7697 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7698}
7699
7700/* auto-toggle front mic */
7701/*
7702static void alc883_mitac_mic_automute(struct hda_codec *codec)
7703{
7704 unsigned int present;
7705 unsigned char bits;
7706
7707 present = snd_hda_codec_read(codec, 0x18, 0,
7708 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7709 bits = present ? HDA_AMP_MUTE : 0;
7710 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7711}
7712*/
7713
7714static void alc883_mitac_automute(struct hda_codec *codec)
7715{
7716 alc883_mitac_hp_automute(codec);
7717 /* alc883_mitac_mic_automute(codec); */
7718}
7719
7720static void alc883_mitac_unsol_event(struct hda_codec *codec,
7721 unsigned int res)
7722{
7723 switch (res >> 26) {
7724 case ALC880_HP_EVENT:
7725 alc883_mitac_hp_automute(codec);
7726 break;
7727 case ALC880_MIC_EVENT:
7728 /* alc883_mitac_mic_automute(codec); */
7729 break;
7730 }
7731}
7732
7733static struct hda_verb alc883_mitac_verbs[] = {
7734 /* HP */
7735 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7737 /* Subwoofer */
7738 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7739 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7740
7741 /* enable unsolicited event */
7742 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7743 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7744
7745 { } /* end */
7746};
7747
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007748static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007749 /* HP */
7750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7752 /* Int speaker */
7753 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7755
7756 /* enable unsolicited event */
7757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007758 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007759
7760 { } /* end */
7761};
7762
Jiang zhefb97dc62008-03-06 11:07:11 +01007763static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7764 /* HP */
7765 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7767 /* Subwoofer */
7768 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7769 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7770
7771 /* enable unsolicited event */
7772 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7773
7774 { } /* end */
7775};
7776
Kailang Yangccc656c2006-10-17 12:32:26 +02007777static struct hda_verb alc883_tagra_verbs[] = {
7778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7780
7781 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007783
Kailang Yangccc656c2006-10-17 12:32:26 +02007784 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7785 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7786 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7787
7788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007789 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7790 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7791 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007792
7793 { } /* end */
7794};
7795
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007796static struct hda_verb alc883_lenovo_101e_verbs[] = {
7797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7798 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7800 { } /* end */
7801};
7802
Kailang Yang272a5272007-05-14 11:00:38 +02007803static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7804 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7806 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7808 { } /* end */
7809};
7810
7811static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7815 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7816 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7817 { } /* end */
7818};
7819
Kailang Yang189609a2007-08-20 11:31:23 +02007820static struct hda_verb alc883_haier_w66_verbs[] = {
7821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7823
7824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7825
7826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7828 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7830 { } /* end */
7831};
7832
Kailang Yange2757d52008-08-26 13:17:46 +02007833static struct hda_verb alc888_lenovo_sky_verbs[] = {
7834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7837 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7838 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7840 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7841 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7842 { } /* end */
7843};
7844
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007845static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007846 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007847 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7848 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007849 { }
7850};
7851
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007852static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007853 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7854 { }
7855};
7856
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007857static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7860 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7861 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7862 { }
7863};
7864
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007865static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007866 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7867 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7868 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7869 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7870 { }
7871};
7872
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007873static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7874 { 2, alc888_3st_hp_2ch_init },
7875 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007876};
7877
Kailang Yang272a5272007-05-14 11:00:38 +02007878/* toggle front-jack and RCA according to the hp-jack state */
7879static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7880{
7881 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007882
Kailang Yang272a5272007-05-14 11:00:38 +02007883 present = snd_hda_codec_read(codec, 0x1b, 0,
7884 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007885 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7886 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7888 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007889}
7890
7891/* toggle RCA according to the front-jack state */
7892static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7893{
7894 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007895
Kailang Yang272a5272007-05-14 11:00:38 +02007896 present = snd_hda_codec_read(codec, 0x14, 0,
7897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007898 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7899 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007900}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007901
Kailang Yang272a5272007-05-14 11:00:38 +02007902static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7903 unsigned int res)
7904{
7905 if ((res >> 26) == ALC880_HP_EVENT)
7906 alc888_lenovo_ms7195_front_automute(codec);
7907 if ((res >> 26) == ALC880_FRONT_EVENT)
7908 alc888_lenovo_ms7195_rca_automute(codec);
7909}
7910
7911static struct hda_verb alc883_medion_md2_verbs[] = {
7912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7914
7915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7916
7917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7918 { } /* end */
7919};
7920
7921/* toggle speaker-output according to the hp-jack state */
7922static void alc883_medion_md2_automute(struct hda_codec *codec)
7923{
7924 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007925
Kailang Yang272a5272007-05-14 11:00:38 +02007926 present = snd_hda_codec_read(codec, 0x14, 0,
7927 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007928 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7929 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007930}
7931
7932static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7933 unsigned int res)
7934{
7935 if ((res >> 26) == ALC880_HP_EVENT)
7936 alc883_medion_md2_automute(codec);
7937}
7938
Kailang Yangccc656c2006-10-17 12:32:26 +02007939/* toggle speaker-output according to the hp-jack state */
7940static void alc883_tagra_automute(struct hda_codec *codec)
7941{
7942 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007943 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007944
7945 present = snd_hda_codec_read(codec, 0x14, 0,
7946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007947 bits = present ? HDA_AMP_MUTE : 0;
7948 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7949 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007950 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7951 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007952}
7953
7954static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7955{
7956 if ((res >> 26) == ALC880_HP_EVENT)
7957 alc883_tagra_automute(codec);
7958}
7959
Jiang zhe368c7a92008-03-04 11:20:33 +01007960/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007961static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007962{
7963 unsigned int present;
7964 unsigned char bits;
7965
7966 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7967 & AC_PINSENSE_PRESENCE;
7968 bits = present ? HDA_AMP_MUTE : 0;
7969 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7970 HDA_AMP_MUTE, bits);
7971}
7972
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007973static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7974{
7975 unsigned int present;
7976
7977 present = snd_hda_codec_read(codec, 0x18, 0,
7978 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7979 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7980 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7981}
7982
7983static void alc883_clevo_m720_automute(struct hda_codec *codec)
7984{
7985 alc883_clevo_m720_hp_automute(codec);
7986 alc883_clevo_m720_mic_automute(codec);
7987}
7988
7989static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007990 unsigned int res)
7991{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007992 switch (res >> 26) {
7993 case ALC880_HP_EVENT:
7994 alc883_clevo_m720_hp_automute(codec);
7995 break;
7996 case ALC880_MIC_EVENT:
7997 alc883_clevo_m720_mic_automute(codec);
7998 break;
7999 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008000}
8001
Jiang zhefb97dc62008-03-06 11:07:11 +01008002/* toggle speaker-output according to the hp-jack state */
8003static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8004{
8005 unsigned int present;
8006 unsigned char bits;
8007
8008 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8009 & AC_PINSENSE_PRESENCE;
8010 bits = present ? HDA_AMP_MUTE : 0;
8011 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8012 HDA_AMP_MUTE, bits);
8013}
8014
8015static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8016 unsigned int res)
8017{
8018 if ((res >> 26) == ALC880_HP_EVENT)
8019 alc883_2ch_fujitsu_pi2515_automute(codec);
8020}
8021
Kailang Yang189609a2007-08-20 11:31:23 +02008022static void alc883_haier_w66_automute(struct hda_codec *codec)
8023{
8024 unsigned int present;
8025 unsigned char bits;
8026
8027 present = snd_hda_codec_read(codec, 0x1b, 0,
8028 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8029 bits = present ? 0x80 : 0;
8030 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8031 0x80, bits);
8032}
8033
8034static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8035 unsigned int res)
8036{
8037 if ((res >> 26) == ALC880_HP_EVENT)
8038 alc883_haier_w66_automute(codec);
8039}
8040
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008041static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8042{
8043 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008044 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008045
8046 present = snd_hda_codec_read(codec, 0x14, 0,
8047 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008048 bits = present ? HDA_AMP_MUTE : 0;
8049 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8050 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008051}
8052
8053static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8054{
8055 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008056 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008057
8058 present = snd_hda_codec_read(codec, 0x1b, 0,
8059 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008060 bits = present ? HDA_AMP_MUTE : 0;
8061 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8062 HDA_AMP_MUTE, bits);
8063 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8064 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008065}
8066
8067static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8068 unsigned int res)
8069{
8070 if ((res >> 26) == ALC880_HP_EVENT)
8071 alc883_lenovo_101e_all_automute(codec);
8072 if ((res >> 26) == ALC880_FRONT_EVENT)
8073 alc883_lenovo_101e_ispeaker_automute(codec);
8074}
8075
Takashi Iwai676a9b52007-08-16 15:23:35 +02008076/* toggle speaker-output according to the hp-jack state */
8077static void alc883_acer_aspire_automute(struct hda_codec *codec)
8078{
8079 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008080
Takashi Iwai676a9b52007-08-16 15:23:35 +02008081 present = snd_hda_codec_read(codec, 0x14, 0,
8082 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8083 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8084 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8085 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8086 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8087}
8088
8089static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8090 unsigned int res)
8091{
8092 if ((res >> 26) == ALC880_HP_EVENT)
8093 alc883_acer_aspire_automute(codec);
8094}
8095
Kailang Yangd1a991a2007-08-15 16:21:59 +02008096static struct hda_verb alc883_acer_eapd_verbs[] = {
8097 /* HP Pin: output 0 (0x0c) */
8098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8100 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8101 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008102 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008104 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008105 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8106 /* eanable EAPD on medion laptop */
8107 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8108 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008109 /* enable unsolicited event */
8110 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008111 { }
8112};
8113
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008114static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8115{
8116 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008117
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008118 present = snd_hda_codec_read(codec, 0x1b, 0,
8119 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8120 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8123 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8124 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8125 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8126 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8128}
8129
8130static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8131 unsigned int res)
8132{
8133 switch (res >> 26) {
8134 case ALC880_HP_EVENT:
8135 printk("hp_event\n");
8136 alc888_6st_dell_front_automute(codec);
8137 break;
8138 }
8139}
8140
Kailang Yange2757d52008-08-26 13:17:46 +02008141static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8142{
8143 unsigned int mute;
8144 unsigned int present;
8145
8146 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8147 present = snd_hda_codec_read(codec, 0x1b, 0,
8148 AC_VERB_GET_PIN_SENSE, 0);
8149 present = (present & 0x80000000) != 0;
8150 if (present) {
8151 /* mute internal speaker */
8152 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8153 HDA_AMP_MUTE, HDA_AMP_MUTE);
8154 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8155 HDA_AMP_MUTE, HDA_AMP_MUTE);
8156 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8157 HDA_AMP_MUTE, HDA_AMP_MUTE);
8158 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8159 HDA_AMP_MUTE, HDA_AMP_MUTE);
8160 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8161 HDA_AMP_MUTE, HDA_AMP_MUTE);
8162 } else {
8163 /* unmute internal speaker if necessary */
8164 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8165 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8166 HDA_AMP_MUTE, mute);
8167 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8168 HDA_AMP_MUTE, mute);
8169 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8170 HDA_AMP_MUTE, mute);
8171 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8172 HDA_AMP_MUTE, mute);
8173 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8174 HDA_AMP_MUTE, mute);
8175 }
8176}
8177
8178static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8179 unsigned int res)
8180{
8181 if ((res >> 26) == ALC880_HP_EVENT)
8182 alc888_lenovo_sky_front_automute(codec);
8183}
8184
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008185/*
8186 * generic initialization of ADC, input mixers and output mixers
8187 */
8188static struct hda_verb alc883_auto_init_verbs[] = {
8189 /*
8190 * Unmute ADC0-2 and set the default input to mic-in
8191 */
8192 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8194 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8196
Takashi Iwaicb53c622007-08-10 17:21:45 +02008197 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008198 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008199 * Note: PASD motherboards uses the Line In 2 as the input for
8200 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008201 */
8202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008208
8209 /*
8210 * Set up output mixers (0x0c - 0x0f)
8211 */
8212 /* set vol=0 to output mixers */
8213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8217 /* set up input amps for analog loopback */
8218 /* Amp Indices: DAC = 0, mixer = 1 */
8219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8227 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8228 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8229
8230 /* FIXME: use matrix-type input source selection */
8231 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8232 /* Input mixer1 */
8233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008236 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8238 /* Input mixer2 */
8239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008242 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008244
8245 { }
8246};
8247
8248/* capture mixer elements */
8249static struct snd_kcontrol_new alc883_capture_mixer[] = {
8250 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8251 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8252 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
8253 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
8254 {
8255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8256 /* The multiple "Capture Source" controls confuse alsamixer
8257 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258 */
8259 /* .name = "Capture Source", */
8260 .name = "Input Source",
8261 .count = 2,
8262 .info = alc882_mux_enum_info,
8263 .get = alc882_mux_enum_get,
8264 .put = alc882_mux_enum_put,
8265 },
8266 { } /* end */
8267};
8268
Kailang Yange2757d52008-08-26 13:17:46 +02008269static struct hda_verb alc888_asus_m90v_verbs[] = {
8270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8273 /* enable unsolicited event */
8274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8275 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8276 { } /* end */
8277};
8278
8279static void alc883_nb_mic_automute(struct hda_codec *codec)
8280{
8281 unsigned int present;
8282
8283 present = snd_hda_codec_read(codec, 0x18, 0,
8284 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8285 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8286 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8287 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8288 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8289}
8290
8291static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8292{
8293 unsigned int present;
8294 unsigned char bits;
8295
8296 present = snd_hda_codec_read(codec, 0x1b, 0,
8297 AC_VERB_GET_PIN_SENSE, 0)
8298 & AC_PINSENSE_PRESENCE;
8299 bits = present ? 0 : PIN_OUT;
8300 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8301 bits);
8302 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8303 bits);
8304 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8305 bits);
8306}
8307
8308static void alc883_mode2_unsol_event(struct hda_codec *codec,
8309 unsigned int res)
8310{
8311 switch (res >> 26) {
8312 case ALC880_HP_EVENT:
8313 alc883_M90V_speaker_automute(codec);
8314 break;
8315 case ALC880_MIC_EVENT:
8316 alc883_nb_mic_automute(codec);
8317 break;
8318 }
8319}
8320
8321static void alc883_mode2_inithook(struct hda_codec *codec)
8322{
8323 alc883_M90V_speaker_automute(codec);
8324 alc883_nb_mic_automute(codec);
8325}
8326
8327static struct hda_verb alc888_asus_eee1601_verbs[] = {
8328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8333 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8334 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8335 /* enable unsolicited event */
8336 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8337 { } /* end */
8338};
8339
8340static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8341{
8342 unsigned int present;
8343 unsigned char bits;
8344
8345 present = snd_hda_codec_read(codec, 0x14, 0,
8346 AC_VERB_GET_PIN_SENSE, 0)
8347 & AC_PINSENSE_PRESENCE;
8348 bits = present ? 0 : PIN_OUT;
8349 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8350 bits);
8351}
8352
8353static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8354 unsigned int res)
8355{
8356 switch (res >> 26) {
8357 case ALC880_HP_EVENT:
8358 alc883_eee1601_speaker_automute(codec);
8359 break;
8360 }
8361}
8362
8363static void alc883_eee1601_inithook(struct hda_codec *codec)
8364{
8365 alc883_eee1601_speaker_automute(codec);
8366}
8367
Takashi Iwaicb53c622007-08-10 17:21:45 +02008368#ifdef CONFIG_SND_HDA_POWER_SAVE
8369#define alc883_loopbacks alc880_loopbacks
8370#endif
8371
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008372/* pcm configuration: identiacal with ALC880 */
8373#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8374#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008375#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008376#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8377#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8378
8379/*
8380 * configuration and preset
8381 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008382static const char *alc883_models[ALC883_MODEL_LAST] = {
8383 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8384 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8385 [ALC883_3ST_6ch] = "3stack-6ch",
8386 [ALC883_6ST_DIG] = "6stack-dig",
8387 [ALC883_TARGA_DIG] = "targa-dig",
8388 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008389 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02008390 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008391 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008392 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008393 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008394 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008395 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8396 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008397 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008398 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008399 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008400 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008401 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008402 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008403 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008404 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008405 [ALC883_AUTO] = "auto",
8406};
8407
8408static struct snd_pci_quirk alc883_cfg_tbl[] = {
8409 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008410 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8411 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8412 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008413 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008414 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008415 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008416 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008417 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8418 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008419 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008420 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008421 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008422 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008423 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008424 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008425 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8426 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008427 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008428 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008429 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008430 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8431 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8432 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008433 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008434 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008435 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008436 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8437 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8438 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8439 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8440 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8441 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8442 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8443 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8444 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008445 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8446 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008447 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008448 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008449 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008450 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008451 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008452 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008453 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8454 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008455 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008456 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008457 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008458 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008459 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008460 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008461 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8462 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008463 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008464 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008465 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008466 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008467 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8468 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008469 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008470 {}
8471};
8472
8473static struct alc_config_preset alc883_presets[] = {
8474 [ALC883_3ST_2ch_DIG] = {
8475 .mixers = { alc883_3ST_2ch_mixer },
8476 .init_verbs = { alc883_init_verbs },
8477 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8478 .dac_nids = alc883_dac_nids,
8479 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008480 .dig_in_nid = ALC883_DIGIN_NID,
8481 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8482 .channel_mode = alc883_3ST_2ch_modes,
8483 .input_mux = &alc883_capture_source,
8484 },
8485 [ALC883_3ST_6ch_DIG] = {
8486 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8487 .init_verbs = { alc883_init_verbs },
8488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8489 .dac_nids = alc883_dac_nids,
8490 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008491 .dig_in_nid = ALC883_DIGIN_NID,
8492 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8493 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008494 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008495 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008496 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008497 [ALC883_3ST_6ch] = {
8498 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8499 .init_verbs = { alc883_init_verbs },
8500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8501 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8503 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008504 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008505 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008506 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008507 [ALC883_3ST_6ch_INTEL] = {
8508 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8509 .init_verbs = { alc883_init_verbs },
8510 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8511 .dac_nids = alc883_dac_nids,
8512 .dig_out_nid = ALC883_DIGOUT_NID,
8513 .dig_in_nid = ALC883_DIGIN_NID,
8514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8515 .channel_mode = alc883_3ST_6ch_intel_modes,
8516 .need_dac_fix = 1,
8517 .input_mux = &alc883_3stack_6ch_intel,
8518 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008519 [ALC883_6ST_DIG] = {
8520 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8521 .init_verbs = { alc883_init_verbs },
8522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8523 .dac_nids = alc883_dac_nids,
8524 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008525 .dig_in_nid = ALC883_DIGIN_NID,
8526 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8527 .channel_mode = alc883_sixstack_modes,
8528 .input_mux = &alc883_capture_source,
8529 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008530 [ALC883_TARGA_DIG] = {
8531 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8532 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8534 .dac_nids = alc883_dac_nids,
8535 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8537 .channel_mode = alc883_3ST_6ch_modes,
8538 .need_dac_fix = 1,
8539 .input_mux = &alc883_capture_source,
8540 .unsol_event = alc883_tagra_unsol_event,
8541 .init_hook = alc883_tagra_automute,
8542 },
8543 [ALC883_TARGA_2ch_DIG] = {
8544 .mixers = { alc883_tagra_2ch_mixer},
8545 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8547 .dac_nids = alc883_dac_nids,
8548 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8550 .channel_mode = alc883_3ST_2ch_modes,
8551 .input_mux = &alc883_capture_source,
8552 .unsol_event = alc883_tagra_unsol_event,
8553 .init_hook = alc883_tagra_automute,
8554 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008555 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008556 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008557 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8558 * and the headphone jack. Turn this on and rely on the
8559 * standard mute methods whenever the user wants to turn
8560 * these outputs off.
8561 */
8562 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8564 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8566 .channel_mode = alc883_3ST_2ch_modes,
8567 .input_mux = &alc883_capture_source,
8568 },
Tobin Davis2880a8672007-08-07 11:50:26 +02008569 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008570 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008571 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02008572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8573 .dac_nids = alc883_dac_nids,
8574 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02008575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8576 .channel_mode = alc883_3ST_2ch_modes,
8577 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008578 .unsol_event = alc883_acer_aspire_unsol_event,
8579 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008580 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008581 [ALC883_MEDION] = {
8582 .mixers = { alc883_fivestack_mixer,
8583 alc883_chmode_mixer },
8584 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008585 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8587 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008588 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8589 .channel_mode = alc883_sixstack_modes,
8590 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008591 },
Kailang Yang272a5272007-05-14 11:00:38 +02008592 [ALC883_MEDION_MD2] = {
8593 .mixers = { alc883_medion_md2_mixer},
8594 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8596 .dac_nids = alc883_dac_nids,
8597 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008598 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8599 .channel_mode = alc883_3ST_2ch_modes,
8600 .input_mux = &alc883_capture_source,
8601 .unsol_event = alc883_medion_md2_unsol_event,
8602 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008603 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008604 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008605 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008606 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8607 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8608 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8610 .channel_mode = alc883_3ST_2ch_modes,
8611 .input_mux = &alc883_capture_source,
8612 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008613 [ALC883_CLEVO_M720] = {
8614 .mixers = { alc883_clevo_m720_mixer },
8615 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8617 .dac_nids = alc883_dac_nids,
8618 .dig_out_nid = ALC883_DIGOUT_NID,
8619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8620 .channel_mode = alc883_3ST_2ch_modes,
8621 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008622 .unsol_event = alc883_clevo_m720_unsol_event,
8623 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008624 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008625 [ALC883_LENOVO_101E_2ch] = {
8626 .mixers = { alc883_lenovo_101e_2ch_mixer},
8627 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8629 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8631 .channel_mode = alc883_3ST_2ch_modes,
8632 .input_mux = &alc883_lenovo_101e_capture_source,
8633 .unsol_event = alc883_lenovo_101e_unsol_event,
8634 .init_hook = alc883_lenovo_101e_all_automute,
8635 },
Kailang Yang272a5272007-05-14 11:00:38 +02008636 [ALC883_LENOVO_NB0763] = {
8637 .mixers = { alc883_lenovo_nb0763_mixer },
8638 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8639 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8640 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008641 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8642 .channel_mode = alc883_3ST_2ch_modes,
8643 .need_dac_fix = 1,
8644 .input_mux = &alc883_lenovo_nb0763_capture_source,
8645 .unsol_event = alc883_medion_md2_unsol_event,
8646 .init_hook = alc883_medion_md2_automute,
8647 },
8648 [ALC888_LENOVO_MS7195_DIG] = {
8649 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8650 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8651 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8652 .dac_nids = alc883_dac_nids,
8653 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008654 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8655 .channel_mode = alc883_3ST_6ch_modes,
8656 .need_dac_fix = 1,
8657 .input_mux = &alc883_capture_source,
8658 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8659 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008660 },
8661 [ALC883_HAIER_W66] = {
8662 .mixers = { alc883_tagra_2ch_mixer},
8663 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8665 .dac_nids = alc883_dac_nids,
8666 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008667 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8668 .channel_mode = alc883_3ST_2ch_modes,
8669 .input_mux = &alc883_capture_source,
8670 .unsol_event = alc883_haier_w66_unsol_event,
8671 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008672 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008673 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008674 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008675 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008676 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8677 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008678 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8679 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008680 .need_dac_fix = 1,
8681 .input_mux = &alc883_capture_source,
8682 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008683 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008684 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008685 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8687 .dac_nids = alc883_dac_nids,
8688 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008689 .dig_in_nid = ALC883_DIGIN_NID,
8690 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8691 .channel_mode = alc883_sixstack_modes,
8692 .input_mux = &alc883_capture_source,
8693 .unsol_event = alc888_6st_dell_unsol_event,
8694 .init_hook = alc888_6st_dell_front_automute,
8695 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008696 [ALC883_MITAC] = {
8697 .mixers = { alc883_mitac_mixer },
8698 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8700 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008701 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8702 .channel_mode = alc883_3ST_2ch_modes,
8703 .input_mux = &alc883_capture_source,
8704 .unsol_event = alc883_mitac_unsol_event,
8705 .init_hook = alc883_mitac_automute,
8706 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008707 [ALC883_FUJITSU_PI2515] = {
8708 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8709 .init_verbs = { alc883_init_verbs,
8710 alc883_2ch_fujitsu_pi2515_verbs},
8711 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8712 .dac_nids = alc883_dac_nids,
8713 .dig_out_nid = ALC883_DIGOUT_NID,
8714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8715 .channel_mode = alc883_3ST_2ch_modes,
8716 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8717 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8718 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8719 },
Kailang Yange2757d52008-08-26 13:17:46 +02008720 [ALC888_LENOVO_SKY] = {
8721 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8722 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8723 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8724 .dac_nids = alc883_dac_nids,
8725 .dig_out_nid = ALC883_DIGOUT_NID,
8726 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
8727 .adc_nids = alc883_adc_nids,
8728 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8729 .channel_mode = alc883_sixstack_modes,
8730 .need_dac_fix = 1,
8731 .input_mux = &alc883_lenovo_sky_capture_source,
8732 .unsol_event = alc883_lenovo_sky_unsol_event,
8733 .init_hook = alc888_lenovo_sky_front_automute,
8734 },
8735 [ALC888_ASUS_M90V] = {
8736 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8737 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8738 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8739 .dac_nids = alc883_dac_nids,
8740 .dig_out_nid = ALC883_DIGOUT_NID,
8741 .dig_in_nid = ALC883_DIGIN_NID,
8742 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8743 .channel_mode = alc883_3ST_6ch_modes,
8744 .need_dac_fix = 1,
8745 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8746 .unsol_event = alc883_mode2_unsol_event,
8747 .init_hook = alc883_mode2_inithook,
8748 },
8749 [ALC888_ASUS_EEE1601] = {
8750 .mixers = { alc883_asus_eee1601_mixer },
8751 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8752 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8753 .dac_nids = alc883_dac_nids,
8754 .dig_out_nid = ALC883_DIGOUT_NID,
8755 .dig_in_nid = ALC883_DIGIN_NID,
8756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8757 .channel_mode = alc883_3ST_2ch_modes,
8758 .need_dac_fix = 1,
8759 .input_mux = &alc883_asus_eee1601_capture_source,
8760 .unsol_event = alc883_eee1601_unsol_event,
8761 .init_hook = alc883_eee1601_inithook,
8762 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008763};
8764
8765
8766/*
8767 * BIOS auto configuration
8768 */
8769static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8770 hda_nid_t nid, int pin_type,
8771 int dac_idx)
8772{
8773 /* set as output */
8774 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008775 int idx;
8776
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008777 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008778 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8779 idx = 4;
8780 else
8781 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8783
8784}
8785
8786static void alc883_auto_init_multi_out(struct hda_codec *codec)
8787{
8788 struct alc_spec *spec = codec->spec;
8789 int i;
8790
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008791 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008792 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008793 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008794 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008795 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008796 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008797 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008798 }
8799}
8800
8801static void alc883_auto_init_hp_out(struct hda_codec *codec)
8802{
8803 struct alc_spec *spec = codec->spec;
8804 hda_nid_t pin;
8805
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008806 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008807 if (pin) /* connect to front */
8808 /* use dac 0 */
8809 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008810 pin = spec->autocfg.speaker_pins[0];
8811 if (pin)
8812 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008813}
8814
8815#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8816#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8817
8818static void alc883_auto_init_analog_input(struct hda_codec *codec)
8819{
8820 struct alc_spec *spec = codec->spec;
8821 int i;
8822
8823 for (i = 0; i < AUTO_PIN_LAST; i++) {
8824 hda_nid_t nid = spec->autocfg.input_pins[i];
8825 if (alc883_is_input_pin(nid)) {
8826 snd_hda_codec_write(codec, nid, 0,
8827 AC_VERB_SET_PIN_WIDGET_CONTROL,
8828 (i <= AUTO_PIN_FRONT_MIC ?
8829 PIN_VREF80 : PIN_IN));
8830 if (nid != ALC883_PIN_CD_NID)
8831 snd_hda_codec_write(codec, nid, 0,
8832 AC_VERB_SET_AMP_GAIN_MUTE,
8833 AMP_OUT_MUTE);
8834 }
8835 }
8836}
8837
Takashi Iwaif511b012008-08-15 16:46:42 +02008838#define alc883_auto_init_input_src alc882_auto_init_input_src
8839
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008840/* almost identical with ALC880 parser... */
8841static int alc883_parse_auto_config(struct hda_codec *codec)
8842{
8843 struct alc_spec *spec = codec->spec;
8844 int err = alc880_parse_auto_config(codec);
8845
8846 if (err < 0)
8847 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008848 else if (!err)
8849 return 0; /* no config found */
8850
8851 err = alc_auto_add_mic_boost(codec);
8852 if (err < 0)
8853 return err;
8854
8855 /* hack - override the init verbs */
8856 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008857 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8858 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008859
8860 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008861}
8862
8863/* additional initialization for auto-configuration model */
8864static void alc883_auto_init(struct hda_codec *codec)
8865{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008866 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008867 alc883_auto_init_multi_out(codec);
8868 alc883_auto_init_hp_out(codec);
8869 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008870 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008871 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008872 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008873}
8874
8875static int patch_alc883(struct hda_codec *codec)
8876{
8877 struct alc_spec *spec;
8878 int err, board_config;
8879
8880 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8881 if (spec == NULL)
8882 return -ENOMEM;
8883
8884 codec->spec = spec;
8885
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008886 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8887
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008888 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8889 alc883_models,
8890 alc883_cfg_tbl);
8891 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8893 "trying auto-probe from BIOS...\n");
8894 board_config = ALC883_AUTO;
8895 }
8896
8897 if (board_config == ALC883_AUTO) {
8898 /* automatic parse from the BIOS config */
8899 err = alc883_parse_auto_config(codec);
8900 if (err < 0) {
8901 alc_free(codec);
8902 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008903 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008904 printk(KERN_INFO
8905 "hda_codec: Cannot set up configuration "
8906 "from BIOS. Using base mode...\n");
8907 board_config = ALC883_3ST_2ch_DIG;
8908 }
8909 }
8910
8911 if (board_config != ALC883_AUTO)
8912 setup_preset(spec, &alc883_presets[board_config]);
8913
Kailang Yang2f893282008-05-27 12:14:47 +02008914 switch (codec->vendor_id) {
8915 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02008916 if (codec->revision_id == 0x100101) {
8917 spec->stream_name_analog = "ALC1200 Analog";
8918 spec->stream_name_digital = "ALC1200 Digital";
8919 } else {
8920 spec->stream_name_analog = "ALC888 Analog";
8921 spec->stream_name_digital = "ALC888 Digital";
8922 }
Kailang Yang2f893282008-05-27 12:14:47 +02008923 break;
8924 case 0x10ec0889:
8925 spec->stream_name_analog = "ALC889 Analog";
8926 spec->stream_name_digital = "ALC889 Digital";
8927 break;
8928 default:
8929 spec->stream_name_analog = "ALC883 Analog";
8930 spec->stream_name_digital = "ALC883 Digital";
8931 break;
8932 }
8933
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008934 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8935 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008936 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008937
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008938 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8939 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8940
Takashi Iwaie1406342008-02-11 18:32:32 +01008941 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8942 spec->adc_nids = alc883_adc_nids;
8943 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008944
Takashi Iwai2134ea42008-01-10 16:53:55 +01008945 spec->vmaster_nid = 0x0c;
8946
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008947 codec->patch_ops = alc_patch_ops;
8948 if (board_config == ALC883_AUTO)
8949 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008950
Takashi Iwaicb53c622007-08-10 17:21:45 +02008951#ifdef CONFIG_SND_HDA_POWER_SAVE
8952 if (!spec->loopback.amplist)
8953 spec->loopback.amplist = alc883_loopbacks;
8954#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008955
8956 return 0;
8957}
8958
8959/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008960 * ALC262 support
8961 */
8962
8963#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8964#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8965
8966#define alc262_dac_nids alc260_dac_nids
8967#define alc262_adc_nids alc882_adc_nids
8968#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008969#define alc262_capsrc_nids alc882_capsrc_nids
8970#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008971
8972#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008973#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008974
Kailang Yang4e555fe2008-08-26 13:05:55 +02008975static hda_nid_t alc262_dmic_adc_nids[1] = {
8976 /* ADC0 */
8977 0x09
8978};
8979
8980static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8981
Kailang Yangdf694da2005-12-05 19:42:22 +01008982static struct snd_kcontrol_new alc262_base_mixer[] = {
8983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8984 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008994 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008995 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008996 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008997 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8999 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009001 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009002};
9003
Kailang Yangccc656c2006-10-17 12:32:26 +02009004static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9006 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9015 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009017 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009018 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02009019 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9021 { } /* end */
9022};
9023
Takashi Iwaice875f02008-01-28 18:17:43 +01009024/* update HP, line and mono-out pins according to the master switch */
9025static void alc262_hp_master_update(struct hda_codec *codec)
9026{
9027 struct alc_spec *spec = codec->spec;
9028 int val = spec->master_sw;
9029
9030 /* HP & line-out */
9031 snd_hda_codec_write_cache(codec, 0x1b, 0,
9032 AC_VERB_SET_PIN_WIDGET_CONTROL,
9033 val ? PIN_HP : 0);
9034 snd_hda_codec_write_cache(codec, 0x15, 0,
9035 AC_VERB_SET_PIN_WIDGET_CONTROL,
9036 val ? PIN_HP : 0);
9037 /* mono (speaker) depending on the HP jack sense */
9038 val = val && !spec->jack_present;
9039 snd_hda_codec_write_cache(codec, 0x16, 0,
9040 AC_VERB_SET_PIN_WIDGET_CONTROL,
9041 val ? PIN_OUT : 0);
9042}
9043
9044static void alc262_hp_bpc_automute(struct hda_codec *codec)
9045{
9046 struct alc_spec *spec = codec->spec;
9047 unsigned int presence;
9048 presence = snd_hda_codec_read(codec, 0x1b, 0,
9049 AC_VERB_GET_PIN_SENSE, 0);
9050 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9051 alc262_hp_master_update(codec);
9052}
9053
9054static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9055{
9056 if ((res >> 26) != ALC880_HP_EVENT)
9057 return;
9058 alc262_hp_bpc_automute(codec);
9059}
9060
9061static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9062{
9063 struct alc_spec *spec = codec->spec;
9064 unsigned int presence;
9065 presence = snd_hda_codec_read(codec, 0x15, 0,
9066 AC_VERB_GET_PIN_SENSE, 0);
9067 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9068 alc262_hp_master_update(codec);
9069}
9070
9071static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9072 unsigned int res)
9073{
9074 if ((res >> 26) != ALC880_HP_EVENT)
9075 return;
9076 alc262_hp_wildwest_automute(codec);
9077}
9078
9079static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9080 struct snd_ctl_elem_value *ucontrol)
9081{
9082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9083 struct alc_spec *spec = codec->spec;
9084 *ucontrol->value.integer.value = spec->master_sw;
9085 return 0;
9086}
9087
9088static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9089 struct snd_ctl_elem_value *ucontrol)
9090{
9091 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9092 struct alc_spec *spec = codec->spec;
9093 int val = !!*ucontrol->value.integer.value;
9094
9095 if (val == spec->master_sw)
9096 return 0;
9097 spec->master_sw = val;
9098 alc262_hp_master_update(codec);
9099 return 1;
9100}
9101
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009103 {
9104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9105 .name = "Master Playback Switch",
9106 .info = snd_ctl_boolean_mono_info,
9107 .get = alc262_hp_master_sw_get,
9108 .put = alc262_hp_master_sw_put,
9109 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9111 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009113 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9114 HDA_OUTPUT),
9115 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9116 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009119 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009120 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009122 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9127 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9128 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9129 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9130 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9131 { } /* end */
9132};
9133
Kailang Yangcd7509a2007-01-26 18:33:17 +01009134static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009135 {
9136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9137 .name = "Master Playback Switch",
9138 .info = snd_ctl_boolean_mono_info,
9139 .get = alc262_hp_master_sw_get,
9140 .put = alc262_hp_master_sw_put,
9141 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9143 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009146 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9147 HDA_OUTPUT),
9148 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9149 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009150 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9151 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009152 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9155 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9156 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9157 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9158 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9159 { } /* end */
9160};
9161
9162static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9163 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9164 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009165 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009166 { } /* end */
9167};
9168
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009169/* mute/unmute internal speaker according to the hp jack and mute state */
9170static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9171{
9172 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009173
9174 if (force || !spec->sense_updated) {
9175 unsigned int present;
9176 present = snd_hda_codec_read(codec, 0x15, 0,
9177 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009178 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009179 spec->sense_updated = 1;
9180 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009181 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9182 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009183}
9184
9185static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9186 unsigned int res)
9187{
9188 if ((res >> 26) != ALC880_HP_EVENT)
9189 return;
9190 alc262_hp_t5735_automute(codec, 1);
9191}
9192
9193static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9194{
9195 alc262_hp_t5735_automute(codec, 1);
9196}
9197
9198static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009199 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9200 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9205 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9206 { } /* end */
9207};
9208
9209static struct hda_verb alc262_hp_t5735_verbs[] = {
9210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9212
9213 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9214 { }
9215};
9216
Kailang Yang8c427222008-01-10 13:03:59 +01009217static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9221 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9224 { } /* end */
9225};
9226
9227static struct hda_verb alc262_hp_rp5700_verbs[] = {
9228 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9229 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9233 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9235 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9238 {}
9239};
9240
9241static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9242 .num_items = 1,
9243 .items = {
9244 { "Line", 0x1 },
9245 },
9246};
9247
Takashi Iwai0724ea22007-08-23 00:31:43 +02009248/* bind hp and internal speaker mute (with plug check) */
9249static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9250 struct snd_ctl_elem_value *ucontrol)
9251{
9252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9253 long *valp = ucontrol->value.integer.value;
9254 int change;
9255
9256 /* change hp mute */
9257 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9258 HDA_AMP_MUTE,
9259 valp[0] ? 0 : HDA_AMP_MUTE);
9260 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9261 HDA_AMP_MUTE,
9262 valp[1] ? 0 : HDA_AMP_MUTE);
9263 if (change) {
9264 /* change speaker according to HP jack state */
9265 struct alc_spec *spec = codec->spec;
9266 unsigned int mute;
9267 if (spec->jack_present)
9268 mute = HDA_AMP_MUTE;
9269 else
9270 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9271 HDA_OUTPUT, 0);
9272 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9273 HDA_AMP_MUTE, mute);
9274 }
9275 return change;
9276}
Takashi Iwai5b319542007-07-26 11:49:22 +02009277
Kailang Yang272a5272007-05-14 11:00:38 +02009278static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009279 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9280 {
9281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9282 .name = "Master Playback Switch",
9283 .info = snd_hda_mixer_amp_switch_info,
9284 .get = snd_hda_mixer_amp_switch_get,
9285 .put = alc262_sony_master_sw_put,
9286 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9287 },
Kailang Yang272a5272007-05-14 11:00:38 +02009288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9290 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9291 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9292 { } /* end */
9293};
9294
Kailang Yang83c34212007-07-05 11:43:05 +02009295static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9297 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9300 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9301 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9302 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9303 { } /* end */
9304};
Kailang Yang272a5272007-05-14 11:00:38 +02009305
Kailang Yangdf694da2005-12-05 19:42:22 +01009306#define alc262_capture_mixer alc882_capture_mixer
9307#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9308
9309/*
9310 * generic initialization of ADC, input mixers and output mixers
9311 */
9312static struct hda_verb alc262_init_verbs[] = {
9313 /*
9314 * Unmute ADC0-2 and set the default input to mic-in
9315 */
9316 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9320 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9322
Takashi Iwaicb53c622007-08-10 17:21:45 +02009323 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009324 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009325 * Note: PASD motherboards uses the Line In 2 as the input for
9326 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009327 */
9328 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009334
9335 /*
9336 * Set up output mixers (0x0c - 0x0e)
9337 */
9338 /* set vol=0 to output mixers */
9339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9342 /* set up input amps for analog loopback */
9343 /* Amp Indices: DAC = 0, mixer = 1 */
9344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9350
9351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9356 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9357
9358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009363
Kailang Yangdf694da2005-12-05 19:42:22 +01009364 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9365 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009366
Kailang Yangdf694da2005-12-05 19:42:22 +01009367 /* FIXME: use matrix-type input source selection */
9368 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9369 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9374 /* Input mixer2 */
9375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9379 /* Input mixer3 */
9380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009384
9385 { }
9386};
9387
Kailang Yang4e555fe2008-08-26 13:05:55 +02009388static struct hda_verb alc262_eapd_verbs[] = {
9389 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9390 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9391 { }
9392};
9393
Kailang Yangccc656c2006-10-17 12:32:26 +02009394static struct hda_verb alc262_hippo_unsol_verbs[] = {
9395 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9397 {}
9398};
9399
9400static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9401 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9402 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9403 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9404
9405 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9406 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9407 {}
9408};
9409
Kailang Yang272a5272007-05-14 11:00:38 +02009410static struct hda_verb alc262_sony_unsol_verbs[] = {
9411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9413 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9414
9415 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009417 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009418};
9419
Kailang Yang4e555fe2008-08-26 13:05:55 +02009420static struct hda_input_mux alc262_dmic_capture_source = {
9421 .num_items = 2,
9422 .items = {
9423 { "Int DMic", 0x9 },
9424 { "Mic", 0x0 },
9425 },
9426};
9427
9428static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9429 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9430 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9434 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9435 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9436 {
9437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9438 /* The multiple "Capture Source" controls confuse alsamixer
9439 * So call somewhat different..
9440 */
9441 /* .name = "Capture Source", */
9442 .name = "Input Source",
9443 .count = 1,
9444 .info = alc_mux_enum_info,
9445 .get = alc_mux_enum_get,
9446 .put = alc_mux_enum_put,
9447 },
9448 { } /* end */
9449};
9450
9451static struct hda_verb alc262_toshiba_s06_verbs[] = {
9452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9456 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9458 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9459 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9460 {}
9461};
9462
9463static void alc262_dmic_automute(struct hda_codec *codec)
9464{
9465 unsigned int present;
9466
9467 present = snd_hda_codec_read(codec, 0x18, 0,
9468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9469 snd_hda_codec_write(codec, 0x22, 0,
9470 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9471}
9472
9473/* toggle speaker-output according to the hp-jack state */
9474static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9475{
9476 unsigned int present;
9477 unsigned char bits;
9478
9479 present = snd_hda_codec_read(codec, 0x15, 0,
9480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9481 bits = present ? 0 : PIN_OUT;
9482 snd_hda_codec_write(codec, 0x14, 0,
9483 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9484}
9485
9486
9487
9488/* unsolicited event for HP jack sensing */
9489static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9490 unsigned int res)
9491{
9492 if ((res >> 26) == ALC880_HP_EVENT)
9493 alc262_toshiba_s06_speaker_automute(codec);
9494 if ((res >> 26) == ALC880_MIC_EVENT)
9495 alc262_dmic_automute(codec);
9496
9497}
9498
9499static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9500{
9501 alc262_toshiba_s06_speaker_automute(codec);
9502 alc262_dmic_automute(codec);
9503}
9504
Kailang Yangccc656c2006-10-17 12:32:26 +02009505/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009506static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009507{
9508 struct alc_spec *spec = codec->spec;
9509 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009510 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009511
Takashi Iwai5b319542007-07-26 11:49:22 +02009512 /* need to execute and sync at first */
9513 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9514 present = snd_hda_codec_read(codec, 0x15, 0,
9515 AC_VERB_GET_PIN_SENSE, 0);
9516 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009517 if (spec->jack_present) {
9518 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009519 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9520 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009521 } else {
9522 /* unmute internal speaker if necessary */
9523 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009524 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9525 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009526 }
9527}
9528
9529/* unsolicited event for HP jack sensing */
9530static void alc262_hippo_unsol_event(struct hda_codec *codec,
9531 unsigned int res)
9532{
9533 if ((res >> 26) != ALC880_HP_EVENT)
9534 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009535 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009536}
9537
Takashi Iwai5b319542007-07-26 11:49:22 +02009538static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009539{
Kailang Yangccc656c2006-10-17 12:32:26 +02009540 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009541 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009542
Takashi Iwai5b319542007-07-26 11:49:22 +02009543 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9544 present = snd_hda_codec_read(codec, 0x1b, 0,
9545 AC_VERB_GET_PIN_SENSE, 0);
9546 present = (present & 0x80000000) != 0;
9547 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009548 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009549 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9550 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009551 } else {
9552 /* unmute internal speaker if necessary */
9553 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009554 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9555 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009556 }
9557}
9558
9559/* unsolicited event for HP jack sensing */
9560static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9561 unsigned int res)
9562{
9563 if ((res >> 26) != ALC880_HP_EVENT)
9564 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009565 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009566}
9567
Takashi Iwai834be882006-03-01 14:16:17 +01009568/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009569 * nec model
9570 * 0x15 = headphone
9571 * 0x16 = internal speaker
9572 * 0x18 = external mic
9573 */
9574
9575static struct snd_kcontrol_new alc262_nec_mixer[] = {
9576 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9577 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9578
9579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9581 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9582
9583 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9585 { } /* end */
9586};
9587
9588static struct hda_verb alc262_nec_verbs[] = {
9589 /* Unmute Speaker */
9590 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9591
9592 /* Headphone */
9593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9595
9596 /* External mic to headphone */
9597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9598 /* External mic to speaker */
9599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9600 {}
9601};
9602
9603/*
Takashi Iwai834be882006-03-01 14:16:17 +01009604 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009605 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9606 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009607 */
9608
9609#define ALC_HP_EVENT 0x37
9610
9611static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9612 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009614 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009616 {}
9617};
9618
Jiang zhe0e31daf2008-03-20 12:12:39 +01009619static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9620 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9621 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9622 {}
9623};
9624
Takashi Iwai834be882006-03-01 14:16:17 +01009625static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009626 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009627 .items = {
9628 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009629 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009630 { "CD", 0x4 },
9631 },
9632};
9633
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009634static struct hda_input_mux alc262_HP_capture_source = {
9635 .num_items = 5,
9636 .items = {
9637 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009638 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009639 { "Line", 0x2 },
9640 { "CD", 0x4 },
9641 { "AUX IN", 0x6 },
9642 },
9643};
9644
zhejiangaccbe492007-08-31 12:36:05 +02009645static struct hda_input_mux alc262_HP_D7000_capture_source = {
9646 .num_items = 4,
9647 .items = {
9648 { "Mic", 0x0 },
9649 { "Front Mic", 0x2 },
9650 { "Line", 0x1 },
9651 { "CD", 0x4 },
9652 },
9653};
9654
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009655/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009656static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9657{
9658 struct alc_spec *spec = codec->spec;
9659 unsigned int mute;
9660
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009661 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009662 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009663 /* need to execute and sync at first */
9664 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009665 /* check laptop HP jack */
9666 present = snd_hda_codec_read(codec, 0x14, 0,
9667 AC_VERB_GET_PIN_SENSE, 0);
9668 /* need to execute and sync at first */
9669 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9670 /* check docking HP jack */
9671 present |= snd_hda_codec_read(codec, 0x1b, 0,
9672 AC_VERB_GET_PIN_SENSE, 0);
9673 if (present & AC_PINSENSE_PRESENCE)
9674 spec->jack_present = 1;
9675 else
9676 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009677 spec->sense_updated = 1;
9678 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009679 /* unmute internal speaker only if both HPs are unplugged and
9680 * master switch is on
9681 */
9682 if (spec->jack_present)
9683 mute = HDA_AMP_MUTE;
9684 else
Takashi Iwai834be882006-03-01 14:16:17 +01009685 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009686 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9687 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009688}
9689
9690/* unsolicited event for HP jack sensing */
9691static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9692 unsigned int res)
9693{
9694 if ((res >> 26) != ALC_HP_EVENT)
9695 return;
9696 alc262_fujitsu_automute(codec, 1);
9697}
9698
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009699static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9700{
9701 alc262_fujitsu_automute(codec, 1);
9702}
9703
Takashi Iwai834be882006-03-01 14:16:17 +01009704/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009705static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9706 .ops = &snd_hda_bind_vol,
9707 .values = {
9708 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9709 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9710 0
9711 },
9712};
Takashi Iwai834be882006-03-01 14:16:17 +01009713
Jiang zhe0e31daf2008-03-20 12:12:39 +01009714/* mute/unmute internal speaker according to the hp jack and mute state */
9715static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9716{
9717 struct alc_spec *spec = codec->spec;
9718 unsigned int mute;
9719
9720 if (force || !spec->sense_updated) {
9721 unsigned int present_int_hp;
9722 /* need to execute and sync at first */
9723 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9724 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9725 AC_VERB_GET_PIN_SENSE, 0);
9726 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9727 spec->sense_updated = 1;
9728 }
9729 if (spec->jack_present) {
9730 /* mute internal speaker */
9731 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9732 HDA_AMP_MUTE, HDA_AMP_MUTE);
9733 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9734 HDA_AMP_MUTE, HDA_AMP_MUTE);
9735 } else {
9736 /* unmute internal speaker if necessary */
9737 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9738 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9739 HDA_AMP_MUTE, mute);
9740 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9741 HDA_AMP_MUTE, mute);
9742 }
9743}
9744
9745/* unsolicited event for HP jack sensing */
9746static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9747 unsigned int res)
9748{
9749 if ((res >> 26) != ALC_HP_EVENT)
9750 return;
9751 alc262_lenovo_3000_automute(codec, 1);
9752}
9753
Takashi Iwai834be882006-03-01 14:16:17 +01009754/* bind hp and internal speaker mute (with plug check) */
9755static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9756 struct snd_ctl_elem_value *ucontrol)
9757{
9758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9759 long *valp = ucontrol->value.integer.value;
9760 int change;
9761
Tony Vroon5d9fab22008-03-14 17:09:18 +01009762 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9763 HDA_AMP_MUTE,
9764 valp ? 0 : HDA_AMP_MUTE);
9765 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9766 HDA_AMP_MUTE,
9767 valp ? 0 : HDA_AMP_MUTE);
9768
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009769 if (change)
9770 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009771 return change;
9772}
9773
9774static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009775 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009776 {
9777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9778 .name = "Master Playback Switch",
9779 .info = snd_hda_mixer_amp_switch_info,
9780 .get = snd_hda_mixer_amp_switch_get,
9781 .put = alc262_fujitsu_master_sw_put,
9782 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9783 },
9784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009786 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9787 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009791 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9792 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9793 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009794 { } /* end */
9795};
9796
Jiang zhe0e31daf2008-03-20 12:12:39 +01009797/* bind hp and internal speaker mute (with plug check) */
9798static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9799 struct snd_ctl_elem_value *ucontrol)
9800{
9801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9802 long *valp = ucontrol->value.integer.value;
9803 int change;
9804
9805 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9806 HDA_AMP_MUTE,
9807 valp ? 0 : HDA_AMP_MUTE);
9808
9809 if (change)
9810 alc262_lenovo_3000_automute(codec, 0);
9811 return change;
9812}
9813
9814static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9815 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9816 {
9817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9818 .name = "Master Playback Switch",
9819 .info = snd_hda_mixer_amp_switch_info,
9820 .get = snd_hda_mixer_amp_switch_get,
9821 .put = alc262_lenovo_3000_master_sw_put,
9822 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9823 },
9824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9829 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9830 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9831 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9832 { } /* end */
9833};
9834
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009835static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9836 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9837 {
9838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9839 .name = "Master Playback Switch",
9840 .info = snd_hda_mixer_amp_switch_info,
9841 .get = snd_hda_mixer_amp_switch_get,
9842 .put = alc262_sony_master_sw_put,
9843 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9844 },
9845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9848 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9850 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9851 { } /* end */
9852};
9853
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009854/* additional init verbs for Benq laptops */
9855static struct hda_verb alc262_EAPD_verbs[] = {
9856 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9857 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9858 {}
9859};
9860
Kailang Yang83c34212007-07-05 11:43:05 +02009861static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9864
9865 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9866 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9867 {}
9868};
9869
Tobin Davisf651b502007-10-26 12:40:47 +02009870/* Samsung Q1 Ultra Vista model setup */
9871static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009872 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9873 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9876 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009877 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009878 { } /* end */
9879};
9880
9881static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009882 /* output mixer */
9883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9886 /* speaker */
9887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9890 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9891 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9896 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9897 /* internal mic */
9898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9900 /* ADC, choose mic */
9901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9902 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9903 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9908 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9909 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009911 {}
9912};
9913
Tobin Davisf651b502007-10-26 12:40:47 +02009914/* mute/unmute internal speaker according to the hp jack and mute state */
9915static void alc262_ultra_automute(struct hda_codec *codec)
9916{
9917 struct alc_spec *spec = codec->spec;
9918 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009919
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009920 mute = 0;
9921 /* auto-mute only when HP is used as HP */
9922 if (!spec->cur_mux[0]) {
9923 unsigned int present;
9924 /* need to execute and sync at first */
9925 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9926 present = snd_hda_codec_read(codec, 0x15, 0,
9927 AC_VERB_GET_PIN_SENSE, 0);
9928 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9929 if (spec->jack_present)
9930 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009931 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009932 /* mute/unmute internal speaker */
9933 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9934 HDA_AMP_MUTE, mute);
9935 /* mute/unmute HP */
9936 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9937 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009938}
9939
9940/* unsolicited event for HP jack sensing */
9941static void alc262_ultra_unsol_event(struct hda_codec *codec,
9942 unsigned int res)
9943{
9944 if ((res >> 26) != ALC880_HP_EVENT)
9945 return;
9946 alc262_ultra_automute(codec);
9947}
9948
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009949static struct hda_input_mux alc262_ultra_capture_source = {
9950 .num_items = 2,
9951 .items = {
9952 { "Mic", 0x1 },
9953 { "Headphone", 0x7 },
9954 },
9955};
9956
9957static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9958 struct snd_ctl_elem_value *ucontrol)
9959{
9960 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9961 struct alc_spec *spec = codec->spec;
9962 int ret;
9963
9964 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9965 if (!ret)
9966 return 0;
9967 /* reprogram the HP pin as mic or HP according to the input source */
9968 snd_hda_codec_write_cache(codec, 0x15, 0,
9969 AC_VERB_SET_PIN_WIDGET_CONTROL,
9970 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9971 alc262_ultra_automute(codec); /* mute/unmute HP */
9972 return ret;
9973}
9974
9975static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9976 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9977 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9978 {
9979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9980 .name = "Capture Source",
9981 .info = alc882_mux_enum_info,
9982 .get = alc882_mux_enum_get,
9983 .put = alc262_ultra_mux_enum_put,
9984 },
9985 { } /* end */
9986};
9987
Kailang Yangdf694da2005-12-05 19:42:22 +01009988/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009989static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9990 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009991{
9992 hda_nid_t nid;
9993 int err;
9994
9995 spec->multiout.num_dacs = 1; /* only use one dac */
9996 spec->multiout.dac_nids = spec->private_dac_nids;
9997 spec->multiout.dac_nids[0] = 2;
9998
9999 nid = cfg->line_out_pins[0];
10000 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010001 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10002 "Front Playback Volume",
10003 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10004 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010005 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010006 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10007 "Front Playback Switch",
10008 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10009 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010010 return err;
10011 }
10012
Takashi Iwai82bc9552006-03-21 11:24:42 +010010013 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010014 if (nid) {
10015 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10017 "Speaker Playback Volume",
10018 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10019 HDA_OUTPUT));
10020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010022 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10023 "Speaker Playback Switch",
10024 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10025 HDA_OUTPUT));
10026 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010027 return err;
10028 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010029 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10030 "Speaker Playback Switch",
10031 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10032 HDA_OUTPUT));
10033 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010034 return err;
10035 }
10036 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010037 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010038 if (nid) {
10039 /* spec->multiout.hp_nid = 2; */
10040 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010041 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10042 "Headphone Playback Volume",
10043 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10044 HDA_OUTPUT));
10045 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010046 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010047 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10048 "Headphone Playback Switch",
10049 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10050 HDA_OUTPUT));
10051 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010052 return err;
10053 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010054 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10055 "Headphone Playback Switch",
10056 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10057 HDA_OUTPUT));
10058 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010059 return err;
10060 }
10061 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010062 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010063}
10064
10065/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010066#define alc262_auto_create_analog_input_ctls \
10067 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010068
10069/*
10070 * generic initialization of ADC, input mixers and output mixers
10071 */
10072static struct hda_verb alc262_volume_init_verbs[] = {
10073 /*
10074 * Unmute ADC0-2 and set the default input to mic-in
10075 */
10076 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10082
Takashi Iwaicb53c622007-08-10 17:21:45 +020010083 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010084 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010085 * Note: PASD motherboards uses the Line In 2 as the input for
10086 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010087 */
10088 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010094
10095 /*
10096 * Set up output mixers (0x0c - 0x0f)
10097 */
10098 /* set vol=0 to output mixers */
10099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010102
Kailang Yangdf694da2005-12-05 19:42:22 +010010103 /* set up input amps for analog loopback */
10104 /* Amp Indices: DAC = 0, mixer = 1 */
10105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10111
10112 /* FIXME: use matrix-type input source selection */
10113 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10114 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10119 /* Input mixer2 */
10120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10124 /* Input mixer3 */
10125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10129
10130 { }
10131};
10132
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010133static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10134 /*
10135 * Unmute ADC0-2 and set the default input to mic-in
10136 */
10137 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10139 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10141 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10143
Takashi Iwaicb53c622007-08-10 17:21:45 +020010144 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010146 * Note: PASD motherboards uses the Line In 2 as the input for
10147 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010148 */
10149 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010157
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010158 /*
10159 * Set up output mixers (0x0c - 0x0e)
10160 */
10161 /* set vol=0 to output mixers */
10162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10165
10166 /* set up input amps for analog loopback */
10167 /* Amp Indices: DAC = 0, mixer = 1 */
10168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10170 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10174
Takashi Iwaice875f02008-01-28 18:17:43 +010010175 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10177 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10178
10179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10181
10182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10184
10185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10189 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10190
10191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10194 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10195 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10196 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10197
10198
10199 /* FIXME: use matrix-type input source selection */
10200 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10201 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10206 /* Input mixer2 */
10207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10211 /* Input mixer3 */
10212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10216
Takashi Iwaice875f02008-01-28 18:17:43 +010010217 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10218
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010219 { }
10220};
10221
Kailang Yangcd7509a2007-01-26 18:33:17 +010010222static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10223 /*
10224 * Unmute ADC0-2 and set the default input to mic-in
10225 */
10226 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10228 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10229 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10230 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10231 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10232
Takashi Iwaicb53c622007-08-10 17:21:45 +020010233 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010234 * mixer widget
10235 * Note: PASD motherboards uses the Line In 2 as the input for front
10236 * panel mic (mic 2)
10237 */
10238 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010247 /*
10248 * Set up output mixers (0x0c - 0x0e)
10249 */
10250 /* set vol=0 to output mixers */
10251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10254
10255 /* set up input amps for analog loopback */
10256 /* Amp Indices: DAC = 0, mixer = 1 */
10257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10263
10264
10265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10271 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10272
10273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10275
10276 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10278
10279 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10283 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10284 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10285
10286 /* FIXME: use matrix-type input source selection */
10287 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10288 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10294 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10296 /* Input mixer2 */
10297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10301 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10302 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10304 /* Input mixer3 */
10305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10310 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10312
Takashi Iwaice875f02008-01-28 18:17:43 +010010313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10314
Kailang Yangcd7509a2007-01-26 18:33:17 +010010315 { }
10316};
10317
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010318static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10319
10320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10321 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10322 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10323
10324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10328
10329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10330 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10332 {}
10333};
10334
10335
Takashi Iwaicb53c622007-08-10 17:21:45 +020010336#ifdef CONFIG_SND_HDA_POWER_SAVE
10337#define alc262_loopbacks alc880_loopbacks
10338#endif
10339
Kailang Yangdf694da2005-12-05 19:42:22 +010010340/* pcm configuration: identiacal with ALC880 */
10341#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10342#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10343#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10344#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10345
10346/*
10347 * BIOS auto configuration
10348 */
10349static int alc262_parse_auto_config(struct hda_codec *codec)
10350{
10351 struct alc_spec *spec = codec->spec;
10352 int err;
10353 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10354
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010355 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10356 alc262_ignore);
10357 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010359 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010360 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010361 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10362 if (err < 0)
10363 return err;
10364 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10365 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010366 return err;
10367
10368 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10369
10370 if (spec->autocfg.dig_out_pin)
10371 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10372 if (spec->autocfg.dig_in_pin)
10373 spec->dig_in_nid = ALC262_DIGIN_NID;
10374
10375 if (spec->kctl_alloc)
10376 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10377
10378 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010379 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010380 spec->input_mux = &spec->private_imux;
10381
Takashi Iwai776e1842007-08-29 15:07:11 +020010382 err = alc_auto_add_mic_boost(codec);
10383 if (err < 0)
10384 return err;
10385
Takashi Iwaie044c392008-10-27 16:56:24 +010010386 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010387 return 1;
10388}
10389
10390#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10391#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10392#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010393#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010394
10395
10396/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010397static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010398{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010399 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010400 alc262_auto_init_multi_out(codec);
10401 alc262_auto_init_hp_out(codec);
10402 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010403 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010404 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010405 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010406}
10407
10408/*
10409 * configuration and preset
10410 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010411static const char *alc262_models[ALC262_MODEL_LAST] = {
10412 [ALC262_BASIC] = "basic",
10413 [ALC262_HIPPO] = "hippo",
10414 [ALC262_HIPPO_1] = "hippo_1",
10415 [ALC262_FUJITSU] = "fujitsu",
10416 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010417 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010418 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010419 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010420 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010421 [ALC262_BENQ_T31] = "benq-t31",
10422 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010423 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010424 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010425 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010426 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010427 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010428 [ALC262_AUTO] = "auto",
10429};
10430
10431static struct snd_pci_quirk alc262_cfg_tbl[] = {
10432 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010433 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010434 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010435 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010436 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10437 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010438 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010439 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010440 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010441 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010442 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010443 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010444 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010445 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010446 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010447 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010448 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010449 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010450 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10451 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10452 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010453 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10454 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010455 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010456 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010457 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010458 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10459 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10460 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010461 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010462 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010463 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010464 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010465 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010466 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010467 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010468 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010469 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010470 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010471 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010472 {}
10473};
10474
10475static struct alc_config_preset alc262_presets[] = {
10476 [ALC262_BASIC] = {
10477 .mixers = { alc262_base_mixer },
10478 .init_verbs = { alc262_init_verbs },
10479 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10480 .dac_nids = alc262_dac_nids,
10481 .hp_nid = 0x03,
10482 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10483 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010484 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010486 [ALC262_HIPPO] = {
10487 .mixers = { alc262_base_mixer },
10488 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10489 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10490 .dac_nids = alc262_dac_nids,
10491 .hp_nid = 0x03,
10492 .dig_out_nid = ALC262_DIGOUT_NID,
10493 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10494 .channel_mode = alc262_modes,
10495 .input_mux = &alc262_capture_source,
10496 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010497 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010498 },
10499 [ALC262_HIPPO_1] = {
10500 .mixers = { alc262_hippo1_mixer },
10501 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10502 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10503 .dac_nids = alc262_dac_nids,
10504 .hp_nid = 0x02,
10505 .dig_out_nid = ALC262_DIGOUT_NID,
10506 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10507 .channel_mode = alc262_modes,
10508 .input_mux = &alc262_capture_source,
10509 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010510 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010511 },
Takashi Iwai834be882006-03-01 14:16:17 +010010512 [ALC262_FUJITSU] = {
10513 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010514 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10515 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010516 .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,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010523 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010524 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010525 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010526 [ALC262_HP_BPC] = {
10527 .mixers = { alc262_HP_BPC_mixer },
10528 .init_verbs = { alc262_HP_BPC_init_verbs },
10529 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10530 .dac_nids = alc262_dac_nids,
10531 .hp_nid = 0x03,
10532 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10533 .channel_mode = alc262_modes,
10534 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010535 .unsol_event = alc262_hp_bpc_unsol_event,
10536 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010537 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010538 [ALC262_HP_BPC_D7000_WF] = {
10539 .mixers = { alc262_HP_BPC_WildWest_mixer },
10540 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10541 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10542 .dac_nids = alc262_dac_nids,
10543 .hp_nid = 0x03,
10544 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10545 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010546 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010547 .unsol_event = alc262_hp_wildwest_unsol_event,
10548 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010549 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010550 [ALC262_HP_BPC_D7000_WL] = {
10551 .mixers = { alc262_HP_BPC_WildWest_mixer,
10552 alc262_HP_BPC_WildWest_option_mixer },
10553 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10554 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10555 .dac_nids = alc262_dac_nids,
10556 .hp_nid = 0x03,
10557 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10558 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010559 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010560 .unsol_event = alc262_hp_wildwest_unsol_event,
10561 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010562 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010563 [ALC262_HP_TC_T5735] = {
10564 .mixers = { alc262_hp_t5735_mixer },
10565 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10566 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10567 .dac_nids = alc262_dac_nids,
10568 .hp_nid = 0x03,
10569 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10570 .channel_mode = alc262_modes,
10571 .input_mux = &alc262_capture_source,
10572 .unsol_event = alc262_hp_t5735_unsol_event,
10573 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010574 },
10575 [ALC262_HP_RP5700] = {
10576 .mixers = { alc262_hp_rp5700_mixer },
10577 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10578 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10579 .dac_nids = alc262_dac_nids,
10580 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10581 .channel_mode = alc262_modes,
10582 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010583 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010584 [ALC262_BENQ_ED8] = {
10585 .mixers = { alc262_base_mixer },
10586 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10588 .dac_nids = alc262_dac_nids,
10589 .hp_nid = 0x03,
10590 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10591 .channel_mode = alc262_modes,
10592 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010593 },
Kailang Yang272a5272007-05-14 11:00:38 +020010594 [ALC262_SONY_ASSAMD] = {
10595 .mixers = { alc262_sony_mixer },
10596 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10597 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10598 .dac_nids = alc262_dac_nids,
10599 .hp_nid = 0x02,
10600 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10601 .channel_mode = alc262_modes,
10602 .input_mux = &alc262_capture_source,
10603 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010604 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010605 },
10606 [ALC262_BENQ_T31] = {
10607 .mixers = { alc262_benq_t31_mixer },
10608 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10609 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10610 .dac_nids = alc262_dac_nids,
10611 .hp_nid = 0x03,
10612 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10613 .channel_mode = alc262_modes,
10614 .input_mux = &alc262_capture_source,
10615 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010616 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010617 },
Tobin Davisf651b502007-10-26 12:40:47 +020010618 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010619 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10620 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010621 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10622 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010623 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10624 .channel_mode = alc262_modes,
10625 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010626 .adc_nids = alc262_adc_nids, /* ADC0 */
10627 .capsrc_nids = alc262_capsrc_nids,
10628 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010629 .unsol_event = alc262_ultra_unsol_event,
10630 .init_hook = alc262_ultra_automute,
10631 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010632 [ALC262_LENOVO_3000] = {
10633 .mixers = { alc262_lenovo_3000_mixer },
10634 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10635 alc262_lenovo_3000_unsol_verbs },
10636 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10637 .dac_nids = alc262_dac_nids,
10638 .hp_nid = 0x03,
10639 .dig_out_nid = ALC262_DIGOUT_NID,
10640 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10641 .channel_mode = alc262_modes,
10642 .input_mux = &alc262_fujitsu_capture_source,
10643 .unsol_event = alc262_lenovo_3000_unsol_event,
10644 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010645 [ALC262_NEC] = {
10646 .mixers = { alc262_nec_mixer },
10647 .init_verbs = { alc262_nec_verbs },
10648 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10649 .dac_nids = alc262_dac_nids,
10650 .hp_nid = 0x03,
10651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10652 .channel_mode = alc262_modes,
10653 .input_mux = &alc262_capture_source,
10654 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010655 [ALC262_TOSHIBA_S06] = {
10656 .mixers = { alc262_toshiba_s06_mixer },
10657 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10658 alc262_eapd_verbs },
10659 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10660 .capsrc_nids = alc262_dmic_capsrc_nids,
10661 .dac_nids = alc262_dac_nids,
10662 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10663 .dig_out_nid = ALC262_DIGOUT_NID,
10664 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10665 .channel_mode = alc262_modes,
10666 .input_mux = &alc262_dmic_capture_source,
10667 .unsol_event = alc262_toshiba_s06_unsol_event,
10668 .init_hook = alc262_toshiba_s06_init_hook,
10669 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010670 [ALC262_TOSHIBA_RX1] = {
10671 .mixers = { alc262_toshiba_rx1_mixer },
10672 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10673 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10674 .dac_nids = alc262_dac_nids,
10675 .hp_nid = 0x03,
10676 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10677 .channel_mode = alc262_modes,
10678 .input_mux = &alc262_capture_source,
10679 .unsol_event = alc262_hippo_unsol_event,
10680 .init_hook = alc262_hippo_automute,
10681 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010682};
10683
10684static int patch_alc262(struct hda_codec *codec)
10685{
10686 struct alc_spec *spec;
10687 int board_config;
10688 int err;
10689
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010690 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010691 if (spec == NULL)
10692 return -ENOMEM;
10693
10694 codec->spec = spec;
10695#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010696 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10697 * under-run
10698 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010699 {
10700 int tmp;
10701 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10702 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10703 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10704 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10705 }
10706#endif
10707
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010708 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10709
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010710 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10711 alc262_models,
10712 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010713
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010714 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010715 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10716 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010717 board_config = ALC262_AUTO;
10718 }
10719
10720 if (board_config == ALC262_AUTO) {
10721 /* automatic parse from the BIOS config */
10722 err = alc262_parse_auto_config(codec);
10723 if (err < 0) {
10724 alc_free(codec);
10725 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010726 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010727 printk(KERN_INFO
10728 "hda_codec: Cannot set up configuration "
10729 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010730 board_config = ALC262_BASIC;
10731 }
10732 }
10733
10734 if (board_config != ALC262_AUTO)
10735 setup_preset(spec, &alc262_presets[board_config]);
10736
10737 spec->stream_name_analog = "ALC262 Analog";
10738 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10739 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010740
Kailang Yangdf694da2005-12-05 19:42:22 +010010741 spec->stream_name_digital = "ALC262 Digital";
10742 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10743 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10744
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010745 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010746 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010747 unsigned int wcap = get_wcaps(codec, 0x07);
10748
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010749 /* get type */
10750 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010751 if (wcap != AC_WID_AUD_IN) {
10752 spec->adc_nids = alc262_adc_nids_alt;
10753 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010754 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010755 spec->mixers[spec->num_mixers] =
10756 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010757 spec->num_mixers++;
10758 } else {
10759 spec->adc_nids = alc262_adc_nids;
10760 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010761 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010762 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10763 spec->num_mixers++;
10764 }
10765 }
10766
Takashi Iwai2134ea42008-01-10 16:53:55 +010010767 spec->vmaster_nid = 0x0c;
10768
Kailang Yangdf694da2005-12-05 19:42:22 +010010769 codec->patch_ops = alc_patch_ops;
10770 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010771 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010772#ifdef CONFIG_SND_HDA_POWER_SAVE
10773 if (!spec->loopback.amplist)
10774 spec->loopback.amplist = alc262_loopbacks;
10775#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010776
Kailang Yangdf694da2005-12-05 19:42:22 +010010777 return 0;
10778}
10779
Kailang Yangdf694da2005-12-05 19:42:22 +010010780/*
Kailang Yanga361d842007-06-05 12:30:55 +020010781 * ALC268 channel source setting (2 channel)
10782 */
10783#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10784#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010785
Kailang Yanga361d842007-06-05 12:30:55 +020010786static hda_nid_t alc268_dac_nids[2] = {
10787 /* front, hp */
10788 0x02, 0x03
10789};
10790
10791static hda_nid_t alc268_adc_nids[2] = {
10792 /* ADC0-1 */
10793 0x08, 0x07
10794};
10795
10796static hda_nid_t alc268_adc_nids_alt[1] = {
10797 /* ADC0 */
10798 0x08
10799};
10800
Takashi Iwaie1406342008-02-11 18:32:32 +010010801static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10802
Kailang Yanga361d842007-06-05 12:30:55 +020010803static struct snd_kcontrol_new alc268_base_mixer[] = {
10804 /* output mixer control */
10805 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10806 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10810 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10811 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010812 { }
10813};
10814
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010815/* bind Beep switches of both NID 0x0f and 0x10 */
10816static struct hda_bind_ctls alc268_bind_beep_sw = {
10817 .ops = &snd_hda_bind_sw,
10818 .values = {
10819 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10820 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10821 0
10822 },
10823};
10824
10825static struct snd_kcontrol_new alc268_beep_mixer[] = {
10826 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10827 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10828 { }
10829};
10830
Kailang Yangd1a991a2007-08-15 16:21:59 +020010831static struct hda_verb alc268_eapd_verbs[] = {
10832 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10833 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10834 { }
10835};
10836
Takashi Iwaid2738092007-08-16 14:59:45 +020010837/* Toshiba specific */
10838#define alc268_toshiba_automute alc262_hippo_automute
10839
10840static struct hda_verb alc268_toshiba_verbs[] = {
10841 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10842 { } /* end */
10843};
10844
Kailang Yang8ef355d2008-08-26 13:10:22 +020010845static struct hda_input_mux alc268_acer_lc_capture_source = {
10846 .num_items = 2,
10847 .items = {
10848 { "i-Mic", 0x6 },
10849 { "E-Mic", 0x0 },
10850 },
10851};
10852
Takashi Iwaid2738092007-08-16 14:59:45 +020010853/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010854/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010855static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10856 .ops = &snd_hda_bind_vol,
10857 .values = {
10858 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10859 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10860 0
10861 },
10862};
10863
Takashi Iwai889c4392007-08-23 18:56:52 +020010864/* mute/unmute internal speaker according to the hp jack and mute state */
10865static void alc268_acer_automute(struct hda_codec *codec, int force)
10866{
10867 struct alc_spec *spec = codec->spec;
10868 unsigned int mute;
10869
10870 if (force || !spec->sense_updated) {
10871 unsigned int present;
10872 present = snd_hda_codec_read(codec, 0x14, 0,
10873 AC_VERB_GET_PIN_SENSE, 0);
10874 spec->jack_present = (present & 0x80000000) != 0;
10875 spec->sense_updated = 1;
10876 }
10877 if (spec->jack_present)
10878 mute = HDA_AMP_MUTE; /* mute internal speaker */
10879 else /* unmute internal speaker if necessary */
10880 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10882 HDA_AMP_MUTE, mute);
10883}
10884
10885
10886/* bind hp and internal speaker mute (with plug check) */
10887static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10888 struct snd_ctl_elem_value *ucontrol)
10889{
10890 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10891 long *valp = ucontrol->value.integer.value;
10892 int change;
10893
10894 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10895 HDA_AMP_MUTE,
10896 valp[0] ? 0 : HDA_AMP_MUTE);
10897 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10898 HDA_AMP_MUTE,
10899 valp[1] ? 0 : HDA_AMP_MUTE);
10900 if (change)
10901 alc268_acer_automute(codec, 0);
10902 return change;
10903}
Takashi Iwaid2738092007-08-16 14:59:45 +020010904
Kailang Yang8ef355d2008-08-26 13:10:22 +020010905static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10906 /* output mixer control */
10907 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10908 {
10909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10910 .name = "Master Playback Switch",
10911 .info = snd_hda_mixer_amp_switch_info,
10912 .get = snd_hda_mixer_amp_switch_get,
10913 .put = alc268_acer_master_sw_put,
10914 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10915 },
10916 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10917 { }
10918};
10919
Takashi Iwaid2738092007-08-16 14:59:45 +020010920static struct snd_kcontrol_new alc268_acer_mixer[] = {
10921 /* output mixer control */
10922 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10923 {
10924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10925 .name = "Master Playback Switch",
10926 .info = snd_hda_mixer_amp_switch_info,
10927 .get = snd_hda_mixer_amp_switch_get,
10928 .put = alc268_acer_master_sw_put,
10929 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10930 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010931 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10932 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10933 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010934 { }
10935};
10936
Kailang Yang8ef355d2008-08-26 13:10:22 +020010937static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10938 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10941 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10942 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10944 { }
10945};
10946
Takashi Iwaid2738092007-08-16 14:59:45 +020010947static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010948 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10949 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10951 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010952 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010954 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10955 { }
10956};
10957
10958/* unsolicited event for HP jack sensing */
10959static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10960 unsigned int res)
10961{
Takashi Iwai889c4392007-08-23 18:56:52 +020010962 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010963 return;
10964 alc268_toshiba_automute(codec);
10965}
10966
10967static void alc268_acer_unsol_event(struct hda_codec *codec,
10968 unsigned int res)
10969{
Takashi Iwai889c4392007-08-23 18:56:52 +020010970 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010971 return;
10972 alc268_acer_automute(codec, 1);
10973}
10974
Takashi Iwai889c4392007-08-23 18:56:52 +020010975static void alc268_acer_init_hook(struct hda_codec *codec)
10976{
10977 alc268_acer_automute(codec, 1);
10978}
10979
Kailang Yang8ef355d2008-08-26 13:10:22 +020010980/* toggle speaker-output according to the hp-jack state */
10981static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10982{
10983 unsigned int present;
10984 unsigned char bits;
10985
10986 present = snd_hda_codec_read(codec, 0x15, 0,
10987 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10988 bits = present ? AMP_IN_MUTE(0) : 0;
10989 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10990 AMP_IN_MUTE(0), bits);
10991 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10992 AMP_IN_MUTE(0), bits);
10993}
10994
10995
10996static void alc268_acer_mic_automute(struct hda_codec *codec)
10997{
10998 unsigned int present;
10999
11000 present = snd_hda_codec_read(codec, 0x18, 0,
11001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11002 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11003 present ? 0x0 : 0x6);
11004}
11005
11006static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11007 unsigned int res)
11008{
11009 if ((res >> 26) == ALC880_HP_EVENT)
11010 alc268_aspire_one_speaker_automute(codec);
11011 if ((res >> 26) == ALC880_MIC_EVENT)
11012 alc268_acer_mic_automute(codec);
11013}
11014
11015static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11016{
11017 alc268_aspire_one_speaker_automute(codec);
11018 alc268_acer_mic_automute(codec);
11019}
11020
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011021static struct snd_kcontrol_new alc268_dell_mixer[] = {
11022 /* output mixer control */
11023 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11024 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11028 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11029 { }
11030};
11031
11032static struct hda_verb alc268_dell_verbs[] = {
11033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11036 { }
11037};
11038
11039/* mute/unmute internal speaker according to the hp jack and mute state */
11040static void alc268_dell_automute(struct hda_codec *codec)
11041{
11042 unsigned int present;
11043 unsigned int mute;
11044
11045 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11046 if (present & 0x80000000)
11047 mute = HDA_AMP_MUTE;
11048 else
11049 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11050 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11051 HDA_AMP_MUTE, mute);
11052}
11053
11054static void alc268_dell_unsol_event(struct hda_codec *codec,
11055 unsigned int res)
11056{
11057 if ((res >> 26) != ALC880_HP_EVENT)
11058 return;
11059 alc268_dell_automute(codec);
11060}
11061
11062#define alc268_dell_init_hook alc268_dell_automute
11063
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011064static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11065 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11066 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11067 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11069 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11070 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11071 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11072 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11073 { }
11074};
11075
11076static struct hda_verb alc267_quanta_il1_verbs[] = {
11077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11078 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11079 { }
11080};
11081
11082static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11083{
11084 unsigned int present;
11085
11086 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11087 & AC_PINSENSE_PRESENCE;
11088 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11089 present ? 0 : PIN_OUT);
11090}
11091
11092static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11093{
11094 unsigned int present;
11095
11096 present = snd_hda_codec_read(codec, 0x18, 0,
11097 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11098 snd_hda_codec_write(codec, 0x23, 0,
11099 AC_VERB_SET_CONNECT_SEL,
11100 present ? 0x00 : 0x01);
11101}
11102
11103static void alc267_quanta_il1_automute(struct hda_codec *codec)
11104{
11105 alc267_quanta_il1_hp_automute(codec);
11106 alc267_quanta_il1_mic_automute(codec);
11107}
11108
11109static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11110 unsigned int res)
11111{
11112 switch (res >> 26) {
11113 case ALC880_HP_EVENT:
11114 alc267_quanta_il1_hp_automute(codec);
11115 break;
11116 case ALC880_MIC_EVENT:
11117 alc267_quanta_il1_mic_automute(codec);
11118 break;
11119 }
11120}
11121
Kailang Yanga361d842007-06-05 12:30:55 +020011122/*
11123 * generic initialization of ADC, input mixers and output mixers
11124 */
11125static struct hda_verb alc268_base_init_verbs[] = {
11126 /* Unmute DAC0-1 and set vol = 0 */
11127 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11128 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11129 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11130 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11131 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11132 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11133
11134 /*
11135 * Set up output mixers (0x0c - 0x0e)
11136 */
11137 /* set vol=0 to output mixers */
11138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11141 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11142
11143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11145
11146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11152 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11153 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11154
11155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11160 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11161 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011162
11163 /* set PCBEEP vol = 0, mute connections */
11164 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11166 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011167
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011168 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011169
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011170 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11172 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011174
Kailang Yanga361d842007-06-05 12:30:55 +020011175 { }
11176};
11177
11178/*
11179 * generic initialization of ADC, input mixers and output mixers
11180 */
11181static struct hda_verb alc268_volume_init_verbs[] = {
11182 /* set output DAC */
11183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11184 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11187
11188 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11190 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11191 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11192 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11193
11194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11199
11200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11202 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11203 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11204
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011205 /* set PCBEEP vol = 0, mute connections */
11206 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11207 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11208 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011209
11210 { }
11211};
11212
11213#define alc268_mux_enum_info alc_mux_enum_info
11214#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010011215#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020011216
11217static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11218 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11219 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11220 {
11221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11222 /* The multiple "Capture Source" controls confuse alsamixer
11223 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011224 */
11225 /* .name = "Capture Source", */
11226 .name = "Input Source",
11227 .count = 1,
11228 .info = alc268_mux_enum_info,
11229 .get = alc268_mux_enum_get,
11230 .put = alc268_mux_enum_put,
11231 },
11232 { } /* end */
11233};
11234
11235static struct snd_kcontrol_new alc268_capture_mixer[] = {
11236 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11237 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11238 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11239 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11240 {
11241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11242 /* The multiple "Capture Source" controls confuse alsamixer
11243 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011244 */
11245 /* .name = "Capture Source", */
11246 .name = "Input Source",
11247 .count = 2,
11248 .info = alc268_mux_enum_info,
11249 .get = alc268_mux_enum_get,
11250 .put = alc268_mux_enum_put,
11251 },
11252 { } /* end */
11253};
11254
11255static struct hda_input_mux alc268_capture_source = {
11256 .num_items = 4,
11257 .items = {
11258 { "Mic", 0x0 },
11259 { "Front Mic", 0x1 },
11260 { "Line", 0x2 },
11261 { "CD", 0x3 },
11262 },
11263};
11264
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011265static struct hda_input_mux alc268_acer_capture_source = {
11266 .num_items = 3,
11267 .items = {
11268 { "Mic", 0x0 },
11269 { "Internal Mic", 0x6 },
11270 { "Line", 0x2 },
11271 },
11272};
11273
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011274#ifdef CONFIG_SND_DEBUG
11275static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011276 /* Volume widgets */
11277 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11278 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11279 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11280 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11281 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11282 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11283 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11284 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11285 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11286 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11287 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11288 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11289 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011290 /* The below appears problematic on some hardwares */
11291 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011292 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11293 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11294 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11295 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11296
11297 /* Modes for retasking pin widgets */
11298 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11299 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11300 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11301 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11302
11303 /* Controls for GPIO pins, assuming they are configured as outputs */
11304 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11305 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11306 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11307 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11308
11309 /* Switches to allow the digital SPDIF output pin to be enabled.
11310 * The ALC268 does not have an SPDIF input.
11311 */
11312 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11313
11314 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11315 * this output to turn on an external amplifier.
11316 */
11317 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11318 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11319
11320 { } /* end */
11321};
11322#endif
11323
Kailang Yanga361d842007-06-05 12:30:55 +020011324/* create input playback/capture controls for the given pin */
11325static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11326 const char *ctlname, int idx)
11327{
11328 char name[32];
11329 int err;
11330
11331 sprintf(name, "%s Playback Volume", ctlname);
11332 if (nid == 0x14) {
11333 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11334 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11335 HDA_OUTPUT));
11336 if (err < 0)
11337 return err;
11338 } else if (nid == 0x15) {
11339 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11340 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11341 HDA_OUTPUT));
11342 if (err < 0)
11343 return err;
11344 } else
11345 return -1;
11346 sprintf(name, "%s Playback Switch", ctlname);
11347 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11348 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11349 if (err < 0)
11350 return err;
11351 return 0;
11352}
11353
11354/* add playback controls from the parsed DAC table */
11355static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11356 const struct auto_pin_cfg *cfg)
11357{
11358 hda_nid_t nid;
11359 int err;
11360
11361 spec->multiout.num_dacs = 2; /* only use one dac */
11362 spec->multiout.dac_nids = spec->private_dac_nids;
11363 spec->multiout.dac_nids[0] = 2;
11364 spec->multiout.dac_nids[1] = 3;
11365
11366 nid = cfg->line_out_pins[0];
11367 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011368 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011369
11370 nid = cfg->speaker_pins[0];
11371 if (nid == 0x1d) {
11372 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11373 "Speaker Playback Volume",
11374 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11375 if (err < 0)
11376 return err;
11377 }
11378 nid = cfg->hp_pins[0];
11379 if (nid)
11380 alc268_new_analog_output(spec, nid, "Headphone", 0);
11381
11382 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11383 if (nid == 0x16) {
11384 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11385 "Mono Playback Switch",
11386 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11387 if (err < 0)
11388 return err;
11389 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011390 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011391}
11392
11393/* create playback/capture controls for input pins */
11394static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11395 const struct auto_pin_cfg *cfg)
11396{
11397 struct hda_input_mux *imux = &spec->private_imux;
11398 int i, idx1;
11399
11400 for (i = 0; i < AUTO_PIN_LAST; i++) {
11401 switch(cfg->input_pins[i]) {
11402 case 0x18:
11403 idx1 = 0; /* Mic 1 */
11404 break;
11405 case 0x19:
11406 idx1 = 1; /* Mic 2 */
11407 break;
11408 case 0x1a:
11409 idx1 = 2; /* Line In */
11410 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011411 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011412 idx1 = 3; /* CD */
11413 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011414 case 0x12:
11415 case 0x13:
11416 idx1 = 6; /* digital mics */
11417 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011418 default:
11419 continue;
11420 }
11421 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11422 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011423 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011424 }
11425 return 0;
11426}
11427
11428static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11429{
11430 struct alc_spec *spec = codec->spec;
11431 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11432 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11433 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11434 unsigned int dac_vol1, dac_vol2;
11435
11436 if (speaker_nid) {
11437 snd_hda_codec_write(codec, speaker_nid, 0,
11438 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11439 snd_hda_codec_write(codec, 0x0f, 0,
11440 AC_VERB_SET_AMP_GAIN_MUTE,
11441 AMP_IN_UNMUTE(1));
11442 snd_hda_codec_write(codec, 0x10, 0,
11443 AC_VERB_SET_AMP_GAIN_MUTE,
11444 AMP_IN_UNMUTE(1));
11445 } else {
11446 snd_hda_codec_write(codec, 0x0f, 0,
11447 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11448 snd_hda_codec_write(codec, 0x10, 0,
11449 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11450 }
11451
11452 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011453 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011454 dac_vol2 = AMP_OUT_ZERO;
11455 else if (line_nid == 0x15)
11456 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011457 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011458 dac_vol2 = AMP_OUT_ZERO;
11459 else if (hp_nid == 0x15)
11460 dac_vol1 = AMP_OUT_ZERO;
11461 if (line_nid != 0x16 || hp_nid != 0x16 ||
11462 spec->autocfg.line_out_pins[1] != 0x16 ||
11463 spec->autocfg.line_out_pins[2] != 0x16)
11464 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11465
11466 snd_hda_codec_write(codec, 0x02, 0,
11467 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11468 snd_hda_codec_write(codec, 0x03, 0,
11469 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11470}
11471
11472/* pcm configuration: identiacal with ALC880 */
11473#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11474#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011475#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011476#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11477
11478/*
11479 * BIOS auto configuration
11480 */
11481static int alc268_parse_auto_config(struct hda_codec *codec)
11482{
11483 struct alc_spec *spec = codec->spec;
11484 int err;
11485 static hda_nid_t alc268_ignore[] = { 0 };
11486
11487 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11488 alc268_ignore);
11489 if (err < 0)
11490 return err;
11491 if (!spec->autocfg.line_outs)
11492 return 0; /* can't find valid BIOS pin config */
11493
11494 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11495 if (err < 0)
11496 return err;
11497 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11498 if (err < 0)
11499 return err;
11500
11501 spec->multiout.max_channels = 2;
11502
11503 /* digital only support output */
11504 if (spec->autocfg.dig_out_pin)
11505 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11506
11507 if (spec->kctl_alloc)
11508 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11509
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011510 if (spec->autocfg.speaker_pins[0] != 0x1d)
11511 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11512
Kailang Yanga361d842007-06-05 12:30:55 +020011513 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11514 spec->num_mux_defs = 1;
11515 spec->input_mux = &spec->private_imux;
11516
Takashi Iwai776e1842007-08-29 15:07:11 +020011517 err = alc_auto_add_mic_boost(codec);
11518 if (err < 0)
11519 return err;
11520
Takashi Iwaie044c392008-10-27 16:56:24 +010011521 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011522 return 1;
11523}
11524
11525#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11526#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11527#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11528
11529/* init callback for auto-configuration model -- overriding the default init */
11530static void alc268_auto_init(struct hda_codec *codec)
11531{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011532 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011533 alc268_auto_init_multi_out(codec);
11534 alc268_auto_init_hp_out(codec);
11535 alc268_auto_init_mono_speaker_out(codec);
11536 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011537 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011538 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011539}
11540
11541/*
11542 * configuration and preset
11543 */
11544static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011545 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011546 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011547 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011548 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011549 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011550 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011551 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011552#ifdef CONFIG_SND_DEBUG
11553 [ALC268_TEST] = "test",
11554#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011555 [ALC268_AUTO] = "auto",
11556};
11557
11558static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011559 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011560 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011561 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011562 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011563 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011564 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11565 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011566 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011567 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011568 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011569 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011570 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011571 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011572 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011573 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011574 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011575 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011576 {}
11577};
11578
11579static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011580 [ALC267_QUANTA_IL1] = {
11581 .mixers = { alc267_quanta_il1_mixer },
11582 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11583 alc267_quanta_il1_verbs },
11584 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11585 .dac_nids = alc268_dac_nids,
11586 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11587 .adc_nids = alc268_adc_nids_alt,
11588 .hp_nid = 0x03,
11589 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11590 .channel_mode = alc268_modes,
11591 .input_mux = &alc268_capture_source,
11592 .unsol_event = alc267_quanta_il1_unsol_event,
11593 .init_hook = alc267_quanta_il1_automute,
11594 },
Kailang Yanga361d842007-06-05 12:30:55 +020011595 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011596 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11597 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011598 .init_verbs = { alc268_base_init_verbs },
11599 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11600 .dac_nids = alc268_dac_nids,
11601 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11602 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011603 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011604 .hp_nid = 0x03,
11605 .dig_out_nid = ALC268_DIGOUT_NID,
11606 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11607 .channel_mode = alc268_modes,
11608 .input_mux = &alc268_capture_source,
11609 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011610 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011611 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11612 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011613 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11614 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011615 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11616 .dac_nids = alc268_dac_nids,
11617 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11618 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011619 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011620 .hp_nid = 0x03,
11621 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11622 .channel_mode = alc268_modes,
11623 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011624 .unsol_event = alc268_toshiba_unsol_event,
11625 .init_hook = alc268_toshiba_automute,
11626 },
11627 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011628 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11629 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011630 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11631 alc268_acer_verbs },
11632 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11633 .dac_nids = alc268_dac_nids,
11634 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11635 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011636 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011637 .hp_nid = 0x02,
11638 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11639 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011640 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011641 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011642 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011643 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011644 [ALC268_ACER_ASPIRE_ONE] = {
11645 .mixers = { alc268_acer_aspire_one_mixer,
11646 alc268_capture_alt_mixer },
11647 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11648 alc268_acer_aspire_one_verbs },
11649 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11650 .dac_nids = alc268_dac_nids,
11651 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11652 .adc_nids = alc268_adc_nids_alt,
11653 .capsrc_nids = alc268_capsrc_nids,
11654 .hp_nid = 0x03,
11655 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11656 .channel_mode = alc268_modes,
11657 .input_mux = &alc268_acer_lc_capture_source,
11658 .unsol_event = alc268_acer_lc_unsol_event,
11659 .init_hook = alc268_acer_lc_init_hook,
11660 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011661 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011662 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011663 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11664 alc268_dell_verbs },
11665 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11666 .dac_nids = alc268_dac_nids,
11667 .hp_nid = 0x02,
11668 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11669 .channel_mode = alc268_modes,
11670 .unsol_event = alc268_dell_unsol_event,
11671 .init_hook = alc268_dell_init_hook,
11672 .input_mux = &alc268_capture_source,
11673 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011674 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011675 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11676 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011677 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11678 alc268_toshiba_verbs },
11679 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11680 .dac_nids = alc268_dac_nids,
11681 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11682 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011683 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011684 .hp_nid = 0x03,
11685 .dig_out_nid = ALC268_DIGOUT_NID,
11686 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11687 .channel_mode = alc268_modes,
11688 .input_mux = &alc268_capture_source,
11689 .unsol_event = alc268_toshiba_unsol_event,
11690 .init_hook = alc268_toshiba_automute
11691 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011692#ifdef CONFIG_SND_DEBUG
11693 [ALC268_TEST] = {
11694 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11695 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11696 alc268_volume_init_verbs },
11697 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11698 .dac_nids = alc268_dac_nids,
11699 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11700 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011701 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011702 .hp_nid = 0x03,
11703 .dig_out_nid = ALC268_DIGOUT_NID,
11704 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11705 .channel_mode = alc268_modes,
11706 .input_mux = &alc268_capture_source,
11707 },
11708#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011709};
11710
11711static int patch_alc268(struct hda_codec *codec)
11712{
11713 struct alc_spec *spec;
11714 int board_config;
11715 int err;
11716
11717 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11718 if (spec == NULL)
11719 return -ENOMEM;
11720
11721 codec->spec = spec;
11722
11723 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11724 alc268_models,
11725 alc268_cfg_tbl);
11726
11727 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11728 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11729 "trying auto-probe from BIOS...\n");
11730 board_config = ALC268_AUTO;
11731 }
11732
11733 if (board_config == ALC268_AUTO) {
11734 /* automatic parse from the BIOS config */
11735 err = alc268_parse_auto_config(codec);
11736 if (err < 0) {
11737 alc_free(codec);
11738 return err;
11739 } else if (!err) {
11740 printk(KERN_INFO
11741 "hda_codec: Cannot set up configuration "
11742 "from BIOS. Using base mode...\n");
11743 board_config = ALC268_3ST;
11744 }
11745 }
11746
11747 if (board_config != ALC268_AUTO)
11748 setup_preset(spec, &alc268_presets[board_config]);
11749
Kailang Yang2f893282008-05-27 12:14:47 +020011750 if (codec->vendor_id == 0x10ec0267) {
11751 spec->stream_name_analog = "ALC267 Analog";
11752 spec->stream_name_digital = "ALC267 Digital";
11753 } else {
11754 spec->stream_name_analog = "ALC268 Analog";
11755 spec->stream_name_digital = "ALC268 Digital";
11756 }
11757
Kailang Yanga361d842007-06-05 12:30:55 +020011758 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11759 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011760 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011761
Kailang Yanga361d842007-06-05 12:30:55 +020011762 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11763
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011764 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11765 /* override the amp caps for beep generator */
11766 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11767 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11768 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11769 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11770 (0 << AC_AMPCAP_MUTE_SHIFT));
11771
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011772 if (!spec->adc_nids && spec->input_mux) {
11773 /* check whether NID 0x07 is valid */
11774 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011775 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011776
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011777 /* get type */
11778 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011779 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011780 spec->adc_nids = alc268_adc_nids_alt;
11781 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11782 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011783 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011784 spec->num_mixers++;
11785 } else {
11786 spec->adc_nids = alc268_adc_nids;
11787 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11788 spec->mixers[spec->num_mixers] =
11789 alc268_capture_mixer;
11790 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011791 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011792 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011793 /* set default input source */
11794 for (i = 0; i < spec->num_adc_nids; i++)
11795 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11796 0, AC_VERB_SET_CONNECT_SEL,
11797 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011798 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011799
11800 spec->vmaster_nid = 0x02;
11801
Kailang Yanga361d842007-06-05 12:30:55 +020011802 codec->patch_ops = alc_patch_ops;
11803 if (board_config == ALC268_AUTO)
11804 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011805
Kailang Yanga361d842007-06-05 12:30:55 +020011806 return 0;
11807}
11808
11809/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011810 * ALC269 channel source setting (2 channel)
11811 */
11812#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11813
11814#define alc269_dac_nids alc260_dac_nids
11815
11816static hda_nid_t alc269_adc_nids[1] = {
11817 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011818 0x08,
11819};
11820
Takashi Iwaie01bf502008-08-21 16:25:07 +020011821static hda_nid_t alc269_capsrc_nids[1] = {
11822 0x23,
11823};
11824
11825/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11826 * not a mux!
11827 */
11828
Kailang Yangf53281e2008-07-18 12:36:43 +020011829static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11830 .num_items = 2,
11831 .items = {
11832 { "i-Mic", 0x5 },
11833 { "e-Mic", 0x0 },
11834 },
11835};
11836
11837static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11838 .num_items = 2,
11839 .items = {
11840 { "i-Mic", 0x1 },
11841 { "e-Mic", 0x0 },
11842 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011843};
11844
11845#define alc269_modes alc260_modes
11846#define alc269_capture_source alc880_lg_lw_capture_source
11847
11848static struct snd_kcontrol_new alc269_base_mixer[] = {
11849 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11850 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011855 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11856 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011857 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11860 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11862 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11863 { } /* end */
11864};
11865
Kailang Yang60db6b52008-08-26 13:13:00 +020011866static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11867 /* output mixer control */
11868 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11869 {
11870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11871 .name = "Master Playback Switch",
11872 .info = snd_hda_mixer_amp_switch_info,
11873 .get = snd_hda_mixer_amp_switch_get,
11874 .put = alc268_acer_master_sw_put,
11875 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11876 },
11877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11880 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11881 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11882 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11883 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11884 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11885 { }
11886};
11887
Kailang Yangf53281e2008-07-18 12:36:43 +020011888/* bind volumes of both NID 0x0c and 0x0d */
11889static struct hda_bind_ctls alc269_epc_bind_vol = {
11890 .ops = &snd_hda_bind_vol,
11891 .values = {
11892 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11893 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11894 0
11895 },
11896};
11897
11898static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11899 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11900 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11901 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11902 { } /* end */
11903};
11904
Kailang Yangf6a92242007-12-13 16:52:54 +010011905/* capture mixer elements */
11906static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011907 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11908 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011909 {
11910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11911 /* The multiple "Capture Source" controls confuse alsamixer
11912 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011913 */
11914 /* .name = "Capture Source", */
11915 .name = "Input Source",
11916 .count = 1,
11917 .info = alc_mux_enum_info,
11918 .get = alc_mux_enum_get,
11919 .put = alc_mux_enum_put,
11920 },
11921 { } /* end */
11922};
11923
Kailang Yangf53281e2008-07-18 12:36:43 +020011924/* capture mixer elements */
11925static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11926 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11927 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11928 { } /* end */
11929};
11930
Takashi Iwai2005af22008-08-20 18:38:26 +020011931/* beep control */
11932static struct snd_kcontrol_new alc269_beep_mixer[] = {
11933 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11934 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11935 { } /* end */
11936};
11937
Kailang Yang60db6b52008-08-26 13:13:00 +020011938static struct hda_verb alc269_quanta_fl1_verbs[] = {
11939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11940 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11943 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11944 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11945 { }
11946};
11947
11948/* toggle speaker-output according to the hp-jack state */
11949static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11950{
11951 unsigned int present;
11952 unsigned char bits;
11953
11954 present = snd_hda_codec_read(codec, 0x15, 0,
11955 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11956 bits = present ? AMP_IN_MUTE(0) : 0;
11957 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11958 AMP_IN_MUTE(0), bits);
11959 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11960 AMP_IN_MUTE(0), bits);
11961
11962 snd_hda_codec_write(codec, 0x20, 0,
11963 AC_VERB_SET_COEF_INDEX, 0x0c);
11964 snd_hda_codec_write(codec, 0x20, 0,
11965 AC_VERB_SET_PROC_COEF, 0x680);
11966
11967 snd_hda_codec_write(codec, 0x20, 0,
11968 AC_VERB_SET_COEF_INDEX, 0x0c);
11969 snd_hda_codec_write(codec, 0x20, 0,
11970 AC_VERB_SET_PROC_COEF, 0x480);
11971}
11972
11973static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11974{
11975 unsigned int present;
11976
11977 present = snd_hda_codec_read(codec, 0x18, 0,
11978 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11979 snd_hda_codec_write(codec, 0x23, 0,
11980 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11981}
11982
11983static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11984 unsigned int res)
11985{
11986 if ((res >> 26) == ALC880_HP_EVENT)
11987 alc269_quanta_fl1_speaker_automute(codec);
11988 if ((res >> 26) == ALC880_MIC_EVENT)
11989 alc269_quanta_fl1_mic_automute(codec);
11990}
11991
11992static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11993{
11994 alc269_quanta_fl1_speaker_automute(codec);
11995 alc269_quanta_fl1_mic_automute(codec);
11996}
11997
11998static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11999 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12000 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12001 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12002 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12005 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12006 {}
12007};
12008
12009static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12011 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12012 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12013 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12014 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12016 {}
12017};
12018
12019/* toggle speaker-output according to the hp-jack state */
12020static void alc269_speaker_automute(struct hda_codec *codec)
12021{
12022 unsigned int present;
12023 unsigned char bits;
12024
12025 present = snd_hda_codec_read(codec, 0x15, 0,
12026 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12027 bits = present ? AMP_IN_MUTE(0) : 0;
12028 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12029 AMP_IN_MUTE(0), bits);
12030 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12031 AMP_IN_MUTE(0), bits);
12032}
12033
12034static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12035{
12036 unsigned int present;
12037
12038 present = snd_hda_codec_read(codec, 0x18, 0,
12039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12040 snd_hda_codec_write(codec, 0x23, 0,
12041 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12042}
12043
12044static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12045{
12046 unsigned int present;
12047
12048 present = snd_hda_codec_read(codec, 0x18, 0,
12049 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12050 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12051 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12052 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12053 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12054}
12055
12056/* unsolicited event for HP jack sensing */
12057static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12058 unsigned int res)
12059{
12060 if ((res >> 26) == ALC880_HP_EVENT)
12061 alc269_speaker_automute(codec);
12062
12063 if ((res >> 26) == ALC880_MIC_EVENT)
12064 alc269_eeepc_dmic_automute(codec);
12065}
12066
12067static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12068{
12069 alc269_speaker_automute(codec);
12070 alc269_eeepc_dmic_automute(codec);
12071}
12072
12073/* unsolicited event for HP jack sensing */
12074static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12075 unsigned int res)
12076{
12077 if ((res >> 26) == ALC880_HP_EVENT)
12078 alc269_speaker_automute(codec);
12079
12080 if ((res >> 26) == ALC880_MIC_EVENT)
12081 alc269_eeepc_amic_automute(codec);
12082}
12083
12084static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12085{
12086 alc269_speaker_automute(codec);
12087 alc269_eeepc_amic_automute(codec);
12088}
12089
Kailang Yangf6a92242007-12-13 16:52:54 +010012090/*
12091 * generic initialization of ADC, input mixers and output mixers
12092 */
12093static struct hda_verb alc269_init_verbs[] = {
12094 /*
12095 * Unmute ADC0 and set the default input to mic-in
12096 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012098
12099 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12100 * analog-loopback mixer widget
12101 * Note: PASD motherboards uses the Line In 2 as the input for
12102 * front panel mic (mic 2)
12103 */
12104 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12110
12111 /*
12112 * Set up output mixers (0x0c - 0x0e)
12113 */
12114 /* set vol=0 to output mixers */
12115 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12116 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12117
12118 /* set up input amps for analog loopback */
12119 /* Amp Indices: DAC = 0, mixer = 1 */
12120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12122 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12126
12127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12128 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12133 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12134
12135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12136 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12137 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12142
12143 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12144 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12145
12146 /* FIXME: use matrix-type input source selection */
12147 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12148 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12153
12154 /* set EAPD */
12155 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12156 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12157 { }
12158};
12159
12160/* add playback controls from the parsed DAC table */
12161static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12162 const struct auto_pin_cfg *cfg)
12163{
12164 hda_nid_t nid;
12165 int err;
12166
12167 spec->multiout.num_dacs = 1; /* only use one dac */
12168 spec->multiout.dac_nids = spec->private_dac_nids;
12169 spec->multiout.dac_nids[0] = 2;
12170
12171 nid = cfg->line_out_pins[0];
12172 if (nid) {
12173 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12174 "Front Playback Volume",
12175 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12176 if (err < 0)
12177 return err;
12178 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12179 "Front Playback Switch",
12180 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12181 if (err < 0)
12182 return err;
12183 }
12184
12185 nid = cfg->speaker_pins[0];
12186 if (nid) {
12187 if (!cfg->line_out_pins[0]) {
12188 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12189 "Speaker Playback Volume",
12190 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12191 HDA_OUTPUT));
12192 if (err < 0)
12193 return err;
12194 }
12195 if (nid == 0x16) {
12196 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12197 "Speaker Playback Switch",
12198 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12199 HDA_OUTPUT));
12200 if (err < 0)
12201 return err;
12202 } else {
12203 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12204 "Speaker Playback Switch",
12205 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12206 HDA_OUTPUT));
12207 if (err < 0)
12208 return err;
12209 }
12210 }
12211 nid = cfg->hp_pins[0];
12212 if (nid) {
12213 /* spec->multiout.hp_nid = 2; */
12214 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12215 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12216 "Headphone Playback Volume",
12217 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12218 HDA_OUTPUT));
12219 if (err < 0)
12220 return err;
12221 }
12222 if (nid == 0x16) {
12223 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12224 "Headphone Playback Switch",
12225 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12226 HDA_OUTPUT));
12227 if (err < 0)
12228 return err;
12229 } else {
12230 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12231 "Headphone Playback Switch",
12232 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12233 HDA_OUTPUT));
12234 if (err < 0)
12235 return err;
12236 }
12237 }
12238 return 0;
12239}
12240
12241#define alc269_auto_create_analog_input_ctls \
12242 alc880_auto_create_analog_input_ctls
12243
12244#ifdef CONFIG_SND_HDA_POWER_SAVE
12245#define alc269_loopbacks alc880_loopbacks
12246#endif
12247
12248/* pcm configuration: identiacal with ALC880 */
12249#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12250#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12251#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12252#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12253
12254/*
12255 * BIOS auto configuration
12256 */
12257static int alc269_parse_auto_config(struct hda_codec *codec)
12258{
12259 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012260 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012261 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12262
12263 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12264 alc269_ignore);
12265 if (err < 0)
12266 return err;
12267
12268 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12269 if (err < 0)
12270 return err;
12271 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12272 if (err < 0)
12273 return err;
12274
12275 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12276
12277 if (spec->autocfg.dig_out_pin)
12278 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12279
12280 if (spec->kctl_alloc)
12281 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12282
Takashi Iwai2005af22008-08-20 18:38:26 +020012283 /* create a beep mixer control if the pin 0x1d isn't assigned */
12284 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12285 if (spec->autocfg.input_pins[i] == 0x1d)
12286 break;
12287 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12288 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
12289
Kailang Yangf6a92242007-12-13 16:52:54 +010012290 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
12291 spec->num_mux_defs = 1;
12292 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012293 /* set default input source */
12294 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12295 0, AC_VERB_SET_CONNECT_SEL,
12296 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012297
12298 err = alc_auto_add_mic_boost(codec);
12299 if (err < 0)
12300 return err;
12301
Kailang Yangf53281e2008-07-18 12:36:43 +020012302 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
12303 spec->num_mixers++;
12304
Takashi Iwaie044c392008-10-27 16:56:24 +010012305 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012306 return 1;
12307}
12308
12309#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12310#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12311#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12312
12313
12314/* init callback for auto-configuration model -- overriding the default init */
12315static void alc269_auto_init(struct hda_codec *codec)
12316{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012317 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012318 alc269_auto_init_multi_out(codec);
12319 alc269_auto_init_hp_out(codec);
12320 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012321 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012322 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012323}
12324
12325/*
12326 * configuration and preset
12327 */
12328static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012329 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012330 [ALC269_QUANTA_FL1] = "quanta",
12331 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12332 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901"
Kailang Yangf6a92242007-12-13 16:52:54 +010012333};
12334
12335static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012336 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012337 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12338 ALC269_ASUS_EEEPC_P703),
12339 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12340 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012341 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12342 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010012343 {}
12344};
12345
12346static struct alc_config_preset alc269_presets[] = {
12347 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020012348 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012349 .init_verbs = { alc269_init_verbs },
12350 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12351 .dac_nids = alc269_dac_nids,
12352 .hp_nid = 0x03,
12353 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12354 .channel_mode = alc269_modes,
12355 .input_mux = &alc269_capture_source,
12356 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012357 [ALC269_QUANTA_FL1] = {
12358 .mixers = { alc269_quanta_fl1_mixer },
12359 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12360 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12361 .dac_nids = alc269_dac_nids,
12362 .hp_nid = 0x03,
12363 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12364 .channel_mode = alc269_modes,
12365 .input_mux = &alc269_capture_source,
12366 .unsol_event = alc269_quanta_fl1_unsol_event,
12367 .init_hook = alc269_quanta_fl1_init_hook,
12368 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012369 [ALC269_ASUS_EEEPC_P703] = {
12370 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
12371 .init_verbs = { alc269_init_verbs,
12372 alc269_eeepc_amic_init_verbs },
12373 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12374 .dac_nids = alc269_dac_nids,
12375 .hp_nid = 0x03,
12376 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12377 .channel_mode = alc269_modes,
12378 .input_mux = &alc269_eeepc_amic_capture_source,
12379 .unsol_event = alc269_eeepc_amic_unsol_event,
12380 .init_hook = alc269_eeepc_amic_inithook,
12381 },
12382 [ALC269_ASUS_EEEPC_P901] = {
12383 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
12384 .init_verbs = { alc269_init_verbs,
12385 alc269_eeepc_dmic_init_verbs },
12386 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12387 .dac_nids = alc269_dac_nids,
12388 .hp_nid = 0x03,
12389 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12390 .channel_mode = alc269_modes,
12391 .input_mux = &alc269_eeepc_dmic_capture_source,
12392 .unsol_event = alc269_eeepc_dmic_unsol_event,
12393 .init_hook = alc269_eeepc_dmic_inithook,
12394 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012395};
12396
12397static int patch_alc269(struct hda_codec *codec)
12398{
12399 struct alc_spec *spec;
12400 int board_config;
12401 int err;
12402
12403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12404 if (spec == NULL)
12405 return -ENOMEM;
12406
12407 codec->spec = spec;
12408
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012409 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12410
Kailang Yangf6a92242007-12-13 16:52:54 +010012411 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12412 alc269_models,
12413 alc269_cfg_tbl);
12414
12415 if (board_config < 0) {
12416 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12417 "trying auto-probe from BIOS...\n");
12418 board_config = ALC269_AUTO;
12419 }
12420
12421 if (board_config == ALC269_AUTO) {
12422 /* automatic parse from the BIOS config */
12423 err = alc269_parse_auto_config(codec);
12424 if (err < 0) {
12425 alc_free(codec);
12426 return err;
12427 } else if (!err) {
12428 printk(KERN_INFO
12429 "hda_codec: Cannot set up configuration "
12430 "from BIOS. Using base mode...\n");
12431 board_config = ALC269_BASIC;
12432 }
12433 }
12434
12435 if (board_config != ALC269_AUTO)
12436 setup_preset(spec, &alc269_presets[board_config]);
12437
12438 spec->stream_name_analog = "ALC269 Analog";
12439 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12440 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12441
12442 spec->stream_name_digital = "ALC269 Digital";
12443 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12444 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12445
12446 spec->adc_nids = alc269_adc_nids;
12447 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012448 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010012449
12450 codec->patch_ops = alc_patch_ops;
12451 if (board_config == ALC269_AUTO)
12452 spec->init_hook = alc269_auto_init;
12453#ifdef CONFIG_SND_HDA_POWER_SAVE
12454 if (!spec->loopback.amplist)
12455 spec->loopback.amplist = alc269_loopbacks;
12456#endif
12457
12458 return 0;
12459}
12460
12461/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012462 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12463 */
12464
12465/*
12466 * set the path ways for 2 channel output
12467 * need to set the codec line out and mic 1 pin widgets to inputs
12468 */
12469static struct hda_verb alc861_threestack_ch2_init[] = {
12470 /* set pin widget 1Ah (line in) for input */
12471 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012472 /* set pin widget 18h (mic1/2) for input, for mic also enable
12473 * the vref
12474 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012475 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12476
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012477 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12478#if 0
12479 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12480 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12481#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012482 { } /* end */
12483};
12484/*
12485 * 6ch mode
12486 * need to set the codec line out and mic 1 pin widgets to outputs
12487 */
12488static struct hda_verb alc861_threestack_ch6_init[] = {
12489 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12490 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12491 /* set pin widget 18h (mic1) for output (CLFE)*/
12492 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12493
12494 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012495 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012496
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12498#if 0
12499 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12500 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12501#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012502 { } /* end */
12503};
12504
12505static struct hda_channel_mode alc861_threestack_modes[2] = {
12506 { 2, alc861_threestack_ch2_init },
12507 { 6, alc861_threestack_ch6_init },
12508};
Takashi Iwai22309c32006-08-09 16:57:28 +020012509/* Set mic1 as input and unmute the mixer */
12510static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12511 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12512 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12513 { } /* end */
12514};
12515/* Set mic1 as output and mute mixer */
12516static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12517 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12518 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12519 { } /* end */
12520};
12521
12522static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12523 { 2, alc861_uniwill_m31_ch2_init },
12524 { 4, alc861_uniwill_m31_ch4_init },
12525};
Kailang Yangdf694da2005-12-05 19:42:22 +010012526
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012527/* Set mic1 and line-in as input and unmute the mixer */
12528static struct hda_verb alc861_asus_ch2_init[] = {
12529 /* set pin widget 1Ah (line in) for input */
12530 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012531 /* set pin widget 18h (mic1/2) for input, for mic also enable
12532 * the vref
12533 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012534 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12535
12536 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12537#if 0
12538 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12539 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12540#endif
12541 { } /* end */
12542};
12543/* Set mic1 nad line-in as output and mute mixer */
12544static struct hda_verb alc861_asus_ch6_init[] = {
12545 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12546 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12547 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12548 /* set pin widget 18h (mic1) for output (CLFE)*/
12549 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12550 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12551 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12552 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12553
12554 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12555#if 0
12556 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12557 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12558#endif
12559 { } /* end */
12560};
12561
12562static struct hda_channel_mode alc861_asus_modes[2] = {
12563 { 2, alc861_asus_ch2_init },
12564 { 6, alc861_asus_ch6_init },
12565};
12566
Kailang Yangdf694da2005-12-05 19:42:22 +010012567/* patch-ALC861 */
12568
12569static struct snd_kcontrol_new alc861_base_mixer[] = {
12570 /* output mixer control */
12571 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12572 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12573 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12574 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12575 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12576
12577 /*Input mixer control */
12578 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12579 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12580 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12581 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12582 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12583 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12585 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12586 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012588
Kailang Yangdf694da2005-12-05 19:42:22 +010012589 /* Capture mixer control */
12590 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12591 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12592 {
12593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12594 .name = "Capture Source",
12595 .count = 1,
12596 .info = alc_mux_enum_info,
12597 .get = alc_mux_enum_get,
12598 .put = alc_mux_enum_put,
12599 },
12600 { } /* end */
12601};
12602
12603static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12604 /* output mixer control */
12605 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12606 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12607 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12608 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12609 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12610
12611 /* Input mixer control */
12612 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12613 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12614 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12615 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12616 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12617 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12619 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012622
Kailang Yangdf694da2005-12-05 19:42:22 +010012623 /* Capture mixer control */
12624 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12625 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12626 {
12627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12628 .name = "Capture Source",
12629 .count = 1,
12630 .info = alc_mux_enum_info,
12631 .get = alc_mux_enum_get,
12632 .put = alc_mux_enum_put,
12633 },
12634 {
12635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12636 .name = "Channel Mode",
12637 .info = alc_ch_mode_info,
12638 .get = alc_ch_mode_get,
12639 .put = alc_ch_mode_put,
12640 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12641 },
12642 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012643};
12644
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012645static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012646 /* output mixer control */
12647 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12649 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012650
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012651 /*Capture mixer control */
12652 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12653 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12654 {
12655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12656 .name = "Capture Source",
12657 .count = 1,
12658 .info = alc_mux_enum_info,
12659 .get = alc_mux_enum_get,
12660 .put = alc_mux_enum_put,
12661 },
12662
12663 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012664};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012665
Takashi Iwai22309c32006-08-09 16:57:28 +020012666static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12667 /* output mixer control */
12668 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12669 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12670 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12671 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12672 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12673
12674 /* Input mixer control */
12675 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12676 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12677 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12678 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12679 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12680 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12682 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12683 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012685
Takashi Iwai22309c32006-08-09 16:57:28 +020012686 /* Capture mixer control */
12687 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12688 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12689 {
12690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12691 .name = "Capture Source",
12692 .count = 1,
12693 .info = alc_mux_enum_info,
12694 .get = alc_mux_enum_get,
12695 .put = alc_mux_enum_put,
12696 },
12697 {
12698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12699 .name = "Channel Mode",
12700 .info = alc_ch_mode_info,
12701 .get = alc_ch_mode_get,
12702 .put = alc_ch_mode_put,
12703 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12704 },
12705 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012706};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012707
12708static struct snd_kcontrol_new alc861_asus_mixer[] = {
12709 /* output mixer control */
12710 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12711 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12712 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12713 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12714 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12715
12716 /* Input mixer control */
12717 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12718 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12719 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12720 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12721 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12722 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12724 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12725 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12727
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012728 /* Capture mixer control */
12729 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12730 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12731 {
12732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12733 .name = "Capture Source",
12734 .count = 1,
12735 .info = alc_mux_enum_info,
12736 .get = alc_mux_enum_get,
12737 .put = alc_mux_enum_put,
12738 },
12739 {
12740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12741 .name = "Channel Mode",
12742 .info = alc_ch_mode_info,
12743 .get = alc_ch_mode_get,
12744 .put = alc_ch_mode_put,
12745 .private_value = ARRAY_SIZE(alc861_asus_modes),
12746 },
12747 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012748};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012749
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012750/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012751static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012752 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12753 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12754 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12755 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12756 { }
12757};
12758
Kailang Yangdf694da2005-12-05 19:42:22 +010012759/*
12760 * generic initialization of ADC, input mixers and output mixers
12761 */
12762static struct hda_verb alc861_base_init_verbs[] = {
12763 /*
12764 * Unmute ADC0 and set the default input to mic-in
12765 */
12766 /* port-A for surround (rear panel) */
12767 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12768 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12769 /* port-B for mic-in (rear panel) with vref */
12770 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12771 /* port-C for line-in (rear panel) */
12772 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12773 /* port-D for Front */
12774 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12775 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12776 /* port-E for HP out (front panel) */
12777 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12778 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012779 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012780 /* port-F for mic-in (front panel) with vref */
12781 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12782 /* port-G for CLFE (rear panel) */
12783 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12784 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12785 /* port-H for side (rear panel) */
12786 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12787 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12788 /* CD-in */
12789 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12790 /* route front mic to ADC1*/
12791 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012793
Kailang Yangdf694da2005-12-05 19:42:22 +010012794 /* Unmute DAC0~3 & spdif out*/
12795 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12796 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12797 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12798 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012800
Kailang Yangdf694da2005-12-05 19:42:22 +010012801 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12802 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12803 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12804 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12805 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012806
Kailang Yangdf694da2005-12-05 19:42:22 +010012807 /* Unmute Stereo Mixer 15 */
12808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012812
12813 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12814 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12818 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12820 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012821 /* hp used DAC 3 (Front) */
12822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12824
12825 { }
12826};
12827
12828static struct hda_verb alc861_threestack_init_verbs[] = {
12829 /*
12830 * Unmute ADC0 and set the default input to mic-in
12831 */
12832 /* port-A for surround (rear panel) */
12833 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12834 /* port-B for mic-in (rear panel) with vref */
12835 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12836 /* port-C for line-in (rear panel) */
12837 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12838 /* port-D for Front */
12839 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12840 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12841 /* port-E for HP out (front panel) */
12842 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12843 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012844 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012845 /* port-F for mic-in (front panel) with vref */
12846 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12847 /* port-G for CLFE (rear panel) */
12848 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12849 /* port-H for side (rear panel) */
12850 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12851 /* CD-in */
12852 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12853 /* route front mic to ADC1*/
12854 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12856 /* Unmute DAC0~3 & spdif out*/
12857 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12858 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12859 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12860 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012862
Kailang Yangdf694da2005-12-05 19:42:22 +010012863 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12864 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12865 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12866 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12867 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012868
Kailang Yangdf694da2005-12-05 19:42:22 +010012869 /* Unmute Stereo Mixer 15 */
12870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012874
12875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12876 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012883 /* hp used DAC 3 (Front) */
12884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12886 { }
12887};
Takashi Iwai22309c32006-08-09 16:57:28 +020012888
12889static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12890 /*
12891 * Unmute ADC0 and set the default input to mic-in
12892 */
12893 /* port-A for surround (rear panel) */
12894 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12895 /* port-B for mic-in (rear panel) with vref */
12896 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12897 /* port-C for line-in (rear panel) */
12898 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12899 /* port-D for Front */
12900 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12901 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12902 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012903 /* this has to be set to VREF80 */
12904 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012905 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012906 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012907 /* port-F for mic-in (front panel) with vref */
12908 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12909 /* port-G for CLFE (rear panel) */
12910 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12911 /* port-H for side (rear panel) */
12912 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12913 /* CD-in */
12914 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12915 /* route front mic to ADC1*/
12916 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12918 /* Unmute DAC0~3 & spdif out*/
12919 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12922 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012924
Takashi Iwai22309c32006-08-09 16:57:28 +020012925 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12926 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12927 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12928 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12929 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012930
Takashi Iwai22309c32006-08-09 16:57:28 +020012931 /* Unmute Stereo Mixer 15 */
12932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012936
12937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12938 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12940 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012945 /* hp used DAC 3 (Front) */
12946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12948 { }
12949};
12950
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012951static struct hda_verb alc861_asus_init_verbs[] = {
12952 /*
12953 * Unmute ADC0 and set the default input to mic-in
12954 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012955 /* port-A for surround (rear panel)
12956 * according to codec#0 this is the HP jack
12957 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012958 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12959 /* route front PCM to HP */
12960 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12961 /* port-B for mic-in (rear panel) with vref */
12962 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12963 /* port-C for line-in (rear panel) */
12964 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12965 /* port-D for Front */
12966 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12967 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12968 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012969 /* this has to be set to VREF80 */
12970 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012971 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012972 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012973 /* port-F for mic-in (front panel) with vref */
12974 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12975 /* port-G for CLFE (rear panel) */
12976 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12977 /* port-H for side (rear panel) */
12978 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12979 /* CD-in */
12980 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12981 /* route front mic to ADC1*/
12982 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12984 /* Unmute DAC0~3 & spdif out*/
12985 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12986 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12987 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12988 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12990 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12991 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12992 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12993 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12994 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012995
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012996 /* Unmute Stereo Mixer 15 */
12997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013001
13002 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13005 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13006 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13008 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013010 /* hp used DAC 3 (Front) */
13011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013012 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13013 { }
13014};
13015
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013016/* additional init verbs for ASUS laptops */
13017static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13018 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13019 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13020 { }
13021};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013022
Kailang Yangdf694da2005-12-05 19:42:22 +010013023/*
13024 * generic initialization of ADC, input mixers and output mixers
13025 */
13026static struct hda_verb alc861_auto_init_verbs[] = {
13027 /*
13028 * Unmute ADC0 and set the default input to mic-in
13029 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013030 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013031 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013032
Kailang Yangdf694da2005-12-05 19:42:22 +010013033 /* Unmute DAC0~3 & spdif out*/
13034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13035 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13037 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013039
Kailang Yangdf694da2005-12-05 19:42:22 +010013040 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13041 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13042 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13043 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13044 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013045
Kailang Yangdf694da2005-12-05 19:42:22 +010013046 /* Unmute Stereo Mixer 15 */
13047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13051
13052 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13056 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13060
13061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013065 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13066 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013067 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013069
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013070 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013071
13072 { }
13073};
13074
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013075static struct hda_verb alc861_toshiba_init_verbs[] = {
13076 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013077
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013078 { }
13079};
13080
13081/* toggle speaker-output according to the hp-jack state */
13082static void alc861_toshiba_automute(struct hda_codec *codec)
13083{
13084 unsigned int present;
13085
13086 present = snd_hda_codec_read(codec, 0x0f, 0,
13087 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013088 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13089 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13090 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13091 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013092}
13093
13094static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13095 unsigned int res)
13096{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013097 if ((res >> 26) == ALC880_HP_EVENT)
13098 alc861_toshiba_automute(codec);
13099}
13100
Kailang Yangdf694da2005-12-05 19:42:22 +010013101/* pcm configuration: identiacal with ALC880 */
13102#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13103#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13104#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13105#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13106
13107
13108#define ALC861_DIGOUT_NID 0x07
13109
13110static struct hda_channel_mode alc861_8ch_modes[1] = {
13111 { 8, NULL }
13112};
13113
13114static hda_nid_t alc861_dac_nids[4] = {
13115 /* front, surround, clfe, side */
13116 0x03, 0x06, 0x05, 0x04
13117};
13118
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013119static hda_nid_t alc660_dac_nids[3] = {
13120 /* front, clfe, surround */
13121 0x03, 0x05, 0x06
13122};
13123
Kailang Yangdf694da2005-12-05 19:42:22 +010013124static hda_nid_t alc861_adc_nids[1] = {
13125 /* ADC0-2 */
13126 0x08,
13127};
13128
13129static struct hda_input_mux alc861_capture_source = {
13130 .num_items = 5,
13131 .items = {
13132 { "Mic", 0x0 },
13133 { "Front Mic", 0x3 },
13134 { "Line", 0x1 },
13135 { "CD", 0x4 },
13136 { "Mixer", 0x5 },
13137 },
13138};
13139
13140/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013141static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13142 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013143{
13144 int i;
13145 hda_nid_t nid;
13146
13147 spec->multiout.dac_nids = spec->private_dac_nids;
13148 for (i = 0; i < cfg->line_outs; i++) {
13149 nid = cfg->line_out_pins[i];
13150 if (nid) {
13151 if (i >= ARRAY_SIZE(alc861_dac_nids))
13152 continue;
13153 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13154 }
13155 }
13156 spec->multiout.num_dacs = cfg->line_outs;
13157 return 0;
13158}
13159
13160/* add playback controls from the parsed DAC table */
13161static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13162 const struct auto_pin_cfg *cfg)
13163{
13164 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013165 static const char *chname[4] = {
13166 "Front", "Surround", NULL /*CLFE*/, "Side"
13167 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013168 hda_nid_t nid;
13169 int i, idx, err;
13170
13171 for (i = 0; i < cfg->line_outs; i++) {
13172 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013173 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013174 continue;
13175 if (nid == 0x05) {
13176 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013177 err = add_control(spec, ALC_CTL_BIND_MUTE,
13178 "Center Playback Switch",
13179 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13180 HDA_OUTPUT));
13181 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013182 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013183 err = add_control(spec, ALC_CTL_BIND_MUTE,
13184 "LFE Playback Switch",
13185 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13186 HDA_OUTPUT));
13187 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013188 return err;
13189 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013190 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13191 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013192 if (nid == alc861_dac_nids[idx])
13193 break;
13194 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013195 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13196 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13197 HDA_OUTPUT));
13198 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013199 return err;
13200 }
13201 }
13202 return 0;
13203}
13204
13205static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13206{
13207 int err;
13208 hda_nid_t nid;
13209
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013211 return 0;
13212
13213 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13214 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013215 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13216 "Headphone Playback Switch",
13217 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13218 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013219 return err;
13220 spec->multiout.hp_nid = nid;
13221 }
13222 return 0;
13223}
13224
13225/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013226static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13227 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013228{
Kailang Yangdf694da2005-12-05 19:42:22 +010013229 struct hda_input_mux *imux = &spec->private_imux;
13230 int i, err, idx, idx1;
13231
13232 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013233 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013234 case 0x0c:
13235 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013236 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013237 break;
13238 case 0x0f:
13239 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013240 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013241 break;
13242 case 0x0d:
13243 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013244 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013245 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013246 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013247 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013248 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013249 break;
13250 case 0x11:
13251 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013252 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013253 break;
13254 default:
13255 continue;
13256 }
13257
Takashi Iwai4a471b72005-12-07 13:56:29 +010013258 err = new_analog_input(spec, cfg->input_pins[i],
13259 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013260 if (err < 0)
13261 return err;
13262
Takashi Iwai4a471b72005-12-07 13:56:29 +010013263 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013264 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013265 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013266 }
13267 return 0;
13268}
13269
13270static struct snd_kcontrol_new alc861_capture_mixer[] = {
13271 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13272 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13273
13274 {
13275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13276 /* The multiple "Capture Source" controls confuse alsamixer
13277 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010013278 */
13279 /* .name = "Capture Source", */
13280 .name = "Input Source",
13281 .count = 1,
13282 .info = alc_mux_enum_info,
13283 .get = alc_mux_enum_get,
13284 .put = alc_mux_enum_put,
13285 },
13286 { } /* end */
13287};
13288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013289static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13290 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013291 int pin_type, int dac_idx)
13292{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013293 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13294 pin_type);
13295 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13296 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013297}
13298
13299static void alc861_auto_init_multi_out(struct hda_codec *codec)
13300{
13301 struct alc_spec *spec = codec->spec;
13302 int i;
13303
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013304 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013305 for (i = 0; i < spec->autocfg.line_outs; i++) {
13306 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013307 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013308 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013309 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013310 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013311 }
13312}
13313
13314static void alc861_auto_init_hp_out(struct hda_codec *codec)
13315{
13316 struct alc_spec *spec = codec->spec;
13317 hda_nid_t pin;
13318
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013319 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013320 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013321 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13322 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013323 pin = spec->autocfg.speaker_pins[0];
13324 if (pin)
13325 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013326}
13327
13328static void alc861_auto_init_analog_input(struct hda_codec *codec)
13329{
13330 struct alc_spec *spec = codec->spec;
13331 int i;
13332
13333 for (i = 0; i < AUTO_PIN_LAST; i++) {
13334 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013335 if (nid >= 0x0c && nid <= 0x11) {
13336 snd_hda_codec_write(codec, nid, 0,
13337 AC_VERB_SET_PIN_WIDGET_CONTROL,
13338 i <= AUTO_PIN_FRONT_MIC ?
13339 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013340 }
13341 }
13342}
13343
13344/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013345/* return 1 if successful, 0 if the proper config is not found,
13346 * or a negative error code
13347 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013348static int alc861_parse_auto_config(struct hda_codec *codec)
13349{
13350 struct alc_spec *spec = codec->spec;
13351 int err;
13352 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013354 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13355 alc861_ignore);
13356 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013357 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013358 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013359 return 0; /* can't find valid BIOS pin config */
13360
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013361 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13362 if (err < 0)
13363 return err;
13364 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13365 if (err < 0)
13366 return err;
13367 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13368 if (err < 0)
13369 return err;
13370 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13371 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013372 return err;
13373
13374 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13375
13376 if (spec->autocfg.dig_out_pin)
13377 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13378
13379 if (spec->kctl_alloc)
13380 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13381
13382 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
13383
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013384 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013385 spec->input_mux = &spec->private_imux;
13386
13387 spec->adc_nids = alc861_adc_nids;
13388 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13389 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
13390 spec->num_mixers++;
13391
Takashi Iwaie044c392008-10-27 16:56:24 +010013392 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013393 return 1;
13394}
13395
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013396/* additional initialization for auto-configuration model */
13397static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013398{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013399 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013400 alc861_auto_init_multi_out(codec);
13401 alc861_auto_init_hp_out(codec);
13402 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013403 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013404 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013405}
13406
Takashi Iwaicb53c622007-08-10 17:21:45 +020013407#ifdef CONFIG_SND_HDA_POWER_SAVE
13408static struct hda_amp_list alc861_loopbacks[] = {
13409 { 0x15, HDA_INPUT, 0 },
13410 { 0x15, HDA_INPUT, 1 },
13411 { 0x15, HDA_INPUT, 2 },
13412 { 0x15, HDA_INPUT, 3 },
13413 { } /* end */
13414};
13415#endif
13416
Kailang Yangdf694da2005-12-05 19:42:22 +010013417
13418/*
13419 * configuration and preset
13420 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013421static const char *alc861_models[ALC861_MODEL_LAST] = {
13422 [ALC861_3ST] = "3stack",
13423 [ALC660_3ST] = "3stack-660",
13424 [ALC861_3ST_DIG] = "3stack-dig",
13425 [ALC861_6ST_DIG] = "6stack-dig",
13426 [ALC861_UNIWILL_M31] = "uniwill-m31",
13427 [ALC861_TOSHIBA] = "toshiba",
13428 [ALC861_ASUS] = "asus",
13429 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13430 [ALC861_AUTO] = "auto",
13431};
13432
13433static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013434 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013435 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13436 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13437 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013438 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013439 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013440 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013441 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13442 * Any other models that need this preset?
13443 */
13444 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013445 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13446 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013447 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13448 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13449 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13450 /* FIXME: the below seems conflict */
13451 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13452 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13453 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013454 {}
13455};
13456
13457static struct alc_config_preset alc861_presets[] = {
13458 [ALC861_3ST] = {
13459 .mixers = { alc861_3ST_mixer },
13460 .init_verbs = { alc861_threestack_init_verbs },
13461 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13462 .dac_nids = alc861_dac_nids,
13463 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13464 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013465 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013466 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13467 .adc_nids = alc861_adc_nids,
13468 .input_mux = &alc861_capture_source,
13469 },
13470 [ALC861_3ST_DIG] = {
13471 .mixers = { alc861_base_mixer },
13472 .init_verbs = { alc861_threestack_init_verbs },
13473 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13474 .dac_nids = alc861_dac_nids,
13475 .dig_out_nid = ALC861_DIGOUT_NID,
13476 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13477 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013478 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013479 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13480 .adc_nids = alc861_adc_nids,
13481 .input_mux = &alc861_capture_source,
13482 },
13483 [ALC861_6ST_DIG] = {
13484 .mixers = { alc861_base_mixer },
13485 .init_verbs = { alc861_base_init_verbs },
13486 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13487 .dac_nids = alc861_dac_nids,
13488 .dig_out_nid = ALC861_DIGOUT_NID,
13489 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13490 .channel_mode = alc861_8ch_modes,
13491 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13492 .adc_nids = alc861_adc_nids,
13493 .input_mux = &alc861_capture_source,
13494 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013495 [ALC660_3ST] = {
13496 .mixers = { alc861_3ST_mixer },
13497 .init_verbs = { alc861_threestack_init_verbs },
13498 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13499 .dac_nids = alc660_dac_nids,
13500 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13501 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013502 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013503 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13504 .adc_nids = alc861_adc_nids,
13505 .input_mux = &alc861_capture_source,
13506 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013507 [ALC861_UNIWILL_M31] = {
13508 .mixers = { alc861_uniwill_m31_mixer },
13509 .init_verbs = { alc861_uniwill_m31_init_verbs },
13510 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13511 .dac_nids = alc861_dac_nids,
13512 .dig_out_nid = ALC861_DIGOUT_NID,
13513 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13514 .channel_mode = alc861_uniwill_m31_modes,
13515 .need_dac_fix = 1,
13516 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13517 .adc_nids = alc861_adc_nids,
13518 .input_mux = &alc861_capture_source,
13519 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013520 [ALC861_TOSHIBA] = {
13521 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013522 .init_verbs = { alc861_base_init_verbs,
13523 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013524 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13525 .dac_nids = alc861_dac_nids,
13526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13527 .channel_mode = alc883_3ST_2ch_modes,
13528 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13529 .adc_nids = alc861_adc_nids,
13530 .input_mux = &alc861_capture_source,
13531 .unsol_event = alc861_toshiba_unsol_event,
13532 .init_hook = alc861_toshiba_automute,
13533 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013534 [ALC861_ASUS] = {
13535 .mixers = { alc861_asus_mixer },
13536 .init_verbs = { alc861_asus_init_verbs },
13537 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13538 .dac_nids = alc861_dac_nids,
13539 .dig_out_nid = ALC861_DIGOUT_NID,
13540 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13541 .channel_mode = alc861_asus_modes,
13542 .need_dac_fix = 1,
13543 .hp_nid = 0x06,
13544 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13545 .adc_nids = alc861_adc_nids,
13546 .input_mux = &alc861_capture_source,
13547 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013548 [ALC861_ASUS_LAPTOP] = {
13549 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13550 .init_verbs = { alc861_asus_init_verbs,
13551 alc861_asus_laptop_init_verbs },
13552 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13553 .dac_nids = alc861_dac_nids,
13554 .dig_out_nid = ALC861_DIGOUT_NID,
13555 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13556 .channel_mode = alc883_3ST_2ch_modes,
13557 .need_dac_fix = 1,
13558 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13559 .adc_nids = alc861_adc_nids,
13560 .input_mux = &alc861_capture_source,
13561 },
13562};
Kailang Yangdf694da2005-12-05 19:42:22 +010013563
13564
13565static int patch_alc861(struct hda_codec *codec)
13566{
13567 struct alc_spec *spec;
13568 int board_config;
13569 int err;
13570
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013571 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013572 if (spec == NULL)
13573 return -ENOMEM;
13574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013575 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013576
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013577 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13578 alc861_models,
13579 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013580
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013581 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013582 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13583 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013584 board_config = ALC861_AUTO;
13585 }
13586
13587 if (board_config == ALC861_AUTO) {
13588 /* automatic parse from the BIOS config */
13589 err = alc861_parse_auto_config(codec);
13590 if (err < 0) {
13591 alc_free(codec);
13592 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013593 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013594 printk(KERN_INFO
13595 "hda_codec: Cannot set up configuration "
13596 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013597 board_config = ALC861_3ST_DIG;
13598 }
13599 }
13600
13601 if (board_config != ALC861_AUTO)
13602 setup_preset(spec, &alc861_presets[board_config]);
13603
13604 spec->stream_name_analog = "ALC861 Analog";
13605 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13606 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13607
13608 spec->stream_name_digital = "ALC861 Digital";
13609 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13610 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13611
Takashi Iwai2134ea42008-01-10 16:53:55 +010013612 spec->vmaster_nid = 0x03;
13613
Kailang Yangdf694da2005-12-05 19:42:22 +010013614 codec->patch_ops = alc_patch_ops;
13615 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013616 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013617#ifdef CONFIG_SND_HDA_POWER_SAVE
13618 if (!spec->loopback.amplist)
13619 spec->loopback.amplist = alc861_loopbacks;
13620#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013621
Kailang Yangdf694da2005-12-05 19:42:22 +010013622 return 0;
13623}
13624
13625/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013626 * ALC861-VD support
13627 *
13628 * Based on ALC882
13629 *
13630 * In addition, an independent DAC
13631 */
13632#define ALC861VD_DIGOUT_NID 0x06
13633
13634static hda_nid_t alc861vd_dac_nids[4] = {
13635 /* front, surr, clfe, side surr */
13636 0x02, 0x03, 0x04, 0x05
13637};
13638
13639/* dac_nids for ALC660vd are in a different order - according to
13640 * Realtek's driver.
13641 * This should probably tesult in a different mixer for 6stack models
13642 * of ALC660vd codecs, but for now there is only 3stack mixer
13643 * - and it is the same as in 861vd.
13644 * adc_nids in ALC660vd are (is) the same as in 861vd
13645 */
13646static hda_nid_t alc660vd_dac_nids[3] = {
13647 /* front, rear, clfe, rear_surr */
13648 0x02, 0x04, 0x03
13649};
13650
13651static hda_nid_t alc861vd_adc_nids[1] = {
13652 /* ADC0 */
13653 0x09,
13654};
13655
Takashi Iwaie1406342008-02-11 18:32:32 +010013656static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13657
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013658/* input MUX */
13659/* FIXME: should be a matrix-type input source selection */
13660static struct hda_input_mux alc861vd_capture_source = {
13661 .num_items = 4,
13662 .items = {
13663 { "Mic", 0x0 },
13664 { "Front Mic", 0x1 },
13665 { "Line", 0x2 },
13666 { "CD", 0x4 },
13667 },
13668};
13669
Kailang Yang272a5272007-05-14 11:00:38 +020013670static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013671 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013672 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013673 { "Ext Mic", 0x0 },
13674 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013675 },
13676};
13677
Kailang Yangd1a991a2007-08-15 16:21:59 +020013678static struct hda_input_mux alc861vd_hp_capture_source = {
13679 .num_items = 2,
13680 .items = {
13681 { "Front Mic", 0x0 },
13682 { "ATAPI Mic", 0x1 },
13683 },
13684};
13685
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013686#define alc861vd_mux_enum_info alc_mux_enum_info
13687#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013688/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13689#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013690
13691/*
13692 * 2ch mode
13693 */
13694static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13695 { 2, NULL }
13696};
13697
13698/*
13699 * 6ch mode
13700 */
13701static struct hda_verb alc861vd_6stack_ch6_init[] = {
13702 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13703 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13705 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13706 { } /* end */
13707};
13708
13709/*
13710 * 8ch mode
13711 */
13712static struct hda_verb alc861vd_6stack_ch8_init[] = {
13713 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13714 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13715 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13716 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13717 { } /* end */
13718};
13719
13720static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13721 { 6, alc861vd_6stack_ch6_init },
13722 { 8, alc861vd_6stack_ch8_init },
13723};
13724
13725static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13726 {
13727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13728 .name = "Channel Mode",
13729 .info = alc_ch_mode_info,
13730 .get = alc_ch_mode_get,
13731 .put = alc_ch_mode_put,
13732 },
13733 { } /* end */
13734};
13735
13736static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13737 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13738 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13739
13740 {
13741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13742 /* The multiple "Capture Source" controls confuse alsamixer
13743 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013744 */
13745 /* .name = "Capture Source", */
13746 .name = "Input Source",
13747 .count = 1,
13748 .info = alc861vd_mux_enum_info,
13749 .get = alc861vd_mux_enum_get,
13750 .put = alc861vd_mux_enum_put,
13751 },
13752 { } /* end */
13753};
13754
13755/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13756 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13757 */
13758static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13759 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13761
13762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13764
13765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13766 HDA_OUTPUT),
13767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13768 HDA_OUTPUT),
13769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13771
13772 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13773 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13774
13775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13776
13777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13780
13781 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13782 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13783 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13784
13785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13787
13788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13790
13791 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13792 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13793
13794 { } /* end */
13795};
13796
13797static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13798 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13799 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13800
13801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13802
13803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13806
13807 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13810
13811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13813
13814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13816
13817 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13818 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13819
13820 { } /* end */
13821};
13822
Kailang Yangbdd148a2007-05-08 15:19:08 +020013823static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13824 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13825 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13826 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13827
13828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13829
13830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13833
13834 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13837
13838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13840
13841 { } /* end */
13842};
13843
Tobin Davisb419f342008-03-07 11:57:51 +010013844/* Pin assignment: Speaker=0x14, HP = 0x15,
13845 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013846 */
13847static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013848 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13849 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013850 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13851 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013852 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13853 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13854 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13855 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13856 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13857 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13858 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13859 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013860 { } /* end */
13861};
13862
Kailang Yangd1a991a2007-08-15 16:21:59 +020013863/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13864 * Front Mic=0x18, ATAPI Mic = 0x19,
13865 */
13866static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13867 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13868 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13870 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13873 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13874 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013875
Kailang Yangd1a991a2007-08-15 16:21:59 +020013876 { } /* end */
13877};
13878
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013879/*
13880 * generic initialization of ADC, input mixers and output mixers
13881 */
13882static struct hda_verb alc861vd_volume_init_verbs[] = {
13883 /*
13884 * Unmute ADC0 and set the default input to mic-in
13885 */
13886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13888
13889 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13890 * the analog-loopback mixer widget
13891 */
13892 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013893 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013898
13899 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013904
13905 /*
13906 * Set up output mixers (0x02 - 0x05)
13907 */
13908 /* set vol=0 to output mixers */
13909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13912 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13913
13914 /* set up input amps for analog loopback */
13915 /* Amp Indices: DAC = 0, mixer = 1 */
13916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13924
13925 { }
13926};
13927
13928/*
13929 * 3-stack pin configuration:
13930 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13931 */
13932static struct hda_verb alc861vd_3stack_init_verbs[] = {
13933 /*
13934 * Set pin mode and muting
13935 */
13936 /* set front pin widgets 0x14 for output */
13937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13939 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13940
13941 /* Mic (rear) pin: input vref at 80% */
13942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13943 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13944 /* Front Mic pin: input vref at 80% */
13945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13947 /* Line In pin: input */
13948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13950 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13953 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13954 /* CD pin widget for input */
13955 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13956
13957 { }
13958};
13959
13960/*
13961 * 6-stack pin configuration:
13962 */
13963static struct hda_verb alc861vd_6stack_init_verbs[] = {
13964 /*
13965 * Set pin mode and muting
13966 */
13967 /* set front pin widgets 0x14 for output */
13968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13970 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13971
13972 /* Rear Pin: output 1 (0x0d) */
13973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13976 /* CLFE Pin: output 2 (0x0e) */
13977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13978 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13979 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13980 /* Side Pin: output 3 (0x0f) */
13981 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13982 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13983 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13984
13985 /* Mic (rear) pin: input vref at 80% */
13986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13988 /* Front Mic pin: input vref at 80% */
13989 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13991 /* Line In pin: input */
13992 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13994 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13996 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13997 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13998 /* CD pin widget for input */
13999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14000
14001 { }
14002};
14003
Kailang Yangbdd148a2007-05-08 15:19:08 +020014004static struct hda_verb alc861vd_eapd_verbs[] = {
14005 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14006 { }
14007};
14008
Kailang Yangf9423e72008-05-27 12:32:25 +020014009static struct hda_verb alc660vd_eapd_verbs[] = {
14010 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14011 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14012 { }
14013};
14014
Kailang Yangbdd148a2007-05-08 15:19:08 +020014015static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14019 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014020 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014021 {}
14022};
14023
14024/* toggle speaker-output according to the hp-jack state */
14025static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14026{
14027 unsigned int present;
14028 unsigned char bits;
14029
14030 present = snd_hda_codec_read(codec, 0x1b, 0,
14031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014032 bits = present ? HDA_AMP_MUTE : 0;
14033 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14034 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014035}
14036
14037static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14038{
14039 unsigned int present;
14040 unsigned char bits;
14041
14042 present = snd_hda_codec_read(codec, 0x18, 0,
14043 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014044 bits = present ? HDA_AMP_MUTE : 0;
14045 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14046 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014047}
14048
14049static void alc861vd_lenovo_automute(struct hda_codec *codec)
14050{
14051 alc861vd_lenovo_hp_automute(codec);
14052 alc861vd_lenovo_mic_automute(codec);
14053}
14054
14055static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14056 unsigned int res)
14057{
14058 switch (res >> 26) {
14059 case ALC880_HP_EVENT:
14060 alc861vd_lenovo_hp_automute(codec);
14061 break;
14062 case ALC880_MIC_EVENT:
14063 alc861vd_lenovo_mic_automute(codec);
14064 break;
14065 }
14066}
14067
Kailang Yang272a5272007-05-14 11:00:38 +020014068static struct hda_verb alc861vd_dallas_verbs[] = {
14069 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14070 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14072 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14073
14074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014082
Kailang Yang272a5272007-05-14 11:00:38 +020014083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14088 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14089 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14090 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14091
14092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14093 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14099 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14100
14101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14105
14106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014107 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014108 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14109
14110 { } /* end */
14111};
14112
14113/* toggle speaker-output according to the hp-jack state */
14114static void alc861vd_dallas_automute(struct hda_codec *codec)
14115{
14116 unsigned int present;
14117
14118 present = snd_hda_codec_read(codec, 0x15, 0,
14119 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014120 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014122}
14123
14124static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14125{
14126 if ((res >> 26) == ALC880_HP_EVENT)
14127 alc861vd_dallas_automute(codec);
14128}
14129
Takashi Iwaicb53c622007-08-10 17:21:45 +020014130#ifdef CONFIG_SND_HDA_POWER_SAVE
14131#define alc861vd_loopbacks alc880_loopbacks
14132#endif
14133
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014134/* pcm configuration: identiacal with ALC880 */
14135#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14136#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14137#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14138#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14139
14140/*
14141 * configuration and preset
14142 */
14143static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14144 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014145 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014146 [ALC861VD_3ST] = "3stack",
14147 [ALC861VD_3ST_DIG] = "3stack-digout",
14148 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014149 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014150 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014151 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014152 [ALC861VD_AUTO] = "auto",
14153};
14154
14155static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014156 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14157 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014158 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014159 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020014160 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020014161 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014162 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014163 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014164 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014165 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014166 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014167 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014168 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014169 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14170 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014171 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014172 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014173 {}
14174};
14175
14176static struct alc_config_preset alc861vd_presets[] = {
14177 [ALC660VD_3ST] = {
14178 .mixers = { alc861vd_3st_mixer },
14179 .init_verbs = { alc861vd_volume_init_verbs,
14180 alc861vd_3stack_init_verbs },
14181 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14182 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014183 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14184 .channel_mode = alc861vd_3stack_2ch_modes,
14185 .input_mux = &alc861vd_capture_source,
14186 },
Mike Crash6963f842007-06-25 12:12:51 +020014187 [ALC660VD_3ST_DIG] = {
14188 .mixers = { alc861vd_3st_mixer },
14189 .init_verbs = { alc861vd_volume_init_verbs,
14190 alc861vd_3stack_init_verbs },
14191 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14192 .dac_nids = alc660vd_dac_nids,
14193 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014194 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14195 .channel_mode = alc861vd_3stack_2ch_modes,
14196 .input_mux = &alc861vd_capture_source,
14197 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014198 [ALC861VD_3ST] = {
14199 .mixers = { alc861vd_3st_mixer },
14200 .init_verbs = { alc861vd_volume_init_verbs,
14201 alc861vd_3stack_init_verbs },
14202 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14203 .dac_nids = alc861vd_dac_nids,
14204 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14205 .channel_mode = alc861vd_3stack_2ch_modes,
14206 .input_mux = &alc861vd_capture_source,
14207 },
14208 [ALC861VD_3ST_DIG] = {
14209 .mixers = { alc861vd_3st_mixer },
14210 .init_verbs = { alc861vd_volume_init_verbs,
14211 alc861vd_3stack_init_verbs },
14212 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14213 .dac_nids = alc861vd_dac_nids,
14214 .dig_out_nid = ALC861VD_DIGOUT_NID,
14215 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14216 .channel_mode = alc861vd_3stack_2ch_modes,
14217 .input_mux = &alc861vd_capture_source,
14218 },
14219 [ALC861VD_6ST_DIG] = {
14220 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14221 .init_verbs = { alc861vd_volume_init_verbs,
14222 alc861vd_6stack_init_verbs },
14223 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14224 .dac_nids = alc861vd_dac_nids,
14225 .dig_out_nid = ALC861VD_DIGOUT_NID,
14226 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14227 .channel_mode = alc861vd_6stack_modes,
14228 .input_mux = &alc861vd_capture_source,
14229 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014230 [ALC861VD_LENOVO] = {
14231 .mixers = { alc861vd_lenovo_mixer },
14232 .init_verbs = { alc861vd_volume_init_verbs,
14233 alc861vd_3stack_init_verbs,
14234 alc861vd_eapd_verbs,
14235 alc861vd_lenovo_unsol_verbs },
14236 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14237 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14239 .channel_mode = alc861vd_3stack_2ch_modes,
14240 .input_mux = &alc861vd_capture_source,
14241 .unsol_event = alc861vd_lenovo_unsol_event,
14242 .init_hook = alc861vd_lenovo_automute,
14243 },
Kailang Yang272a5272007-05-14 11:00:38 +020014244 [ALC861VD_DALLAS] = {
14245 .mixers = { alc861vd_dallas_mixer },
14246 .init_verbs = { alc861vd_dallas_verbs },
14247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14248 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014249 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14250 .channel_mode = alc861vd_3stack_2ch_modes,
14251 .input_mux = &alc861vd_dallas_capture_source,
14252 .unsol_event = alc861vd_dallas_unsol_event,
14253 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014254 },
14255 [ALC861VD_HP] = {
14256 .mixers = { alc861vd_hp_mixer },
14257 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14258 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14259 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014260 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014261 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14262 .channel_mode = alc861vd_3stack_2ch_modes,
14263 .input_mux = &alc861vd_hp_capture_source,
14264 .unsol_event = alc861vd_dallas_unsol_event,
14265 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014266 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014267};
14268
14269/*
14270 * BIOS auto configuration
14271 */
14272static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14273 hda_nid_t nid, int pin_type, int dac_idx)
14274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014275 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014276}
14277
14278static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14279{
14280 struct alc_spec *spec = codec->spec;
14281 int i;
14282
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014283 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014284 for (i = 0; i <= HDA_SIDE; i++) {
14285 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014286 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014287 if (nid)
14288 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014289 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014290 }
14291}
14292
14293
14294static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14295{
14296 struct alc_spec *spec = codec->spec;
14297 hda_nid_t pin;
14298
14299 pin = spec->autocfg.hp_pins[0];
14300 if (pin) /* connect to front and use dac 0 */
14301 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014302 pin = spec->autocfg.speaker_pins[0];
14303 if (pin)
14304 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014305}
14306
14307#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14308#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14309
14310static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14311{
14312 struct alc_spec *spec = codec->spec;
14313 int i;
14314
14315 for (i = 0; i < AUTO_PIN_LAST; i++) {
14316 hda_nid_t nid = spec->autocfg.input_pins[i];
14317 if (alc861vd_is_input_pin(nid)) {
14318 snd_hda_codec_write(codec, nid, 0,
14319 AC_VERB_SET_PIN_WIDGET_CONTROL,
14320 i <= AUTO_PIN_FRONT_MIC ?
14321 PIN_VREF80 : PIN_IN);
14322 if (nid != ALC861VD_PIN_CD_NID)
14323 snd_hda_codec_write(codec, nid, 0,
14324 AC_VERB_SET_AMP_GAIN_MUTE,
14325 AMP_OUT_MUTE);
14326 }
14327 }
14328}
14329
Takashi Iwaif511b012008-08-15 16:46:42 +020014330#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14331
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014332#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14333#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14334
14335/* add playback controls from the parsed DAC table */
14336/* Based on ALC880 version. But ALC861VD has separate,
14337 * different NIDs for mute/unmute switch and volume control */
14338static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14339 const struct auto_pin_cfg *cfg)
14340{
14341 char name[32];
14342 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14343 hda_nid_t nid_v, nid_s;
14344 int i, err;
14345
14346 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014347 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014348 continue;
14349 nid_v = alc861vd_idx_to_mixer_vol(
14350 alc880_dac_to_idx(
14351 spec->multiout.dac_nids[i]));
14352 nid_s = alc861vd_idx_to_mixer_switch(
14353 alc880_dac_to_idx(
14354 spec->multiout.dac_nids[i]));
14355
14356 if (i == 2) {
14357 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014358 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14359 "Center Playback Volume",
14360 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14361 HDA_OUTPUT));
14362 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014363 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14365 "LFE Playback Volume",
14366 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14367 HDA_OUTPUT));
14368 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014369 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014370 err = add_control(spec, ALC_CTL_BIND_MUTE,
14371 "Center Playback Switch",
14372 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14373 HDA_INPUT));
14374 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014376 err = add_control(spec, ALC_CTL_BIND_MUTE,
14377 "LFE Playback Switch",
14378 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14379 HDA_INPUT));
14380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014381 return err;
14382 } else {
14383 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014384 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14385 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14386 HDA_OUTPUT));
14387 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014388 return err;
14389 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014390 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014391 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014392 HDA_INPUT));
14393 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014394 return err;
14395 }
14396 }
14397 return 0;
14398}
14399
14400/* add playback controls for speaker and HP outputs */
14401/* Based on ALC880 version. But ALC861VD has separate,
14402 * different NIDs for mute/unmute switch and volume control */
14403static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14404 hda_nid_t pin, const char *pfx)
14405{
14406 hda_nid_t nid_v, nid_s;
14407 int err;
14408 char name[32];
14409
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014410 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014411 return 0;
14412
14413 if (alc880_is_fixed_pin(pin)) {
14414 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14415 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014416 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014417 spec->multiout.hp_nid = nid_v;
14418 else
14419 spec->multiout.extra_out_nid[0] = nid_v;
14420 /* control HP volume/switch on the output mixer amp */
14421 nid_v = alc861vd_idx_to_mixer_vol(
14422 alc880_fixed_pin_idx(pin));
14423 nid_s = alc861vd_idx_to_mixer_switch(
14424 alc880_fixed_pin_idx(pin));
14425
14426 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014427 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14428 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14429 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014430 return err;
14431 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014432 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14433 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14434 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014435 return err;
14436 } else if (alc880_is_multi_pin(pin)) {
14437 /* set manual connection */
14438 /* we have only a switch on HP-out PIN */
14439 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014440 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14441 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14442 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014443 return err;
14444 }
14445 return 0;
14446}
14447
14448/* parse the BIOS configuration and set up the alc_spec
14449 * return 1 if successful, 0 if the proper config is not found,
14450 * or a negative error code
14451 * Based on ALC880 version - had to change it to override
14452 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14453static int alc861vd_parse_auto_config(struct hda_codec *codec)
14454{
14455 struct alc_spec *spec = codec->spec;
14456 int err;
14457 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14458
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014459 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14460 alc861vd_ignore);
14461 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014462 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014463 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014464 return 0; /* can't find valid BIOS pin config */
14465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014466 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14467 if (err < 0)
14468 return err;
14469 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14470 if (err < 0)
14471 return err;
14472 err = alc861vd_auto_create_extra_out(spec,
14473 spec->autocfg.speaker_pins[0],
14474 "Speaker");
14475 if (err < 0)
14476 return err;
14477 err = alc861vd_auto_create_extra_out(spec,
14478 spec->autocfg.hp_pins[0],
14479 "Headphone");
14480 if (err < 0)
14481 return err;
14482 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14483 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014484 return err;
14485
14486 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14487
14488 if (spec->autocfg.dig_out_pin)
14489 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14490
14491 if (spec->kctl_alloc)
14492 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14493
14494 spec->init_verbs[spec->num_init_verbs++]
14495 = alc861vd_volume_init_verbs;
14496
14497 spec->num_mux_defs = 1;
14498 spec->input_mux = &spec->private_imux;
14499
Takashi Iwai776e1842007-08-29 15:07:11 +020014500 err = alc_auto_add_mic_boost(codec);
14501 if (err < 0)
14502 return err;
14503
Takashi Iwaie044c392008-10-27 16:56:24 +010014504 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014505 return 1;
14506}
14507
14508/* additional initialization for auto-configuration model */
14509static void alc861vd_auto_init(struct hda_codec *codec)
14510{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014511 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014512 alc861vd_auto_init_multi_out(codec);
14513 alc861vd_auto_init_hp_out(codec);
14514 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014515 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014517 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014518}
14519
14520static int patch_alc861vd(struct hda_codec *codec)
14521{
14522 struct alc_spec *spec;
14523 int err, board_config;
14524
14525 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14526 if (spec == NULL)
14527 return -ENOMEM;
14528
14529 codec->spec = spec;
14530
14531 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14532 alc861vd_models,
14533 alc861vd_cfg_tbl);
14534
14535 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14536 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14537 "ALC861VD, trying auto-probe from BIOS...\n");
14538 board_config = ALC861VD_AUTO;
14539 }
14540
14541 if (board_config == ALC861VD_AUTO) {
14542 /* automatic parse from the BIOS config */
14543 err = alc861vd_parse_auto_config(codec);
14544 if (err < 0) {
14545 alc_free(codec);
14546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014547 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014548 printk(KERN_INFO
14549 "hda_codec: Cannot set up configuration "
14550 "from BIOS. Using base mode...\n");
14551 board_config = ALC861VD_3ST;
14552 }
14553 }
14554
14555 if (board_config != ALC861VD_AUTO)
14556 setup_preset(spec, &alc861vd_presets[board_config]);
14557
Kailang Yang2f893282008-05-27 12:14:47 +020014558 if (codec->vendor_id == 0x10ec0660) {
14559 spec->stream_name_analog = "ALC660-VD Analog";
14560 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014561 /* always turn on EAPD */
14562 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020014563 } else {
14564 spec->stream_name_analog = "ALC861VD Analog";
14565 spec->stream_name_digital = "ALC861VD Digital";
14566 }
14567
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014568 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14569 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14570
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014571 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14572 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14573
14574 spec->adc_nids = alc861vd_adc_nids;
14575 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014576 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014577
14578 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
14579 spec->num_mixers++;
14580
Takashi Iwai2134ea42008-01-10 16:53:55 +010014581 spec->vmaster_nid = 0x02;
14582
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014583 codec->patch_ops = alc_patch_ops;
14584
14585 if (board_config == ALC861VD_AUTO)
14586 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014587#ifdef CONFIG_SND_HDA_POWER_SAVE
14588 if (!spec->loopback.amplist)
14589 spec->loopback.amplist = alc861vd_loopbacks;
14590#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014591
14592 return 0;
14593}
14594
14595/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014596 * ALC662 support
14597 *
14598 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14599 * configuration. Each pin widget can choose any input DACs and a mixer.
14600 * Each ADC is connected from a mixer of all inputs. This makes possible
14601 * 6-channel independent captures.
14602 *
14603 * In addition, an independent DAC for the multi-playback (not used in this
14604 * driver yet).
14605 */
14606#define ALC662_DIGOUT_NID 0x06
14607#define ALC662_DIGIN_NID 0x0a
14608
14609static hda_nid_t alc662_dac_nids[4] = {
14610 /* front, rear, clfe, rear_surr */
14611 0x02, 0x03, 0x04
14612};
14613
14614static hda_nid_t alc662_adc_nids[1] = {
14615 /* ADC1-2 */
14616 0x09,
14617};
Takashi Iwaie1406342008-02-11 18:32:32 +010014618
Kailang Yang77a261b2008-02-19 11:38:05 +010014619static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014620
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014621/* input MUX */
14622/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014623static struct hda_input_mux alc662_capture_source = {
14624 .num_items = 4,
14625 .items = {
14626 { "Mic", 0x0 },
14627 { "Front Mic", 0x1 },
14628 { "Line", 0x2 },
14629 { "CD", 0x4 },
14630 },
14631};
14632
14633static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14634 .num_items = 2,
14635 .items = {
14636 { "Mic", 0x1 },
14637 { "Line", 0x2 },
14638 },
14639};
Kailang Yang291702f2007-10-16 14:28:03 +020014640
14641static struct hda_input_mux alc662_eeepc_capture_source = {
14642 .num_items = 2,
14643 .items = {
14644 { "i-Mic", 0x1 },
14645 { "e-Mic", 0x0 },
14646 },
14647};
14648
Kailang Yang6dda9f42008-05-27 12:05:31 +020014649static struct hda_input_mux alc663_capture_source = {
14650 .num_items = 3,
14651 .items = {
14652 { "Mic", 0x0 },
14653 { "Front Mic", 0x1 },
14654 { "Line", 0x2 },
14655 },
14656};
14657
14658static struct hda_input_mux alc663_m51va_capture_source = {
14659 .num_items = 2,
14660 .items = {
14661 { "Ext-Mic", 0x0 },
14662 { "D-Mic", 0x9 },
14663 },
14664};
14665
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014666#define alc662_mux_enum_info alc_mux_enum_info
14667#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014668#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014669
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014670/*
14671 * 2ch mode
14672 */
14673static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14674 { 2, NULL }
14675};
14676
14677/*
14678 * 2ch mode
14679 */
14680static struct hda_verb alc662_3ST_ch2_init[] = {
14681 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14682 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14683 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14684 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14685 { } /* end */
14686};
14687
14688/*
14689 * 6ch mode
14690 */
14691static struct hda_verb alc662_3ST_ch6_init[] = {
14692 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14693 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14694 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14698 { } /* end */
14699};
14700
14701static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14702 { 2, alc662_3ST_ch2_init },
14703 { 6, alc662_3ST_ch6_init },
14704};
14705
14706/*
14707 * 2ch mode
14708 */
14709static struct hda_verb alc662_sixstack_ch6_init[] = {
14710 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14711 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14712 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14713 { } /* end */
14714};
14715
14716/*
14717 * 6ch mode
14718 */
14719static struct hda_verb alc662_sixstack_ch8_init[] = {
14720 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14721 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14722 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14723 { } /* end */
14724};
14725
14726static struct hda_channel_mode alc662_5stack_modes[2] = {
14727 { 2, alc662_sixstack_ch6_init },
14728 { 6, alc662_sixstack_ch8_init },
14729};
14730
14731/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14732 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14733 */
14734
14735static struct snd_kcontrol_new alc662_base_mixer[] = {
14736 /* output mixer control */
14737 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014738 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014739 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014740 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014741 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14742 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014743 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14744 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14746
14747 /*Input mixer control */
14748 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14749 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14750 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14751 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14752 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14753 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14755 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014756 { } /* end */
14757};
14758
14759static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14760 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014761 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14763 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14764 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14765 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14766 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14771 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14772 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014773 { } /* end */
14774};
14775
14776static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14777 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014778 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014779 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014780 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014781 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14782 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014783 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14784 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14788 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14789 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14791 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14793 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14794 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14795 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014796 { } /* end */
14797};
14798
14799static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14800 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14801 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014802 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14803 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014809 { } /* end */
14810};
14811
Kailang Yang291702f2007-10-16 14:28:03 +020014812static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014813 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014814
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014815 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14816 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014817
14818 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14819 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14820 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14821
14822 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14823 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14824 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14825 { } /* end */
14826};
14827
Kailang Yang8c427222008-01-10 13:03:59 +010014828static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014829 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14830 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14832 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14834 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14835 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14836 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014837 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014838 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14843 { } /* end */
14844};
14845
Kailang Yangf1d4e282008-08-26 14:03:29 +020014846static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14847 .ops = &snd_hda_bind_vol,
14848 .values = {
14849 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14850 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14851 0
14852 },
14853};
14854
14855static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14856 .ops = &snd_hda_bind_sw,
14857 .values = {
14858 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14859 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14860 0
14861 },
14862};
14863
Kailang Yang6dda9f42008-05-27 12:05:31 +020014864static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014865 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14866 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14869 { } /* end */
14870};
14871
14872static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14873 .ops = &snd_hda_bind_sw,
14874 .values = {
14875 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14876 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14877 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14878 0
14879 },
14880};
14881
14882static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14883 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14884 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14887 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14888 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14889
14890 { } /* end */
14891};
14892
14893static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14894 .ops = &snd_hda_bind_sw,
14895 .values = {
14896 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14897 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14898 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14899 0
14900 },
14901};
14902
14903static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14904 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14905 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14908 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14909 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14910 { } /* end */
14911};
14912
14913static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014914 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14915 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014916 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14919 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14920 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14921 { } /* end */
14922};
14923
14924static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14925 .ops = &snd_hda_bind_vol,
14926 .values = {
14927 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14928 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14929 0
14930 },
14931};
14932
14933static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14934 .ops = &snd_hda_bind_sw,
14935 .values = {
14936 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14937 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14938 0
14939 },
14940};
14941
14942static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14943 HDA_BIND_VOL("Master Playback Volume",
14944 &alc663_asus_two_bind_master_vol),
14945 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014950 { } /* end */
14951};
14952
14953static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14954 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14955 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014960 { } /* end */
14961};
14962
14963static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14964 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14965 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14966 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14967 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14969
14970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14972 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14973 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14974 { } /* end */
14975};
14976
14977static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14978 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14979 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14981
14982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14984 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14985 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14988 { } /* end */
14989};
14990
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014991static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14992 {
14993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14994 .name = "Channel Mode",
14995 .info = alc_ch_mode_info,
14996 .get = alc_ch_mode_get,
14997 .put = alc_ch_mode_put,
14998 },
14999 { } /* end */
15000};
15001
15002static struct hda_verb alc662_init_verbs[] = {
15003 /* ADC: mute amp left and right */
15004 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15005 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15006 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15007
Takashi Iwaicb53c622007-08-10 17:21:45 +020015008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013
Kailang Yangb60dd392007-09-20 12:50:29 +020015014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15019 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015020
15021 /* Front Pin: output 0 (0x0c) */
15022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15024
15025 /* Rear Pin: output 1 (0x0d) */
15026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15028
15029 /* CLFE Pin: output 2 (0x0e) */
15030 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15032
15033 /* Mic (rear) pin: input vref at 80% */
15034 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15035 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15036 /* Front Mic pin: input vref at 80% */
15037 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15039 /* Line In pin: input */
15040 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15041 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15042 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15043 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15044 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15045 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15046 /* CD pin widget for input */
15047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15048
15049 /* FIXME: use matrix-type input source selection */
15050 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15051 /* Input mixer */
15052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015056
15057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015061
15062 /* always trun on EAPD */
15063 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15064 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15065
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015066 { }
15067};
15068
15069static struct hda_verb alc662_sue_init_verbs[] = {
15070 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15071 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015072 {}
15073};
15074
15075static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15077 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15078 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015079};
15080
Kailang Yang8c427222008-01-10 13:03:59 +010015081/* Set Unsolicited Event*/
15082static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15085 {}
15086};
15087
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015088/*
15089 * generic initialization of ADC, input mixers and output mixers
15090 */
15091static struct hda_verb alc662_auto_init_verbs[] = {
15092 /*
15093 * Unmute ADC and set the default input to mic-in
15094 */
15095 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15097
15098 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15099 * mixer widget
15100 * Note: PASD motherboards uses the Line In 2 as the input for front
15101 * panel mic (mic 2)
15102 */
15103 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015109
15110 /*
15111 * Set up output mixers (0x0c - 0x0f)
15112 */
15113 /* set vol=0 to output mixers */
15114 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15115 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15117
15118 /* set up input amps for analog loopback */
15119 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15122 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015126
15127
15128 /* FIXME: use matrix-type input source selection */
15129 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15130 /* Input mixer */
15131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015133 { }
15134};
15135
Takashi Iwai24fb9172008-09-02 14:48:20 +020015136/* additional verbs for ALC663 */
15137static struct hda_verb alc663_auto_init_verbs[] = {
15138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15139 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15140 { }
15141};
15142
Kailang Yang6dda9f42008-05-27 12:05:31 +020015143static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15145 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015146 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15147 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015148 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015151 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15152 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15153 {}
15154};
15155
Kailang Yangf1d4e282008-08-26 14:03:29 +020015156static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15157 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15158 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15159 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15160 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15162 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15163 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15164 {}
15165};
15166
15167static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15169 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15171 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15174 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15175 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15176 {}
15177};
15178
15179static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15182 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15185 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15186 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15187 {}
15188};
15189
15190static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15191 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15192 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15193 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15194 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15200 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15201 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15202 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15203 {}
15204};
15205
15206static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15207 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15210 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15216 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15217 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15218 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15219 {}
15220};
15221
Kailang Yang6dda9f42008-05-27 12:05:31 +020015222static struct hda_verb alc663_g71v_init_verbs[] = {
15223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15224 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15225 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15226
15227 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15228 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15229 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15230
15231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15232 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15233 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15234 {}
15235};
15236
15237static struct hda_verb alc663_g50v_init_verbs[] = {
15238 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15239 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15240 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15241
15242 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15243 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15244 {}
15245};
15246
Kailang Yangf1d4e282008-08-26 14:03:29 +020015247static struct hda_verb alc662_ecs_init_verbs[] = {
15248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15250 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15252 {}
15253};
15254
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015255/* capture mixer elements */
15256static struct snd_kcontrol_new alc662_capture_mixer[] = {
15257 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15258 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15259 {
15260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15261 /* The multiple "Capture Source" controls confuse alsamixer
15262 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263 */
15264 /* .name = "Capture Source", */
15265 .name = "Input Source",
15266 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010015267 .info = alc662_mux_enum_info,
15268 .get = alc662_mux_enum_get,
15269 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015270 },
15271 { } /* end */
15272};
15273
Kailang Yangf1d4e282008-08-26 14:03:29 +020015274static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15275 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15276 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15277 { } /* end */
15278};
15279
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015280static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15281{
15282 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015283 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015284
15285 present = snd_hda_codec_read(codec, 0x14, 0,
15286 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015287 bits = present ? HDA_AMP_MUTE : 0;
15288 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15289 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015290}
15291
15292static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15293{
15294 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015295 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015296
15297 present = snd_hda_codec_read(codec, 0x1b, 0,
15298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015299 bits = present ? HDA_AMP_MUTE : 0;
15300 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15301 HDA_AMP_MUTE, bits);
15302 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15303 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015304}
15305
15306static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15307 unsigned int res)
15308{
15309 if ((res >> 26) == ALC880_HP_EVENT)
15310 alc662_lenovo_101e_all_automute(codec);
15311 if ((res >> 26) == ALC880_FRONT_EVENT)
15312 alc662_lenovo_101e_ispeaker_automute(codec);
15313}
15314
Kailang Yang291702f2007-10-16 14:28:03 +020015315static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15316{
15317 unsigned int present;
15318
15319 present = snd_hda_codec_read(codec, 0x18, 0,
15320 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15321 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15322 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15323 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15324 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15325 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15326 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15327 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15328 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15329}
15330
15331/* unsolicited event for HP jack sensing */
15332static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15333 unsigned int res)
15334{
15335 if ((res >> 26) == ALC880_HP_EVENT)
15336 alc262_hippo1_automute( codec );
15337
15338 if ((res >> 26) == ALC880_MIC_EVENT)
15339 alc662_eeepc_mic_automute(codec);
15340}
15341
15342static void alc662_eeepc_inithook(struct hda_codec *codec)
15343{
15344 alc262_hippo1_automute( codec );
15345 alc662_eeepc_mic_automute(codec);
15346}
15347
Kailang Yang8c427222008-01-10 13:03:59 +010015348static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15349{
15350 unsigned int mute;
15351 unsigned int present;
15352
15353 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15354 present = snd_hda_codec_read(codec, 0x14, 0,
15355 AC_VERB_GET_PIN_SENSE, 0);
15356 present = (present & 0x80000000) != 0;
15357 if (present) {
15358 /* mute internal speaker */
15359 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015360 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015361 } else {
15362 /* unmute internal speaker if necessary */
15363 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15364 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015365 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015366 }
15367}
15368
15369/* unsolicited event for HP jack sensing */
15370static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15371 unsigned int res)
15372{
15373 if ((res >> 26) == ALC880_HP_EVENT)
15374 alc662_eeepc_ep20_automute(codec);
15375}
15376
15377static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15378{
15379 alc662_eeepc_ep20_automute(codec);
15380}
15381
Kailang Yang6dda9f42008-05-27 12:05:31 +020015382static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15383{
15384 unsigned int present;
15385 unsigned char bits;
15386
15387 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015388 AC_VERB_GET_PIN_SENSE, 0)
15389 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015390 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015391 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15392 AMP_IN_MUTE(0), bits);
15393 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15394 AMP_IN_MUTE(0), bits);
15395}
15396
15397static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15398{
15399 unsigned int present;
15400 unsigned char bits;
15401
15402 present = snd_hda_codec_read(codec, 0x21, 0,
15403 AC_VERB_GET_PIN_SENSE, 0)
15404 & AC_PINSENSE_PRESENCE;
15405 bits = present ? HDA_AMP_MUTE : 0;
15406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15407 AMP_IN_MUTE(0), bits);
15408 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15409 AMP_IN_MUTE(0), bits);
15410 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15411 AMP_IN_MUTE(0), bits);
15412 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15413 AMP_IN_MUTE(0), bits);
15414}
15415
15416static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15417{
15418 unsigned int present;
15419 unsigned char bits;
15420
15421 present = snd_hda_codec_read(codec, 0x15, 0,
15422 AC_VERB_GET_PIN_SENSE, 0)
15423 & AC_PINSENSE_PRESENCE;
15424 bits = present ? HDA_AMP_MUTE : 0;
15425 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15426 AMP_IN_MUTE(0), bits);
15427 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15428 AMP_IN_MUTE(0), bits);
15429 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15430 AMP_IN_MUTE(0), bits);
15431 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15432 AMP_IN_MUTE(0), bits);
15433}
15434
15435static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15436{
15437 unsigned int present;
15438 unsigned char bits;
15439
15440 present = snd_hda_codec_read(codec, 0x1b, 0,
15441 AC_VERB_GET_PIN_SENSE, 0)
15442 & AC_PINSENSE_PRESENCE;
15443 bits = present ? 0 : PIN_OUT;
15444 snd_hda_codec_write(codec, 0x14, 0,
15445 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15446}
15447
15448static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15449{
15450 unsigned int present1, present2;
15451
15452 present1 = snd_hda_codec_read(codec, 0x21, 0,
15453 AC_VERB_GET_PIN_SENSE, 0)
15454 & AC_PINSENSE_PRESENCE;
15455 present2 = snd_hda_codec_read(codec, 0x15, 0,
15456 AC_VERB_GET_PIN_SENSE, 0)
15457 & AC_PINSENSE_PRESENCE;
15458
15459 if (present1 || present2) {
15460 snd_hda_codec_write_cache(codec, 0x14, 0,
15461 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15462 } else {
15463 snd_hda_codec_write_cache(codec, 0x14, 0,
15464 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15465 }
15466}
15467
15468static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15469{
15470 unsigned int present1, present2;
15471
15472 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15473 AC_VERB_GET_PIN_SENSE, 0)
15474 & AC_PINSENSE_PRESENCE;
15475 present2 = snd_hda_codec_read(codec, 0x15, 0,
15476 AC_VERB_GET_PIN_SENSE, 0)
15477 & AC_PINSENSE_PRESENCE;
15478
15479 if (present1 || present2) {
15480 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15481 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15482 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15483 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15484 } else {
15485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15486 AMP_IN_MUTE(0), 0);
15487 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15488 AMP_IN_MUTE(0), 0);
15489 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015490}
15491
15492static void alc663_m51va_mic_automute(struct hda_codec *codec)
15493{
15494 unsigned int present;
15495
15496 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015497 AC_VERB_GET_PIN_SENSE, 0)
15498 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015499 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015500 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015501 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015502 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015503 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015504 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015505 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015506 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015507}
15508
15509static void alc663_m51va_unsol_event(struct hda_codec *codec,
15510 unsigned int res)
15511{
15512 switch (res >> 26) {
15513 case ALC880_HP_EVENT:
15514 alc663_m51va_speaker_automute(codec);
15515 break;
15516 case ALC880_MIC_EVENT:
15517 alc663_m51va_mic_automute(codec);
15518 break;
15519 }
15520}
15521
15522static void alc663_m51va_inithook(struct hda_codec *codec)
15523{
15524 alc663_m51va_speaker_automute(codec);
15525 alc663_m51va_mic_automute(codec);
15526}
15527
Kailang Yangf1d4e282008-08-26 14:03:29 +020015528/* ***************** Mode1 ******************************/
15529static void alc663_mode1_unsol_event(struct hda_codec *codec,
15530 unsigned int res)
15531{
15532 switch (res >> 26) {
15533 case ALC880_HP_EVENT:
15534 alc663_m51va_speaker_automute(codec);
15535 break;
15536 case ALC880_MIC_EVENT:
15537 alc662_eeepc_mic_automute(codec);
15538 break;
15539 }
15540}
15541
15542static void alc663_mode1_inithook(struct hda_codec *codec)
15543{
15544 alc663_m51va_speaker_automute(codec);
15545 alc662_eeepc_mic_automute(codec);
15546}
15547/* ***************** Mode2 ******************************/
15548static void alc662_mode2_unsol_event(struct hda_codec *codec,
15549 unsigned int res)
15550{
15551 switch (res >> 26) {
15552 case ALC880_HP_EVENT:
15553 alc662_f5z_speaker_automute(codec);
15554 break;
15555 case ALC880_MIC_EVENT:
15556 alc662_eeepc_mic_automute(codec);
15557 break;
15558 }
15559}
15560
15561static void alc662_mode2_inithook(struct hda_codec *codec)
15562{
15563 alc662_f5z_speaker_automute(codec);
15564 alc662_eeepc_mic_automute(codec);
15565}
15566/* ***************** Mode3 ******************************/
15567static void alc663_mode3_unsol_event(struct hda_codec *codec,
15568 unsigned int res)
15569{
15570 switch (res >> 26) {
15571 case ALC880_HP_EVENT:
15572 alc663_two_hp_m1_speaker_automute(codec);
15573 break;
15574 case ALC880_MIC_EVENT:
15575 alc662_eeepc_mic_automute(codec);
15576 break;
15577 }
15578}
15579
15580static void alc663_mode3_inithook(struct hda_codec *codec)
15581{
15582 alc663_two_hp_m1_speaker_automute(codec);
15583 alc662_eeepc_mic_automute(codec);
15584}
15585/* ***************** Mode4 ******************************/
15586static void alc663_mode4_unsol_event(struct hda_codec *codec,
15587 unsigned int res)
15588{
15589 switch (res >> 26) {
15590 case ALC880_HP_EVENT:
15591 alc663_21jd_two_speaker_automute(codec);
15592 break;
15593 case ALC880_MIC_EVENT:
15594 alc662_eeepc_mic_automute(codec);
15595 break;
15596 }
15597}
15598
15599static void alc663_mode4_inithook(struct hda_codec *codec)
15600{
15601 alc663_21jd_two_speaker_automute(codec);
15602 alc662_eeepc_mic_automute(codec);
15603}
15604/* ***************** Mode5 ******************************/
15605static void alc663_mode5_unsol_event(struct hda_codec *codec,
15606 unsigned int res)
15607{
15608 switch (res >> 26) {
15609 case ALC880_HP_EVENT:
15610 alc663_15jd_two_speaker_automute(codec);
15611 break;
15612 case ALC880_MIC_EVENT:
15613 alc662_eeepc_mic_automute(codec);
15614 break;
15615 }
15616}
15617
15618static void alc663_mode5_inithook(struct hda_codec *codec)
15619{
15620 alc663_15jd_two_speaker_automute(codec);
15621 alc662_eeepc_mic_automute(codec);
15622}
15623/* ***************** Mode6 ******************************/
15624static void alc663_mode6_unsol_event(struct hda_codec *codec,
15625 unsigned int res)
15626{
15627 switch (res >> 26) {
15628 case ALC880_HP_EVENT:
15629 alc663_two_hp_m2_speaker_automute(codec);
15630 break;
15631 case ALC880_MIC_EVENT:
15632 alc662_eeepc_mic_automute(codec);
15633 break;
15634 }
15635}
15636
15637static void alc663_mode6_inithook(struct hda_codec *codec)
15638{
15639 alc663_two_hp_m2_speaker_automute(codec);
15640 alc662_eeepc_mic_automute(codec);
15641}
15642
Kailang Yang6dda9f42008-05-27 12:05:31 +020015643static void alc663_g71v_hp_automute(struct hda_codec *codec)
15644{
15645 unsigned int present;
15646 unsigned char bits;
15647
15648 present = snd_hda_codec_read(codec, 0x21, 0,
15649 AC_VERB_GET_PIN_SENSE, 0)
15650 & AC_PINSENSE_PRESENCE;
15651 bits = present ? HDA_AMP_MUTE : 0;
15652 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15653 HDA_AMP_MUTE, bits);
15654 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15655 HDA_AMP_MUTE, bits);
15656}
15657
15658static void alc663_g71v_front_automute(struct hda_codec *codec)
15659{
15660 unsigned int present;
15661 unsigned char bits;
15662
15663 present = snd_hda_codec_read(codec, 0x15, 0,
15664 AC_VERB_GET_PIN_SENSE, 0)
15665 & AC_PINSENSE_PRESENCE;
15666 bits = present ? HDA_AMP_MUTE : 0;
15667 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15668 HDA_AMP_MUTE, bits);
15669}
15670
15671static void alc663_g71v_unsol_event(struct hda_codec *codec,
15672 unsigned int res)
15673{
15674 switch (res >> 26) {
15675 case ALC880_HP_EVENT:
15676 alc663_g71v_hp_automute(codec);
15677 break;
15678 case ALC880_FRONT_EVENT:
15679 alc663_g71v_front_automute(codec);
15680 break;
15681 case ALC880_MIC_EVENT:
15682 alc662_eeepc_mic_automute(codec);
15683 break;
15684 }
15685}
15686
15687static void alc663_g71v_inithook(struct hda_codec *codec)
15688{
15689 alc663_g71v_front_automute(codec);
15690 alc663_g71v_hp_automute(codec);
15691 alc662_eeepc_mic_automute(codec);
15692}
15693
15694static void alc663_g50v_unsol_event(struct hda_codec *codec,
15695 unsigned int res)
15696{
15697 switch (res >> 26) {
15698 case ALC880_HP_EVENT:
15699 alc663_m51va_speaker_automute(codec);
15700 break;
15701 case ALC880_MIC_EVENT:
15702 alc662_eeepc_mic_automute(codec);
15703 break;
15704 }
15705}
15706
15707static void alc663_g50v_inithook(struct hda_codec *codec)
15708{
15709 alc663_m51va_speaker_automute(codec);
15710 alc662_eeepc_mic_automute(codec);
15711}
15712
Kailang Yangf1d4e282008-08-26 14:03:29 +020015713/* bind hp and internal speaker mute (with plug check) */
15714static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15715 struct snd_ctl_elem_value *ucontrol)
15716{
15717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15718 long *valp = ucontrol->value.integer.value;
15719 int change;
15720
15721 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15722 HDA_AMP_MUTE,
15723 valp[0] ? 0 : HDA_AMP_MUTE);
15724 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15725 HDA_AMP_MUTE,
15726 valp[1] ? 0 : HDA_AMP_MUTE);
15727 if (change)
15728 alc262_hippo1_automute(codec);
15729 return change;
15730}
15731
15732static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15733 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15734 {
15735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15736 .name = "Master Playback Switch",
15737 .info = snd_hda_mixer_amp_switch_info,
15738 .get = snd_hda_mixer_amp_switch_get,
15739 .put = alc662_ecs_master_sw_put,
15740 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15741 },
15742
15743 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15744 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15745 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15746
15747 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15748 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15749 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15750 { } /* end */
15751};
15752
Takashi Iwaicb53c622007-08-10 17:21:45 +020015753#ifdef CONFIG_SND_HDA_POWER_SAVE
15754#define alc662_loopbacks alc880_loopbacks
15755#endif
15756
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015757
15758/* pcm configuration: identiacal with ALC880 */
15759#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15760#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15761#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15762#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15763
15764/*
15765 * configuration and preset
15766 */
15767static const char *alc662_models[ALC662_MODEL_LAST] = {
15768 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15769 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15770 [ALC662_3ST_6ch] = "3stack-6ch",
15771 [ALC662_5ST_DIG] = "6stack-dig",
15772 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015773 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015774 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015775 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015776 [ALC663_ASUS_M51VA] = "m51va",
15777 [ALC663_ASUS_G71V] = "g71v",
15778 [ALC663_ASUS_H13] = "h13",
15779 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015780 [ALC663_ASUS_MODE1] = "asus-mode1",
15781 [ALC662_ASUS_MODE2] = "asus-mode2",
15782 [ALC663_ASUS_MODE3] = "asus-mode3",
15783 [ALC663_ASUS_MODE4] = "asus-mode4",
15784 [ALC663_ASUS_MODE5] = "asus-mode5",
15785 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 [ALC662_AUTO] = "auto",
15787};
15788
15789static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015790 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015791 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015792 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015793 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015794 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015795 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15796 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15797 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15798 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15799 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15800 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15801 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15802 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15803 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015804 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015805 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15806 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15807 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15808 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15809 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15810 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15811 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15812 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15813 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15814 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15815 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15816 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15817 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15818 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15819 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15820 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15821 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15822 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15823 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15824 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15825 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15826 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015827 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15828 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015829 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015830 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15831 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015832 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15833 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015834 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015835 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015836 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015837 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15838 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15839 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015840 {}
15841};
15842
15843static struct alc_config_preset alc662_presets[] = {
15844 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015845 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015846 .init_verbs = { alc662_init_verbs },
15847 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15848 .dac_nids = alc662_dac_nids,
15849 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015850 .dig_in_nid = ALC662_DIGIN_NID,
15851 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15852 .channel_mode = alc662_3ST_2ch_modes,
15853 .input_mux = &alc662_capture_source,
15854 },
15855 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015856 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15857 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015858 .init_verbs = { alc662_init_verbs },
15859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15860 .dac_nids = alc662_dac_nids,
15861 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015862 .dig_in_nid = ALC662_DIGIN_NID,
15863 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15864 .channel_mode = alc662_3ST_6ch_modes,
15865 .need_dac_fix = 1,
15866 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015867 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015868 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015869 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
15870 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015871 .init_verbs = { alc662_init_verbs },
15872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15873 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15875 .channel_mode = alc662_3ST_6ch_modes,
15876 .need_dac_fix = 1,
15877 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015878 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015879 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015880 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
15881 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015882 .init_verbs = { alc662_init_verbs },
15883 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15884 .dac_nids = alc662_dac_nids,
15885 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015886 .dig_in_nid = ALC662_DIGIN_NID,
15887 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15888 .channel_mode = alc662_5stack_modes,
15889 .input_mux = &alc662_capture_source,
15890 },
15891 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020015892 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015893 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15894 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15895 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15897 .channel_mode = alc662_3ST_2ch_modes,
15898 .input_mux = &alc662_lenovo_101e_capture_source,
15899 .unsol_event = alc662_lenovo_101e_unsol_event,
15900 .init_hook = alc662_lenovo_101e_all_automute,
15901 },
Kailang Yang291702f2007-10-16 14:28:03 +020015902 [ALC662_ASUS_EEEPC_P701] = {
15903 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
15904 .init_verbs = { alc662_init_verbs,
15905 alc662_eeepc_sue_init_verbs },
15906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15907 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15909 .channel_mode = alc662_3ST_2ch_modes,
15910 .input_mux = &alc662_eeepc_capture_source,
15911 .unsol_event = alc662_eeepc_unsol_event,
15912 .init_hook = alc662_eeepc_inithook,
15913 },
Kailang Yang8c427222008-01-10 13:03:59 +010015914 [ALC662_ASUS_EEEPC_EP20] = {
15915 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
15916 alc662_chmode_mixer },
15917 .init_verbs = { alc662_init_verbs,
15918 alc662_eeepc_ep20_sue_init_verbs },
15919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15920 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15922 .channel_mode = alc662_3ST_6ch_modes,
15923 .input_mux = &alc662_lenovo_101e_capture_source,
15924 .unsol_event = alc662_eeepc_ep20_unsol_event,
15925 .init_hook = alc662_eeepc_ep20_inithook,
15926 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015927 [ALC662_ECS] = {
15928 .mixers = { alc662_ecs_mixer, alc662_capture_mixer },
15929 .init_verbs = { alc662_init_verbs,
15930 alc662_ecs_init_verbs },
15931 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15932 .dac_nids = alc662_dac_nids,
15933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15934 .channel_mode = alc662_3ST_2ch_modes,
15935 .input_mux = &alc662_eeepc_capture_source,
15936 .unsol_event = alc662_eeepc_unsol_event,
15937 .init_hook = alc662_eeepc_inithook,
15938 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015939 [ALC663_ASUS_M51VA] = {
15940 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15941 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15942 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15943 .dac_nids = alc662_dac_nids,
15944 .dig_out_nid = ALC662_DIGOUT_NID,
15945 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15946 .channel_mode = alc662_3ST_2ch_modes,
15947 .input_mux = &alc663_m51va_capture_source,
15948 .unsol_event = alc663_m51va_unsol_event,
15949 .init_hook = alc663_m51va_inithook,
15950 },
15951 [ALC663_ASUS_G71V] = {
15952 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
15953 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15955 .dac_nids = alc662_dac_nids,
15956 .dig_out_nid = ALC662_DIGOUT_NID,
15957 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15958 .channel_mode = alc662_3ST_2ch_modes,
15959 .input_mux = &alc662_eeepc_capture_source,
15960 .unsol_event = alc663_g71v_unsol_event,
15961 .init_hook = alc663_g71v_inithook,
15962 },
15963 [ALC663_ASUS_H13] = {
15964 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
15965 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15966 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15967 .dac_nids = alc662_dac_nids,
15968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15969 .channel_mode = alc662_3ST_2ch_modes,
15970 .input_mux = &alc663_m51va_capture_source,
15971 .unsol_event = alc663_m51va_unsol_event,
15972 .init_hook = alc663_m51va_inithook,
15973 },
15974 [ALC663_ASUS_G50V] = {
15975 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
15976 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15978 .dac_nids = alc662_dac_nids,
15979 .dig_out_nid = ALC662_DIGOUT_NID,
15980 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15981 .channel_mode = alc662_3ST_6ch_modes,
15982 .input_mux = &alc663_capture_source,
15983 .unsol_event = alc663_g50v_unsol_event,
15984 .init_hook = alc663_g50v_inithook,
15985 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015986 [ALC663_ASUS_MODE1] = {
15987 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer },
15988 .init_verbs = { alc662_init_verbs,
15989 alc663_21jd_amic_init_verbs },
15990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15991 .hp_nid = 0x03,
15992 .dac_nids = alc662_dac_nids,
15993 .dig_out_nid = ALC662_DIGOUT_NID,
15994 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15995 .channel_mode = alc662_3ST_2ch_modes,
15996 .input_mux = &alc662_eeepc_capture_source,
15997 .unsol_event = alc663_mode1_unsol_event,
15998 .init_hook = alc663_mode1_inithook,
15999 },
16000 [ALC662_ASUS_MODE2] = {
16001 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer },
16002 .init_verbs = { alc662_init_verbs,
16003 alc662_1bjd_amic_init_verbs },
16004 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16005 .dac_nids = alc662_dac_nids,
16006 .dig_out_nid = ALC662_DIGOUT_NID,
16007 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16008 .channel_mode = alc662_3ST_2ch_modes,
16009 .input_mux = &alc662_eeepc_capture_source,
16010 .unsol_event = alc662_mode2_unsol_event,
16011 .init_hook = alc662_mode2_inithook,
16012 },
16013 [ALC663_ASUS_MODE3] = {
16014 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer },
16015 .init_verbs = { alc662_init_verbs,
16016 alc663_two_hp_amic_m1_init_verbs },
16017 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16018 .hp_nid = 0x03,
16019 .dac_nids = alc662_dac_nids,
16020 .dig_out_nid = ALC662_DIGOUT_NID,
16021 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16022 .channel_mode = alc662_3ST_2ch_modes,
16023 .input_mux = &alc662_eeepc_capture_source,
16024 .unsol_event = alc663_mode3_unsol_event,
16025 .init_hook = alc663_mode3_inithook,
16026 },
16027 [ALC663_ASUS_MODE4] = {
16028 .mixers = { alc663_asus_21jd_clfe_mixer,
16029 alc662_auto_capture_mixer},
16030 .init_verbs = { alc662_init_verbs,
16031 alc663_21jd_amic_init_verbs},
16032 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16033 .hp_nid = 0x03,
16034 .dac_nids = alc662_dac_nids,
16035 .dig_out_nid = ALC662_DIGOUT_NID,
16036 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16037 .channel_mode = alc662_3ST_2ch_modes,
16038 .input_mux = &alc662_eeepc_capture_source,
16039 .unsol_event = alc663_mode4_unsol_event,
16040 .init_hook = alc663_mode4_inithook,
16041 },
16042 [ALC663_ASUS_MODE5] = {
16043 .mixers = { alc663_asus_15jd_clfe_mixer,
16044 alc662_auto_capture_mixer },
16045 .init_verbs = { alc662_init_verbs,
16046 alc663_15jd_amic_init_verbs },
16047 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16048 .hp_nid = 0x03,
16049 .dac_nids = alc662_dac_nids,
16050 .dig_out_nid = ALC662_DIGOUT_NID,
16051 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16052 .channel_mode = alc662_3ST_2ch_modes,
16053 .input_mux = &alc662_eeepc_capture_source,
16054 .unsol_event = alc663_mode5_unsol_event,
16055 .init_hook = alc663_mode5_inithook,
16056 },
16057 [ALC663_ASUS_MODE6] = {
16058 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer },
16059 .init_verbs = { alc662_init_verbs,
16060 alc663_two_hp_amic_m2_init_verbs },
16061 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16062 .hp_nid = 0x03,
16063 .dac_nids = alc662_dac_nids,
16064 .dig_out_nid = ALC662_DIGOUT_NID,
16065 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16066 .channel_mode = alc662_3ST_2ch_modes,
16067 .input_mux = &alc662_eeepc_capture_source,
16068 .unsol_event = alc663_mode6_unsol_event,
16069 .init_hook = alc663_mode6_inithook,
16070 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071};
16072
16073
16074/*
16075 * BIOS auto configuration
16076 */
16077
16078/* add playback controls from the parsed DAC table */
16079static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16080 const struct auto_pin_cfg *cfg)
16081{
16082 char name[32];
16083 static const char *chname[4] = {
16084 "Front", "Surround", NULL /*CLFE*/, "Side"
16085 };
16086 hda_nid_t nid;
16087 int i, err;
16088
16089 for (i = 0; i < cfg->line_outs; i++) {
16090 if (!spec->multiout.dac_nids[i])
16091 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016092 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016093 if (i == 2) {
16094 /* Center/LFE */
16095 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16096 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016097 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16098 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016099 if (err < 0)
16100 return err;
16101 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16102 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016103 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16104 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016105 if (err < 0)
16106 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016107 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016108 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016109 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016110 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016111 if (err < 0)
16112 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016113 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016114 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016115 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016116 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016117 if (err < 0)
16118 return err;
16119 } else {
16120 sprintf(name, "%s Playback Volume", chname[i]);
16121 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016122 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16123 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016124 if (err < 0)
16125 return err;
16126 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016127 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16128 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16129 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016130 if (err < 0)
16131 return err;
16132 }
16133 }
16134 return 0;
16135}
16136
16137/* add playback controls for speaker and HP outputs */
16138static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16139 const char *pfx)
16140{
16141 hda_nid_t nid;
16142 int err;
16143 char name[32];
16144
16145 if (!pin)
16146 return 0;
16147
Takashi Iwai24fb9172008-09-02 14:48:20 +020016148 if (pin == 0x17) {
16149 /* ALC663 has a mono output pin on 0x17 */
16150 sprintf(name, "%s Playback Switch", pfx);
16151 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16152 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16153 return err;
16154 }
16155
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016156 if (alc880_is_fixed_pin(pin)) {
16157 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16158 /* printk("DAC nid=%x\n",nid); */
16159 /* specify the DAC as the extra output */
16160 if (!spec->multiout.hp_nid)
16161 spec->multiout.hp_nid = nid;
16162 else
16163 spec->multiout.extra_out_nid[0] = nid;
16164 /* control HP volume/switch on the output mixer amp */
16165 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16166 sprintf(name, "%s Playback Volume", pfx);
16167 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16168 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16169 if (err < 0)
16170 return err;
16171 sprintf(name, "%s Playback Switch", pfx);
16172 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16173 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16174 if (err < 0)
16175 return err;
16176 } else if (alc880_is_multi_pin(pin)) {
16177 /* set manual connection */
16178 /* we have only a switch on HP-out PIN */
16179 sprintf(name, "%s Playback Switch", pfx);
16180 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16181 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16182 if (err < 0)
16183 return err;
16184 }
16185 return 0;
16186}
16187
16188/* create playback/capture controls for input pins */
16189static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16190 const struct auto_pin_cfg *cfg)
16191{
16192 struct hda_input_mux *imux = &spec->private_imux;
16193 int i, err, idx;
16194
16195 for (i = 0; i < AUTO_PIN_LAST; i++) {
16196 if (alc880_is_input_pin(cfg->input_pins[i])) {
16197 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16198 err = new_analog_input(spec, cfg->input_pins[i],
16199 auto_pin_cfg_labels[i],
16200 idx, 0x0b);
16201 if (err < 0)
16202 return err;
16203 imux->items[imux->num_items].label =
16204 auto_pin_cfg_labels[i];
16205 imux->items[imux->num_items].index =
16206 alc880_input_pin_idx(cfg->input_pins[i]);
16207 imux->num_items++;
16208 }
16209 }
16210 return 0;
16211}
16212
16213static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16214 hda_nid_t nid, int pin_type,
16215 int dac_idx)
16216{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016217 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016218 /* need the manual connection? */
16219 if (alc880_is_multi_pin(nid)) {
16220 struct alc_spec *spec = codec->spec;
16221 int idx = alc880_multi_pin_idx(nid);
16222 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16223 AC_VERB_SET_CONNECT_SEL,
16224 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16225 }
16226}
16227
16228static void alc662_auto_init_multi_out(struct hda_codec *codec)
16229{
16230 struct alc_spec *spec = codec->spec;
16231 int i;
16232
Kailang Yang8c427222008-01-10 13:03:59 +010016233 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016234 for (i = 0; i <= HDA_SIDE; i++) {
16235 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016236 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016237 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016238 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016239 i);
16240 }
16241}
16242
16243static void alc662_auto_init_hp_out(struct hda_codec *codec)
16244{
16245 struct alc_spec *spec = codec->spec;
16246 hda_nid_t pin;
16247
16248 pin = spec->autocfg.hp_pins[0];
16249 if (pin) /* connect to front */
16250 /* use dac 0 */
16251 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016252 pin = spec->autocfg.speaker_pins[0];
16253 if (pin)
16254 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016255}
16256
16257#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16258#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16259
16260static void alc662_auto_init_analog_input(struct hda_codec *codec)
16261{
16262 struct alc_spec *spec = codec->spec;
16263 int i;
16264
16265 for (i = 0; i < AUTO_PIN_LAST; i++) {
16266 hda_nid_t nid = spec->autocfg.input_pins[i];
16267 if (alc662_is_input_pin(nid)) {
16268 snd_hda_codec_write(codec, nid, 0,
16269 AC_VERB_SET_PIN_WIDGET_CONTROL,
16270 (i <= AUTO_PIN_FRONT_MIC ?
16271 PIN_VREF80 : PIN_IN));
16272 if (nid != ALC662_PIN_CD_NID)
16273 snd_hda_codec_write(codec, nid, 0,
16274 AC_VERB_SET_AMP_GAIN_MUTE,
16275 AMP_OUT_MUTE);
16276 }
16277 }
16278}
16279
Takashi Iwaif511b012008-08-15 16:46:42 +020016280#define alc662_auto_init_input_src alc882_auto_init_input_src
16281
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016282static int alc662_parse_auto_config(struct hda_codec *codec)
16283{
16284 struct alc_spec *spec = codec->spec;
16285 int err;
16286 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16287
16288 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16289 alc662_ignore);
16290 if (err < 0)
16291 return err;
16292 if (!spec->autocfg.line_outs)
16293 return 0; /* can't find valid BIOS pin config */
16294
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016295 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16296 if (err < 0)
16297 return err;
16298 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16299 if (err < 0)
16300 return err;
16301 err = alc662_auto_create_extra_out(spec,
16302 spec->autocfg.speaker_pins[0],
16303 "Speaker");
16304 if (err < 0)
16305 return err;
16306 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16307 "Headphone");
16308 if (err < 0)
16309 return err;
16310 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16311 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312 return err;
16313
16314 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16315
16316 if (spec->autocfg.dig_out_pin)
16317 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16318
16319 if (spec->kctl_alloc)
16320 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
16321
16322 spec->num_mux_defs = 1;
16323 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016324
Takashi Iwai8c872862007-06-19 12:11:16 +020016325 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020016326 if (codec->vendor_id == 0x10ec0663)
16327 spec->init_verbs[spec->num_init_verbs++] =
16328 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020016329
16330 err = alc_auto_add_mic_boost(codec);
16331 if (err < 0)
16332 return err;
16333
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016334 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16335 spec->num_mixers++;
Takashi Iwaie044c392008-10-27 16:56:24 +010016336
16337 store_pin_configs(codec);
Takashi Iwai8c872862007-06-19 12:11:16 +020016338 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016339}
16340
16341/* additional initialization for auto-configuration model */
16342static void alc662_auto_init(struct hda_codec *codec)
16343{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016344 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016345 alc662_auto_init_multi_out(codec);
16346 alc662_auto_init_hp_out(codec);
16347 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016348 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016349 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016350 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016351}
16352
16353static int patch_alc662(struct hda_codec *codec)
16354{
16355 struct alc_spec *spec;
16356 int err, board_config;
16357
16358 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16359 if (!spec)
16360 return -ENOMEM;
16361
16362 codec->spec = spec;
16363
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016364 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16365
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016366 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16367 alc662_models,
16368 alc662_cfg_tbl);
16369 if (board_config < 0) {
16370 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16371 "trying auto-probe from BIOS...\n");
16372 board_config = ALC662_AUTO;
16373 }
16374
16375 if (board_config == ALC662_AUTO) {
16376 /* automatic parse from the BIOS config */
16377 err = alc662_parse_auto_config(codec);
16378 if (err < 0) {
16379 alc_free(codec);
16380 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020016381 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016382 printk(KERN_INFO
16383 "hda_codec: Cannot set up configuration "
16384 "from BIOS. Using base mode...\n");
16385 board_config = ALC662_3ST_2ch_DIG;
16386 }
16387 }
16388
16389 if (board_config != ALC662_AUTO)
16390 setup_preset(spec, &alc662_presets[board_config]);
16391
Kailang Yang6dda9f42008-05-27 12:05:31 +020016392 if (codec->vendor_id == 0x10ec0663) {
16393 spec->stream_name_analog = "ALC663 Analog";
16394 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016395 } else if (codec->vendor_id == 0x10ec0272) {
16396 spec->stream_name_analog = "ALC272 Analog";
16397 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016398 } else {
16399 spec->stream_name_analog = "ALC662 Analog";
16400 spec->stream_name_digital = "ALC662 Digital";
16401 }
16402
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016403 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16404 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16405
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016406 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16407 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16408
Takashi Iwaie1406342008-02-11 18:32:32 +010016409 spec->adc_nids = alc662_adc_nids;
16410 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16411 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016412
Takashi Iwai2134ea42008-01-10 16:53:55 +010016413 spec->vmaster_nid = 0x02;
16414
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016415 codec->patch_ops = alc_patch_ops;
16416 if (board_config == ALC662_AUTO)
16417 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016418#ifdef CONFIG_SND_HDA_POWER_SAVE
16419 if (!spec->loopback.amplist)
16420 spec->loopback.amplist = alc662_loopbacks;
16421#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016422
16423 return 0;
16424}
16425
16426/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016427 * patch entries
16428 */
16429struct hda_codec_preset snd_hda_preset_realtek[] = {
16430 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016431 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016432 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016433 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016434 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016435 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016436 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016437 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016438 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16439 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16440 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016441 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16442 .patch = patch_alc883 },
16443 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16444 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016445 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016446 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016447 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016448 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016449 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16450 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016451 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016452 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016453 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016454 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016455 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016456 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16457 .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016458 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016459 {} /* terminator */
16460};