blob: d511ce4b11ad20f4abde9b2c2a52d5bbac6412d3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 ALC262_AUTO,
108 ALC262_MODEL_LAST /* last tag */
109};
110
Kailang Yanga361d842007-06-05 12:30:55 +0200111/* ALC268 models */
112enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200113 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200115 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200116 ALC268_ACER,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100133 ALC269_AUTO,
134 ALC269_MODEL_LAST /* last tag */
135};
136
Kailang Yangdf694da2005-12-05 19:42:22 +0100137/* ALC861 models */
138enum {
139 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200140 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100141 ALC861_3ST_DIG,
142 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200143 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200144 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200145 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100146 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100147 ALC861_AUTO,
148 ALC861_MODEL_LAST,
149};
150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100151/* ALC861-VD models */
152enum {
153 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200154 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100155 ALC861VD_3ST,
156 ALC861VD_3ST_DIG,
157 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200158 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200159 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200160 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_AUTO,
162 ALC861VD_MODEL_LAST,
163};
164
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200165/* ALC662 models */
166enum {
167 ALC662_3ST_2ch_DIG,
168 ALC662_3ST_6ch_DIG,
169 ALC662_3ST_6ch,
170 ALC662_5ST_DIG,
171 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200172 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100173 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200174 ALC663_ASUS_M51VA,
175 ALC663_ASUS_G71V,
176 ALC663_ASUS_H13,
177 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200178 ALC662_ECS,
179 ALC663_ASUS_MODE1,
180 ALC662_ASUS_MODE2,
181 ALC663_ASUS_MODE3,
182 ALC663_ASUS_MODE4,
183 ALC663_ASUS_MODE5,
184 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200185 ALC662_AUTO,
186 ALC662_MODEL_LAST,
187};
188
Kailang Yangdf694da2005-12-05 19:42:22 +0100189/* ALC882 models */
190enum {
191 ALC882_3ST_DIG,
192 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200193 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200194 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200195 ALC882_TARGA,
196 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200197 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100198 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200199 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200200 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100202 ALC882_MODEL_LAST,
203};
204
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200205/* ALC883 models */
206enum {
207 ALC883_3ST_2ch_DIG,
208 ALC883_3ST_6ch_DIG,
209 ALC883_3ST_6ch,
210 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200211 ALC883_TARGA_DIG,
212 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200213 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200214 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200215 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200216 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100217 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200218 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200219 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200220 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200221 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200222 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200223 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100224 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100225 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100226 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100227 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200228 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_ASUS_M90V,
230 ALC888_ASUS_EEE1601,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200231 ALC883_AUTO,
232 ALC883_MODEL_LAST,
233};
234
Kailang Yangdf694da2005-12-05 19:42:22 +0100235/* for GPIO Poll */
236#define GPIO_MASK 0x03
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238struct alc_spec {
239 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100242 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Kailang Yangdf694da2005-12-05 19:42:22 +0100244 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200245 * don't forget NULL
246 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200247 */
248 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Takashi Iwai16ded522005-06-10 19:58:24 +0200250 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 struct hda_pcm_stream *stream_analog_playback;
252 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100253 struct hda_pcm_stream *stream_analog_alt_playback;
254 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200256 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 struct hda_pcm_stream *stream_digital_playback;
258 struct hda_pcm_stream *stream_digital_capture;
259
260 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200261 struct hda_multi_out multiout; /* playback set-up
262 * max_channels, dacs must be set
263 * dig_out_nid and hp_nid are optional
264 */
Takashi Iwai63300792008-01-24 15:31:36 +0100265 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267 /* capture */
268 unsigned int num_adc_nids;
269 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100270 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200271 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100272 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200275 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 const struct hda_input_mux *input_mux;
277 unsigned int cur_mux[3];
278
279 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100280 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200282 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100285 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200286
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200287 /* dynamic controls, init_verbs and input_mux */
288 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200289 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200290 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200291 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100292
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100293 /* hooks */
294 void (*init_hook)(struct hda_codec *codec);
295 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
296
Takashi Iwai834be882006-03-01 14:16:17 +0100297 /* for pin sensing */
298 unsigned int sense_updated: 1;
299 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100300 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200301
Takashi Iwai2134ea42008-01-10 16:53:55 +0100302 /* for virtual master */
303 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200304#ifdef CONFIG_SND_HDA_POWER_SAVE
305 struct hda_loopback_check loopback;
306#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200307
308 /* for PLL fix */
309 hda_nid_t pll_nid;
310 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100311
312#ifdef SND_HDA_NEEDS_RESUME
313#define ALC_MAX_PINS 16
314 unsigned int num_pins;
315 hda_nid_t pin_nids[ALC_MAX_PINS];
316 unsigned int pin_cfgs[ALC_MAX_PINS];
317#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100318};
319
320/*
321 * configuration template - to be copied to the spec instance
322 */
323struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200324 struct snd_kcontrol_new *mixers[5]; /* should be identical size
325 * with spec
326 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100327 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100328 const struct hda_verb *init_verbs[5];
329 unsigned int num_dacs;
330 hda_nid_t *dac_nids;
331 hda_nid_t dig_out_nid; /* optional */
332 hda_nid_t hp_nid; /* optional */
333 unsigned int num_adc_nids;
334 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100335 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100336 hda_nid_t dig_in_nid;
337 unsigned int num_channel_mode;
338 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200339 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200340 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100341 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100342 void (*unsol_event)(struct hda_codec *, unsigned int);
343 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200344#ifdef CONFIG_SND_HDA_POWER_SAVE
345 struct hda_amp_list *loopbacks;
346#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347};
348
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
350/*
351 * input MUX handling
352 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200353static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
356 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
357 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200358 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
359 if (mux_idx >= spec->num_mux_defs)
360 mux_idx = 0;
361 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362}
363
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200364static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
365 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366{
367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
368 struct alc_spec *spec = codec->spec;
369 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
370
371 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
372 return 0;
373}
374
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200375static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
379 struct alc_spec *spec = codec->spec;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100380 const struct hda_input_mux *imux = spec->input_mux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaie1406342008-02-11 18:32:32 +0100382 hda_nid_t nid = spec->capsrc_nids ?
383 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100385 if (spec->is_mix_capture) {
386 /* Matrix-mixer style (e.g. ALC882) */
387 unsigned int *cur_val = &spec->cur_mux[adc_idx];
388 unsigned int i, idx;
389
390 idx = ucontrol->value.enumerated.item[0];
391 if (idx >= imux->num_items)
392 idx = imux->num_items - 1;
393 if (*cur_val == idx)
394 return 0;
395 for (i = 0; i < imux->num_items; i++) {
396 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
397 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
398 imux->items[i].index,
399 HDA_AMP_MUTE, v);
400 }
401 *cur_val = idx;
402 return 1;
403 } else {
404 /* MUX style (e.g. ALC880) */
405 unsigned int mux_idx;
406 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
407 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx],
408 ucontrol, nid,
409 &spec->cur_mux[adc_idx]);
410 }
411}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200412
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413/*
414 * channel mode setting
415 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200416static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100421 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
422 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423}
424
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200425static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427{
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100430 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200431 spec->num_channel_mode,
432 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433}
434
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200440 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
441 spec->num_channel_mode,
442 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200443 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200444 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
445 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100449 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200450 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451 * being part of a format specifier. Maximum allowed length of a value is
452 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100453 *
454 * Note: some retasking pin complexes seem to ignore requests for input
455 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
456 * are requested. Therefore order this list so that this behaviour will not
457 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200458 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
459 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200460 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100461static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100462 "Mic 50pc bias", "Mic 80pc bias",
463 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100464};
465static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100466 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467};
468/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200469 * in the pin being assumed to be exclusively an input or an output pin. In
470 * addition, "input" pins may or may not process the mic bias option
471 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
472 * accept requests for bias as of chip versions up to March 2006) and/or
473 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200475#define ALC_PIN_DIR_IN 0x00
476#define ALC_PIN_DIR_OUT 0x01
477#define ALC_PIN_DIR_INOUT 0x02
478#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
479#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100480
Kailang Yangea1fb292008-08-26 12:58:38 +0200481/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 * For each direction the minimum and maximum values are given.
483 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200484static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 { 0, 2 }, /* ALC_PIN_DIR_IN */
486 { 3, 4 }, /* ALC_PIN_DIR_OUT */
487 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200488 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
489 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100490};
491#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
492#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
493#define alc_pin_mode_n_items(_dir) \
494 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
495
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200496static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200498{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499 unsigned int item_num = uinfo->value.enumerated.item;
500 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
501
502 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200503 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
505
506 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
507 item_num = alc_pin_mode_min(dir);
508 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200509 return 0;
510}
511
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200512static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
513 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200514{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200519 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
521 AC_VERB_GET_PIN_WIDGET_CONTROL,
522 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524 /* Find enumerated value for current pinctl setting */
525 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200526 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 return 0;
530}
531
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534{
535 signed int change;
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 hda_nid_t nid = kcontrol->private_value & 0xffff;
538 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
539 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
541 AC_VERB_GET_PIN_WIDGET_CONTROL,
542 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200544 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 val = alc_pin_mode_min(dir);
546
547 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100548 if (change) {
549 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200550 snd_hda_codec_write_cache(codec, nid, 0,
551 AC_VERB_SET_PIN_WIDGET_CONTROL,
552 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100553
Kailang Yangea1fb292008-08-26 12:58:38 +0200554 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100555 * for the requested pin mode. Enum values of 2 or less are
556 * input modes.
557 *
558 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200559 * reduces noise slightly (particularly on input) so we'll
560 * do it. However, having both input and output buffers
561 * enabled simultaneously doesn't seem to be problematic if
562 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100563 */
564 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200565 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
566 HDA_AMP_MUTE, HDA_AMP_MUTE);
567 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
568 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100569 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200570 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
571 HDA_AMP_MUTE, HDA_AMP_MUTE);
572 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
573 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100574 }
575 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200576 return change;
577}
578
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200580 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 .info = alc_pin_mode_info, \
582 .get = alc_pin_mode_get, \
583 .put = alc_pin_mode_put, \
584 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100585
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100586/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
587 * together using a mask with more than one bit set. This control is
588 * currently used only by the ALC260 test model. At this stage they are not
589 * needed for any "production" models.
590 */
591#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200592#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200593
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200594static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100596{
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 hda_nid_t nid = kcontrol->private_value & 0xffff;
599 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
600 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601 unsigned int val = snd_hda_codec_read(codec, nid, 0,
602 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100603
604 *valp = (val & mask) != 0;
605 return 0;
606}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200607static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100609{
610 signed int change;
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 hda_nid_t nid = kcontrol->private_value & 0xffff;
613 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
614 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
616 AC_VERB_GET_GPIO_DATA,
617 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100618
619 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200620 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
621 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100622 gpio_data &= ~mask;
623 else
624 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200625 snd_hda_codec_write_cache(codec, nid, 0,
626 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627
628 return change;
629}
630#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
631 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
632 .info = alc_gpio_data_info, \
633 .get = alc_gpio_data_get, \
634 .put = alc_gpio_data_put, \
635 .private_value = nid | (mask<<16) }
636#endif /* CONFIG_SND_DEBUG */
637
Jonathan Woithe92621f12006-02-28 11:47:47 +0100638/* A switch control to allow the enabling of the digital IO pins on the
639 * ALC260. This is incredibly simplistic; the intention of this control is
640 * to provide something in the test model allowing digital outputs to be
641 * identified if present. If models are found which can utilise these
642 * outputs a more complete mixer control can be devised for those models if
643 * necessary.
644 */
645#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200646#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200647
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200648static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100650{
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
652 hda_nid_t nid = kcontrol->private_value & 0xffff;
653 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
654 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100656 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100657
658 *valp = (val & mask) != 0;
659 return 0;
660}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200661static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
662 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100663{
664 signed int change;
665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
666 hda_nid_t nid = kcontrol->private_value & 0xffff;
667 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
668 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200669 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100670 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100672
673 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200674 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100675 if (val==0)
676 ctrl_data &= ~mask;
677 else
678 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200679 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
680 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681
682 return change;
683}
684#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
685 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
686 .info = alc_spdif_ctrl_info, \
687 .get = alc_spdif_ctrl_get, \
688 .put = alc_spdif_ctrl_put, \
689 .private_value = nid | (mask<<16) }
690#endif /* CONFIG_SND_DEBUG */
691
Jonathan Woithef8225f62008-01-08 12:16:54 +0100692/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
693 * Again, this is only used in the ALC26x test models to help identify when
694 * the EAPD line must be asserted for features to work.
695 */
696#ifdef CONFIG_SND_DEBUG
697#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
698
699static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
700 struct snd_ctl_elem_value *ucontrol)
701{
702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
703 hda_nid_t nid = kcontrol->private_value & 0xffff;
704 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
705 long *valp = ucontrol->value.integer.value;
706 unsigned int val = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
708
709 *valp = (val & mask) != 0;
710 return 0;
711}
712
713static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
714 struct snd_ctl_elem_value *ucontrol)
715{
716 int change;
717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
718 hda_nid_t nid = kcontrol->private_value & 0xffff;
719 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
720 long val = *ucontrol->value.integer.value;
721 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
722 AC_VERB_GET_EAPD_BTLENABLE,
723 0x00);
724
725 /* Set/unset the masked control bit(s) as needed */
726 change = (!val ? 0 : mask) != (ctrl_data & mask);
727 if (!val)
728 ctrl_data &= ~mask;
729 else
730 ctrl_data |= mask;
731 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
732 ctrl_data);
733
734 return change;
735}
736
737#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
738 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
739 .info = alc_eapd_ctrl_info, \
740 .get = alc_eapd_ctrl_get, \
741 .put = alc_eapd_ctrl_put, \
742 .private_value = nid | (mask<<16) }
743#endif /* CONFIG_SND_DEBUG */
744
Kailang Yangdf694da2005-12-05 19:42:22 +0100745/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100746 */
747static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
748{
749 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
750 return;
751 spec->mixers[spec->num_mixers++] = mix;
752}
753
754static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
755{
756 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
757 return;
758 spec->init_verbs[spec->num_init_verbs++] = verb;
759}
760
761/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100762 * set up from the preset table
763 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200764static void setup_preset(struct alc_spec *spec,
765 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100766{
767 int i;
768
769 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100770 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100771 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200772 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
773 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100774 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200775
Kailang Yangdf694da2005-12-05 19:42:22 +0100776 spec->channel_mode = preset->channel_mode;
777 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200778 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100779
780 spec->multiout.max_channels = spec->channel_mode[0].channels;
781
782 spec->multiout.num_dacs = preset->num_dacs;
783 spec->multiout.dac_nids = preset->dac_nids;
784 spec->multiout.dig_out_nid = preset->dig_out_nid;
785 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200786
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200787 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200788 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200789 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100790 spec->input_mux = preset->input_mux;
791
792 spec->num_adc_nids = preset->num_adc_nids;
793 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100794 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100795 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100796
797 spec->unsol_event = preset->unsol_event;
798 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200799#ifdef CONFIG_SND_HDA_POWER_SAVE
800 spec->loopback.amplist = preset->loopbacks;
801#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100802}
803
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200804/* Enable GPIO mask and set output */
805static struct hda_verb alc_gpio1_init_verbs[] = {
806 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
807 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
808 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
809 { }
810};
811
812static struct hda_verb alc_gpio2_init_verbs[] = {
813 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
814 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
815 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
816 { }
817};
818
Kailang Yangbdd148a2007-05-08 15:19:08 +0200819static struct hda_verb alc_gpio3_init_verbs[] = {
820 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
821 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
822 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
823 { }
824};
825
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200826/*
827 * Fix hardware PLL issue
828 * On some codecs, the analog PLL gating control must be off while
829 * the default value is 1.
830 */
831static void alc_fix_pll(struct hda_codec *codec)
832{
833 struct alc_spec *spec = codec->spec;
834 unsigned int val;
835
836 if (!spec->pll_nid)
837 return;
838 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
839 spec->pll_coef_idx);
840 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
841 AC_VERB_GET_PROC_COEF, 0);
842 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
843 spec->pll_coef_idx);
844 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
845 val & ~(1 << spec->pll_coef_bit));
846}
847
848static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
849 unsigned int coef_idx, unsigned int coef_bit)
850{
851 struct alc_spec *spec = codec->spec;
852 spec->pll_nid = nid;
853 spec->pll_coef_idx = coef_idx;
854 spec->pll_coef_bit = coef_bit;
855 alc_fix_pll(codec);
856}
857
Kailang Yangc9b58002007-10-16 14:30:01 +0200858static void alc_sku_automute(struct hda_codec *codec)
859{
860 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200861 unsigned int present;
862 unsigned int hp_nid = spec->autocfg.hp_pins[0];
863 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
864
865 /* need to execute and sync at first */
866 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
867 present = snd_hda_codec_read(codec, hp_nid, 0,
868 AC_VERB_GET_PIN_SENSE, 0);
869 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100870 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
871 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200872}
873
Takashi Iwai4605b712008-10-31 14:18:24 +0100874#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200875static void alc_mic_automute(struct hda_codec *codec)
876{
877 struct alc_spec *spec = codec->spec;
878 unsigned int present;
879 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
880 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
881 unsigned int mix_nid = spec->capsrc_nids[0];
882 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
883
884 capsrc_idx_mic = mic_nid - 0x18;
885 capsrc_idx_fmic = fmic_nid - 0x18;
886 present = snd_hda_codec_read(codec, mic_nid, 0,
887 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
888 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
889 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
890 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
891 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
892 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
894}
Takashi Iwai4605b712008-10-31 14:18:24 +0100895#else
896#define alc_mic_automute(codec) /* NOP */
897#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200898
Kailang Yangc9b58002007-10-16 14:30:01 +0200899/* unsolicited event for HP jack sensing */
900static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
901{
902 if (codec->vendor_id == 0x10ec0880)
903 res >>= 28;
904 else
905 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200906 if (res == ALC880_HP_EVENT)
907 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200908
Kailang Yang7fb0d782008-10-15 11:12:35 +0200909 if (res == ALC880_MIC_EVENT)
910 alc_mic_automute(codec);
911}
912
913static void alc_inithook(struct hda_codec *codec)
914{
Kailang Yangc9b58002007-10-16 14:30:01 +0200915 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200916 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200917}
918
Kailang Yangf9423e72008-05-27 12:32:25 +0200919/* additional initialization for ALC888 variants */
920static void alc888_coef_init(struct hda_codec *codec)
921{
922 unsigned int tmp;
923
924 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
925 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
926 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
927 if ((tmp & 0xf0) == 2)
928 /* alc888S-VC */
929 snd_hda_codec_read(codec, 0x20, 0,
930 AC_VERB_SET_PROC_COEF, 0x830);
931 else
932 /* alc888-VB */
933 snd_hda_codec_read(codec, 0x20, 0,
934 AC_VERB_SET_PROC_COEF, 0x3030);
935}
936
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200937/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
938 * 31 ~ 16 : Manufacture ID
939 * 15 ~ 8 : SKU ID
940 * 7 ~ 0 : Assembly ID
941 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
942 */
943static void alc_subsystem_id(struct hda_codec *codec,
944 unsigned int porta, unsigned int porte,
945 unsigned int portd)
946{
Kailang Yangc9b58002007-10-16 14:30:01 +0200947 unsigned int ass, tmp, i;
948 unsigned nid;
949 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200950
Kailang Yangc9b58002007-10-16 14:30:01 +0200951 ass = codec->subsystem_id & 0xffff;
952 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
953 goto do_sku;
954
Kailang Yangea1fb292008-08-26 12:58:38 +0200955 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200956 * 31~30 : port conetcivity
957 * 29~21 : reserve
958 * 20 : PCBEEP input
959 * 19~16 : Check sum (15:1)
960 * 15~1 : Custom
961 * 0 : override
962 */
963 nid = 0x1d;
964 if (codec->vendor_id == 0x10ec0260)
965 nid = 0x17;
966 ass = snd_hda_codec_read(codec, nid, 0,
967 AC_VERB_GET_CONFIG_DEFAULT, 0);
968 if (!(ass & 1) && !(ass & 0x100000))
969 return;
970 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200971 return;
972
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 /* check sum */
974 tmp = 0;
975 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100976 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200977 tmp++;
978 }
979 if (((ass >> 16) & 0xf) != tmp)
980 return;
981do_sku:
982 /*
983 * 0 : override
984 * 1 : Swap Jack
985 * 2 : 0 --> Desktop, 1 --> Laptop
986 * 3~5 : External Amplifier control
987 * 7~6 : Reserved
988 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200989 tmp = (ass & 0x38) >> 3; /* external Amp control */
990 switch (tmp) {
991 case 1:
992 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
993 break;
994 case 3:
995 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
996 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200997 case 7:
998 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
999 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001000 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001001 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001002 case 0x10ec0260:
1003 snd_hda_codec_write(codec, 0x0f, 0,
1004 AC_VERB_SET_EAPD_BTLENABLE, 2);
1005 snd_hda_codec_write(codec, 0x10, 0,
1006 AC_VERB_SET_EAPD_BTLENABLE, 2);
1007 break;
1008 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001009 case 0x10ec0267:
1010 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001011 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001012 case 0x10ec0660:
1013 case 0x10ec0662:
1014 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001015 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001016 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001017 snd_hda_codec_write(codec, 0x14, 0,
1018 AC_VERB_SET_EAPD_BTLENABLE, 2);
1019 snd_hda_codec_write(codec, 0x15, 0,
1020 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001021 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001022 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001023 switch (codec->vendor_id) {
1024 case 0x10ec0260:
1025 snd_hda_codec_write(codec, 0x1a, 0,
1026 AC_VERB_SET_COEF_INDEX, 7);
1027 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1028 AC_VERB_GET_PROC_COEF, 0);
1029 snd_hda_codec_write(codec, 0x1a, 0,
1030 AC_VERB_SET_COEF_INDEX, 7);
1031 snd_hda_codec_write(codec, 0x1a, 0,
1032 AC_VERB_SET_PROC_COEF,
1033 tmp | 0x2010);
1034 break;
1035 case 0x10ec0262:
1036 case 0x10ec0880:
1037 case 0x10ec0882:
1038 case 0x10ec0883:
1039 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001040 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001041 snd_hda_codec_write(codec, 0x20, 0,
1042 AC_VERB_SET_COEF_INDEX, 7);
1043 tmp = snd_hda_codec_read(codec, 0x20, 0,
1044 AC_VERB_GET_PROC_COEF, 0);
1045 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001046 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001047 snd_hda_codec_write(codec, 0x20, 0,
1048 AC_VERB_SET_PROC_COEF,
1049 tmp | 0x2010);
1050 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001051 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001052 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001053 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001054 case 0x10ec0267:
1055 case 0x10ec0268:
1056 snd_hda_codec_write(codec, 0x20, 0,
1057 AC_VERB_SET_COEF_INDEX, 7);
1058 tmp = snd_hda_codec_read(codec, 0x20, 0,
1059 AC_VERB_GET_PROC_COEF, 0);
1060 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001061 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001062 snd_hda_codec_write(codec, 0x20, 0,
1063 AC_VERB_SET_PROC_COEF,
1064 tmp | 0x3000);
1065 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001066 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001067 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001068 break;
1069 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001070
Kailang Yang8c427222008-01-10 13:03:59 +01001071 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001072 * when the external headphone out jack is plugged"
1073 */
Kailang Yang8c427222008-01-10 13:03:59 +01001074 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001075 return;
1076 /*
1077 * 10~8 : Jack location
1078 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1079 * 14~13: Resvered
1080 * 15 : 1 --> enable the function "Mute internal speaker
1081 * when the external headphone out jack is plugged"
1082 */
1083 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001084 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001085 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001086 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001087 else
1088 return;
1089 }
1090
1091 if (!spec->autocfg.hp_pins[0]) {
1092 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1093 if (tmp == 0)
1094 spec->autocfg.hp_pins[0] = porta;
1095 else if (tmp == 1)
1096 spec->autocfg.hp_pins[0] = porte;
1097 else if (tmp == 2)
1098 spec->autocfg.hp_pins[0] = portd;
1099 else
1100 return;
1101 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001102 if (spec->autocfg.hp_pins[0])
1103 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1104 AC_VERB_SET_UNSOLICITED_ENABLE,
1105 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001106
Takashi Iwai4605b712008-10-31 14:18:24 +01001107#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001108 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1109 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1110 snd_hda_codec_write(codec,
1111 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1112 AC_VERB_SET_UNSOLICITED_ENABLE,
1113 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001114#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001115
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117}
1118
Takashi Iwai41e41f12005-06-08 14:48:49 +02001119/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001120 * Fix-up pin default configurations
1121 */
1122
1123struct alc_pincfg {
1124 hda_nid_t nid;
1125 u32 val;
1126};
1127
1128static void alc_fix_pincfg(struct hda_codec *codec,
1129 const struct snd_pci_quirk *quirk,
1130 const struct alc_pincfg **pinfix)
1131{
1132 const struct alc_pincfg *cfg;
1133
1134 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1135 if (!quirk)
1136 return;
1137
1138 cfg = pinfix[quirk->value];
1139 for (; cfg->nid; cfg++) {
1140 int i;
1141 u32 val = cfg->val;
1142 for (i = 0; i < 4; i++) {
1143 snd_hda_codec_write(codec, cfg->nid, 0,
1144 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1145 val & 0xff);
1146 val >>= 8;
1147 }
1148 }
1149}
1150
1151/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001152 * ALC880 3-stack model
1153 *
1154 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001155 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1156 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 */
1158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001159static hda_nid_t alc880_dac_nids[4] = {
1160 /* front, rear, clfe, rear_surr */
1161 0x02, 0x05, 0x04, 0x03
1162};
1163
1164static hda_nid_t alc880_adc_nids[3] = {
1165 /* ADC0-2 */
1166 0x07, 0x08, 0x09,
1167};
1168
1169/* The datasheet says the node 0x07 is connected from inputs,
1170 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001171 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001173static hda_nid_t alc880_adc_nids_alt[2] = {
1174 /* ADC1-2 */
1175 0x08, 0x09,
1176};
1177
1178#define ALC880_DIGOUT_NID 0x06
1179#define ALC880_DIGIN_NID 0x0a
1180
1181static struct hda_input_mux alc880_capture_source = {
1182 .num_items = 4,
1183 .items = {
1184 { "Mic", 0x0 },
1185 { "Front Mic", 0x3 },
1186 { "Line", 0x2 },
1187 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001189};
1190
1191/* channel source setting (2/6 channel selection for 3-stack) */
1192/* 2ch mode */
1193static struct hda_verb alc880_threestack_ch2_init[] = {
1194 /* set line-in to input, mute it */
1195 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1196 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1197 /* set mic-in to input vref 80%, mute it */
1198 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1199 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 { } /* end */
1201};
1202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001203/* 6ch mode */
1204static struct hda_verb alc880_threestack_ch6_init[] = {
1205 /* set line-in to output, unmute it */
1206 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1207 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1208 /* set mic-in to output, unmute it */
1209 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1210 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1211 { } /* end */
1212};
1213
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001214static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001215 { 2, alc880_threestack_ch2_init },
1216 { 6, alc880_threestack_ch6_init },
1217};
1218
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001219static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001222 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001223 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001224 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1225 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1227 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1235 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1236 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1237 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001239 {
1240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1241 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001242 .info = alc_ch_mode_info,
1243 .get = alc_ch_mode_get,
1244 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001245 },
1246 { } /* end */
1247};
1248
1249/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001250static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1251 struct snd_ctl_elem_info *uinfo)
1252{
1253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1254 struct alc_spec *spec = codec->spec;
1255 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001256
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001257 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1258 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1259 HDA_INPUT);
1260 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1261 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1262 return err;
1263}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001265static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1266 unsigned int size, unsigned int __user *tlv)
1267{
1268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1269 struct alc_spec *spec = codec->spec;
1270 int err;
1271
1272 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1273 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1274 HDA_INPUT);
1275 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1276 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1277 return err;
1278}
1279
1280typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1281 struct snd_ctl_elem_value *ucontrol);
1282
1283static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1284 struct snd_ctl_elem_value *ucontrol,
1285 getput_call_t func)
1286{
1287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1288 struct alc_spec *spec = codec->spec;
1289 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1290 int err;
1291
1292 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1293 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1294 3, 0, HDA_INPUT);
1295 err = func(kcontrol, ucontrol);
1296 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1297 return err;
1298}
1299
1300static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1301 struct snd_ctl_elem_value *ucontrol)
1302{
1303 return alc_cap_getput_caller(kcontrol, ucontrol,
1304 snd_hda_mixer_amp_volume_get);
1305}
1306
1307static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1308 struct snd_ctl_elem_value *ucontrol)
1309{
1310 return alc_cap_getput_caller(kcontrol, ucontrol,
1311 snd_hda_mixer_amp_volume_put);
1312}
1313
1314/* capture mixer elements */
1315#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1316
1317static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1318 struct snd_ctl_elem_value *ucontrol)
1319{
1320 return alc_cap_getput_caller(kcontrol, ucontrol,
1321 snd_hda_mixer_amp_switch_get);
1322}
1323
1324static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1325 struct snd_ctl_elem_value *ucontrol)
1326{
1327 return alc_cap_getput_caller(kcontrol, ucontrol,
1328 snd_hda_mixer_amp_switch_put);
1329}
1330
1331#define DEFINE_CAPMIX(num) \
1332static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1333 { \
1334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1335 .name = "Capture Switch", \
1336 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1337 .count = num, \
1338 .info = alc_cap_sw_info, \
1339 .get = alc_cap_sw_get, \
1340 .put = alc_cap_sw_put, \
1341 }, \
1342 { \
1343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1344 .name = "Capture Volume", \
1345 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1346 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1347 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1348 .count = num, \
1349 .info = alc_cap_vol_info, \
1350 .get = alc_cap_vol_get, \
1351 .put = alc_cap_vol_put, \
1352 .tlv = { .c = alc_cap_vol_tlv }, \
1353 }, \
1354 { } /* end */ \
1355}
1356
1357/* up to three ADCs */
1358DEFINE_CAPMIX(1);
1359DEFINE_CAPMIX(2);
1360DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001361
1362
1363/*
1364 * ALC880 5-stack model
1365 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001366 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1367 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001368 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1369 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1370 */
1371
1372/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001373static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001374 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001375 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376 { } /* end */
1377};
1378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001379/* channel source setting (6/8 channel selection for 5-stack) */
1380/* 6ch mode */
1381static struct hda_verb alc880_fivestack_ch6_init[] = {
1382 /* set line-in to input, mute it */
1383 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1384 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001385 { } /* end */
1386};
1387
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001388/* 8ch mode */
1389static struct hda_verb alc880_fivestack_ch8_init[] = {
1390 /* set line-in to output, unmute it */
1391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1393 { } /* end */
1394};
1395
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001396static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001397 { 6, alc880_fivestack_ch6_init },
1398 { 8, alc880_fivestack_ch8_init },
1399};
1400
1401
1402/*
1403 * ALC880 6-stack model
1404 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001405 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1406 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1408 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1409 */
1410
1411static hda_nid_t alc880_6st_dac_nids[4] = {
1412 /* front, rear, clfe, rear_surr */
1413 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001414};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001415
1416static struct hda_input_mux alc880_6stack_capture_source = {
1417 .num_items = 4,
1418 .items = {
1419 { "Mic", 0x0 },
1420 { "Front Mic", 0x1 },
1421 { "Line", 0x2 },
1422 { "CD", 0x4 },
1423 },
1424};
1425
1426/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001427static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428 { 8, NULL },
1429};
1430
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001431static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001433 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001436 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1437 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001438 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1439 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001440 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001441 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1445 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1451 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001452 {
1453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1454 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001455 .info = alc_ch_mode_info,
1456 .get = alc_ch_mode_get,
1457 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001458 },
1459 { } /* end */
1460};
1461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001462
1463/*
1464 * ALC880 W810 model
1465 *
1466 * W810 has rear IO for:
1467 * Front (DAC 02)
1468 * Surround (DAC 03)
1469 * Center/LFE (DAC 04)
1470 * Digital out (06)
1471 *
1472 * The system also has a pair of internal speakers, and a headphone jack.
1473 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001474 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001475 * There is a variable resistor to control the speaker or headphone
1476 * volume. This is a hardware-only device without a software API.
1477 *
1478 * Plugging headphones in will disable the internal speakers. This is
1479 * implemented in hardware, not via the driver using jack sense. In
1480 * a similar fashion, plugging into the rear socket marked "front" will
1481 * disable both the speakers and headphones.
1482 *
1483 * For input, there's a microphone jack, and an "audio in" jack.
1484 * These may not do anything useful with this driver yet, because I
1485 * haven't setup any initialization verbs for these yet...
1486 */
1487
1488static hda_nid_t alc880_w810_dac_nids[3] = {
1489 /* front, rear/surround, clfe */
1490 0x02, 0x03, 0x04
1491};
1492
1493/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001494static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001495 { 6, NULL }
1496};
1497
1498/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001499static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001501 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001502 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001503 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001504 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1505 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001506 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1507 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1509 { } /* end */
1510};
1511
1512
1513/*
1514 * Z710V model
1515 *
1516 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001517 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1518 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001519 */
1520
1521static hda_nid_t alc880_z71v_dac_nids[1] = {
1522 0x02
1523};
1524#define ALC880_Z71V_HP_DAC 0x03
1525
1526/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001527static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001528 { 2, NULL }
1529};
1530
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001531static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001533 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001535 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001536 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1537 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1540 { } /* end */
1541};
1542
1543
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001544/*
1545 * ALC880 F1734 model
1546 *
1547 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1548 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1549 */
1550
1551static hda_nid_t alc880_f1734_dac_nids[1] = {
1552 0x03
1553};
1554#define ALC880_F1734_HP_DAC 0x02
1555
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001556static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001557 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001558 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001559 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1560 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001565 { } /* end */
1566};
1567
Takashi Iwai937b4162008-02-11 14:52:36 +01001568static struct hda_input_mux alc880_f1734_capture_source = {
1569 .num_items = 2,
1570 .items = {
1571 { "Mic", 0x1 },
1572 { "CD", 0x4 },
1573 },
1574};
1575
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001576
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577/*
1578 * ALC880 ASUS model
1579 *
1580 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1581 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1582 * Mic = 0x18, Line = 0x1a
1583 */
1584
1585#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1586#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1587
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001588static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001589 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001590 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001591 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001592 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001593 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1594 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001595 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1596 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1602 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001603 {
1604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1605 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001606 .info = alc_ch_mode_info,
1607 .get = alc_ch_mode_get,
1608 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001609 },
1610 { } /* end */
1611};
1612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001613/*
1614 * ALC880 ASUS W1V model
1615 *
1616 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1617 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1618 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1619 */
1620
1621/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001622static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001623 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1624 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001625 { } /* end */
1626};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001627
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001628/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001629static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001630 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1631 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1632 { } /* end */
1633};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001634
Kailang Yangdf694da2005-12-05 19:42:22 +01001635/* TCL S700 */
1636static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1638 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1640 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1641 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1644 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1645 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001646 { } /* end */
1647};
1648
Kailang Yangccc656c2006-10-17 12:32:26 +02001649/* Uniwill */
1650static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1652 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1654 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001655 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1656 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1657 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1658 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1659 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1660 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1661 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1662 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1666 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1667 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1668 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1669 {
1670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1671 .name = "Channel Mode",
1672 .info = alc_ch_mode_info,
1673 .get = alc_ch_mode_get,
1674 .put = alc_ch_mode_put,
1675 },
1676 { } /* end */
1677};
1678
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001679static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1680 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1681 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1683 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1686 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1687 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1688 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1689 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1690 { } /* end */
1691};
1692
Kailang Yangccc656c2006-10-17 12:32:26 +02001693static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1695 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1696 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1697 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1700 { } /* end */
1701};
1702
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001704 * virtual master controls
1705 */
1706
1707/*
1708 * slave controls for virtual master
1709 */
1710static const char *alc_slave_vols[] = {
1711 "Front Playback Volume",
1712 "Surround Playback Volume",
1713 "Center Playback Volume",
1714 "LFE Playback Volume",
1715 "Side Playback Volume",
1716 "Headphone Playback Volume",
1717 "Speaker Playback Volume",
1718 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001719 "Line-Out Playback Volume",
1720 NULL,
1721};
1722
1723static const char *alc_slave_sws[] = {
1724 "Front Playback Switch",
1725 "Surround Playback Switch",
1726 "Center Playback Switch",
1727 "LFE Playback Switch",
1728 "Side Playback Switch",
1729 "Headphone Playback Switch",
1730 "Speaker Playback Switch",
1731 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001732 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001733 NULL,
1734};
1735
1736/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001739
1740static void alc_free_kctls(struct hda_codec *codec);
1741
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742static int alc_build_controls(struct hda_codec *codec)
1743{
1744 struct alc_spec *spec = codec->spec;
1745 int err;
1746 int i;
1747
1748 for (i = 0; i < spec->num_mixers; i++) {
1749 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1750 if (err < 0)
1751 return err;
1752 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001753 if (spec->cap_mixer) {
1754 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1755 if (err < 0)
1756 return err;
1757 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001759 err = snd_hda_create_spdif_out_ctls(codec,
1760 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 if (err < 0)
1762 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001763 err = snd_hda_create_spdif_share_sw(codec,
1764 &spec->multiout);
1765 if (err < 0)
1766 return err;
1767 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 }
1769 if (spec->dig_in_nid) {
1770 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1771 if (err < 0)
1772 return err;
1773 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001774
1775 /* if we have no master control, let's create it */
1776 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001777 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001778 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001779 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001780 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001781 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001782 if (err < 0)
1783 return err;
1784 }
1785 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1786 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1787 NULL, alc_slave_sws);
1788 if (err < 0)
1789 return err;
1790 }
1791
Takashi Iwai603c4012008-07-30 15:01:44 +02001792 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793 return 0;
1794}
1795
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001796
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797/*
1798 * initialize the codec volumes, etc
1799 */
1800
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801/*
1802 * generic initialization of ADC, input mixers and output mixers
1803 */
1804static struct hda_verb alc880_volume_init_verbs[] = {
1805 /*
1806 * Unmute ADC0-2 and set the default input to mic-in
1807 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001808 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001810 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001812 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001813 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1816 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001817 * Note: PASD motherboards uses the Line In 2 as the input for front
1818 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 /*
1830 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832 /* set vol=0 to output mixers */
1833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1837 /* set up input amps for analog loopback */
1838 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001845 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847
1848 { }
1849};
1850
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001851/*
1852 * 3-stack pin configuration:
1853 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1854 */
1855static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1856 /*
1857 * preset connection lists of input pins
1858 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1859 */
1860 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1861 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1862 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1863
1864 /*
1865 * Set pin mode and muting
1866 */
1867 /* set front pin widgets 0x14 for output */
1868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1869 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1873 /* Mic2 (as headphone out) for HP output */
1874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1876 /* Line In pin widget for input */
1877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1879 /* Line2 (as front mic) pin widget for input and vref at 80% */
1880 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1881 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1882 /* CD pin widget for input */
1883 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1884
1885 { }
1886};
1887
1888/*
1889 * 5-stack pin configuration:
1890 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1891 * line-in/side = 0x1a, f-mic = 0x1b
1892 */
1893static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1894 /*
1895 * preset connection lists of input pins
1896 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1897 */
1898 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1899 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1900
1901 /*
1902 * Set pin mode and muting
1903 */
1904 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001905 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1906 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1907 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1908 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909 /* unmute pins for output (no gain on this amp) */
1910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1914
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1918 /* Mic2 (as headphone out) for HP output */
1919 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 /* Line In pin widget for input */
1922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1924 /* Line2 (as front mic) pin widget for input and vref at 80% */
1925 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1926 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1927 /* CD pin widget for input */
1928 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929
1930 { }
1931};
1932
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001933/*
1934 * W810 pin configuration:
1935 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1936 */
1937static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 /* hphone/speaker input selector: front DAC */
1939 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1940
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1945 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947
1948 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001949 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951 { }
1952};
1953
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001954/*
1955 * Z71V pin configuration:
1956 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1957 */
1958static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001963
Takashi Iwai16ded522005-06-10 19:58:24 +02001964 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001968
1969 { }
1970};
1971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972/*
1973 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001974 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1975 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001976 */
1977static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1978 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1979
Takashi Iwai16ded522005-06-10 19:58:24 +02001980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001986 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988
Takashi Iwai16ded522005-06-10 19:58:24 +02001989 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001991 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001993 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001996 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001997 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001998
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999 { }
2000};
Takashi Iwai16ded522005-06-10 19:58:24 +02002001
Kailang Yangccc656c2006-10-17 12:32:26 +02002002/*
2003 * Uniwill pin configuration:
2004 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2005 * line = 0x1a
2006 */
2007static struct hda_verb alc880_uniwill_init_verbs[] = {
2008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2009
2010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2024
2025 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2031 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2032 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2033 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2034
2035 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2036 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2037
2038 { }
2039};
2040
2041/*
2042* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002043* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002044 */
2045static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2046 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2047
2048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2052 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2060
2061 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2062 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2067
2068 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2069 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2070
2071 { }
2072};
2073
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002074static struct hda_verb alc880_beep_init_verbs[] = {
2075 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2076 { }
2077};
2078
Kailang Yangccc656c2006-10-17 12:32:26 +02002079/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002080static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002081{
2082 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002083 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002084
2085 present = snd_hda_codec_read(codec, 0x14, 0,
2086 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002087 bits = present ? HDA_AMP_MUTE : 0;
2088 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2089 HDA_AMP_MUTE, bits);
2090 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2091 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002092}
2093
2094/* auto-toggle front mic */
2095static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2096{
2097 unsigned int present;
2098 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002099
2100 present = snd_hda_codec_read(codec, 0x18, 0,
2101 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002102 bits = present ? HDA_AMP_MUTE : 0;
2103 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002104}
2105
2106static void alc880_uniwill_automute(struct hda_codec *codec)
2107{
2108 alc880_uniwill_hp_automute(codec);
2109 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002110}
2111
2112static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2113 unsigned int res)
2114{
2115 /* Looks like the unsol event is incompatible with the standard
2116 * definition. 4bit tag is placed at 28 bit!
2117 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002118 switch (res >> 28) {
2119 case ALC880_HP_EVENT:
2120 alc880_uniwill_hp_automute(codec);
2121 break;
2122 case ALC880_MIC_EVENT:
2123 alc880_uniwill_mic_automute(codec);
2124 break;
2125 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002126}
2127
2128static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2129{
2130 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002131 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002132
2133 present = snd_hda_codec_read(codec, 0x14, 0,
2134 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002135 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002136 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002137}
2138
2139static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2140{
2141 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002142
Kailang Yangccc656c2006-10-17 12:32:26 +02002143 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002144 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2145 present &= HDA_AMP_VOLMASK;
2146 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2147 HDA_AMP_VOLMASK, present);
2148 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2149 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002150}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002151
Kailang Yangccc656c2006-10-17 12:32:26 +02002152static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2153 unsigned int res)
2154{
2155 /* Looks like the unsol event is incompatible with the standard
2156 * definition. 4bit tag is placed at 28 bit!
2157 */
2158 if ((res >> 28) == ALC880_HP_EVENT)
2159 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002160 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002161 alc880_uniwill_p53_dcvol_automute(codec);
2162}
2163
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164/*
2165 * F1734 pin configuration:
2166 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2167 */
2168static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002169 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002170 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2171 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2172 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2173 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2174
2175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2176 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2179
2180 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002189
Takashi Iwai937b4162008-02-11 14:52:36 +01002190 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2191 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2192
Takashi Iwai16ded522005-06-10 19:58:24 +02002193 { }
2194};
2195
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196/*
2197 * ASUS pin configuration:
2198 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2199 */
2200static struct hda_verb alc880_pin_asus_init_verbs[] = {
2201 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2202 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2203 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2204 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2205
2206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2212 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2214
2215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2219 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002224
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 { }
2226};
2227
2228/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002229#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2230#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231
Kailang Yangdf694da2005-12-05 19:42:22 +01002232/* Clevo m520g init */
2233static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2234 /* headphone output */
2235 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2236 /* line-out */
2237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2239 /* Line-in */
2240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2242 /* CD */
2243 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2244 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2245 /* Mic1 (rear panel) */
2246 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2247 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2248 /* Mic2 (front panel) */
2249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2251 /* headphone */
2252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2254 /* change to EAPD mode */
2255 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2256 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2257
2258 { }
2259};
2260
2261static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002262 /* change to EAPD mode */
2263 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2264 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2265
Kailang Yangdf694da2005-12-05 19:42:22 +01002266 /* Headphone output */
2267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2268 /* Front output*/
2269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2270 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2271
2272 /* Line In pin widget for input */
2273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2274 /* CD pin widget for input */
2275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2276 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2278
2279 /* change to EAPD mode */
2280 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2281 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2282
2283 { }
2284};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002285
2286/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002287 * LG m1 express dual
2288 *
2289 * Pin assignment:
2290 * Rear Line-In/Out (blue): 0x14
2291 * Build-in Mic-In: 0x15
2292 * Speaker-out: 0x17
2293 * HP-Out (green): 0x1b
2294 * Mic-In/Out (red): 0x19
2295 * SPDIF-Out: 0x1e
2296 */
2297
2298/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2299static hda_nid_t alc880_lg_dac_nids[3] = {
2300 0x05, 0x02, 0x03
2301};
2302
2303/* seems analog CD is not working */
2304static struct hda_input_mux alc880_lg_capture_source = {
2305 .num_items = 3,
2306 .items = {
2307 { "Mic", 0x1 },
2308 { "Line", 0x5 },
2309 { "Internal Mic", 0x6 },
2310 },
2311};
2312
2313/* 2,4,6 channel modes */
2314static struct hda_verb alc880_lg_ch2_init[] = {
2315 /* set line-in and mic-in to input */
2316 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2317 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2318 { }
2319};
2320
2321static struct hda_verb alc880_lg_ch4_init[] = {
2322 /* set line-in to out and mic-in to input */
2323 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2324 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2325 { }
2326};
2327
2328static struct hda_verb alc880_lg_ch6_init[] = {
2329 /* set line-in and mic-in to output */
2330 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2331 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2332 { }
2333};
2334
2335static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2336 { 2, alc880_lg_ch2_init },
2337 { 4, alc880_lg_ch4_init },
2338 { 6, alc880_lg_ch6_init },
2339};
2340
2341static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002342 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2343 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002344 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2345 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2346 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2347 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2349 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2353 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2355 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2356 {
2357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2358 .name = "Channel Mode",
2359 .info = alc_ch_mode_info,
2360 .get = alc_ch_mode_get,
2361 .put = alc_ch_mode_put,
2362 },
2363 { } /* end */
2364};
2365
2366static struct hda_verb alc880_lg_init_verbs[] = {
2367 /* set capture source to mic-in */
2368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2369 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2370 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2371 /* mute all amp mixer inputs */
2372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002375 /* line-in to input */
2376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2378 /* built-in mic */
2379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2381 /* speaker-out */
2382 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2383 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2384 /* mic-in to input */
2385 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2388 /* HP-out */
2389 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2390 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2391 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2392 /* jack sense */
2393 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2394 { }
2395};
2396
2397/* toggle speaker-output according to the hp-jack state */
2398static void alc880_lg_automute(struct hda_codec *codec)
2399{
2400 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002401 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002402
2403 present = snd_hda_codec_read(codec, 0x1b, 0,
2404 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002405 bits = present ? HDA_AMP_MUTE : 0;
2406 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2407 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002408}
2409
2410static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2411{
2412 /* Looks like the unsol event is incompatible with the standard
2413 * definition. 4bit tag is placed at 28 bit!
2414 */
2415 if ((res >> 28) == 0x01)
2416 alc880_lg_automute(codec);
2417}
2418
2419/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002420 * LG LW20
2421 *
2422 * Pin assignment:
2423 * Speaker-out: 0x14
2424 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002425 * Built-in Mic-In: 0x19
2426 * Line-In: 0x1b
2427 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002428 * SPDIF-Out: 0x1e
2429 */
2430
Takashi Iwaid6815182006-03-23 16:06:23 +01002431static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002432 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002433 .items = {
2434 { "Mic", 0x0 },
2435 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002436 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002437 },
2438};
2439
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002440#define alc880_lg_lw_modes alc880_threestack_modes
2441
Takashi Iwaid6815182006-03-23 16:06:23 +01002442static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2444 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2446 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2455 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2456 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002457 {
2458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2459 .name = "Channel Mode",
2460 .info = alc_ch_mode_info,
2461 .get = alc_ch_mode_get,
2462 .put = alc_ch_mode_put,
2463 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002464 { } /* end */
2465};
2466
2467static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002468 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2469 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2470 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2471
Takashi Iwaid6815182006-03-23 16:06:23 +01002472 /* set capture source to mic-in */
2473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2474 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002477 /* speaker-out */
2478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2482 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2483 /* mic-in to input */
2484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2486 /* built-in mic */
2487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2489 /* jack sense */
2490 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2491 { }
2492};
2493
2494/* toggle speaker-output according to the hp-jack state */
2495static void alc880_lg_lw_automute(struct hda_codec *codec)
2496{
2497 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002498 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002499
2500 present = snd_hda_codec_read(codec, 0x1b, 0,
2501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002502 bits = present ? HDA_AMP_MUTE : 0;
2503 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2504 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002505}
2506
2507static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2508{
2509 /* Looks like the unsol event is incompatible with the standard
2510 * definition. 4bit tag is placed at 28 bit!
2511 */
2512 if ((res >> 28) == 0x01)
2513 alc880_lg_lw_automute(codec);
2514}
2515
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002516static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2517 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2518 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2520 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2521 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2522 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2523 { } /* end */
2524};
2525
2526static struct hda_input_mux alc880_medion_rim_capture_source = {
2527 .num_items = 2,
2528 .items = {
2529 { "Mic", 0x0 },
2530 { "Internal Mic", 0x1 },
2531 },
2532};
2533
2534static struct hda_verb alc880_medion_rim_init_verbs[] = {
2535 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2536
2537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2539
2540 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2541 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2542 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2543 /* Mic2 (as headphone out) for HP output */
2544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2546 /* Internal Speaker */
2547 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2548 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2549
2550 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2551 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2552
2553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2554 { }
2555};
2556
2557/* toggle speaker-output according to the hp-jack state */
2558static void alc880_medion_rim_automute(struct hda_codec *codec)
2559{
2560 unsigned int present;
2561 unsigned char bits;
2562
2563 present = snd_hda_codec_read(codec, 0x14, 0,
2564 AC_VERB_GET_PIN_SENSE, 0)
2565 & AC_PINSENSE_PRESENCE;
2566 bits = present ? HDA_AMP_MUTE : 0;
2567 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2568 HDA_AMP_MUTE, bits);
2569 if (present)
2570 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2571 else
2572 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2573}
2574
2575static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2576 unsigned int res)
2577{
2578 /* Looks like the unsol event is incompatible with the standard
2579 * definition. 4bit tag is placed at 28 bit!
2580 */
2581 if ((res >> 28) == ALC880_HP_EVENT)
2582 alc880_medion_rim_automute(codec);
2583}
2584
Takashi Iwaicb53c622007-08-10 17:21:45 +02002585#ifdef CONFIG_SND_HDA_POWER_SAVE
2586static struct hda_amp_list alc880_loopbacks[] = {
2587 { 0x0b, HDA_INPUT, 0 },
2588 { 0x0b, HDA_INPUT, 1 },
2589 { 0x0b, HDA_INPUT, 2 },
2590 { 0x0b, HDA_INPUT, 3 },
2591 { 0x0b, HDA_INPUT, 4 },
2592 { } /* end */
2593};
2594
2595static struct hda_amp_list alc880_lg_loopbacks[] = {
2596 { 0x0b, HDA_INPUT, 1 },
2597 { 0x0b, HDA_INPUT, 6 },
2598 { 0x0b, HDA_INPUT, 7 },
2599 { } /* end */
2600};
2601#endif
2602
Takashi Iwaid6815182006-03-23 16:06:23 +01002603/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002604 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002605 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002606
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607static int alc_init(struct hda_codec *codec)
2608{
2609 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 unsigned int i;
2611
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002612 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002613 if (codec->vendor_id == 0x10ec0888)
2614 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002615
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 for (i = 0; i < spec->num_init_verbs; i++)
2617 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002618
2619 if (spec->init_hook)
2620 spec->init_hook(codec);
2621
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 return 0;
2623}
2624
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002625static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2626{
2627 struct alc_spec *spec = codec->spec;
2628
2629 if (spec->unsol_event)
2630 spec->unsol_event(codec, res);
2631}
2632
Takashi Iwaicb53c622007-08-10 17:21:45 +02002633#ifdef CONFIG_SND_HDA_POWER_SAVE
2634static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2635{
2636 struct alc_spec *spec = codec->spec;
2637 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2638}
2639#endif
2640
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641/*
2642 * Analog playback callbacks
2643 */
2644static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2645 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002646 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647{
2648 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002649 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2650 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651}
2652
2653static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2654 struct hda_codec *codec,
2655 unsigned int stream_tag,
2656 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002657 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658{
2659 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002660 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2661 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662}
2663
2664static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2665 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002666 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667{
2668 struct alc_spec *spec = codec->spec;
2669 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2670}
2671
2672/*
2673 * Digital out
2674 */
2675static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2676 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002677 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678{
2679 struct alc_spec *spec = codec->spec;
2680 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2681}
2682
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002683static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2684 struct hda_codec *codec,
2685 unsigned int stream_tag,
2686 unsigned int format,
2687 struct snd_pcm_substream *substream)
2688{
2689 struct alc_spec *spec = codec->spec;
2690 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2691 stream_tag, format, substream);
2692}
2693
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2695 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002696 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697{
2698 struct alc_spec *spec = codec->spec;
2699 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2700}
2701
2702/*
2703 * Analog capture
2704 */
Takashi Iwai63300792008-01-24 15:31:36 +01002705static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 struct hda_codec *codec,
2707 unsigned int stream_tag,
2708 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002709 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710{
2711 struct alc_spec *spec = codec->spec;
2712
Takashi Iwai63300792008-01-24 15:31:36 +01002713 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002714 stream_tag, 0, format);
2715 return 0;
2716}
2717
Takashi Iwai63300792008-01-24 15:31:36 +01002718static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002720 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721{
2722 struct alc_spec *spec = codec->spec;
2723
Takashi Iwai888afa12008-03-18 09:57:50 +01002724 snd_hda_codec_cleanup_stream(codec,
2725 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 return 0;
2727}
2728
2729
2730/*
2731 */
2732static struct hda_pcm_stream alc880_pcm_analog_playback = {
2733 .substreams = 1,
2734 .channels_min = 2,
2735 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002736 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 .ops = {
2738 .open = alc880_playback_pcm_open,
2739 .prepare = alc880_playback_pcm_prepare,
2740 .cleanup = alc880_playback_pcm_cleanup
2741 },
2742};
2743
2744static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002745 .substreams = 1,
2746 .channels_min = 2,
2747 .channels_max = 2,
2748 /* NID is set in alc_build_pcms */
2749};
2750
2751static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2752 .substreams = 1,
2753 .channels_min = 2,
2754 .channels_max = 2,
2755 /* NID is set in alc_build_pcms */
2756};
2757
2758static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2759 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002760 .channels_min = 2,
2761 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002762 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002764 .prepare = alc880_alt_capture_pcm_prepare,
2765 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002766 },
2767};
2768
2769static struct hda_pcm_stream alc880_pcm_digital_playback = {
2770 .substreams = 1,
2771 .channels_min = 2,
2772 .channels_max = 2,
2773 /* NID is set in alc_build_pcms */
2774 .ops = {
2775 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002776 .close = alc880_dig_playback_pcm_close,
2777 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002778 },
2779};
2780
2781static struct hda_pcm_stream alc880_pcm_digital_capture = {
2782 .substreams = 1,
2783 .channels_min = 2,
2784 .channels_max = 2,
2785 /* NID is set in alc_build_pcms */
2786};
2787
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002788/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002789static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002790 .substreams = 0,
2791 .channels_min = 0,
2792 .channels_max = 0,
2793};
2794
Linus Torvalds1da177e2005-04-16 15:20:36 -07002795static int alc_build_pcms(struct hda_codec *codec)
2796{
2797 struct alc_spec *spec = codec->spec;
2798 struct hda_pcm *info = spec->pcm_rec;
2799 int i;
2800
2801 codec->num_pcms = 1;
2802 codec->pcm_info = info;
2803
2804 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002805 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002806 if (snd_BUG_ON(!spec->multiout.dac_nids))
2807 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002808 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2809 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2810 }
2811 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002812 if (snd_BUG_ON(!spec->adc_nids))
2813 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002814 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2815 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2816 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002817
Takashi Iwai4a471b72005-12-07 13:56:29 +01002818 if (spec->channel_mode) {
2819 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2820 for (i = 0; i < spec->num_channel_mode; i++) {
2821 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2822 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2823 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002824 }
2825 }
2826
Takashi Iwaie08a0072006-09-07 17:52:14 +02002827 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002829 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002830 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002831 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002832 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002833 if (spec->multiout.dig_out_nid &&
2834 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2836 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2837 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002838 if (spec->dig_in_nid &&
2839 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2841 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2842 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002843 /* FIXME: do we need this for all Realtek codec models? */
2844 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002845 }
2846
Takashi Iwaie08a0072006-09-07 17:52:14 +02002847 /* If the use of more than one ADC is requested for the current
2848 * model, configure a second analog capture-only PCM.
2849 */
2850 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002851 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2852 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002853 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002854 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002855 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002856 if (spec->alt_dac_nid) {
2857 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2858 *spec->stream_analog_alt_playback;
2859 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2860 spec->alt_dac_nid;
2861 } else {
2862 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2863 alc_pcm_null_stream;
2864 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2865 }
2866 if (spec->num_adc_nids > 1) {
2867 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2868 *spec->stream_analog_alt_capture;
2869 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2870 spec->adc_nids[1];
2871 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2872 spec->num_adc_nids - 1;
2873 } else {
2874 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2875 alc_pcm_null_stream;
2876 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002877 }
2878 }
2879
Linus Torvalds1da177e2005-04-16 15:20:36 -07002880 return 0;
2881}
2882
Takashi Iwai603c4012008-07-30 15:01:44 +02002883static void alc_free_kctls(struct hda_codec *codec)
2884{
2885 struct alc_spec *spec = codec->spec;
2886
2887 if (spec->kctls.list) {
2888 struct snd_kcontrol_new *kctl = spec->kctls.list;
2889 int i;
2890 for (i = 0; i < spec->kctls.used; i++)
2891 kfree(kctl[i].name);
2892 }
2893 snd_array_free(&spec->kctls);
2894}
2895
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896static void alc_free(struct hda_codec *codec)
2897{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002900 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901 return;
2902
Takashi Iwai603c4012008-07-30 15:01:44 +02002903 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002904 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002905 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002906}
2907
Takashi Iwaie044c392008-10-27 16:56:24 +01002908#ifdef SND_HDA_NEEDS_RESUME
2909static void store_pin_configs(struct hda_codec *codec)
2910{
2911 struct alc_spec *spec = codec->spec;
2912 hda_nid_t nid, end_nid;
2913
2914 end_nid = codec->start_nid + codec->num_nodes;
2915 for (nid = codec->start_nid; nid < end_nid; nid++) {
2916 unsigned int wid_caps = get_wcaps(codec, nid);
2917 unsigned int wid_type =
2918 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2919 if (wid_type != AC_WID_PIN)
2920 continue;
2921 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
2922 break;
2923 spec->pin_nids[spec->num_pins] = nid;
2924 spec->pin_cfgs[spec->num_pins] =
2925 snd_hda_codec_read(codec, nid, 0,
2926 AC_VERB_GET_CONFIG_DEFAULT, 0);
2927 spec->num_pins++;
2928 }
2929}
2930
2931static void resume_pin_configs(struct hda_codec *codec)
2932{
2933 struct alc_spec *spec = codec->spec;
2934 int i;
2935
2936 for (i = 0; i < spec->num_pins; i++) {
2937 hda_nid_t pin_nid = spec->pin_nids[i];
2938 unsigned int pin_config = spec->pin_cfgs[i];
2939 snd_hda_codec_write(codec, pin_nid, 0,
2940 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2941 pin_config & 0x000000ff);
2942 snd_hda_codec_write(codec, pin_nid, 0,
2943 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2944 (pin_config & 0x0000ff00) >> 8);
2945 snd_hda_codec_write(codec, pin_nid, 0,
2946 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2947 (pin_config & 0x00ff0000) >> 16);
2948 snd_hda_codec_write(codec, pin_nid, 0,
2949 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2950 pin_config >> 24);
2951 }
2952}
2953
2954static int alc_resume(struct hda_codec *codec)
2955{
2956 resume_pin_configs(codec);
2957 codec->patch_ops.init(codec);
2958 snd_hda_codec_resume_amp(codec);
2959 snd_hda_codec_resume_cache(codec);
2960 return 0;
2961}
2962#else
2963#define store_pin_configs(codec)
2964#endif
2965
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966/*
2967 */
2968static struct hda_codec_ops alc_patch_ops = {
2969 .build_controls = alc_build_controls,
2970 .build_pcms = alc_build_pcms,
2971 .init = alc_init,
2972 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002973 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01002974#ifdef SND_HDA_NEEDS_RESUME
2975 .resume = alc_resume,
2976#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02002977#ifdef CONFIG_SND_HDA_POWER_SAVE
2978 .check_power_status = alc_check_power_status,
2979#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980};
2981
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002982
2983/*
2984 * Test configuration for debugging
2985 *
2986 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2987 * enum controls.
2988 */
2989#ifdef CONFIG_SND_DEBUG
2990static hda_nid_t alc880_test_dac_nids[4] = {
2991 0x02, 0x03, 0x04, 0x05
2992};
2993
2994static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002995 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002996 .items = {
2997 { "In-1", 0x0 },
2998 { "In-2", 0x1 },
2999 { "In-3", 0x2 },
3000 { "In-4", 0x3 },
3001 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003002 { "Front", 0x5 },
3003 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003004 },
3005};
3006
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003007static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003008 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003009 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003010 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003011 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003012};
3013
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003014static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3015 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003016{
3017 static char *texts[] = {
3018 "N/A", "Line Out", "HP Out",
3019 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3020 };
3021 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3022 uinfo->count = 1;
3023 uinfo->value.enumerated.items = 8;
3024 if (uinfo->value.enumerated.item >= 8)
3025 uinfo->value.enumerated.item = 7;
3026 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3027 return 0;
3028}
3029
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003030static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3031 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003032{
3033 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3034 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3035 unsigned int pin_ctl, item = 0;
3036
3037 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3038 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3039 if (pin_ctl & AC_PINCTL_OUT_EN) {
3040 if (pin_ctl & AC_PINCTL_HP_EN)
3041 item = 2;
3042 else
3043 item = 1;
3044 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3045 switch (pin_ctl & AC_PINCTL_VREFEN) {
3046 case AC_PINCTL_VREF_HIZ: item = 3; break;
3047 case AC_PINCTL_VREF_50: item = 4; break;
3048 case AC_PINCTL_VREF_GRD: item = 5; break;
3049 case AC_PINCTL_VREF_80: item = 6; break;
3050 case AC_PINCTL_VREF_100: item = 7; break;
3051 }
3052 }
3053 ucontrol->value.enumerated.item[0] = item;
3054 return 0;
3055}
3056
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003057static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3058 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003059{
3060 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3061 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3062 static unsigned int ctls[] = {
3063 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3064 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3065 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3066 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3067 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3068 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3069 };
3070 unsigned int old_ctl, new_ctl;
3071
3072 old_ctl = snd_hda_codec_read(codec, nid, 0,
3073 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3074 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3075 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003076 int val;
3077 snd_hda_codec_write_cache(codec, nid, 0,
3078 AC_VERB_SET_PIN_WIDGET_CONTROL,
3079 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003080 val = ucontrol->value.enumerated.item[0] >= 3 ?
3081 HDA_AMP_MUTE : 0;
3082 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3083 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003084 return 1;
3085 }
3086 return 0;
3087}
3088
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003089static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3090 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003091{
3092 static char *texts[] = {
3093 "Front", "Surround", "CLFE", "Side"
3094 };
3095 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3096 uinfo->count = 1;
3097 uinfo->value.enumerated.items = 4;
3098 if (uinfo->value.enumerated.item >= 4)
3099 uinfo->value.enumerated.item = 3;
3100 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3101 return 0;
3102}
3103
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003104static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3105 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003106{
3107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3108 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3109 unsigned int sel;
3110
3111 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3112 ucontrol->value.enumerated.item[0] = sel & 3;
3113 return 0;
3114}
3115
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003116static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3117 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003118{
3119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3120 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3121 unsigned int sel;
3122
3123 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3124 if (ucontrol->value.enumerated.item[0] != sel) {
3125 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003126 snd_hda_codec_write_cache(codec, nid, 0,
3127 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003128 return 1;
3129 }
3130 return 0;
3131}
3132
3133#define PIN_CTL_TEST(xname,nid) { \
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3135 .name = xname, \
3136 .info = alc_test_pin_ctl_info, \
3137 .get = alc_test_pin_ctl_get, \
3138 .put = alc_test_pin_ctl_put, \
3139 .private_value = nid \
3140 }
3141
3142#define PIN_SRC_TEST(xname,nid) { \
3143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3144 .name = xname, \
3145 .info = alc_test_pin_src_info, \
3146 .get = alc_test_pin_src_get, \
3147 .put = alc_test_pin_src_put, \
3148 .private_value = nid \
3149 }
3150
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003151static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003152 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3153 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3154 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3155 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003156 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3157 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3158 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3159 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003160 PIN_CTL_TEST("Front Pin Mode", 0x14),
3161 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3162 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3163 PIN_CTL_TEST("Side Pin Mode", 0x17),
3164 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3165 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3166 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3167 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3168 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3169 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3170 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3171 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3172 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3173 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3174 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3175 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3176 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3177 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3178 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3179 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003182 {
3183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3184 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003185 .info = alc_ch_mode_info,
3186 .get = alc_ch_mode_get,
3187 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003188 },
3189 { } /* end */
3190};
3191
3192static struct hda_verb alc880_test_init_verbs[] = {
3193 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3197 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3200 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003202 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3206 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003207 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3211 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003212 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003217 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3219 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003220 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003223 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003228 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003230 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003232 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003233 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003234 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 /* Analog input/passthru */
3236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003241 { }
3242};
3243#endif
3244
Linus Torvalds1da177e2005-04-16 15:20:36 -07003245/*
3246 */
3247
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003248static const char *alc880_models[ALC880_MODEL_LAST] = {
3249 [ALC880_3ST] = "3stack",
3250 [ALC880_TCL_S700] = "tcl",
3251 [ALC880_3ST_DIG] = "3stack-digout",
3252 [ALC880_CLEVO] = "clevo",
3253 [ALC880_5ST] = "5stack",
3254 [ALC880_5ST_DIG] = "5stack-digout",
3255 [ALC880_W810] = "w810",
3256 [ALC880_Z71V] = "z71v",
3257 [ALC880_6ST] = "6stack",
3258 [ALC880_6ST_DIG] = "6stack-digout",
3259 [ALC880_ASUS] = "asus",
3260 [ALC880_ASUS_W1V] = "asus-w1v",
3261 [ALC880_ASUS_DIG] = "asus-dig",
3262 [ALC880_ASUS_DIG2] = "asus-dig2",
3263 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003264 [ALC880_UNIWILL_P53] = "uniwill-p53",
3265 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003266 [ALC880_F1734] = "F1734",
3267 [ALC880_LG] = "lg",
3268 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003269 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003270#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003271 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003272#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003273 [ALC880_AUTO] = "auto",
3274};
3275
3276static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003277 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003278 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3279 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3280 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3281 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3282 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3283 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3284 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3285 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003286 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3287 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003288 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3289 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3290 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3291 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3292 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3293 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3294 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3295 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3296 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3297 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003298 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003299 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3300 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3301 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003302 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003303 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003304 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3305 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003306 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3307 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003308 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3309 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3310 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3311 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003312 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3313 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003314 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003315 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003316 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003317 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003318 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3319 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003320 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003321 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003322 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003323 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003324 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003325 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003326 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003327 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003328 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003329 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3330 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003331 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003332 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3333 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3334 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3335 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003336 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3337 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003338 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003339 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003340 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3341 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003342 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3343 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3344 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003345 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3346 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3347 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348 {}
3349};
3350
Takashi Iwai16ded522005-06-10 19:58:24 +02003351/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003352 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003353 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003354static struct alc_config_preset alc880_presets[] = {
3355 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003356 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003357 .init_verbs = { alc880_volume_init_verbs,
3358 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003359 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003360 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003361 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3362 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003363 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003364 .input_mux = &alc880_capture_source,
3365 },
3366 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003367 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003368 .init_verbs = { alc880_volume_init_verbs,
3369 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003370 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003371 .dac_nids = alc880_dac_nids,
3372 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003373 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3374 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003375 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003376 .input_mux = &alc880_capture_source,
3377 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003378 [ALC880_TCL_S700] = {
3379 .mixers = { alc880_tcl_s700_mixer },
3380 .init_verbs = { alc880_volume_init_verbs,
3381 alc880_pin_tcl_S700_init_verbs,
3382 alc880_gpio2_init_verbs },
3383 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3384 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003385 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3386 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003387 .hp_nid = 0x03,
3388 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3389 .channel_mode = alc880_2_jack_modes,
3390 .input_mux = &alc880_capture_source,
3391 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003392 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003393 .mixers = { alc880_three_stack_mixer,
3394 alc880_five_stack_mixer},
3395 .init_verbs = { alc880_volume_init_verbs,
3396 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003397 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3398 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003399 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3400 .channel_mode = alc880_fivestack_modes,
3401 .input_mux = &alc880_capture_source,
3402 },
3403 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003404 .mixers = { alc880_three_stack_mixer,
3405 alc880_five_stack_mixer },
3406 .init_verbs = { alc880_volume_init_verbs,
3407 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003408 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3409 .dac_nids = alc880_dac_nids,
3410 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003411 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3412 .channel_mode = alc880_fivestack_modes,
3413 .input_mux = &alc880_capture_source,
3414 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003415 [ALC880_6ST] = {
3416 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003417 .init_verbs = { alc880_volume_init_verbs,
3418 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003419 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3420 .dac_nids = alc880_6st_dac_nids,
3421 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3422 .channel_mode = alc880_sixstack_modes,
3423 .input_mux = &alc880_6stack_capture_source,
3424 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003425 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003426 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003427 .init_verbs = { alc880_volume_init_verbs,
3428 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003429 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3430 .dac_nids = alc880_6st_dac_nids,
3431 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003432 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3433 .channel_mode = alc880_sixstack_modes,
3434 .input_mux = &alc880_6stack_capture_source,
3435 },
3436 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003438 .init_verbs = { alc880_volume_init_verbs,
3439 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003440 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003441 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3442 .dac_nids = alc880_w810_dac_nids,
3443 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003444 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3445 .channel_mode = alc880_w810_modes,
3446 .input_mux = &alc880_capture_source,
3447 },
3448 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003450 .init_verbs = { alc880_volume_init_verbs,
3451 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003452 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3453 .dac_nids = alc880_z71v_dac_nids,
3454 .dig_out_nid = ALC880_DIGOUT_NID,
3455 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3457 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003458 .input_mux = &alc880_capture_source,
3459 },
3460 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003462 .init_verbs = { alc880_volume_init_verbs,
3463 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3465 .dac_nids = alc880_f1734_dac_nids,
3466 .hp_nid = 0x02,
3467 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3468 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003469 .input_mux = &alc880_f1734_capture_source,
3470 .unsol_event = alc880_uniwill_p53_unsol_event,
3471 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003472 },
3473 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003475 .init_verbs = { alc880_volume_init_verbs,
3476 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003477 alc880_gpio1_init_verbs },
3478 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3479 .dac_nids = alc880_asus_dac_nids,
3480 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3481 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003482 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003483 .input_mux = &alc880_capture_source,
3484 },
3485 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003487 .init_verbs = { alc880_volume_init_verbs,
3488 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 alc880_gpio1_init_verbs },
3490 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3491 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003492 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003493 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3494 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003495 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003496 .input_mux = &alc880_capture_source,
3497 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003498 [ALC880_ASUS_DIG2] = {
3499 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003500 .init_verbs = { alc880_volume_init_verbs,
3501 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003502 alc880_gpio2_init_verbs }, /* use GPIO2 */
3503 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3504 .dac_nids = alc880_asus_dac_nids,
3505 .dig_out_nid = ALC880_DIGOUT_NID,
3506 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3507 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003508 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003509 .input_mux = &alc880_capture_source,
3510 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003511 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003512 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003513 .init_verbs = { alc880_volume_init_verbs,
3514 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515 alc880_gpio1_init_verbs },
3516 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3517 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003518 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003519 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3520 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003521 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003522 .input_mux = &alc880_capture_source,
3523 },
3524 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003525 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003526 .init_verbs = { alc880_volume_init_verbs,
3527 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003528 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3529 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003530 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3532 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003533 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003534 .input_mux = &alc880_capture_source,
3535 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003536 [ALC880_UNIWILL] = {
3537 .mixers = { alc880_uniwill_mixer },
3538 .init_verbs = { alc880_volume_init_verbs,
3539 alc880_uniwill_init_verbs },
3540 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3541 .dac_nids = alc880_asus_dac_nids,
3542 .dig_out_nid = ALC880_DIGOUT_NID,
3543 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3544 .channel_mode = alc880_threestack_modes,
3545 .need_dac_fix = 1,
3546 .input_mux = &alc880_capture_source,
3547 .unsol_event = alc880_uniwill_unsol_event,
3548 .init_hook = alc880_uniwill_automute,
3549 },
3550 [ALC880_UNIWILL_P53] = {
3551 .mixers = { alc880_uniwill_p53_mixer },
3552 .init_verbs = { alc880_volume_init_verbs,
3553 alc880_uniwill_p53_init_verbs },
3554 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3555 .dac_nids = alc880_asus_dac_nids,
3556 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003557 .channel_mode = alc880_threestack_modes,
3558 .input_mux = &alc880_capture_source,
3559 .unsol_event = alc880_uniwill_p53_unsol_event,
3560 .init_hook = alc880_uniwill_p53_hp_automute,
3561 },
3562 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003563 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003564 alc880_pcbeep_mixer, },
3565 .init_verbs = { alc880_volume_init_verbs,
3566 alc880_uniwill_p53_init_verbs,
3567 alc880_beep_init_verbs },
3568 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3569 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003570 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003571 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3572 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003573 .input_mux = &alc880_capture_source,
3574 .unsol_event = alc880_uniwill_p53_unsol_event,
3575 .init_hook = alc880_uniwill_p53_hp_automute,
3576 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003577 [ALC880_CLEVO] = {
3578 .mixers = { alc880_three_stack_mixer },
3579 .init_verbs = { alc880_volume_init_verbs,
3580 alc880_pin_clevo_init_verbs },
3581 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3582 .dac_nids = alc880_dac_nids,
3583 .hp_nid = 0x03,
3584 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3585 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003586 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003587 .input_mux = &alc880_capture_source,
3588 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003589 [ALC880_LG] = {
3590 .mixers = { alc880_lg_mixer },
3591 .init_verbs = { alc880_volume_init_verbs,
3592 alc880_lg_init_verbs },
3593 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3594 .dac_nids = alc880_lg_dac_nids,
3595 .dig_out_nid = ALC880_DIGOUT_NID,
3596 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3597 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003598 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003599 .input_mux = &alc880_lg_capture_source,
3600 .unsol_event = alc880_lg_unsol_event,
3601 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003602#ifdef CONFIG_SND_HDA_POWER_SAVE
3603 .loopbacks = alc880_lg_loopbacks,
3604#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003605 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003606 [ALC880_LG_LW] = {
3607 .mixers = { alc880_lg_lw_mixer },
3608 .init_verbs = { alc880_volume_init_verbs,
3609 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003610 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003611 .dac_nids = alc880_dac_nids,
3612 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003613 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3614 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003615 .input_mux = &alc880_lg_lw_capture_source,
3616 .unsol_event = alc880_lg_lw_unsol_event,
3617 .init_hook = alc880_lg_lw_automute,
3618 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003619 [ALC880_MEDION_RIM] = {
3620 .mixers = { alc880_medion_rim_mixer },
3621 .init_verbs = { alc880_volume_init_verbs,
3622 alc880_medion_rim_init_verbs,
3623 alc_gpio2_init_verbs },
3624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3625 .dac_nids = alc880_dac_nids,
3626 .dig_out_nid = ALC880_DIGOUT_NID,
3627 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3628 .channel_mode = alc880_2_jack_modes,
3629 .input_mux = &alc880_medion_rim_capture_source,
3630 .unsol_event = alc880_medion_rim_unsol_event,
3631 .init_hook = alc880_medion_rim_automute,
3632 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003633#ifdef CONFIG_SND_DEBUG
3634 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635 .mixers = { alc880_test_mixer },
3636 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003637 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3638 .dac_nids = alc880_test_dac_nids,
3639 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003640 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3641 .channel_mode = alc880_test_modes,
3642 .input_mux = &alc880_test_capture_source,
3643 },
3644#endif
3645};
3646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003647/*
3648 * Automatic parse of I/O pins from the BIOS configuration
3649 */
3650
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003651enum {
3652 ALC_CTL_WIDGET_VOL,
3653 ALC_CTL_WIDGET_MUTE,
3654 ALC_CTL_BIND_MUTE,
3655};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003656static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003657 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3658 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003659 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003660};
3661
3662/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003663static int add_control(struct alc_spec *spec, int type, const char *name,
3664 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003665{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003666 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003667
Takashi Iwai603c4012008-07-30 15:01:44 +02003668 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3669 knew = snd_array_new(&spec->kctls);
3670 if (!knew)
3671 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003672 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003673 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003674 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003675 return -ENOMEM;
3676 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677 return 0;
3678}
3679
3680#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3681#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3682#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3683#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3684#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3685#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3686#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3687#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3688#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3689#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3690#define ALC880_PIN_CD_NID 0x1c
3691
3692/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3694 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003695{
3696 hda_nid_t nid;
3697 int assigned[4];
3698 int i, j;
3699
3700 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003701 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702
3703 /* check the pins hardwired to audio widget */
3704 for (i = 0; i < cfg->line_outs; i++) {
3705 nid = cfg->line_out_pins[i];
3706 if (alc880_is_fixed_pin(nid)) {
3707 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003708 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709 assigned[idx] = 1;
3710 }
3711 }
3712 /* left pins can be connect to any audio widget */
3713 for (i = 0; i < cfg->line_outs; i++) {
3714 nid = cfg->line_out_pins[i];
3715 if (alc880_is_fixed_pin(nid))
3716 continue;
3717 /* search for an empty channel */
3718 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003719 if (!assigned[j]) {
3720 spec->multiout.dac_nids[i] =
3721 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722 assigned[j] = 1;
3723 break;
3724 }
3725 }
3726 }
3727 spec->multiout.num_dacs = cfg->line_outs;
3728 return 0;
3729}
3730
3731/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003732static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3733 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003734{
3735 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003736 static const char *chname[4] = {
3737 "Front", "Surround", NULL /*CLFE*/, "Side"
3738 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739 hda_nid_t nid;
3740 int i, err;
3741
3742 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003743 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 continue;
3745 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3746 if (i == 2) {
3747 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3749 "Center Playback Volume",
3750 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3751 HDA_OUTPUT));
3752 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003754 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3755 "LFE Playback Volume",
3756 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3757 HDA_OUTPUT));
3758 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003759 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 err = add_control(spec, ALC_CTL_BIND_MUTE,
3761 "Center Playback Switch",
3762 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3763 HDA_INPUT));
3764 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003765 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003766 err = add_control(spec, ALC_CTL_BIND_MUTE,
3767 "LFE Playback Switch",
3768 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3769 HDA_INPUT));
3770 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 return err;
3772 } else {
3773 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003774 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3775 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3776 HDA_OUTPUT));
3777 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003778 return err;
3779 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003780 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3781 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3782 HDA_INPUT));
3783 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 return err;
3785 }
3786 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787 return 0;
3788}
3789
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003790/* add playback controls for speaker and HP outputs */
3791static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3792 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793{
3794 hda_nid_t nid;
3795 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003796 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003797
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003798 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 return 0;
3800
3801 if (alc880_is_fixed_pin(pin)) {
3802 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003803 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003804 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003806 else
3807 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003808 /* control HP volume/switch on the output mixer amp */
3809 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003810 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003811 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3812 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3813 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003814 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003815 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003816 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3817 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3818 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003819 return err;
3820 } else if (alc880_is_multi_pin(pin)) {
3821 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003823 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003824 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3825 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3826 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003827 return err;
3828 }
3829 return 0;
3830}
3831
3832/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003833static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3834 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003835 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003836{
3837 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003838 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003839
3840 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003841 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3842 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3843 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 return err;
3845 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003846 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3847 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3848 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 return err;
3850 return 0;
3851}
3852
3853/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003854static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3855 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003858 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003859
3860 for (i = 0; i < AUTO_PIN_LAST; i++) {
3861 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003862 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003863 err = new_analog_input(spec, cfg->input_pins[i],
3864 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003865 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003866 if (err < 0)
3867 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003868 imux->items[imux->num_items].label =
3869 auto_pin_cfg_labels[i];
3870 imux->items[imux->num_items].index =
3871 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003872 imux->num_items++;
3873 }
3874 }
3875 return 0;
3876}
3877
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003878static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3879 unsigned int pin_type)
3880{
3881 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3882 pin_type);
3883 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3885 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003886}
3887
Kailang Yangdf694da2005-12-05 19:42:22 +01003888static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3889 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003890 int dac_idx)
3891{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003892 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003893 /* need the manual connection? */
3894 if (alc880_is_multi_pin(nid)) {
3895 struct alc_spec *spec = codec->spec;
3896 int idx = alc880_multi_pin_idx(nid);
3897 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3898 AC_VERB_SET_CONNECT_SEL,
3899 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3900 }
3901}
3902
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003903static int get_pin_type(int line_out_type)
3904{
3905 if (line_out_type == AUTO_PIN_HP_OUT)
3906 return PIN_HP;
3907 else
3908 return PIN_OUT;
3909}
3910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911static void alc880_auto_init_multi_out(struct hda_codec *codec)
3912{
3913 struct alc_spec *spec = codec->spec;
3914 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003915
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003916 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003917 for (i = 0; i < spec->autocfg.line_outs; i++) {
3918 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003919 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3920 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003921 }
3922}
3923
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003924static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925{
3926 struct alc_spec *spec = codec->spec;
3927 hda_nid_t pin;
3928
Takashi Iwai82bc9552006-03-21 11:24:42 +01003929 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003930 if (pin) /* connect to front */
3931 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003932 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003933 if (pin) /* connect to front */
3934 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3935}
3936
3937static void alc880_auto_init_analog_input(struct hda_codec *codec)
3938{
3939 struct alc_spec *spec = codec->spec;
3940 int i;
3941
3942 for (i = 0; i < AUTO_PIN_LAST; i++) {
3943 hda_nid_t nid = spec->autocfg.input_pins[i];
3944 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003945 snd_hda_codec_write(codec, nid, 0,
3946 AC_VERB_SET_PIN_WIDGET_CONTROL,
3947 i <= AUTO_PIN_FRONT_MIC ?
3948 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003949 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003950 snd_hda_codec_write(codec, nid, 0,
3951 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003952 AMP_OUT_MUTE);
3953 }
3954 }
3955}
3956
3957/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003958/* return 1 if successful, 0 if the proper config is not found,
3959 * or a negative error code
3960 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961static int alc880_parse_auto_config(struct hda_codec *codec)
3962{
3963 struct alc_spec *spec = codec->spec;
3964 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003965 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003967 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3968 alc880_ignore);
3969 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003971 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003972 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003973
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003974 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3975 if (err < 0)
3976 return err;
3977 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3978 if (err < 0)
3979 return err;
3980 err = alc880_auto_create_extra_out(spec,
3981 spec->autocfg.speaker_pins[0],
3982 "Speaker");
3983 if (err < 0)
3984 return err;
3985 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3986 "Headphone");
3987 if (err < 0)
3988 return err;
3989 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3990 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 return err;
3992
3993 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3994
3995 if (spec->autocfg.dig_out_pin)
3996 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3997 if (spec->autocfg.dig_in_pin)
3998 spec->dig_in_nid = ALC880_DIGIN_NID;
3999
Takashi Iwai603c4012008-07-30 15:01:44 +02004000 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004001 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002
Takashi Iwaid88897e2008-10-31 15:01:37 +01004003 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004005 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006 spec->input_mux = &spec->private_imux;
4007
Takashi Iwaie044c392008-10-27 16:56:24 +01004008 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004009 return 1;
4010}
4011
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004012/* additional initialization for auto-configuration model */
4013static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004014{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004015 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004017 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004019 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004020 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021}
4022
4023/*
4024 * OK, here we have finally the patch for ALC880
4025 */
4026
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004027static void set_capture_mixer(struct alc_spec *spec)
4028{
4029 static struct snd_kcontrol_new *caps[3] = {
4030 alc_capture_mixer1,
4031 alc_capture_mixer2,
4032 alc_capture_mixer3,
4033 };
4034 if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
4035 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4036}
4037
Linus Torvalds1da177e2005-04-16 15:20:36 -07004038static int patch_alc880(struct hda_codec *codec)
4039{
4040 struct alc_spec *spec;
4041 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004042 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004043
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004044 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004045 if (spec == NULL)
4046 return -ENOMEM;
4047
4048 codec->spec = spec;
4049
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004050 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4051 alc880_models,
4052 alc880_cfg_tbl);
4053 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004054 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4055 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004057 }
4058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004059 if (board_config == ALC880_AUTO) {
4060 /* automatic parse from the BIOS config */
4061 err = alc880_parse_auto_config(codec);
4062 if (err < 0) {
4063 alc_free(codec);
4064 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004065 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004066 printk(KERN_INFO
4067 "hda_codec: Cannot set up configuration "
4068 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 board_config = ALC880_3ST;
4070 }
4071 }
4072
Kailang Yangdf694da2005-12-05 19:42:22 +01004073 if (board_config != ALC880_AUTO)
4074 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004075
4076 spec->stream_name_analog = "ALC880 Analog";
4077 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4078 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004079 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004080
4081 spec->stream_name_digital = "ALC880 Digital";
4082 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4083 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4084
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004085 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004087 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004088 /* get type */
4089 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 if (wcap != AC_WID_AUD_IN) {
4091 spec->adc_nids = alc880_adc_nids_alt;
4092 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 } else {
4094 spec->adc_nids = alc880_adc_nids;
4095 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096 }
4097 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004098 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004099
Takashi Iwai2134ea42008-01-10 16:53:55 +01004100 spec->vmaster_nid = 0x0c;
4101
Linus Torvalds1da177e2005-04-16 15:20:36 -07004102 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004104 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004105#ifdef CONFIG_SND_HDA_POWER_SAVE
4106 if (!spec->loopback.amplist)
4107 spec->loopback.amplist = alc880_loopbacks;
4108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004109
4110 return 0;
4111}
4112
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114/*
4115 * ALC260 support
4116 */
4117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118static hda_nid_t alc260_dac_nids[1] = {
4119 /* front */
4120 0x02,
4121};
4122
4123static hda_nid_t alc260_adc_nids[1] = {
4124 /* ADC0 */
4125 0x04,
4126};
4127
Kailang Yangdf694da2005-12-05 19:42:22 +01004128static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004129 /* ADC1 */
4130 0x05,
4131};
4132
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004133/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4134 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4135 */
4136static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004137 /* ADC0, ADC1 */
4138 0x04, 0x05
4139};
4140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141#define ALC260_DIGOUT_NID 0x03
4142#define ALC260_DIGIN_NID 0x06
4143
4144static struct hda_input_mux alc260_capture_source = {
4145 .num_items = 4,
4146 .items = {
4147 { "Mic", 0x0 },
4148 { "Front Mic", 0x1 },
4149 { "Line", 0x2 },
4150 { "CD", 0x4 },
4151 },
4152};
4153
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004154/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004155 * headphone jack and the internal CD lines since these are the only pins at
4156 * which audio can appear. For flexibility, also allow the option of
4157 * recording the mixer output on the second ADC (ADC0 doesn't have a
4158 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004159 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004160static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4161 {
4162 .num_items = 3,
4163 .items = {
4164 { "Mic/Line", 0x0 },
4165 { "CD", 0x4 },
4166 { "Headphone", 0x2 },
4167 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004168 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004169 {
4170 .num_items = 4,
4171 .items = {
4172 { "Mic/Line", 0x0 },
4173 { "CD", 0x4 },
4174 { "Headphone", 0x2 },
4175 { "Mixer", 0x5 },
4176 },
4177 },
4178
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004179};
4180
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004181/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4182 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004183 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004184static struct hda_input_mux alc260_acer_capture_sources[2] = {
4185 {
4186 .num_items = 4,
4187 .items = {
4188 { "Mic", 0x0 },
4189 { "Line", 0x2 },
4190 { "CD", 0x4 },
4191 { "Headphone", 0x5 },
4192 },
4193 },
4194 {
4195 .num_items = 5,
4196 .items = {
4197 { "Mic", 0x0 },
4198 { "Line", 0x2 },
4199 { "CD", 0x4 },
4200 { "Headphone", 0x6 },
4201 { "Mixer", 0x5 },
4202 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004203 },
4204};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004205/*
4206 * This is just place-holder, so there's something for alc_build_pcms to look
4207 * at when it calculates the maximum number of channels. ALC260 has no mixer
4208 * element which allows changing the channel mode, so the verb list is
4209 * never used.
4210 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004211static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004212 { 2, NULL },
4213};
4214
Kailang Yangdf694da2005-12-05 19:42:22 +01004215
4216/* Mixer combinations
4217 *
4218 * basic: base_output + input + pc_beep + capture
4219 * HP: base_output + input + capture_alt
4220 * HP_3013: hp_3013 + input + capture
4221 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004222 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004223 */
4224
4225static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004226 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004227 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4229 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4230 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4231 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4232 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004233};
Kailang Yangdf694da2005-12-05 19:42:22 +01004234
4235static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004236 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4237 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4238 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4239 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4241 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4243 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004244 { } /* end */
4245};
4246
Kailang Yangdf694da2005-12-05 19:42:22 +01004247static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4248 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4249 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4250 { } /* end */
4251};
4252
Takashi Iwaibec15c32008-01-28 18:16:30 +01004253/* update HP, line and mono out pins according to the master switch */
4254static void alc260_hp_master_update(struct hda_codec *codec,
4255 hda_nid_t hp, hda_nid_t line,
4256 hda_nid_t mono)
4257{
4258 struct alc_spec *spec = codec->spec;
4259 unsigned int val = spec->master_sw ? PIN_HP : 0;
4260 /* change HP and line-out pins */
4261 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4262 val);
4263 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4264 val);
4265 /* mono (speaker) depending on the HP jack sense */
4266 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4267 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4268 val);
4269}
4270
4271static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4272 struct snd_ctl_elem_value *ucontrol)
4273{
4274 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4275 struct alc_spec *spec = codec->spec;
4276 *ucontrol->value.integer.value = spec->master_sw;
4277 return 0;
4278}
4279
4280static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4281 struct snd_ctl_elem_value *ucontrol)
4282{
4283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4284 struct alc_spec *spec = codec->spec;
4285 int val = !!*ucontrol->value.integer.value;
4286 hda_nid_t hp, line, mono;
4287
4288 if (val == spec->master_sw)
4289 return 0;
4290 spec->master_sw = val;
4291 hp = (kcontrol->private_value >> 16) & 0xff;
4292 line = (kcontrol->private_value >> 8) & 0xff;
4293 mono = kcontrol->private_value & 0xff;
4294 alc260_hp_master_update(codec, hp, line, mono);
4295 return 1;
4296}
4297
4298static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4299 {
4300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4301 .name = "Master Playback Switch",
4302 .info = snd_ctl_boolean_mono_info,
4303 .get = alc260_hp_master_sw_get,
4304 .put = alc260_hp_master_sw_put,
4305 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4306 },
4307 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4308 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4309 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4310 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4311 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4312 HDA_OUTPUT),
4313 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4314 { } /* end */
4315};
4316
4317static struct hda_verb alc260_hp_unsol_verbs[] = {
4318 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4319 {},
4320};
4321
4322static void alc260_hp_automute(struct hda_codec *codec)
4323{
4324 struct alc_spec *spec = codec->spec;
4325 unsigned int present;
4326
4327 present = snd_hda_codec_read(codec, 0x10, 0,
4328 AC_VERB_GET_PIN_SENSE, 0);
4329 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4330 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4331}
4332
4333static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4334{
4335 if ((res >> 26) == ALC880_HP_EVENT)
4336 alc260_hp_automute(codec);
4337}
4338
Kailang Yangdf694da2005-12-05 19:42:22 +01004339static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004340 {
4341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4342 .name = "Master Playback Switch",
4343 .info = snd_ctl_boolean_mono_info,
4344 .get = alc260_hp_master_sw_get,
4345 .put = alc260_hp_master_sw_put,
4346 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4347 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4349 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4350 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4351 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004354 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4355 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004356 { } /* end */
4357};
4358
Kailang Yang3f878302008-08-26 13:02:23 +02004359static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4360 .ops = &snd_hda_bind_vol,
4361 .values = {
4362 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4363 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4364 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4365 0
4366 },
4367};
4368
4369static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4370 .ops = &snd_hda_bind_sw,
4371 .values = {
4372 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4373 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4374 0
4375 },
4376};
4377
4378static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4379 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4380 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4381 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4383 { } /* end */
4384};
4385
Takashi Iwaibec15c32008-01-28 18:16:30 +01004386static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4387 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4388 {},
4389};
4390
4391static void alc260_hp_3013_automute(struct hda_codec *codec)
4392{
4393 struct alc_spec *spec = codec->spec;
4394 unsigned int present;
4395
4396 present = snd_hda_codec_read(codec, 0x15, 0,
4397 AC_VERB_GET_PIN_SENSE, 0);
4398 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4399 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4400}
4401
4402static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4403 unsigned int res)
4404{
4405 if ((res >> 26) == ALC880_HP_EVENT)
4406 alc260_hp_3013_automute(codec);
4407}
4408
Kailang Yang3f878302008-08-26 13:02:23 +02004409static void alc260_hp_3012_automute(struct hda_codec *codec)
4410{
4411 unsigned int present, bits;
4412
4413 present = snd_hda_codec_read(codec, 0x10, 0,
4414 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4415
4416 bits = present ? 0 : PIN_OUT;
4417 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4418 bits);
4419 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4420 bits);
4421 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4422 bits);
4423}
4424
4425static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4426 unsigned int res)
4427{
4428 if ((res >> 26) == ALC880_HP_EVENT)
4429 alc260_hp_3012_automute(codec);
4430}
4431
4432/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004433 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4434 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004435static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004437 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004438 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004439 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4440 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4441 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4442 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004443 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004444 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4445 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004446 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4447 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 { } /* end */
4449};
4450
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004451/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4452 * versions of the ALC260 don't act on requests to enable mic bias from NID
4453 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4454 * datasheet doesn't mention this restriction. At this stage it's not clear
4455 * whether this behaviour is intentional or is a hardware bug in chip
4456 * revisions available in early 2006. Therefore for now allow the
4457 * "Headphone Jack Mode" control to span all choices, but if it turns out
4458 * that the lack of mic bias for this NID is intentional we could change the
4459 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4460 *
4461 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4462 * don't appear to make the mic bias available from the "line" jack, even
4463 * though the NID used for this jack (0x14) can supply it. The theory is
4464 * that perhaps Acer have included blocking capacitors between the ALC260
4465 * and the output jack. If this turns out to be the case for all such
4466 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4467 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004468 *
4469 * The C20x Tablet series have a mono internal speaker which is controlled
4470 * via the chip's Mono sum widget and pin complex, so include the necessary
4471 * controls for such models. On models without a "mono speaker" the control
4472 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004473 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004474static struct snd_kcontrol_new alc260_acer_mixer[] = {
4475 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4476 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004477 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004478 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004479 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004480 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004481 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004482 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4483 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4485 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4486 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4487 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4488 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4489 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4490 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4491 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4492 { } /* end */
4493};
4494
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004495/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4496 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4497 */
4498static struct snd_kcontrol_new alc260_will_mixer[] = {
4499 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4500 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4502 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4503 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4504 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4505 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4506 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4507 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4508 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4509 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4510 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4511 { } /* end */
4512};
4513
4514/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4515 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4516 */
4517static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4518 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4519 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4521 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4522 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4523 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4524 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4525 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4526 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4527 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4528 { } /* end */
4529};
4530
Kailang Yangdf694da2005-12-05 19:42:22 +01004531/*
4532 * initialization verbs
4533 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004534static struct hda_verb alc260_init_verbs[] = {
4535 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004537 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004539 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004540 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004541 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004542 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004543 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004545 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004546 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004547 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004549 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004551 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4553 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004554 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004555 /* set connection select to line in (default select for this ADC) */
4556 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004557 /* mute capture amp left and right */
4558 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4559 /* set connection select to line in (default select for this ADC) */
4560 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004561 /* set vol=0 Line-Out mixer amp left and right */
4562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4563 /* unmute pin widget amp left and right (no gain on this amp) */
4564 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4565 /* set vol=0 HP mixer amp left and right */
4566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4567 /* unmute pin widget amp left and right (no gain on this amp) */
4568 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4569 /* set vol=0 Mono mixer amp left and right */
4570 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4571 /* unmute pin widget amp left and right (no gain on this amp) */
4572 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4573 /* unmute LINE-2 out pin */
4574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004575 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4576 * Line In 2 = 0x03
4577 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004578 /* mute analog inputs */
4579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004584 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004585 /* mute Front out path */
4586 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4588 /* mute Headphone out path */
4589 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4590 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4591 /* mute Mono out path */
4592 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4593 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004594 { }
4595};
4596
Takashi Iwai474167d2006-05-17 17:17:43 +02004597#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004598static struct hda_verb alc260_hp_init_verbs[] = {
4599 /* Headphone and output */
4600 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4601 /* mono output */
4602 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4603 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4604 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4605 /* Mic2 (front panel) pin widget for input and vref at 80% */
4606 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4607 /* Line In pin widget for input */
4608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4609 /* Line-2 pin widget for output */
4610 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4611 /* CD pin widget for input */
4612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4613 /* unmute amp left and right */
4614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4615 /* set connection select to line in (default select for this ADC) */
4616 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4617 /* unmute Line-Out mixer amp left and right (volume = 0) */
4618 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4619 /* mute pin widget amp left and right (no gain on this amp) */
4620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4621 /* unmute HP mixer amp left and right (volume = 0) */
4622 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4623 /* mute pin widget amp left and right (no gain on this amp) */
4624 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4626 * Line In 2 = 0x03
4627 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004628 /* mute analog inputs */
4629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004634 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4635 /* Unmute Front out path */
4636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4638 /* Unmute Headphone out path */
4639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4641 /* Unmute Mono out path */
4642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4643 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4644 { }
4645};
Takashi Iwai474167d2006-05-17 17:17:43 +02004646#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004647
4648static struct hda_verb alc260_hp_3013_init_verbs[] = {
4649 /* Line out and output */
4650 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4651 /* mono output */
4652 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4653 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4654 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4655 /* Mic2 (front panel) pin widget for input and vref at 80% */
4656 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4657 /* Line In pin widget for input */
4658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4659 /* Headphone pin widget for output */
4660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4661 /* CD pin widget for input */
4662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4663 /* unmute amp left and right */
4664 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4665 /* set connection select to line in (default select for this ADC) */
4666 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4667 /* unmute Line-Out mixer amp left and right (volume = 0) */
4668 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4669 /* mute pin widget amp left and right (no gain on this amp) */
4670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4671 /* unmute HP mixer amp left and right (volume = 0) */
4672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4673 /* mute pin widget amp left and right (no gain on this amp) */
4674 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004675 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4676 * Line In 2 = 0x03
4677 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004678 /* mute analog inputs */
4679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004684 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4685 /* Unmute Front out path */
4686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4688 /* Unmute Headphone out path */
4689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4691 /* Unmute Mono out path */
4692 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4693 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4694 { }
4695};
4696
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004697/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004698 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4699 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004700 */
4701static struct hda_verb alc260_fujitsu_init_verbs[] = {
4702 /* Disable all GPIOs */
4703 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4704 /* Internal speaker is connected to headphone pin */
4705 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4706 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004708 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4709 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4710 /* Ensure all other unused pins are disabled and muted. */
4711 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4712 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004713 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004714 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004715 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004716 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004719
Jonathan Woithef7ace402006-02-28 11:46:14 +01004720 /* Disable digital (SPDIF) pins */
4721 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4722 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004723
Kailang Yangea1fb292008-08-26 12:58:38 +02004724 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004725 * when acting as an output.
4726 */
4727 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4728
4729 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4731 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4736 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4738 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004739
Jonathan Woithef7ace402006-02-28 11:46:14 +01004740 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4741 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4742 /* Unmute Line1 pin widget output buffer since it starts as an output.
4743 * If the pin mode is changed by the user the pin mode control will
4744 * take care of enabling the pin's input/output buffers as needed.
4745 * Therefore there's no need to enable the input buffer at this
4746 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004747 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004749 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004750 * mixer ctrl)
4751 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004752 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004753
Jonathan Woithef7ace402006-02-28 11:46:14 +01004754 /* Mute capture amp left and right */
4755 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004756 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004757 * in (on mic1 pin)
4758 */
4759 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004760
Jonathan Woithef7ace402006-02-28 11:46:14 +01004761 /* Do the same for the second ADC: mute capture input amp and
4762 * set ADC connection to line in (on mic1 pin)
4763 */
4764 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4765 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004766
Jonathan Woithef7ace402006-02-28 11:46:14 +01004767 /* Mute all inputs to mixer widget (even unconnected ones) */
4768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4769 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4773 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4774 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4775 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004776
4777 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004778};
4779
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004780/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4781 * similar laptops (adapted from Fujitsu init verbs).
4782 */
4783static struct hda_verb alc260_acer_init_verbs[] = {
4784 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4785 * the headphone jack. Turn this on and rely on the standard mute
4786 * methods whenever the user wants to turn these outputs off.
4787 */
4788 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4789 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4790 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4791 /* Internal speaker/Headphone jack is connected to Line-out pin */
4792 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4793 /* Internal microphone/Mic jack is connected to Mic1 pin */
4794 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4795 /* Line In jack is connected to Line1 pin */
4796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004797 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4798 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004799 /* Ensure all other unused pins are disabled and muted. */
4800 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4801 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004802 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4803 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4806 /* Disable digital (SPDIF) pins */
4807 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4808 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4809
Kailang Yangea1fb292008-08-26 12:58:38 +02004810 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004811 * bus when acting as outputs.
4812 */
4813 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4814 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4815
4816 /* Start with output sum widgets muted and their output gains at min */
4817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4819 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4823 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4824 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4825 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004827 /* Unmute Line-out pin widget amp left and right
4828 * (no equiv mixer ctrl)
4829 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004830 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004831 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4832 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004833 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4834 * inputs. If the pin mode is changed by the user the pin mode control
4835 * will take care of enabling the pin's input/output buffers as needed.
4836 * Therefore there's no need to enable the input buffer at this
4837 * stage.
4838 */
4839 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4841
4842 /* Mute capture amp left and right */
4843 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4844 /* Set ADC connection select to match default mixer setting - mic
4845 * (on mic1 pin)
4846 */
4847 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4848
4849 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004850 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004851 */
4852 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004853 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004854
4855 /* Mute all inputs to mixer widget (even unconnected ones) */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4862 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4864
4865 { }
4866};
4867
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004868static struct hda_verb alc260_will_verbs[] = {
4869 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4870 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4871 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4872 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4873 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4874 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4875 {}
4876};
4877
4878static struct hda_verb alc260_replacer_672v_verbs[] = {
4879 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4880 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4881 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4882
4883 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4884 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4885 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4886
4887 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4888 {}
4889};
4890
4891/* toggle speaker-output according to the hp-jack state */
4892static void alc260_replacer_672v_automute(struct hda_codec *codec)
4893{
4894 unsigned int present;
4895
4896 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4897 present = snd_hda_codec_read(codec, 0x0f, 0,
4898 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4899 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004900 snd_hda_codec_write_cache(codec, 0x01, 0,
4901 AC_VERB_SET_GPIO_DATA, 1);
4902 snd_hda_codec_write_cache(codec, 0x0f, 0,
4903 AC_VERB_SET_PIN_WIDGET_CONTROL,
4904 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004905 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004906 snd_hda_codec_write_cache(codec, 0x01, 0,
4907 AC_VERB_SET_GPIO_DATA, 0);
4908 snd_hda_codec_write_cache(codec, 0x0f, 0,
4909 AC_VERB_SET_PIN_WIDGET_CONTROL,
4910 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004911 }
4912}
4913
4914static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4915 unsigned int res)
4916{
4917 if ((res >> 26) == ALC880_HP_EVENT)
4918 alc260_replacer_672v_automute(codec);
4919}
4920
Kailang Yang3f878302008-08-26 13:02:23 +02004921static struct hda_verb alc260_hp_dc7600_verbs[] = {
4922 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4924 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4925 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4926 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4928 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4929 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4930 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4931 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4932 {}
4933};
4934
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004935/* Test configuration for debugging, modelled after the ALC880 test
4936 * configuration.
4937 */
4938#ifdef CONFIG_SND_DEBUG
4939static hda_nid_t alc260_test_dac_nids[1] = {
4940 0x02,
4941};
4942static hda_nid_t alc260_test_adc_nids[2] = {
4943 0x04, 0x05,
4944};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004945/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004946 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004947 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004948 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004949static struct hda_input_mux alc260_test_capture_sources[2] = {
4950 {
4951 .num_items = 7,
4952 .items = {
4953 { "MIC1 pin", 0x0 },
4954 { "MIC2 pin", 0x1 },
4955 { "LINE1 pin", 0x2 },
4956 { "LINE2 pin", 0x3 },
4957 { "CD pin", 0x4 },
4958 { "LINE-OUT pin", 0x5 },
4959 { "HP-OUT pin", 0x6 },
4960 },
4961 },
4962 {
4963 .num_items = 8,
4964 .items = {
4965 { "MIC1 pin", 0x0 },
4966 { "MIC2 pin", 0x1 },
4967 { "LINE1 pin", 0x2 },
4968 { "LINE2 pin", 0x3 },
4969 { "CD pin", 0x4 },
4970 { "Mixer", 0x5 },
4971 { "LINE-OUT pin", 0x6 },
4972 { "HP-OUT pin", 0x7 },
4973 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004974 },
4975};
4976static struct snd_kcontrol_new alc260_test_mixer[] = {
4977 /* Output driver widgets */
4978 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4979 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4980 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4981 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4982 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4983 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4984
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004985 /* Modes for retasking pin widgets
4986 * Note: the ALC260 doesn't seem to act on requests to enable mic
4987 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4988 * mention this restriction. At this stage it's not clear whether
4989 * this behaviour is intentional or is a hardware bug in chip
4990 * revisions available at least up until early 2006. Therefore for
4991 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4992 * choices, but if it turns out that the lack of mic bias for these
4993 * NIDs is intentional we could change their modes from
4994 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4995 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004996 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4997 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4998 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4999 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5000 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5001 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5002
5003 /* Loopback mixer controls */
5004 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5005 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5006 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5007 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5008 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5009 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5010 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5011 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5014 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5015 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5016 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5017 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5018 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5019 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005020
5021 /* Controls for GPIO pins, assuming they are configured as outputs */
5022 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5023 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5024 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5025 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5026
Jonathan Woithe92621f12006-02-28 11:47:47 +01005027 /* Switches to allow the digital IO pins to be enabled. The datasheet
5028 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005029 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005030 */
5031 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5032 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5033
Jonathan Woithef8225f62008-01-08 12:16:54 +01005034 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5035 * this output to turn on an external amplifier.
5036 */
5037 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5038 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5039
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005040 { } /* end */
5041};
5042static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005043 /* Enable all GPIOs as outputs with an initial value of 0 */
5044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5045 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5046 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5047
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005048 /* Enable retasking pins as output, initially without power amp */
5049 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5050 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5052 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5053 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5054 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5055
Jonathan Woithe92621f12006-02-28 11:47:47 +01005056 /* Disable digital (SPDIF) pins initially, but users can enable
5057 * them via a mixer switch. In the case of SPDIF-out, this initverb
5058 * payload also sets the generation to 0, output to be in "consumer"
5059 * PCM format, copyright asserted, no pre-emphasis and no validity
5060 * control.
5061 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005062 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5063 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5064
Kailang Yangea1fb292008-08-26 12:58:38 +02005065 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005066 * OUT1 sum bus when acting as an output.
5067 */
5068 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5069 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5070 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5071 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5072
5073 /* Start with output sum widgets muted and their output gains at min */
5074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5077 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5078 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5080 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5081 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5082 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5083
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005084 /* Unmute retasking pin widget output buffers since the default
5085 * state appears to be output. As the pin mode is changed by the
5086 * user the pin mode control will take care of enabling the pin's
5087 * input/output buffers as needed.
5088 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005089 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5092 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5093 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5094 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5095 /* Also unmute the mono-out pin widget */
5096 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5097
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005098 /* Mute capture amp left and right */
5099 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005100 /* Set ADC connection select to match default mixer setting (mic1
5101 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005102 */
5103 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5104
5105 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005106 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005107 */
5108 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5109 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5110
5111 /* Mute all inputs to mixer widget (even unconnected ones) */
5112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5120
5121 { }
5122};
5123#endif
5124
Takashi Iwai63300792008-01-24 15:31:36 +01005125#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5126#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005127
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005128#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5129#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5130
Kailang Yangdf694da2005-12-05 19:42:22 +01005131/*
5132 * for BIOS auto-configuration
5133 */
5134
5135static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005136 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005137{
5138 hda_nid_t nid_vol;
5139 unsigned long vol_val, sw_val;
5140 char name[32];
5141 int err;
5142
5143 if (nid >= 0x0f && nid < 0x11) {
5144 nid_vol = nid - 0x7;
5145 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5146 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5147 } else if (nid == 0x11) {
5148 nid_vol = nid - 0x7;
5149 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5150 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5151 } else if (nid >= 0x12 && nid <= 0x15) {
5152 nid_vol = 0x08;
5153 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5154 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5155 } else
5156 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005157
Takashi Iwai863b4512008-10-21 17:01:47 +02005158 if (!(*vol_bits & (1 << nid_vol))) {
5159 /* first control for the volume widget */
5160 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5161 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5162 if (err < 0)
5163 return err;
5164 *vol_bits |= (1 << nid_vol);
5165 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005166 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005167 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5168 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 return err;
5170 return 1;
5171}
5172
5173/* add playback controls from the parsed DAC table */
5174static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5175 const struct auto_pin_cfg *cfg)
5176{
5177 hda_nid_t nid;
5178 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005179 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005180
5181 spec->multiout.num_dacs = 1;
5182 spec->multiout.dac_nids = spec->private_dac_nids;
5183 spec->multiout.dac_nids[0] = 0x02;
5184
5185 nid = cfg->line_out_pins[0];
5186 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005187 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005188 if (err < 0)
5189 return err;
5190 }
5191
Takashi Iwai82bc9552006-03-21 11:24:42 +01005192 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005194 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005195 if (err < 0)
5196 return err;
5197 }
5198
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005199 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005201 err = alc260_add_playback_controls(spec, nid, "Headphone",
5202 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005203 if (err < 0)
5204 return err;
5205 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005207}
5208
5209/* create playback/capture controls for input pins */
5210static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5211 const struct auto_pin_cfg *cfg)
5212{
Kailang Yangdf694da2005-12-05 19:42:22 +01005213 struct hda_input_mux *imux = &spec->private_imux;
5214 int i, err, idx;
5215
5216 for (i = 0; i < AUTO_PIN_LAST; i++) {
5217 if (cfg->input_pins[i] >= 0x12) {
5218 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005219 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005220 auto_pin_cfg_labels[i], idx,
5221 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005222 if (err < 0)
5223 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005224 imux->items[imux->num_items].label =
5225 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005226 imux->items[imux->num_items].index = idx;
5227 imux->num_items++;
5228 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005229 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005230 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005231 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005232 auto_pin_cfg_labels[i], idx,
5233 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005234 if (err < 0)
5235 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005236 imux->items[imux->num_items].label =
5237 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005238 imux->items[imux->num_items].index = idx;
5239 imux->num_items++;
5240 }
5241 }
5242 return 0;
5243}
5244
5245static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5246 hda_nid_t nid, int pin_type,
5247 int sel_idx)
5248{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005249 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005250 /* need the manual connection? */
5251 if (nid >= 0x12) {
5252 int idx = nid - 0x12;
5253 snd_hda_codec_write(codec, idx + 0x0b, 0,
5254 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005255 }
5256}
5257
5258static void alc260_auto_init_multi_out(struct hda_codec *codec)
5259{
5260 struct alc_spec *spec = codec->spec;
5261 hda_nid_t nid;
5262
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005263 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005264 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005265 if (nid) {
5266 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5267 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5268 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005269
Takashi Iwai82bc9552006-03-21 11:24:42 +01005270 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005271 if (nid)
5272 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5273
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005274 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005275 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005276 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005277}
Kailang Yangdf694da2005-12-05 19:42:22 +01005278
5279#define ALC260_PIN_CD_NID 0x16
5280static void alc260_auto_init_analog_input(struct hda_codec *codec)
5281{
5282 struct alc_spec *spec = codec->spec;
5283 int i;
5284
5285 for (i = 0; i < AUTO_PIN_LAST; i++) {
5286 hda_nid_t nid = spec->autocfg.input_pins[i];
5287 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005288 snd_hda_codec_write(codec, nid, 0,
5289 AC_VERB_SET_PIN_WIDGET_CONTROL,
5290 i <= AUTO_PIN_FRONT_MIC ?
5291 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005292 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005293 snd_hda_codec_write(codec, nid, 0,
5294 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005295 AMP_OUT_MUTE);
5296 }
5297 }
5298}
5299
5300/*
5301 * generic initialization of ADC, input mixers and output mixers
5302 */
5303static struct hda_verb alc260_volume_init_verbs[] = {
5304 /*
5305 * Unmute ADC0-1 and set the default input to mic-in
5306 */
5307 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005311
Kailang Yangdf694da2005-12-05 19:42:22 +01005312 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5313 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005314 * Note: PASD motherboards uses the Line In 2 as the input for
5315 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005316 */
5317 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005318 /* mute analog inputs */
5319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005324
5325 /*
5326 * Set up output mixers (0x08 - 0x0a)
5327 */
5328 /* set vol=0 to output mixers */
5329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5331 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5332 /* set up input amps for analog loopback */
5333 /* Amp Indices: DAC = 0, mixer = 1 */
5334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5338 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5339 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005340
Kailang Yangdf694da2005-12-05 19:42:22 +01005341 { }
5342};
5343
5344static int alc260_parse_auto_config(struct hda_codec *codec)
5345{
5346 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005347 int err;
5348 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5349
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005350 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5351 alc260_ignore);
5352 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005353 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005354 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5355 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005356 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005357 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005358 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005359 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5360 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005361 return err;
5362
5363 spec->multiout.max_channels = 2;
5364
5365 if (spec->autocfg.dig_out_pin)
5366 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005367 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005368 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005369
Takashi Iwaid88897e2008-10-31 15:01:37 +01005370 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005371
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005372 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005373 spec->input_mux = &spec->private_imux;
5374
Takashi Iwaie044c392008-10-27 16:56:24 +01005375 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005376 return 1;
5377}
5378
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005379/* additional initialization for auto-configuration model */
5380static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005381{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005382 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005383 alc260_auto_init_multi_out(codec);
5384 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005385 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005386 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005387}
5388
Takashi Iwaicb53c622007-08-10 17:21:45 +02005389#ifdef CONFIG_SND_HDA_POWER_SAVE
5390static struct hda_amp_list alc260_loopbacks[] = {
5391 { 0x07, HDA_INPUT, 0 },
5392 { 0x07, HDA_INPUT, 1 },
5393 { 0x07, HDA_INPUT, 2 },
5394 { 0x07, HDA_INPUT, 3 },
5395 { 0x07, HDA_INPUT, 4 },
5396 { } /* end */
5397};
5398#endif
5399
Kailang Yangdf694da2005-12-05 19:42:22 +01005400/*
5401 * ALC260 configurations
5402 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005403static const char *alc260_models[ALC260_MODEL_LAST] = {
5404 [ALC260_BASIC] = "basic",
5405 [ALC260_HP] = "hp",
5406 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005407 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005408 [ALC260_FUJITSU_S702X] = "fujitsu",
5409 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005410 [ALC260_WILL] = "will",
5411 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005412#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005413 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005414#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005415 [ALC260_AUTO] = "auto",
5416};
5417
5418static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005419 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005420 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005421 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005422 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005423 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005424 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005425 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005426 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5427 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5428 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5429 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5430 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5431 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5432 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5433 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5434 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005435 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005436 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005437 {}
5438};
5439
Kailang Yangdf694da2005-12-05 19:42:22 +01005440static struct alc_config_preset alc260_presets[] = {
5441 [ALC260_BASIC] = {
5442 .mixers = { alc260_base_output_mixer,
5443 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005444 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005445 .init_verbs = { alc260_init_verbs },
5446 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5447 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005448 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005449 .adc_nids = alc260_adc_nids,
5450 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5451 .channel_mode = alc260_modes,
5452 .input_mux = &alc260_capture_source,
5453 },
5454 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005455 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005456 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005457 .init_verbs = { alc260_init_verbs,
5458 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005459 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5460 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005461 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5462 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005463 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5464 .channel_mode = alc260_modes,
5465 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005466 .unsol_event = alc260_hp_unsol_event,
5467 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005468 },
Kailang Yang3f878302008-08-26 13:02:23 +02005469 [ALC260_HP_DC7600] = {
5470 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005471 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005472 .init_verbs = { alc260_init_verbs,
5473 alc260_hp_dc7600_verbs },
5474 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5475 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005476 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5477 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005478 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5479 .channel_mode = alc260_modes,
5480 .input_mux = &alc260_capture_source,
5481 .unsol_event = alc260_hp_3012_unsol_event,
5482 .init_hook = alc260_hp_3012_automute,
5483 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005484 [ALC260_HP_3013] = {
5485 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005486 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005487 .init_verbs = { alc260_hp_3013_init_verbs,
5488 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5490 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005491 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5492 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005493 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5494 .channel_mode = alc260_modes,
5495 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005496 .unsol_event = alc260_hp_3013_unsol_event,
5497 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005498 },
5499 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005500 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005501 .init_verbs = { alc260_fujitsu_init_verbs },
5502 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5503 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005504 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5505 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005506 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5507 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005508 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5509 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005510 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005511 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005512 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005513 .init_verbs = { alc260_acer_init_verbs },
5514 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5515 .dac_nids = alc260_dac_nids,
5516 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5517 .adc_nids = alc260_dual_adc_nids,
5518 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5519 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005520 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5521 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005522 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005523 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005524 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005525 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5526 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5527 .dac_nids = alc260_dac_nids,
5528 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5529 .adc_nids = alc260_adc_nids,
5530 .dig_out_nid = ALC260_DIGOUT_NID,
5531 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5532 .channel_mode = alc260_modes,
5533 .input_mux = &alc260_capture_source,
5534 },
5535 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005536 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005537 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5538 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5539 .dac_nids = alc260_dac_nids,
5540 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5541 .adc_nids = alc260_adc_nids,
5542 .dig_out_nid = ALC260_DIGOUT_NID,
5543 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5544 .channel_mode = alc260_modes,
5545 .input_mux = &alc260_capture_source,
5546 .unsol_event = alc260_replacer_672v_unsol_event,
5547 .init_hook = alc260_replacer_672v_automute,
5548 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005549#ifdef CONFIG_SND_DEBUG
5550 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005551 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005552 .init_verbs = { alc260_test_init_verbs },
5553 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5554 .dac_nids = alc260_test_dac_nids,
5555 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5556 .adc_nids = alc260_test_adc_nids,
5557 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5558 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005559 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5560 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005561 },
5562#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005563};
5564
Linus Torvalds1da177e2005-04-16 15:20:36 -07005565static int patch_alc260(struct hda_codec *codec)
5566{
5567 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005568 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005569
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005570 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005571 if (spec == NULL)
5572 return -ENOMEM;
5573
5574 codec->spec = spec;
5575
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005576 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5577 alc260_models,
5578 alc260_cfg_tbl);
5579 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005580 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5581 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005582 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005583 }
5584
Kailang Yangdf694da2005-12-05 19:42:22 +01005585 if (board_config == ALC260_AUTO) {
5586 /* automatic parse from the BIOS config */
5587 err = alc260_parse_auto_config(codec);
5588 if (err < 0) {
5589 alc_free(codec);
5590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005591 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005592 printk(KERN_INFO
5593 "hda_codec: Cannot set up configuration "
5594 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005595 board_config = ALC260_BASIC;
5596 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005597 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005598
Kailang Yangdf694da2005-12-05 19:42:22 +01005599 if (board_config != ALC260_AUTO)
5600 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005601
5602 spec->stream_name_analog = "ALC260 Analog";
5603 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5604 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5605
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005606 spec->stream_name_digital = "ALC260 Digital";
5607 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5608 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5609
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005610 set_capture_mixer(spec);
5611
Takashi Iwai2134ea42008-01-10 16:53:55 +01005612 spec->vmaster_nid = 0x08;
5613
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005615 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005616 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005617#ifdef CONFIG_SND_HDA_POWER_SAVE
5618 if (!spec->loopback.amplist)
5619 spec->loopback.amplist = alc260_loopbacks;
5620#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005621
5622 return 0;
5623}
5624
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005625
Linus Torvalds1da177e2005-04-16 15:20:36 -07005626/*
5627 * ALC882 support
5628 *
5629 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5630 * configuration. Each pin widget can choose any input DACs and a mixer.
5631 * Each ADC is connected from a mixer of all inputs. This makes possible
5632 * 6-channel independent captures.
5633 *
5634 * In addition, an independent DAC for the multi-playback (not used in this
5635 * driver yet).
5636 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005637#define ALC882_DIGOUT_NID 0x06
5638#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005639
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005640static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005641 { 8, NULL }
5642};
5643
5644static hda_nid_t alc882_dac_nids[4] = {
5645 /* front, rear, clfe, rear_surr */
5646 0x02, 0x03, 0x04, 0x05
5647};
5648
Kailang Yangdf694da2005-12-05 19:42:22 +01005649/* identical with ALC880 */
5650#define alc882_adc_nids alc880_adc_nids
5651#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005652
Takashi Iwaie1406342008-02-11 18:32:32 +01005653static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5654static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5655
Linus Torvalds1da177e2005-04-16 15:20:36 -07005656/* input MUX */
5657/* FIXME: should be a matrix-type input source selection */
5658
5659static struct hda_input_mux alc882_capture_source = {
5660 .num_items = 4,
5661 .items = {
5662 { "Mic", 0x0 },
5663 { "Front Mic", 0x1 },
5664 { "Line", 0x2 },
5665 { "CD", 0x4 },
5666 },
5667};
Kailang Yangdf694da2005-12-05 19:42:22 +01005668/*
Kailang Yang272a5272007-05-14 11:00:38 +02005669 * 2ch mode
5670 */
5671static struct hda_verb alc882_3ST_ch2_init[] = {
5672 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5673 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5674 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5675 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5676 { } /* end */
5677};
5678
5679/*
5680 * 6ch mode
5681 */
5682static struct hda_verb alc882_3ST_ch6_init[] = {
5683 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5684 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5685 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5688 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5689 { } /* end */
5690};
5691
5692static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5693 { 2, alc882_3ST_ch2_init },
5694 { 6, alc882_3ST_ch6_init },
5695};
5696
5697/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005698 * 6ch mode
5699 */
5700static struct hda_verb alc882_sixstack_ch6_init[] = {
5701 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5702 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5703 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5704 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5705 { } /* end */
5706};
5707
5708/*
5709 * 8ch mode
5710 */
5711static struct hda_verb alc882_sixstack_ch8_init[] = {
5712 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5713 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5714 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5715 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5716 { } /* end */
5717};
5718
5719static struct hda_channel_mode alc882_sixstack_modes[2] = {
5720 { 6, alc882_sixstack_ch6_init },
5721 { 8, alc882_sixstack_ch8_init },
5722};
5723
Takashi Iwai87350ad2007-08-16 18:19:38 +02005724/*
5725 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5726 */
5727
5728/*
5729 * 2ch mode
5730 */
5731static struct hda_verb alc885_mbp_ch2_init[] = {
5732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5733 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5734 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5735 { } /* end */
5736};
5737
5738/*
5739 * 6ch mode
5740 */
5741static struct hda_verb alc885_mbp_ch6_init[] = {
5742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5744 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5745 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5746 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5747 { } /* end */
5748};
5749
5750static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5751 { 2, alc885_mbp_ch2_init },
5752 { 6, alc885_mbp_ch6_init },
5753};
5754
5755
Linus Torvalds1da177e2005-04-16 15:20:36 -07005756/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5757 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5758 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005759static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005764 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005769 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5781 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5782 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005783 { } /* end */
5784};
5785
Takashi Iwai87350ad2007-08-16 18:19:38 +02005786static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5788 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5789 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5790 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5792 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5794 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005795 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5797 { } /* end */
5798};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005799static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5800 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5801 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
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_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5809 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5810 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5811 { } /* end */
5812};
5813
Kailang Yang272a5272007-05-14 11:00:38 +02005814static struct snd_kcontrol_new alc882_targa_mixer[] = {
5815 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5816 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5820 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5821 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005827 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005828 { } /* end */
5829};
5830
5831/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5832 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5833 */
5834static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5836 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5838 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 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("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5844 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005848 { } /* end */
5849};
5850
Takashi Iwai914759b2007-09-06 14:52:04 +02005851static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5852 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5854 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5855 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5856 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5857 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5858 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5862 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5863 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5864 { } /* end */
5865};
5866
Kailang Yangdf694da2005-12-05 19:42:22 +01005867static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5868 {
5869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5870 .name = "Channel Mode",
5871 .info = alc_ch_mode_info,
5872 .get = alc_ch_mode_get,
5873 .put = alc_ch_mode_put,
5874 },
5875 { } /* end */
5876};
5877
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878static struct hda_verb alc882_init_verbs[] = {
5879 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005883 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005887 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005892 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005896 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005899 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005900 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005903 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005904 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005905 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005906 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005907 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005908 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005909 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005910 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005911 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005912 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005913 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5915 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005916 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005917 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5918 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005919 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5921 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5923 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5924 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005925 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005926 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005927
5928 /* FIXME: use matrix-type input source selection */
5929 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5930 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005935 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5939 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005940 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5945 /* ADC1: mute amp left and right */
5946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005947 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005948 /* ADC2: mute amp left and right */
5949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005950 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005951 /* ADC3: mute amp left and right */
5952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005953 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005954
5955 { }
5956};
5957
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005958static struct hda_verb alc882_eapd_verbs[] = {
5959 /* change to EAPD mode */
5960 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005961 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005962 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005963};
5964
Tobin Davis9102cd12006-12-15 10:02:12 +01005965/* Mac Pro test */
5966static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5972 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5973 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5974 { } /* end */
5975};
5976
5977static struct hda_verb alc882_macpro_init_verbs[] = {
5978 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5982 /* Front Pin: output 0 (0x0c) */
5983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5985 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5986 /* Front Mic pin: input vref at 80% */
5987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5989 /* Speaker: output */
5990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5992 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5993 /* Headphone output (output 0 - 0x0c) */
5994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5996 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5997
5998 /* FIXME: use matrix-type input source selection */
5999 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6000 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6004 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6005 /* Input mixer2 */
6006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6010 /* Input mixer3 */
6011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6015 /* ADC1: mute amp left and right */
6016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6018 /* ADC2: mute amp left and right */
6019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6021 /* ADC3: mute amp left and right */
6022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6023 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6024
6025 { }
6026};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006027
Takashi Iwai87350ad2007-08-16 18:19:38 +02006028/* Macbook Pro rev3 */
6029static struct hda_verb alc885_mbp3_init_verbs[] = {
6030 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6031 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6034 /* Rear mixer */
6035 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6036 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6038 /* Front Pin: output 0 (0x0c) */
6039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6041 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6042 /* HP Pin: output 0 (0x0d) */
6043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6046 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6047 /* Mic (rear) pin: input vref at 80% */
6048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6050 /* Front Mic pin: input vref at 80% */
6051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6053 /* Line In pin: use output 1 when in LineOut mode */
6054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6056 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6057
6058 /* FIXME: use matrix-type input source selection */
6059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6060 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6065 /* Input mixer2 */
6066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6070 /* Input mixer3 */
6071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6075 /* ADC1: mute amp left and right */
6076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6077 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6078 /* ADC2: mute amp left and right */
6079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6080 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6081 /* ADC3: mute amp left and right */
6082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6083 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6084
6085 { }
6086};
6087
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006088/* iMac 24 mixer. */
6089static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6090 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6091 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6092 { } /* end */
6093};
6094
6095/* iMac 24 init verbs. */
6096static struct hda_verb alc885_imac24_init_verbs[] = {
6097 /* Internal speakers: output 0 (0x0c) */
6098 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6100 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6101 /* Internal speakers: output 0 (0x0c) */
6102 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6104 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6105 /* Headphone: output 0 (0x0c) */
6106 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6108 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6109 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6110 /* Front Mic: input vref at 80% */
6111 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6112 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6113 { }
6114};
6115
6116/* Toggle speaker-output according to the hp-jack state */
6117static void alc885_imac24_automute(struct hda_codec *codec)
6118{
6119 unsigned int present;
6120
6121 present = snd_hda_codec_read(codec, 0x14, 0,
6122 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006123 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6124 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6125 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6126 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006127}
6128
6129/* Processes unsolicited events. */
6130static void alc885_imac24_unsol_event(struct hda_codec *codec,
6131 unsigned int res)
6132{
6133 /* Headphone insertion or removal. */
6134 if ((res >> 26) == ALC880_HP_EVENT)
6135 alc885_imac24_automute(codec);
6136}
6137
Takashi Iwai87350ad2007-08-16 18:19:38 +02006138static void alc885_mbp3_automute(struct hda_codec *codec)
6139{
6140 unsigned int present;
6141
6142 present = snd_hda_codec_read(codec, 0x15, 0,
6143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6144 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6145 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6146 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6147 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6148
6149}
6150static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6151 unsigned int res)
6152{
6153 /* Headphone insertion or removal. */
6154 if ((res >> 26) == ALC880_HP_EVENT)
6155 alc885_mbp3_automute(codec);
6156}
6157
6158
Kailang Yang272a5272007-05-14 11:00:38 +02006159static struct hda_verb alc882_targa_verbs[] = {
6160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6162
6163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006165
Kailang Yang272a5272007-05-14 11:00:38 +02006166 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6167 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6168 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6169
6170 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6171 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6172 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6173 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6174 { } /* end */
6175};
6176
6177/* toggle speaker-output according to the hp-jack state */
6178static void alc882_targa_automute(struct hda_codec *codec)
6179{
6180 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006181
Kailang Yang272a5272007-05-14 11:00:38 +02006182 present = snd_hda_codec_read(codec, 0x14, 0,
6183 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006184 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6185 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006186 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6187 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006188}
6189
6190static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6191{
6192 /* Looks like the unsol event is incompatible with the standard
6193 * definition. 4bit tag is placed at 26 bit!
6194 */
6195 if (((res >> 26) == ALC880_HP_EVENT)) {
6196 alc882_targa_automute(codec);
6197 }
6198}
6199
6200static struct hda_verb alc882_asus_a7j_verbs[] = {
6201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6203
6204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6206 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006207
Kailang Yang272a5272007-05-14 11:00:38 +02006208 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6210 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6211
6212 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6213 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6214 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6215 { } /* end */
6216};
6217
Takashi Iwai914759b2007-09-06 14:52:04 +02006218static struct hda_verb alc882_asus_a7m_verbs[] = {
6219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6221
6222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006225
Takashi Iwai914759b2007-09-06 14:52:04 +02006226 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6228 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6229
6230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6233 { } /* end */
6234};
6235
Tobin Davis9102cd12006-12-15 10:02:12 +01006236static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6237{
6238 unsigned int gpiostate, gpiomask, gpiodir;
6239
6240 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6241 AC_VERB_GET_GPIO_DATA, 0);
6242
6243 if (!muted)
6244 gpiostate |= (1 << pin);
6245 else
6246 gpiostate &= ~(1 << pin);
6247
6248 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6249 AC_VERB_GET_GPIO_MASK, 0);
6250 gpiomask |= (1 << pin);
6251
6252 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6253 AC_VERB_GET_GPIO_DIRECTION, 0);
6254 gpiodir |= (1 << pin);
6255
6256
6257 snd_hda_codec_write(codec, codec->afg, 0,
6258 AC_VERB_SET_GPIO_MASK, gpiomask);
6259 snd_hda_codec_write(codec, codec->afg, 0,
6260 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6261
6262 msleep(1);
6263
6264 snd_hda_codec_write(codec, codec->afg, 0,
6265 AC_VERB_SET_GPIO_DATA, gpiostate);
6266}
6267
Takashi Iwai7debbe52007-08-16 15:01:03 +02006268/* set up GPIO at initialization */
6269static void alc885_macpro_init_hook(struct hda_codec *codec)
6270{
6271 alc882_gpio_mute(codec, 0, 0);
6272 alc882_gpio_mute(codec, 1, 0);
6273}
6274
6275/* set up GPIO and update auto-muting at initialization */
6276static void alc885_imac24_init_hook(struct hda_codec *codec)
6277{
6278 alc885_macpro_init_hook(codec);
6279 alc885_imac24_automute(codec);
6280}
6281
Kailang Yangdf694da2005-12-05 19:42:22 +01006282/*
6283 * generic initialization of ADC, input mixers and output mixers
6284 */
6285static struct hda_verb alc882_auto_init_verbs[] = {
6286 /*
6287 * Unmute ADC0-2 and set the default input to mic-in
6288 */
6289 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6291 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6293 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6295
Takashi Iwaicb53c622007-08-10 17:21:45 +02006296 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006298 * Note: PASD motherboards uses the Line In 2 as the input for
6299 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006300 */
6301 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006307
6308 /*
6309 * Set up output mixers (0x0c - 0x0f)
6310 */
6311 /* set vol=0 to output mixers */
6312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6316 /* set up input amps for analog loopback */
6317 /* Amp Indices: DAC = 0, mixer = 1 */
6318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6326 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6327 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6328
6329 /* FIXME: use matrix-type input source selection */
6330 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6331 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6336 /* Input mixer2 */
6337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6341 /* Input mixer3 */
6342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6346
6347 { }
6348};
6349
Takashi Iwaicb53c622007-08-10 17:21:45 +02006350#ifdef CONFIG_SND_HDA_POWER_SAVE
6351#define alc882_loopbacks alc880_loopbacks
6352#endif
6353
Kailang Yangdf694da2005-12-05 19:42:22 +01006354/* pcm configuration: identiacal with ALC880 */
6355#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6356#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6357#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6358#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6359
6360/*
6361 * configuration and preset
6362 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006363static const char *alc882_models[ALC882_MODEL_LAST] = {
6364 [ALC882_3ST_DIG] = "3stack-dig",
6365 [ALC882_6ST_DIG] = "6stack-dig",
6366 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006367 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006368 [ALC882_TARGA] = "targa",
6369 [ALC882_ASUS_A7J] = "asus-a7j",
6370 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006371 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006372 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006373 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006374 [ALC882_AUTO] = "auto",
6375};
6376
6377static struct snd_pci_quirk alc882_cfg_tbl[] = {
6378 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006379 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006380 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006381 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006382 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006383 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006384 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006385 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006386 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006387 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6388 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6389 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006390 {}
6391};
6392
6393static struct alc_config_preset alc882_presets[] = {
6394 [ALC882_3ST_DIG] = {
6395 .mixers = { alc882_base_mixer },
6396 .init_verbs = { alc882_init_verbs },
6397 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6398 .dac_nids = alc882_dac_nids,
6399 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006400 .dig_in_nid = ALC882_DIGIN_NID,
6401 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6402 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006403 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006404 .input_mux = &alc882_capture_source,
6405 },
6406 [ALC882_6ST_DIG] = {
6407 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6408 .init_verbs = { alc882_init_verbs },
6409 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6410 .dac_nids = alc882_dac_nids,
6411 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006412 .dig_in_nid = ALC882_DIGIN_NID,
6413 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6414 .channel_mode = alc882_sixstack_modes,
6415 .input_mux = &alc882_capture_source,
6416 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006417 [ALC882_ARIMA] = {
6418 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6419 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6420 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6421 .dac_nids = alc882_dac_nids,
6422 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6423 .channel_mode = alc882_sixstack_modes,
6424 .input_mux = &alc882_capture_source,
6425 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006426 [ALC882_W2JC] = {
6427 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6428 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6429 alc880_gpio1_init_verbs },
6430 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6431 .dac_nids = alc882_dac_nids,
6432 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6433 .channel_mode = alc880_threestack_modes,
6434 .need_dac_fix = 1,
6435 .input_mux = &alc882_capture_source,
6436 .dig_out_nid = ALC882_DIGOUT_NID,
6437 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006438 [ALC885_MBP3] = {
6439 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6440 .init_verbs = { alc885_mbp3_init_verbs,
6441 alc880_gpio1_init_verbs },
6442 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6443 .dac_nids = alc882_dac_nids,
6444 .channel_mode = alc885_mbp_6ch_modes,
6445 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6446 .input_mux = &alc882_capture_source,
6447 .dig_out_nid = ALC882_DIGOUT_NID,
6448 .dig_in_nid = ALC882_DIGIN_NID,
6449 .unsol_event = alc885_mbp3_unsol_event,
6450 .init_hook = alc885_mbp3_automute,
6451 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006452 [ALC885_MACPRO] = {
6453 .mixers = { alc882_macpro_mixer },
6454 .init_verbs = { alc882_macpro_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6456 .dac_nids = alc882_dac_nids,
6457 .dig_out_nid = ALC882_DIGOUT_NID,
6458 .dig_in_nid = ALC882_DIGIN_NID,
6459 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6460 .channel_mode = alc882_ch_modes,
6461 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006462 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006463 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006464 [ALC885_IMAC24] = {
6465 .mixers = { alc885_imac24_mixer },
6466 .init_verbs = { alc885_imac24_init_verbs },
6467 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6468 .dac_nids = alc882_dac_nids,
6469 .dig_out_nid = ALC882_DIGOUT_NID,
6470 .dig_in_nid = ALC882_DIGIN_NID,
6471 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6472 .channel_mode = alc882_ch_modes,
6473 .input_mux = &alc882_capture_source,
6474 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006475 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006476 },
Kailang Yang272a5272007-05-14 11:00:38 +02006477 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006478 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006479 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6480 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6481 .dac_nids = alc882_dac_nids,
6482 .dig_out_nid = ALC882_DIGOUT_NID,
6483 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6484 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006485 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006486 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6487 .channel_mode = alc882_3ST_6ch_modes,
6488 .need_dac_fix = 1,
6489 .input_mux = &alc882_capture_source,
6490 .unsol_event = alc882_targa_unsol_event,
6491 .init_hook = alc882_targa_automute,
6492 },
6493 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006494 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006495 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6496 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6497 .dac_nids = alc882_dac_nids,
6498 .dig_out_nid = ALC882_DIGOUT_NID,
6499 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6500 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006501 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006502 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6503 .channel_mode = alc882_3ST_6ch_modes,
6504 .need_dac_fix = 1,
6505 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006506 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006507 [ALC882_ASUS_A7M] = {
6508 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6509 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6510 alc880_gpio1_init_verbs,
6511 alc882_asus_a7m_verbs },
6512 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6513 .dac_nids = alc882_dac_nids,
6514 .dig_out_nid = ALC882_DIGOUT_NID,
6515 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6516 .channel_mode = alc880_threestack_modes,
6517 .need_dac_fix = 1,
6518 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006519 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006520};
6521
6522
6523/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006524 * Pin config fixes
6525 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006526enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006527 PINFIX_ABIT_AW9D_MAX
6528};
6529
6530static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6531 { 0x15, 0x01080104 }, /* side */
6532 { 0x16, 0x01011012 }, /* rear */
6533 { 0x17, 0x01016011 }, /* clfe */
6534 { }
6535};
6536
6537static const struct alc_pincfg *alc882_pin_fixes[] = {
6538 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6539};
6540
6541static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6542 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6543 {}
6544};
6545
6546/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006547 * BIOS auto configuration
6548 */
6549static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6550 hda_nid_t nid, int pin_type,
6551 int dac_idx)
6552{
6553 /* set as output */
6554 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006555 int idx;
6556
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006557 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006558 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6559 idx = 4;
6560 else
6561 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006562 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6563
6564}
6565
6566static void alc882_auto_init_multi_out(struct hda_codec *codec)
6567{
6568 struct alc_spec *spec = codec->spec;
6569 int i;
6570
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006571 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006572 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006573 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006574 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006575 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006576 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006577 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006578 }
6579}
6580
6581static void alc882_auto_init_hp_out(struct hda_codec *codec)
6582{
6583 struct alc_spec *spec = codec->spec;
6584 hda_nid_t pin;
6585
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006586 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006587 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006588 /* use dac 0 */
6589 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006590 pin = spec->autocfg.speaker_pins[0];
6591 if (pin)
6592 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006593}
6594
6595#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6596#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6597
6598static void alc882_auto_init_analog_input(struct hda_codec *codec)
6599{
6600 struct alc_spec *spec = codec->spec;
6601 int i;
6602
6603 for (i = 0; i < AUTO_PIN_LAST; i++) {
6604 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006605 unsigned int vref;
6606 if (!nid)
6607 continue;
6608 vref = PIN_IN;
6609 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006610 unsigned int pincap;
6611 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6612 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006613 AC_PINCAP_VREF_80)
6614 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006615 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006616 snd_hda_codec_write(codec, nid, 0,
6617 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6618 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6619 snd_hda_codec_write(codec, nid, 0,
6620 AC_VERB_SET_AMP_GAIN_MUTE,
6621 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006622 }
6623}
6624
Takashi Iwaif511b012008-08-15 16:46:42 +02006625static void alc882_auto_init_input_src(struct hda_codec *codec)
6626{
6627 struct alc_spec *spec = codec->spec;
6628 const struct hda_input_mux *imux = spec->input_mux;
6629 int c;
6630
6631 for (c = 0; c < spec->num_adc_nids; c++) {
6632 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6633 hda_nid_t nid = spec->capsrc_nids[c];
6634 int conns, mute, idx, item;
6635
6636 conns = snd_hda_get_connections(codec, nid, conn_list,
6637 ARRAY_SIZE(conn_list));
6638 if (conns < 0)
6639 continue;
6640 for (idx = 0; idx < conns; idx++) {
6641 /* if the current connection is the selected one,
6642 * unmute it as default - otherwise mute it
6643 */
6644 mute = AMP_IN_MUTE(idx);
6645 for (item = 0; item < imux->num_items; item++) {
6646 if (imux->items[item].index == idx) {
6647 if (spec->cur_mux[c] == item)
6648 mute = AMP_IN_UNMUTE(idx);
6649 break;
6650 }
6651 }
6652 snd_hda_codec_write(codec, nid, 0,
6653 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6654 }
6655 }
6656}
6657
Takashi Iwai776e1842007-08-29 15:07:11 +02006658/* add mic boosts if needed */
6659static int alc_auto_add_mic_boost(struct hda_codec *codec)
6660{
6661 struct alc_spec *spec = codec->spec;
6662 int err;
6663 hda_nid_t nid;
6664
6665 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006666 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006667 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6668 "Mic Boost",
6669 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6670 if (err < 0)
6671 return err;
6672 }
6673 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006674 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006675 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6676 "Front Mic Boost",
6677 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6678 if (err < 0)
6679 return err;
6680 }
6681 return 0;
6682}
6683
Kailang Yangdf694da2005-12-05 19:42:22 +01006684/* almost identical with ALC880 parser... */
6685static int alc882_parse_auto_config(struct hda_codec *codec)
6686{
6687 struct alc_spec *spec = codec->spec;
6688 int err = alc880_parse_auto_config(codec);
6689
6690 if (err < 0)
6691 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006692 else if (!err)
6693 return 0; /* no config found */
6694
6695 err = alc_auto_add_mic_boost(codec);
6696 if (err < 0)
6697 return err;
6698
6699 /* hack - override the init verbs */
6700 spec->init_verbs[0] = alc882_auto_init_verbs;
6701
6702 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006703}
6704
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006705/* additional initialization for auto-configuration model */
6706static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006707{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006708 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006709 alc882_auto_init_multi_out(codec);
6710 alc882_auto_init_hp_out(codec);
6711 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006712 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006713 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006714 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006715}
6716
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006717static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6718
Linus Torvalds1da177e2005-04-16 15:20:36 -07006719static int patch_alc882(struct hda_codec *codec)
6720{
6721 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006722 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006724 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006725 if (spec == NULL)
6726 return -ENOMEM;
6727
Linus Torvalds1da177e2005-04-16 15:20:36 -07006728 codec->spec = spec;
6729
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006730 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6731 alc882_models,
6732 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006733
Kailang Yangdf694da2005-12-05 19:42:22 +01006734 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006735 /* Pick up systems that don't supply PCI SSID */
6736 switch (codec->subsystem_id) {
6737 case 0x106b0c00: /* Mac Pro */
6738 board_config = ALC885_MACPRO;
6739 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006740 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006741 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006742 board_config = ALC885_IMAC24;
6743 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006744 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006745 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006746 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006747 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006748 board_config = ALC885_MBP3;
6749 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006750 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006751 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006752 if (codec->revision_id == 0x100101 ||
6753 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006754 alc_free(codec);
6755 return patch_alc883(codec);
6756 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006757 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6758 "trying auto-probe from BIOS...\n");
6759 board_config = ALC882_AUTO;
6760 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006761 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006762
Takashi Iwaif95474e2007-07-10 00:47:43 +02006763 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6764
Kailang Yangdf694da2005-12-05 19:42:22 +01006765 if (board_config == ALC882_AUTO) {
6766 /* automatic parse from the BIOS config */
6767 err = alc882_parse_auto_config(codec);
6768 if (err < 0) {
6769 alc_free(codec);
6770 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006771 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006772 printk(KERN_INFO
6773 "hda_codec: Cannot set up configuration "
6774 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006775 board_config = ALC882_3ST_DIG;
6776 }
6777 }
6778
6779 if (board_config != ALC882_AUTO)
6780 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006781
Kailang Yang2f893282008-05-27 12:14:47 +02006782 if (codec->vendor_id == 0x10ec0885) {
6783 spec->stream_name_analog = "ALC885 Analog";
6784 spec->stream_name_digital = "ALC885 Digital";
6785 } else {
6786 spec->stream_name_analog = "ALC882 Analog";
6787 spec->stream_name_digital = "ALC882 Digital";
6788 }
6789
Kailang Yangdf694da2005-12-05 19:42:22 +01006790 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6791 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006792 /* FIXME: setup DAC5 */
6793 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6794 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006795
Kailang Yangdf694da2005-12-05 19:42:22 +01006796 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6797 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006798
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01006799 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006800 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006802 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006803 /* get type */
6804 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006805 if (wcap != AC_WID_AUD_IN) {
6806 spec->adc_nids = alc882_adc_nids_alt;
6807 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006808 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01006809 } else {
6810 spec->adc_nids = alc882_adc_nids;
6811 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006812 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006813 }
6814 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006815 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006816
Takashi Iwai2134ea42008-01-10 16:53:55 +01006817 spec->vmaster_nid = 0x0c;
6818
Linus Torvalds1da177e2005-04-16 15:20:36 -07006819 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006821 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006822#ifdef CONFIG_SND_HDA_POWER_SAVE
6823 if (!spec->loopback.amplist)
6824 spec->loopback.amplist = alc882_loopbacks;
6825#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006826
6827 return 0;
6828}
6829
6830/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006831 * ALC883 support
6832 *
6833 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6834 * configuration. Each pin widget can choose any input DACs and a mixer.
6835 * Each ADC is connected from a mixer of all inputs. This makes possible
6836 * 6-channel independent captures.
6837 *
6838 * In addition, an independent DAC for the multi-playback (not used in this
6839 * driver yet).
6840 */
6841#define ALC883_DIGOUT_NID 0x06
6842#define ALC883_DIGIN_NID 0x0a
6843
6844static hda_nid_t alc883_dac_nids[4] = {
6845 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006846 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006847};
6848
6849static hda_nid_t alc883_adc_nids[2] = {
6850 /* ADC1-2 */
6851 0x08, 0x09,
6852};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006853
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006854static hda_nid_t alc883_adc_nids_alt[1] = {
6855 /* ADC1 */
6856 0x08,
6857};
6858
Takashi Iwaie1406342008-02-11 18:32:32 +01006859static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6860
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006861/* input MUX */
6862/* FIXME: should be a matrix-type input source selection */
6863
6864static struct hda_input_mux alc883_capture_source = {
6865 .num_items = 4,
6866 .items = {
6867 { "Mic", 0x0 },
6868 { "Front Mic", 0x1 },
6869 { "Line", 0x2 },
6870 { "CD", 0x4 },
6871 },
6872};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006873
Jiang zhe17bba1b2008-06-04 12:11:07 +02006874static struct hda_input_mux alc883_3stack_6ch_intel = {
6875 .num_items = 4,
6876 .items = {
6877 { "Mic", 0x1 },
6878 { "Front Mic", 0x0 },
6879 { "Line", 0x2 },
6880 { "CD", 0x4 },
6881 },
6882};
6883
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006884static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6885 .num_items = 2,
6886 .items = {
6887 { "Mic", 0x1 },
6888 { "Line", 0x2 },
6889 },
6890};
6891
Kailang Yang272a5272007-05-14 11:00:38 +02006892static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6893 .num_items = 4,
6894 .items = {
6895 { "Mic", 0x0 },
6896 { "iMic", 0x1 },
6897 { "Line", 0x2 },
6898 { "CD", 0x4 },
6899 },
6900};
6901
Jiang zhefb97dc62008-03-06 11:07:11 +01006902static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6903 .num_items = 2,
6904 .items = {
6905 { "Mic", 0x0 },
6906 { "Int Mic", 0x1 },
6907 },
6908};
6909
Kailang Yange2757d52008-08-26 13:17:46 +02006910static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6911 .num_items = 3,
6912 .items = {
6913 { "Mic", 0x0 },
6914 { "Front Mic", 0x1 },
6915 { "Line", 0x4 },
6916 },
6917};
6918
6919static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6920 .num_items = 2,
6921 .items = {
6922 { "Mic", 0x0 },
6923 { "Line", 0x2 },
6924 },
6925};
6926
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006927/*
6928 * 2ch mode
6929 */
6930static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6931 { 2, NULL }
6932};
6933
6934/*
6935 * 2ch mode
6936 */
6937static struct hda_verb alc883_3ST_ch2_init[] = {
6938 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6939 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6940 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6941 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6942 { } /* end */
6943};
6944
6945/*
Tobin Davisb2011312007-09-17 12:45:11 +02006946 * 4ch mode
6947 */
6948static struct hda_verb alc883_3ST_ch4_init[] = {
6949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6951 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6952 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6953 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6954 { } /* end */
6955};
6956
6957/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006958 * 6ch mode
6959 */
6960static struct hda_verb alc883_3ST_ch6_init[] = {
6961 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6962 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6963 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6964 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6965 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6966 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6967 { } /* end */
6968};
6969
Tobin Davisb2011312007-09-17 12:45:11 +02006970static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006971 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006972 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006973 { 6, alc883_3ST_ch6_init },
6974};
6975
6976/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006977 * 2ch mode
6978 */
6979static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6980 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6981 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6982 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6983 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6984 { } /* end */
6985};
6986
6987/*
6988 * 4ch mode
6989 */
6990static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6991 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6992 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6993 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6994 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6995 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6996 { } /* end */
6997};
6998
6999/*
7000 * 6ch mode
7001 */
7002static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7003 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7004 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7005 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7006 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7007 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7008 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7009 { } /* end */
7010};
7011
7012static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7013 { 2, alc883_3ST_ch2_intel_init },
7014 { 4, alc883_3ST_ch4_intel_init },
7015 { 6, alc883_3ST_ch6_intel_init },
7016};
7017
7018/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007019 * 6ch mode
7020 */
7021static struct hda_verb alc883_sixstack_ch6_init[] = {
7022 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7023 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7024 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7025 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7026 { } /* end */
7027};
7028
7029/*
7030 * 8ch mode
7031 */
7032static struct hda_verb alc883_sixstack_ch8_init[] = {
7033 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7034 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7035 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7036 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7037 { } /* end */
7038};
7039
7040static struct hda_channel_mode alc883_sixstack_modes[2] = {
7041 { 6, alc883_sixstack_ch6_init },
7042 { 8, alc883_sixstack_ch8_init },
7043};
7044
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007045static struct hda_verb alc883_medion_eapd_verbs[] = {
7046 /* eanable EAPD on medion laptop */
7047 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7048 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7049 { }
7050};
7051
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007052/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7053 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7054 */
7055
7056static struct snd_kcontrol_new alc883_base_mixer[] = {
7057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7060 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7061 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7066 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7078 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7079 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007080 { } /* end */
7081};
7082
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007083static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7086 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7089 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7095 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007097 { } /* end */
7098};
7099
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007100static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007101 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7102 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7104 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7106 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7109 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7110 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007111 { } /* end */
7112};
7113
Jiang zhefb97dc62008-03-06 11:07:11 +01007114static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7116 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7118 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7120 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7122 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7123 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7124 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007125 { } /* end */
7126};
7127
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007128static struct snd_kcontrol_new alc883_3ST_2ch_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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007140 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7142 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7143 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007144 { } /* end */
7145};
7146
7147static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7148 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7149 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7150 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7151 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7152 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7153 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7154 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7155 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007165 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007169 { } /* end */
7170};
7171
Jiang zhe17bba1b2008-06-04 12:11:07 +02007172static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7174 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7176 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7177 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7178 HDA_OUTPUT),
7179 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7180 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7181 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7182 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7183 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7184 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7191 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7192 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7193 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7194 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007195 { } /* end */
7196};
7197
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007198static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007200 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007201 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007202 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7210 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7211 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007213 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007216 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007217 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7218 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7219 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007220 { } /* end */
7221};
7222
Kailang Yangccc656c2006-10-17 12:32:26 +02007223static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7226 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7227 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7228 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7229 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7230 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7231 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7232 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007238 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007240 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007241};
Kailang Yangccc656c2006-10-17 12:32:26 +02007242
7243static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7244 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7246 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7247 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7248 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007250 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007251 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007252 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7253 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7254 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007255 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007256};
Kailang Yangccc656c2006-10-17 12:32:26 +02007257
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007258static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007261 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7262 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007267 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007268};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007269
Kailang Yang272a5272007-05-14 11:00:38 +02007270static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7271 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7272 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7278 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7279 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007280 { } /* end */
7281};
7282
7283static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7285 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7286 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7287 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7288 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007293 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007294};
Kailang Yang272a5272007-05-14 11:00:38 +02007295
Tobin Davis2880a862007-08-07 11:50:26 +02007296static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007297 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7298 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7301 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007305 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007306};
Tobin Davis2880a862007-08-07 11:50:26 +02007307
Kailang Yange2757d52008-08-26 13:17:46 +02007308static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7310 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7311 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7312 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7313 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7314 0x0d, 1, 0x0, HDA_OUTPUT),
7315 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7316 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7317 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7318 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7319 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7320 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7321 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7322 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7323 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7324 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7325 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7327 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7329 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007332 { } /* end */
7333};
7334
7335static struct hda_bind_ctls alc883_bind_cap_vol = {
7336 .ops = &snd_hda_bind_vol,
7337 .values = {
7338 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7339 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7340 0
7341 },
7342};
7343
7344static struct hda_bind_ctls alc883_bind_cap_switch = {
7345 .ops = &snd_hda_bind_sw,
7346 .values = {
7347 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7348 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7349 0
7350 },
7351};
7352
7353static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7355 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7356 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007362 { } /* end */
7363};
7364
7365static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007366 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7367 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7368 {
7369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7370 /* .name = "Capture Source", */
7371 .name = "Input Source",
7372 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007373 .info = alc_mux_enum_info,
7374 .get = alc_mux_enum_get,
7375 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007376 },
7377 { } /* end */
7378};
7379
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007380static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7381 {
7382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7383 .name = "Channel Mode",
7384 .info = alc_ch_mode_info,
7385 .get = alc_ch_mode_get,
7386 .put = alc_ch_mode_put,
7387 },
7388 { } /* end */
7389};
7390
7391static struct hda_verb alc883_init_verbs[] = {
7392 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007394 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7395 /* ADC2: mute amp left and right */
7396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7398 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7402 /* Rear mixer */
7403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7406 /* CLFE mixer */
7407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7408 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7409 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7410 /* Side mixer */
7411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7413 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7414
Takashi Iwaicb53c622007-08-10 17:21:45 +02007415 /* mute analog input loopbacks */
7416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007421
7422 /* Front Pin: output 0 (0x0c) */
7423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7425 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7426 /* Rear Pin: output 1 (0x0d) */
7427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7429 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7430 /* CLFE Pin: output 2 (0x0e) */
7431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7432 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7433 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7434 /* Side Pin: output 3 (0x0f) */
7435 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7436 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7437 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7438 /* Mic (rear) pin: input vref at 80% */
7439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7441 /* Front Mic pin: input vref at 80% */
7442 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7444 /* Line In pin: input */
7445 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7446 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7447 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7451 /* CD pin widget for input */
7452 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7453
7454 /* FIXME: use matrix-type input source selection */
7455 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7456 /* Input mixer2 */
7457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007461 /* Input mixer3 */
7462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007466 { }
7467};
7468
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007469/* toggle speaker-output according to the hp-jack state */
7470static void alc883_mitac_hp_automute(struct hda_codec *codec)
7471{
7472 unsigned int present;
7473
7474 present = snd_hda_codec_read(codec, 0x15, 0,
7475 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7476 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7477 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7478 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7479 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7480}
7481
7482/* auto-toggle front mic */
7483/*
7484static void alc883_mitac_mic_automute(struct hda_codec *codec)
7485{
7486 unsigned int present;
7487 unsigned char bits;
7488
7489 present = snd_hda_codec_read(codec, 0x18, 0,
7490 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7491 bits = present ? HDA_AMP_MUTE : 0;
7492 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7493}
7494*/
7495
7496static void alc883_mitac_automute(struct hda_codec *codec)
7497{
7498 alc883_mitac_hp_automute(codec);
7499 /* alc883_mitac_mic_automute(codec); */
7500}
7501
7502static void alc883_mitac_unsol_event(struct hda_codec *codec,
7503 unsigned int res)
7504{
7505 switch (res >> 26) {
7506 case ALC880_HP_EVENT:
7507 alc883_mitac_hp_automute(codec);
7508 break;
7509 case ALC880_MIC_EVENT:
7510 /* alc883_mitac_mic_automute(codec); */
7511 break;
7512 }
7513}
7514
7515static struct hda_verb alc883_mitac_verbs[] = {
7516 /* HP */
7517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7519 /* Subwoofer */
7520 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7521 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7522
7523 /* enable unsolicited event */
7524 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7525 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7526
7527 { } /* end */
7528};
7529
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007530static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007531 /* HP */
7532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7534 /* Int speaker */
7535 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7537
7538 /* enable unsolicited event */
7539 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007540 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007541
7542 { } /* end */
7543};
7544
Jiang zhefb97dc62008-03-06 11:07:11 +01007545static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7546 /* HP */
7547 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7549 /* Subwoofer */
7550 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7552
7553 /* enable unsolicited event */
7554 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7555
7556 { } /* end */
7557};
7558
Kailang Yangccc656c2006-10-17 12:32:26 +02007559static struct hda_verb alc883_tagra_verbs[] = {
7560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7562
7563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7564 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007565
Kailang Yangccc656c2006-10-17 12:32:26 +02007566 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7568 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7569
7570 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007571 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7572 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7573 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007574
7575 { } /* end */
7576};
7577
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007578static struct hda_verb alc883_lenovo_101e_verbs[] = {
7579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7580 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7582 { } /* end */
7583};
7584
Kailang Yang272a5272007-05-14 11:00:38 +02007585static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7588 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7590 { } /* end */
7591};
7592
7593static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7597 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7598 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7599 { } /* end */
7600};
7601
Kailang Yang189609a2007-08-20 11:31:23 +02007602static struct hda_verb alc883_haier_w66_verbs[] = {
7603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7605
7606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7607
7608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7609 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7610 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7611 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7612 { } /* end */
7613};
7614
Kailang Yange2757d52008-08-26 13:17:46 +02007615static struct hda_verb alc888_lenovo_sky_verbs[] = {
7616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7621 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7622 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7623 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7624 { } /* end */
7625};
7626
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007627static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007628 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007629 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7630 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007631 { }
7632};
7633
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007634static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007635 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7636 { }
7637};
7638
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007639static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7642 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7643 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7644 { }
7645};
7646
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007647static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7650 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7651 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7652 { }
7653};
7654
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007655static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7656 { 2, alc888_3st_hp_2ch_init },
7657 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007658};
7659
Kailang Yang272a5272007-05-14 11:00:38 +02007660/* toggle front-jack and RCA according to the hp-jack state */
7661static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7662{
7663 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007664
Kailang Yang272a5272007-05-14 11:00:38 +02007665 present = snd_hda_codec_read(codec, 0x1b, 0,
7666 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007667 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7668 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7669 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7670 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007671}
7672
7673/* toggle RCA according to the front-jack state */
7674static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7675{
7676 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007677
Kailang Yang272a5272007-05-14 11:00:38 +02007678 present = snd_hda_codec_read(codec, 0x14, 0,
7679 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007680 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7681 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007682}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007683
Kailang Yang272a5272007-05-14 11:00:38 +02007684static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7685 unsigned int res)
7686{
7687 if ((res >> 26) == ALC880_HP_EVENT)
7688 alc888_lenovo_ms7195_front_automute(codec);
7689 if ((res >> 26) == ALC880_FRONT_EVENT)
7690 alc888_lenovo_ms7195_rca_automute(codec);
7691}
7692
7693static struct hda_verb alc883_medion_md2_verbs[] = {
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7696
7697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7698
7699 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7700 { } /* end */
7701};
7702
7703/* toggle speaker-output according to the hp-jack state */
7704static void alc883_medion_md2_automute(struct hda_codec *codec)
7705{
7706 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007707
Kailang Yang272a5272007-05-14 11:00:38 +02007708 present = snd_hda_codec_read(codec, 0x14, 0,
7709 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007710 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7711 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007712}
7713
7714static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7715 unsigned int res)
7716{
7717 if ((res >> 26) == ALC880_HP_EVENT)
7718 alc883_medion_md2_automute(codec);
7719}
7720
Kailang Yangccc656c2006-10-17 12:32:26 +02007721/* toggle speaker-output according to the hp-jack state */
7722static void alc883_tagra_automute(struct hda_codec *codec)
7723{
7724 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007725 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007726
7727 present = snd_hda_codec_read(codec, 0x14, 0,
7728 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007729 bits = present ? HDA_AMP_MUTE : 0;
7730 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7731 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007732 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7733 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007734}
7735
7736static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7737{
7738 if ((res >> 26) == ALC880_HP_EVENT)
7739 alc883_tagra_automute(codec);
7740}
7741
Jiang zhe368c7a92008-03-04 11:20:33 +01007742/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007743static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007744{
7745 unsigned int present;
7746 unsigned char bits;
7747
7748 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7749 & AC_PINSENSE_PRESENCE;
7750 bits = present ? HDA_AMP_MUTE : 0;
7751 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7752 HDA_AMP_MUTE, bits);
7753}
7754
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007755static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7756{
7757 unsigned int present;
7758
7759 present = snd_hda_codec_read(codec, 0x18, 0,
7760 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7761 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7762 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7763}
7764
7765static void alc883_clevo_m720_automute(struct hda_codec *codec)
7766{
7767 alc883_clevo_m720_hp_automute(codec);
7768 alc883_clevo_m720_mic_automute(codec);
7769}
7770
7771static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007772 unsigned int res)
7773{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007774 switch (res >> 26) {
7775 case ALC880_HP_EVENT:
7776 alc883_clevo_m720_hp_automute(codec);
7777 break;
7778 case ALC880_MIC_EVENT:
7779 alc883_clevo_m720_mic_automute(codec);
7780 break;
7781 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007782}
7783
Jiang zhefb97dc62008-03-06 11:07:11 +01007784/* toggle speaker-output according to the hp-jack state */
7785static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7786{
7787 unsigned int present;
7788 unsigned char bits;
7789
7790 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7791 & AC_PINSENSE_PRESENCE;
7792 bits = present ? HDA_AMP_MUTE : 0;
7793 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7794 HDA_AMP_MUTE, bits);
7795}
7796
7797static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7798 unsigned int res)
7799{
7800 if ((res >> 26) == ALC880_HP_EVENT)
7801 alc883_2ch_fujitsu_pi2515_automute(codec);
7802}
7803
Kailang Yang189609a2007-08-20 11:31:23 +02007804static void alc883_haier_w66_automute(struct hda_codec *codec)
7805{
7806 unsigned int present;
7807 unsigned char bits;
7808
7809 present = snd_hda_codec_read(codec, 0x1b, 0,
7810 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7811 bits = present ? 0x80 : 0;
7812 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7813 0x80, bits);
7814}
7815
7816static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7817 unsigned int res)
7818{
7819 if ((res >> 26) == ALC880_HP_EVENT)
7820 alc883_haier_w66_automute(codec);
7821}
7822
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007823static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7824{
7825 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007826 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007827
7828 present = snd_hda_codec_read(codec, 0x14, 0,
7829 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007830 bits = present ? HDA_AMP_MUTE : 0;
7831 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7832 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007833}
7834
7835static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7836{
7837 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007838 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007839
7840 present = snd_hda_codec_read(codec, 0x1b, 0,
7841 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007842 bits = present ? HDA_AMP_MUTE : 0;
7843 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7844 HDA_AMP_MUTE, bits);
7845 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7846 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007847}
7848
7849static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7850 unsigned int res)
7851{
7852 if ((res >> 26) == ALC880_HP_EVENT)
7853 alc883_lenovo_101e_all_automute(codec);
7854 if ((res >> 26) == ALC880_FRONT_EVENT)
7855 alc883_lenovo_101e_ispeaker_automute(codec);
7856}
7857
Takashi Iwai676a9b52007-08-16 15:23:35 +02007858/* toggle speaker-output according to the hp-jack state */
7859static void alc883_acer_aspire_automute(struct hda_codec *codec)
7860{
7861 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007862
Takashi Iwai676a9b52007-08-16 15:23:35 +02007863 present = snd_hda_codec_read(codec, 0x14, 0,
7864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7865 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7866 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7867 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7868 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7869}
7870
7871static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7872 unsigned int res)
7873{
7874 if ((res >> 26) == ALC880_HP_EVENT)
7875 alc883_acer_aspire_automute(codec);
7876}
7877
Kailang Yangd1a991a2007-08-15 16:21:59 +02007878static struct hda_verb alc883_acer_eapd_verbs[] = {
7879 /* HP Pin: output 0 (0x0c) */
7880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7882 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007886 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007887 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7888 /* eanable EAPD on medion laptop */
7889 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7890 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007891 /* enable unsolicited event */
7892 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007893 { }
7894};
7895
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007896static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7897{
7898 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007899
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007900 present = snd_hda_codec_read(codec, 0x1b, 0,
7901 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7902 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7903 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7904 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7905 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7906 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7907 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7908 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7909 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7910}
7911
7912static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7913 unsigned int res)
7914{
7915 switch (res >> 26) {
7916 case ALC880_HP_EVENT:
7917 printk("hp_event\n");
7918 alc888_6st_dell_front_automute(codec);
7919 break;
7920 }
7921}
7922
Kailang Yange2757d52008-08-26 13:17:46 +02007923static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
7924{
7925 unsigned int mute;
7926 unsigned int present;
7927
7928 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7929 present = snd_hda_codec_read(codec, 0x1b, 0,
7930 AC_VERB_GET_PIN_SENSE, 0);
7931 present = (present & 0x80000000) != 0;
7932 if (present) {
7933 /* mute internal speaker */
7934 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7935 HDA_AMP_MUTE, HDA_AMP_MUTE);
7936 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7937 HDA_AMP_MUTE, HDA_AMP_MUTE);
7938 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7939 HDA_AMP_MUTE, HDA_AMP_MUTE);
7940 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7941 HDA_AMP_MUTE, HDA_AMP_MUTE);
7942 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7943 HDA_AMP_MUTE, HDA_AMP_MUTE);
7944 } else {
7945 /* unmute internal speaker if necessary */
7946 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7947 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7948 HDA_AMP_MUTE, mute);
7949 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7950 HDA_AMP_MUTE, mute);
7951 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7952 HDA_AMP_MUTE, mute);
7953 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7954 HDA_AMP_MUTE, mute);
7955 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7956 HDA_AMP_MUTE, mute);
7957 }
7958}
7959
7960static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
7961 unsigned int res)
7962{
7963 if ((res >> 26) == ALC880_HP_EVENT)
7964 alc888_lenovo_sky_front_automute(codec);
7965}
7966
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967/*
7968 * generic initialization of ADC, input mixers and output mixers
7969 */
7970static struct hda_verb alc883_auto_init_verbs[] = {
7971 /*
7972 * Unmute ADC0-2 and set the default input to mic-in
7973 */
7974 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7978
Takashi Iwaicb53c622007-08-10 17:21:45 +02007979 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007980 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007981 * Note: PASD motherboards uses the Line In 2 as the input for
7982 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007983 */
7984 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007990
7991 /*
7992 * Set up output mixers (0x0c - 0x0f)
7993 */
7994 /* set vol=0 to output mixers */
7995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7999 /* set up input amps for analog loopback */
8000 /* Amp Indices: DAC = 0, mixer = 1 */
8001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8003 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8004 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8005 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8006 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8009 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8010 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8011
8012 /* FIXME: use matrix-type input source selection */
8013 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8014 /* Input mixer1 */
8015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008018 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008019 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8020 /* Input mixer2 */
8021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008024 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008026
8027 { }
8028};
8029
Kailang Yange2757d52008-08-26 13:17:46 +02008030static struct hda_verb alc888_asus_m90v_verbs[] = {
8031 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8034 /* enable unsolicited event */
8035 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8036 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8037 { } /* end */
8038};
8039
8040static void alc883_nb_mic_automute(struct hda_codec *codec)
8041{
8042 unsigned int present;
8043
8044 present = snd_hda_codec_read(codec, 0x18, 0,
8045 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8046 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8047 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8048 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8049 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8050}
8051
8052static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8053{
8054 unsigned int present;
8055 unsigned char bits;
8056
8057 present = snd_hda_codec_read(codec, 0x1b, 0,
8058 AC_VERB_GET_PIN_SENSE, 0)
8059 & AC_PINSENSE_PRESENCE;
8060 bits = present ? 0 : PIN_OUT;
8061 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8062 bits);
8063 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8064 bits);
8065 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8066 bits);
8067}
8068
8069static void alc883_mode2_unsol_event(struct hda_codec *codec,
8070 unsigned int res)
8071{
8072 switch (res >> 26) {
8073 case ALC880_HP_EVENT:
8074 alc883_M90V_speaker_automute(codec);
8075 break;
8076 case ALC880_MIC_EVENT:
8077 alc883_nb_mic_automute(codec);
8078 break;
8079 }
8080}
8081
8082static void alc883_mode2_inithook(struct hda_codec *codec)
8083{
8084 alc883_M90V_speaker_automute(codec);
8085 alc883_nb_mic_automute(codec);
8086}
8087
8088static struct hda_verb alc888_asus_eee1601_verbs[] = {
8089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8094 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8095 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8096 /* enable unsolicited event */
8097 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8098 { } /* end */
8099};
8100
8101static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8102{
8103 unsigned int present;
8104 unsigned char bits;
8105
8106 present = snd_hda_codec_read(codec, 0x14, 0,
8107 AC_VERB_GET_PIN_SENSE, 0)
8108 & AC_PINSENSE_PRESENCE;
8109 bits = present ? 0 : PIN_OUT;
8110 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8111 bits);
8112}
8113
8114static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8115 unsigned int res)
8116{
8117 switch (res >> 26) {
8118 case ALC880_HP_EVENT:
8119 alc883_eee1601_speaker_automute(codec);
8120 break;
8121 }
8122}
8123
8124static void alc883_eee1601_inithook(struct hda_codec *codec)
8125{
8126 alc883_eee1601_speaker_automute(codec);
8127}
8128
Takashi Iwaicb53c622007-08-10 17:21:45 +02008129#ifdef CONFIG_SND_HDA_POWER_SAVE
8130#define alc883_loopbacks alc880_loopbacks
8131#endif
8132
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008133/* pcm configuration: identiacal with ALC880 */
8134#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8135#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008136#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008137#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8138#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8139
8140/*
8141 * configuration and preset
8142 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008143static const char *alc883_models[ALC883_MODEL_LAST] = {
8144 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8145 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8146 [ALC883_3ST_6ch] = "3stack-6ch",
8147 [ALC883_6ST_DIG] = "6stack-dig",
8148 [ALC883_TARGA_DIG] = "targa-dig",
8149 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008150 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008151 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008152 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008153 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008154 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008155 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008156 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8157 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008158 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008159 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008160 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008161 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008162 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008163 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008164 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008165 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008166 [ALC883_AUTO] = "auto",
8167};
8168
8169static struct snd_pci_quirk alc883_cfg_tbl[] = {
8170 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008171 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8172 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8173 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008174 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008175 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008176 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008177 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008178 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8179 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008180 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008181 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008182 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Kailang Yange2757d52008-08-26 13:17:46 +02008183 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008184 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008185 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008186 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8187 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008188 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008189 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008190 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008191 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8192 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8193 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008194 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008195 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008196 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008197 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8198 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8199 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8200 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8201 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8202 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8203 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8204 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8205 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008206 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8207 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008208 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008209 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008210 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008211 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008212 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008213 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008214 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8215 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008216 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008217 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008218 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008219 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008220 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008221 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008222 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8223 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008224 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008225 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008226 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008227 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008228 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8229 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008230 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008231 {}
8232};
8233
8234static struct alc_config_preset alc883_presets[] = {
8235 [ALC883_3ST_2ch_DIG] = {
8236 .mixers = { alc883_3ST_2ch_mixer },
8237 .init_verbs = { alc883_init_verbs },
8238 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8239 .dac_nids = alc883_dac_nids,
8240 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008241 .dig_in_nid = ALC883_DIGIN_NID,
8242 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8243 .channel_mode = alc883_3ST_2ch_modes,
8244 .input_mux = &alc883_capture_source,
8245 },
8246 [ALC883_3ST_6ch_DIG] = {
8247 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8248 .init_verbs = { alc883_init_verbs },
8249 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8250 .dac_nids = alc883_dac_nids,
8251 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008252 .dig_in_nid = ALC883_DIGIN_NID,
8253 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8254 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008255 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008256 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008257 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008258 [ALC883_3ST_6ch] = {
8259 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8260 .init_verbs = { alc883_init_verbs },
8261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8262 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008263 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8264 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008265 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008266 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008267 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008268 [ALC883_3ST_6ch_INTEL] = {
8269 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8270 .init_verbs = { alc883_init_verbs },
8271 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8272 .dac_nids = alc883_dac_nids,
8273 .dig_out_nid = ALC883_DIGOUT_NID,
8274 .dig_in_nid = ALC883_DIGIN_NID,
8275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8276 .channel_mode = alc883_3ST_6ch_intel_modes,
8277 .need_dac_fix = 1,
8278 .input_mux = &alc883_3stack_6ch_intel,
8279 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008280 [ALC883_6ST_DIG] = {
8281 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8282 .init_verbs = { alc883_init_verbs },
8283 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8284 .dac_nids = alc883_dac_nids,
8285 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008286 .dig_in_nid = ALC883_DIGIN_NID,
8287 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8288 .channel_mode = alc883_sixstack_modes,
8289 .input_mux = &alc883_capture_source,
8290 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008291 [ALC883_TARGA_DIG] = {
8292 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8293 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8295 .dac_nids = alc883_dac_nids,
8296 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008297 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8298 .channel_mode = alc883_3ST_6ch_modes,
8299 .need_dac_fix = 1,
8300 .input_mux = &alc883_capture_source,
8301 .unsol_event = alc883_tagra_unsol_event,
8302 .init_hook = alc883_tagra_automute,
8303 },
8304 [ALC883_TARGA_2ch_DIG] = {
8305 .mixers = { alc883_tagra_2ch_mixer},
8306 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8307 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8308 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008309 .adc_nids = alc883_adc_nids_alt,
8310 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008311 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008312 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8313 .channel_mode = alc883_3ST_2ch_modes,
8314 .input_mux = &alc883_capture_source,
8315 .unsol_event = alc883_tagra_unsol_event,
8316 .init_hook = alc883_tagra_automute,
8317 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008318 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008319 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008320 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8321 * and the headphone jack. Turn this on and rely on the
8322 * standard mute methods whenever the user wants to turn
8323 * these outputs off.
8324 */
8325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8327 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008328 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8329 .channel_mode = alc883_3ST_2ch_modes,
8330 .input_mux = &alc883_capture_source,
8331 },
Tobin Davis2880a862007-08-07 11:50:26 +02008332 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008333 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008334 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8336 .dac_nids = alc883_dac_nids,
8337 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008338 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8339 .channel_mode = alc883_3ST_2ch_modes,
8340 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008341 .unsol_event = alc883_acer_aspire_unsol_event,
8342 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008343 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008344 [ALC883_MEDION] = {
8345 .mixers = { alc883_fivestack_mixer,
8346 alc883_chmode_mixer },
8347 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008348 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008349 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8350 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008351 .adc_nids = alc883_adc_nids_alt,
8352 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008353 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8354 .channel_mode = alc883_sixstack_modes,
8355 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008356 },
Kailang Yang272a5272007-05-14 11:00:38 +02008357 [ALC883_MEDION_MD2] = {
8358 .mixers = { alc883_medion_md2_mixer},
8359 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8360 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8361 .dac_nids = alc883_dac_nids,
8362 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8364 .channel_mode = alc883_3ST_2ch_modes,
8365 .input_mux = &alc883_capture_source,
8366 .unsol_event = alc883_medion_md2_unsol_event,
8367 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008368 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008369 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008370 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008371 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8372 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8373 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008374 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8375 .channel_mode = alc883_3ST_2ch_modes,
8376 .input_mux = &alc883_capture_source,
8377 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008378 [ALC883_CLEVO_M720] = {
8379 .mixers = { alc883_clevo_m720_mixer },
8380 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008381 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8382 .dac_nids = alc883_dac_nids,
8383 .dig_out_nid = ALC883_DIGOUT_NID,
8384 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8385 .channel_mode = alc883_3ST_2ch_modes,
8386 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008387 .unsol_event = alc883_clevo_m720_unsol_event,
8388 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008389 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008390 [ALC883_LENOVO_101E_2ch] = {
8391 .mixers = { alc883_lenovo_101e_2ch_mixer},
8392 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8393 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8394 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008395 .adc_nids = alc883_adc_nids_alt,
8396 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008397 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8398 .channel_mode = alc883_3ST_2ch_modes,
8399 .input_mux = &alc883_lenovo_101e_capture_source,
8400 .unsol_event = alc883_lenovo_101e_unsol_event,
8401 .init_hook = alc883_lenovo_101e_all_automute,
8402 },
Kailang Yang272a5272007-05-14 11:00:38 +02008403 [ALC883_LENOVO_NB0763] = {
8404 .mixers = { alc883_lenovo_nb0763_mixer },
8405 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8407 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008408 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8409 .channel_mode = alc883_3ST_2ch_modes,
8410 .need_dac_fix = 1,
8411 .input_mux = &alc883_lenovo_nb0763_capture_source,
8412 .unsol_event = alc883_medion_md2_unsol_event,
8413 .init_hook = alc883_medion_md2_automute,
8414 },
8415 [ALC888_LENOVO_MS7195_DIG] = {
8416 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8417 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8419 .dac_nids = alc883_dac_nids,
8420 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8422 .channel_mode = alc883_3ST_6ch_modes,
8423 .need_dac_fix = 1,
8424 .input_mux = &alc883_capture_source,
8425 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8426 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008427 },
8428 [ALC883_HAIER_W66] = {
8429 .mixers = { alc883_tagra_2ch_mixer},
8430 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8432 .dac_nids = alc883_dac_nids,
8433 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8435 .channel_mode = alc883_3ST_2ch_modes,
8436 .input_mux = &alc883_capture_source,
8437 .unsol_event = alc883_haier_w66_unsol_event,
8438 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008439 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008440 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008442 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8444 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008445 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8446 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008447 .need_dac_fix = 1,
8448 .input_mux = &alc883_capture_source,
8449 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008450 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008451 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008452 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8454 .dac_nids = alc883_dac_nids,
8455 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008456 .dig_in_nid = ALC883_DIGIN_NID,
8457 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8458 .channel_mode = alc883_sixstack_modes,
8459 .input_mux = &alc883_capture_source,
8460 .unsol_event = alc888_6st_dell_unsol_event,
8461 .init_hook = alc888_6st_dell_front_automute,
8462 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008463 [ALC883_MITAC] = {
8464 .mixers = { alc883_mitac_mixer },
8465 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8467 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8469 .channel_mode = alc883_3ST_2ch_modes,
8470 .input_mux = &alc883_capture_source,
8471 .unsol_event = alc883_mitac_unsol_event,
8472 .init_hook = alc883_mitac_automute,
8473 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008474 [ALC883_FUJITSU_PI2515] = {
8475 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8476 .init_verbs = { alc883_init_verbs,
8477 alc883_2ch_fujitsu_pi2515_verbs},
8478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8479 .dac_nids = alc883_dac_nids,
8480 .dig_out_nid = ALC883_DIGOUT_NID,
8481 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8482 .channel_mode = alc883_3ST_2ch_modes,
8483 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8484 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8485 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8486 },
Kailang Yange2757d52008-08-26 13:17:46 +02008487 [ALC888_LENOVO_SKY] = {
8488 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8489 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8490 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8491 .dac_nids = alc883_dac_nids,
8492 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008493 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8494 .channel_mode = alc883_sixstack_modes,
8495 .need_dac_fix = 1,
8496 .input_mux = &alc883_lenovo_sky_capture_source,
8497 .unsol_event = alc883_lenovo_sky_unsol_event,
8498 .init_hook = alc888_lenovo_sky_front_automute,
8499 },
8500 [ALC888_ASUS_M90V] = {
8501 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8502 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8503 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8504 .dac_nids = alc883_dac_nids,
8505 .dig_out_nid = ALC883_DIGOUT_NID,
8506 .dig_in_nid = ALC883_DIGIN_NID,
8507 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8508 .channel_mode = alc883_3ST_6ch_modes,
8509 .need_dac_fix = 1,
8510 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8511 .unsol_event = alc883_mode2_unsol_event,
8512 .init_hook = alc883_mode2_inithook,
8513 },
8514 [ALC888_ASUS_EEE1601] = {
8515 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008516 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008517 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8518 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8519 .dac_nids = alc883_dac_nids,
8520 .dig_out_nid = ALC883_DIGOUT_NID,
8521 .dig_in_nid = ALC883_DIGIN_NID,
8522 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8523 .channel_mode = alc883_3ST_2ch_modes,
8524 .need_dac_fix = 1,
8525 .input_mux = &alc883_asus_eee1601_capture_source,
8526 .unsol_event = alc883_eee1601_unsol_event,
8527 .init_hook = alc883_eee1601_inithook,
8528 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008529};
8530
8531
8532/*
8533 * BIOS auto configuration
8534 */
8535static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8536 hda_nid_t nid, int pin_type,
8537 int dac_idx)
8538{
8539 /* set as output */
8540 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008541 int idx;
8542
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008543 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008544 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8545 idx = 4;
8546 else
8547 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008548 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8549
8550}
8551
8552static void alc883_auto_init_multi_out(struct hda_codec *codec)
8553{
8554 struct alc_spec *spec = codec->spec;
8555 int i;
8556
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008557 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008558 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008559 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008560 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008561 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008562 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008563 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008564 }
8565}
8566
8567static void alc883_auto_init_hp_out(struct hda_codec *codec)
8568{
8569 struct alc_spec *spec = codec->spec;
8570 hda_nid_t pin;
8571
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008572 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008573 if (pin) /* connect to front */
8574 /* use dac 0 */
8575 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008576 pin = spec->autocfg.speaker_pins[0];
8577 if (pin)
8578 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008579}
8580
8581#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8582#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8583
8584static void alc883_auto_init_analog_input(struct hda_codec *codec)
8585{
8586 struct alc_spec *spec = codec->spec;
8587 int i;
8588
8589 for (i = 0; i < AUTO_PIN_LAST; i++) {
8590 hda_nid_t nid = spec->autocfg.input_pins[i];
8591 if (alc883_is_input_pin(nid)) {
8592 snd_hda_codec_write(codec, nid, 0,
8593 AC_VERB_SET_PIN_WIDGET_CONTROL,
8594 (i <= AUTO_PIN_FRONT_MIC ?
8595 PIN_VREF80 : PIN_IN));
8596 if (nid != ALC883_PIN_CD_NID)
8597 snd_hda_codec_write(codec, nid, 0,
8598 AC_VERB_SET_AMP_GAIN_MUTE,
8599 AMP_OUT_MUTE);
8600 }
8601 }
8602}
8603
Takashi Iwaif511b012008-08-15 16:46:42 +02008604#define alc883_auto_init_input_src alc882_auto_init_input_src
8605
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008606/* almost identical with ALC880 parser... */
8607static int alc883_parse_auto_config(struct hda_codec *codec)
8608{
8609 struct alc_spec *spec = codec->spec;
8610 int err = alc880_parse_auto_config(codec);
8611
8612 if (err < 0)
8613 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008614 else if (!err)
8615 return 0; /* no config found */
8616
8617 err = alc_auto_add_mic_boost(codec);
8618 if (err < 0)
8619 return err;
8620
8621 /* hack - override the init verbs */
8622 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008623
8624 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008625}
8626
8627/* additional initialization for auto-configuration model */
8628static void alc883_auto_init(struct hda_codec *codec)
8629{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008630 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008631 alc883_auto_init_multi_out(codec);
8632 alc883_auto_init_hp_out(codec);
8633 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008634 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008635 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008636 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008637}
8638
8639static int patch_alc883(struct hda_codec *codec)
8640{
8641 struct alc_spec *spec;
8642 int err, board_config;
8643
8644 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8645 if (spec == NULL)
8646 return -ENOMEM;
8647
8648 codec->spec = spec;
8649
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008650 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8651
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008652 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8653 alc883_models,
8654 alc883_cfg_tbl);
8655 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008656 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8657 "trying auto-probe from BIOS...\n");
8658 board_config = ALC883_AUTO;
8659 }
8660
8661 if (board_config == ALC883_AUTO) {
8662 /* automatic parse from the BIOS config */
8663 err = alc883_parse_auto_config(codec);
8664 if (err < 0) {
8665 alc_free(codec);
8666 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008667 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008668 printk(KERN_INFO
8669 "hda_codec: Cannot set up configuration "
8670 "from BIOS. Using base mode...\n");
8671 board_config = ALC883_3ST_2ch_DIG;
8672 }
8673 }
8674
8675 if (board_config != ALC883_AUTO)
8676 setup_preset(spec, &alc883_presets[board_config]);
8677
Kailang Yang2f893282008-05-27 12:14:47 +02008678 switch (codec->vendor_id) {
8679 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02008680 if (codec->revision_id == 0x100101) {
8681 spec->stream_name_analog = "ALC1200 Analog";
8682 spec->stream_name_digital = "ALC1200 Digital";
8683 } else {
8684 spec->stream_name_analog = "ALC888 Analog";
8685 spec->stream_name_digital = "ALC888 Digital";
8686 }
Kailang Yang2f893282008-05-27 12:14:47 +02008687 break;
8688 case 0x10ec0889:
8689 spec->stream_name_analog = "ALC889 Analog";
8690 spec->stream_name_digital = "ALC889 Digital";
8691 break;
8692 default:
8693 spec->stream_name_analog = "ALC883 Analog";
8694 spec->stream_name_digital = "ALC883 Digital";
8695 break;
8696 }
8697
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008698 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8699 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008700 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008701
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008702 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8703 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8704
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008705 if (!spec->num_adc_nids) {
8706 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8707 spec->adc_nids = alc883_adc_nids;
8708 }
8709 if (!spec->capsrc_nids)
8710 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008711 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008712 if (!spec->cap_mixer)
8713 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008714
Takashi Iwai2134ea42008-01-10 16:53:55 +01008715 spec->vmaster_nid = 0x0c;
8716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008717 codec->patch_ops = alc_patch_ops;
8718 if (board_config == ALC883_AUTO)
8719 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008720
Takashi Iwaicb53c622007-08-10 17:21:45 +02008721#ifdef CONFIG_SND_HDA_POWER_SAVE
8722 if (!spec->loopback.amplist)
8723 spec->loopback.amplist = alc883_loopbacks;
8724#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725
8726 return 0;
8727}
8728
8729/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008730 * ALC262 support
8731 */
8732
8733#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8734#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8735
8736#define alc262_dac_nids alc260_dac_nids
8737#define alc262_adc_nids alc882_adc_nids
8738#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008739#define alc262_capsrc_nids alc882_capsrc_nids
8740#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008741
8742#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008743#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008744
Kailang Yang4e555fe2008-08-26 13:05:55 +02008745static hda_nid_t alc262_dmic_adc_nids[1] = {
8746 /* ADC0 */
8747 0x09
8748};
8749
8750static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8751
Kailang Yangdf694da2005-12-05 19:42:22 +01008752static struct snd_kcontrol_new alc262_base_mixer[] = {
8753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8754 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008762 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008764 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008765 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008766 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8770 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008771 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008772};
8773
Kailang Yangccc656c2006-10-17 12:32:26 +02008774static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8776 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008783 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008786 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008787 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008788 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008789 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8791 { } /* end */
8792};
8793
Takashi Iwaice875f02008-01-28 18:17:43 +01008794/* update HP, line and mono-out pins according to the master switch */
8795static void alc262_hp_master_update(struct hda_codec *codec)
8796{
8797 struct alc_spec *spec = codec->spec;
8798 int val = spec->master_sw;
8799
8800 /* HP & line-out */
8801 snd_hda_codec_write_cache(codec, 0x1b, 0,
8802 AC_VERB_SET_PIN_WIDGET_CONTROL,
8803 val ? PIN_HP : 0);
8804 snd_hda_codec_write_cache(codec, 0x15, 0,
8805 AC_VERB_SET_PIN_WIDGET_CONTROL,
8806 val ? PIN_HP : 0);
8807 /* mono (speaker) depending on the HP jack sense */
8808 val = val && !spec->jack_present;
8809 snd_hda_codec_write_cache(codec, 0x16, 0,
8810 AC_VERB_SET_PIN_WIDGET_CONTROL,
8811 val ? PIN_OUT : 0);
8812}
8813
8814static void alc262_hp_bpc_automute(struct hda_codec *codec)
8815{
8816 struct alc_spec *spec = codec->spec;
8817 unsigned int presence;
8818 presence = snd_hda_codec_read(codec, 0x1b, 0,
8819 AC_VERB_GET_PIN_SENSE, 0);
8820 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8821 alc262_hp_master_update(codec);
8822}
8823
8824static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8825{
8826 if ((res >> 26) != ALC880_HP_EVENT)
8827 return;
8828 alc262_hp_bpc_automute(codec);
8829}
8830
8831static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8832{
8833 struct alc_spec *spec = codec->spec;
8834 unsigned int presence;
8835 presence = snd_hda_codec_read(codec, 0x15, 0,
8836 AC_VERB_GET_PIN_SENSE, 0);
8837 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8838 alc262_hp_master_update(codec);
8839}
8840
8841static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8842 unsigned int res)
8843{
8844 if ((res >> 26) != ALC880_HP_EVENT)
8845 return;
8846 alc262_hp_wildwest_automute(codec);
8847}
8848
8849static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8850 struct snd_ctl_elem_value *ucontrol)
8851{
8852 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8853 struct alc_spec *spec = codec->spec;
8854 *ucontrol->value.integer.value = spec->master_sw;
8855 return 0;
8856}
8857
8858static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8859 struct snd_ctl_elem_value *ucontrol)
8860{
8861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8862 struct alc_spec *spec = codec->spec;
8863 int val = !!*ucontrol->value.integer.value;
8864
8865 if (val == spec->master_sw)
8866 return 0;
8867 spec->master_sw = val;
8868 alc262_hp_master_update(codec);
8869 return 1;
8870}
8871
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008872static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008873 {
8874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8875 .name = "Master Playback Switch",
8876 .info = snd_ctl_boolean_mono_info,
8877 .get = alc262_hp_master_sw_get,
8878 .put = alc262_hp_master_sw_put,
8879 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8881 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008883 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8884 HDA_OUTPUT),
8885 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8886 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8891 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008892 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008893 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8894 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8897 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8898 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8899 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8900 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8901 { } /* end */
8902};
8903
Kailang Yangcd7509a2007-01-26 18:33:17 +01008904static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008905 {
8906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8907 .name = "Master Playback Switch",
8908 .info = snd_ctl_boolean_mono_info,
8909 .get = alc262_hp_master_sw_get,
8910 .put = alc262_hp_master_sw_put,
8911 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008916 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8917 HDA_OUTPUT),
8918 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8919 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8921 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008922 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8927 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8928 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8929 { } /* end */
8930};
8931
8932static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8933 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8934 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008935 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008936 { } /* end */
8937};
8938
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008939/* mute/unmute internal speaker according to the hp jack and mute state */
8940static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8941{
8942 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008943
8944 if (force || !spec->sense_updated) {
8945 unsigned int present;
8946 present = snd_hda_codec_read(codec, 0x15, 0,
8947 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008948 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008949 spec->sense_updated = 1;
8950 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008951 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8952 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008953}
8954
8955static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8956 unsigned int res)
8957{
8958 if ((res >> 26) != ALC880_HP_EVENT)
8959 return;
8960 alc262_hp_t5735_automute(codec, 1);
8961}
8962
8963static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8964{
8965 alc262_hp_t5735_automute(codec, 1);
8966}
8967
8968static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008969 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8975 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8976 { } /* end */
8977};
8978
8979static struct hda_verb alc262_hp_t5735_verbs[] = {
8980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8982
8983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8984 { }
8985};
8986
Kailang Yang8c427222008-01-10 13:03:59 +01008987static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8991 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8994 { } /* end */
8995};
8996
8997static struct hda_verb alc262_hp_rp5700_verbs[] = {
8998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8999 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9000 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9002 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9007 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9008 {}
9009};
9010
9011static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9012 .num_items = 1,
9013 .items = {
9014 { "Line", 0x1 },
9015 },
9016};
9017
Takashi Iwai0724ea22007-08-23 00:31:43 +02009018/* bind hp and internal speaker mute (with plug check) */
9019static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9020 struct snd_ctl_elem_value *ucontrol)
9021{
9022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9023 long *valp = ucontrol->value.integer.value;
9024 int change;
9025
9026 /* change hp mute */
9027 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9028 HDA_AMP_MUTE,
9029 valp[0] ? 0 : HDA_AMP_MUTE);
9030 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9031 HDA_AMP_MUTE,
9032 valp[1] ? 0 : HDA_AMP_MUTE);
9033 if (change) {
9034 /* change speaker according to HP jack state */
9035 struct alc_spec *spec = codec->spec;
9036 unsigned int mute;
9037 if (spec->jack_present)
9038 mute = HDA_AMP_MUTE;
9039 else
9040 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9041 HDA_OUTPUT, 0);
9042 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9043 HDA_AMP_MUTE, mute);
9044 }
9045 return change;
9046}
Takashi Iwai5b319542007-07-26 11:49:22 +02009047
Kailang Yang272a5272007-05-14 11:00:38 +02009048static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009049 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9050 {
9051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9052 .name = "Master Playback Switch",
9053 .info = snd_hda_mixer_amp_switch_info,
9054 .get = snd_hda_mixer_amp_switch_get,
9055 .put = alc262_sony_master_sw_put,
9056 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9057 },
Kailang Yang272a5272007-05-14 11:00:38 +02009058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9060 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9061 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9062 { } /* end */
9063};
9064
Kailang Yang83c34212007-07-05 11:43:05 +02009065static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9066 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9067 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9071 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9072 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9073 { } /* end */
9074};
Kailang Yang272a5272007-05-14 11:00:38 +02009075
Kailang Yangdf694da2005-12-05 19:42:22 +01009076#define alc262_capture_mixer alc882_capture_mixer
9077#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9078
9079/*
9080 * generic initialization of ADC, input mixers and output mixers
9081 */
9082static struct hda_verb alc262_init_verbs[] = {
9083 /*
9084 * Unmute ADC0-2 and set the default input to mic-in
9085 */
9086 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9088 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9090 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9092
Takashi Iwaicb53c622007-08-10 17:21:45 +02009093 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009094 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009095 * Note: PASD motherboards uses the Line In 2 as the input for
9096 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009097 */
9098 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009104
9105 /*
9106 * Set up output mixers (0x0c - 0x0e)
9107 */
9108 /* set vol=0 to output mixers */
9109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9112 /* set up input amps for analog loopback */
9113 /* Amp Indices: DAC = 0, mixer = 1 */
9114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9120
9121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9123 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9124 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9125 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9126 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9127
9128 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9131 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009133
Kailang Yangdf694da2005-12-05 19:42:22 +01009134 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9135 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009136
Kailang Yangdf694da2005-12-05 19:42:22 +01009137 /* FIXME: use matrix-type input source selection */
9138 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9139 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9141 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9142 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9144 /* Input mixer2 */
9145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9149 /* Input mixer3 */
9150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009154
9155 { }
9156};
9157
Kailang Yang4e555fe2008-08-26 13:05:55 +02009158static struct hda_verb alc262_eapd_verbs[] = {
9159 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9160 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9161 { }
9162};
9163
Kailang Yangccc656c2006-10-17 12:32:26 +02009164static struct hda_verb alc262_hippo_unsol_verbs[] = {
9165 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9167 {}
9168};
9169
9170static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9171 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9172 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9174
9175 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9176 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9177 {}
9178};
9179
Kailang Yang272a5272007-05-14 11:00:38 +02009180static struct hda_verb alc262_sony_unsol_verbs[] = {
9181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9182 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9184
9185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009187 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009188};
9189
Kailang Yang4e555fe2008-08-26 13:05:55 +02009190static struct hda_input_mux alc262_dmic_capture_source = {
9191 .num_items = 2,
9192 .items = {
9193 { "Int DMic", 0x9 },
9194 { "Mic", 0x0 },
9195 },
9196};
9197
9198static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9199 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9200 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009204 { } /* end */
9205};
9206
9207static struct hda_verb alc262_toshiba_s06_verbs[] = {
9208 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9212 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9213 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9214 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9215 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9216 {}
9217};
9218
9219static void alc262_dmic_automute(struct hda_codec *codec)
9220{
9221 unsigned int present;
9222
9223 present = snd_hda_codec_read(codec, 0x18, 0,
9224 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9225 snd_hda_codec_write(codec, 0x22, 0,
9226 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9227}
9228
9229/* toggle speaker-output according to the hp-jack state */
9230static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9231{
9232 unsigned int present;
9233 unsigned char bits;
9234
9235 present = snd_hda_codec_read(codec, 0x15, 0,
9236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9237 bits = present ? 0 : PIN_OUT;
9238 snd_hda_codec_write(codec, 0x14, 0,
9239 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9240}
9241
9242
9243
9244/* unsolicited event for HP jack sensing */
9245static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9246 unsigned int res)
9247{
9248 if ((res >> 26) == ALC880_HP_EVENT)
9249 alc262_toshiba_s06_speaker_automute(codec);
9250 if ((res >> 26) == ALC880_MIC_EVENT)
9251 alc262_dmic_automute(codec);
9252
9253}
9254
9255static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9256{
9257 alc262_toshiba_s06_speaker_automute(codec);
9258 alc262_dmic_automute(codec);
9259}
9260
Kailang Yangccc656c2006-10-17 12:32:26 +02009261/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009262static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009263{
9264 struct alc_spec *spec = codec->spec;
9265 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009266 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009267
Takashi Iwai5b319542007-07-26 11:49:22 +02009268 /* need to execute and sync at first */
9269 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9270 present = snd_hda_codec_read(codec, 0x15, 0,
9271 AC_VERB_GET_PIN_SENSE, 0);
9272 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009273 if (spec->jack_present) {
9274 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009275 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9276 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009277 } else {
9278 /* unmute internal speaker if necessary */
9279 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009280 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9281 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009282 }
9283}
9284
9285/* unsolicited event for HP jack sensing */
9286static void alc262_hippo_unsol_event(struct hda_codec *codec,
9287 unsigned int res)
9288{
9289 if ((res >> 26) != ALC880_HP_EVENT)
9290 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009291 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009292}
9293
Takashi Iwai5b319542007-07-26 11:49:22 +02009294static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009295{
Kailang Yangccc656c2006-10-17 12:32:26 +02009296 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009297 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009298
Takashi Iwai5b319542007-07-26 11:49:22 +02009299 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9300 present = snd_hda_codec_read(codec, 0x1b, 0,
9301 AC_VERB_GET_PIN_SENSE, 0);
9302 present = (present & 0x80000000) != 0;
9303 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009304 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009305 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9306 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009307 } else {
9308 /* unmute internal speaker if necessary */
9309 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009310 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9311 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009312 }
9313}
9314
9315/* unsolicited event for HP jack sensing */
9316static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9317 unsigned int res)
9318{
9319 if ((res >> 26) != ALC880_HP_EVENT)
9320 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009321 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009322}
9323
Takashi Iwai834be882006-03-01 14:16:17 +01009324/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009325 * nec model
9326 * 0x15 = headphone
9327 * 0x16 = internal speaker
9328 * 0x18 = external mic
9329 */
9330
9331static struct snd_kcontrol_new alc262_nec_mixer[] = {
9332 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9333 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9334
9335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9338
9339 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9341 { } /* end */
9342};
9343
9344static struct hda_verb alc262_nec_verbs[] = {
9345 /* Unmute Speaker */
9346 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9347
9348 /* Headphone */
9349 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9351
9352 /* External mic to headphone */
9353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9354 /* External mic to speaker */
9355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356 {}
9357};
9358
9359/*
Takashi Iwai834be882006-03-01 14:16:17 +01009360 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009361 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9362 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009363 */
9364
9365#define ALC_HP_EVENT 0x37
9366
9367static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9368 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009370 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009372 {}
9373};
9374
Jiang zhe0e31daf2008-03-20 12:12:39 +01009375static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9376 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9378 {}
9379};
9380
Takashi Iwai834be882006-03-01 14:16:17 +01009381static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009382 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009383 .items = {
9384 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009385 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009386 { "CD", 0x4 },
9387 },
9388};
9389
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009390static struct hda_input_mux alc262_HP_capture_source = {
9391 .num_items = 5,
9392 .items = {
9393 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009394 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395 { "Line", 0x2 },
9396 { "CD", 0x4 },
9397 { "AUX IN", 0x6 },
9398 },
9399};
9400
zhejiangaccbe492007-08-31 12:36:05 +02009401static struct hda_input_mux alc262_HP_D7000_capture_source = {
9402 .num_items = 4,
9403 .items = {
9404 { "Mic", 0x0 },
9405 { "Front Mic", 0x2 },
9406 { "Line", 0x1 },
9407 { "CD", 0x4 },
9408 },
9409};
9410
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009411/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009412static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9413{
9414 struct alc_spec *spec = codec->spec;
9415 unsigned int mute;
9416
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009417 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009418 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009419 /* need to execute and sync at first */
9420 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009421 /* check laptop HP jack */
9422 present = snd_hda_codec_read(codec, 0x14, 0,
9423 AC_VERB_GET_PIN_SENSE, 0);
9424 /* need to execute and sync at first */
9425 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9426 /* check docking HP jack */
9427 present |= snd_hda_codec_read(codec, 0x1b, 0,
9428 AC_VERB_GET_PIN_SENSE, 0);
9429 if (present & AC_PINSENSE_PRESENCE)
9430 spec->jack_present = 1;
9431 else
9432 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009433 spec->sense_updated = 1;
9434 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009435 /* unmute internal speaker only if both HPs are unplugged and
9436 * master switch is on
9437 */
9438 if (spec->jack_present)
9439 mute = HDA_AMP_MUTE;
9440 else
Takashi Iwai834be882006-03-01 14:16:17 +01009441 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009442 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9443 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009444}
9445
9446/* unsolicited event for HP jack sensing */
9447static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9448 unsigned int res)
9449{
9450 if ((res >> 26) != ALC_HP_EVENT)
9451 return;
9452 alc262_fujitsu_automute(codec, 1);
9453}
9454
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009455static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9456{
9457 alc262_fujitsu_automute(codec, 1);
9458}
9459
Takashi Iwai834be882006-03-01 14:16:17 +01009460/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009461static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9462 .ops = &snd_hda_bind_vol,
9463 .values = {
9464 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9465 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9466 0
9467 },
9468};
Takashi Iwai834be882006-03-01 14:16:17 +01009469
Jiang zhe0e31daf2008-03-20 12:12:39 +01009470/* mute/unmute internal speaker according to the hp jack and mute state */
9471static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9472{
9473 struct alc_spec *spec = codec->spec;
9474 unsigned int mute;
9475
9476 if (force || !spec->sense_updated) {
9477 unsigned int present_int_hp;
9478 /* need to execute and sync at first */
9479 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9480 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9481 AC_VERB_GET_PIN_SENSE, 0);
9482 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9483 spec->sense_updated = 1;
9484 }
9485 if (spec->jack_present) {
9486 /* mute internal speaker */
9487 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9488 HDA_AMP_MUTE, HDA_AMP_MUTE);
9489 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9490 HDA_AMP_MUTE, HDA_AMP_MUTE);
9491 } else {
9492 /* unmute internal speaker if necessary */
9493 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9494 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9495 HDA_AMP_MUTE, mute);
9496 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9497 HDA_AMP_MUTE, mute);
9498 }
9499}
9500
9501/* unsolicited event for HP jack sensing */
9502static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9503 unsigned int res)
9504{
9505 if ((res >> 26) != ALC_HP_EVENT)
9506 return;
9507 alc262_lenovo_3000_automute(codec, 1);
9508}
9509
Takashi Iwai834be882006-03-01 14:16:17 +01009510/* bind hp and internal speaker mute (with plug check) */
9511static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9512 struct snd_ctl_elem_value *ucontrol)
9513{
9514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9515 long *valp = ucontrol->value.integer.value;
9516 int change;
9517
Tony Vroon5d9fab22008-03-14 17:09:18 +01009518 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9519 HDA_AMP_MUTE,
9520 valp ? 0 : HDA_AMP_MUTE);
9521 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9522 HDA_AMP_MUTE,
9523 valp ? 0 : HDA_AMP_MUTE);
9524
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009525 if (change)
9526 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009527 return change;
9528}
9529
9530static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009531 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009532 {
9533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9534 .name = "Master Playback Switch",
9535 .info = snd_hda_mixer_amp_switch_info,
9536 .get = snd_hda_mixer_amp_switch_get,
9537 .put = alc262_fujitsu_master_sw_put,
9538 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9539 },
9540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009542 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9543 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009544 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009547 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9548 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9549 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009550 { } /* end */
9551};
9552
Jiang zhe0e31daf2008-03-20 12:12:39 +01009553/* bind hp and internal speaker mute (with plug check) */
9554static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9555 struct snd_ctl_elem_value *ucontrol)
9556{
9557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9558 long *valp = ucontrol->value.integer.value;
9559 int change;
9560
9561 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9562 HDA_AMP_MUTE,
9563 valp ? 0 : HDA_AMP_MUTE);
9564
9565 if (change)
9566 alc262_lenovo_3000_automute(codec, 0);
9567 return change;
9568}
9569
9570static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9571 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9572 {
9573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9574 .name = "Master Playback Switch",
9575 .info = snd_hda_mixer_amp_switch_info,
9576 .get = snd_hda_mixer_amp_switch_get,
9577 .put = alc262_lenovo_3000_master_sw_put,
9578 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9579 },
9580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9585 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9586 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9587 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9588 { } /* end */
9589};
9590
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009591static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9592 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9593 {
9594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9595 .name = "Master Playback Switch",
9596 .info = snd_hda_mixer_amp_switch_info,
9597 .get = snd_hda_mixer_amp_switch_get,
9598 .put = alc262_sony_master_sw_put,
9599 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9600 },
9601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9602 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9605 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9606 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9607 { } /* end */
9608};
9609
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009610/* additional init verbs for Benq laptops */
9611static struct hda_verb alc262_EAPD_verbs[] = {
9612 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9613 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9614 {}
9615};
9616
Kailang Yang83c34212007-07-05 11:43:05 +02009617static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9619 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9620
9621 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9622 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9623 {}
9624};
9625
Tobin Davisf651b502007-10-26 12:40:47 +02009626/* Samsung Q1 Ultra Vista model setup */
9627static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009628 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9629 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9632 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009633 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009634 { } /* end */
9635};
9636
9637static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009638 /* output mixer */
9639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9642 /* speaker */
9643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9647 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9653 /* internal mic */
9654 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9656 /* ADC, choose mic */
9657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009667 {}
9668};
9669
Tobin Davisf651b502007-10-26 12:40:47 +02009670/* mute/unmute internal speaker according to the hp jack and mute state */
9671static void alc262_ultra_automute(struct hda_codec *codec)
9672{
9673 struct alc_spec *spec = codec->spec;
9674 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009675
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009676 mute = 0;
9677 /* auto-mute only when HP is used as HP */
9678 if (!spec->cur_mux[0]) {
9679 unsigned int present;
9680 /* need to execute and sync at first */
9681 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9682 present = snd_hda_codec_read(codec, 0x15, 0,
9683 AC_VERB_GET_PIN_SENSE, 0);
9684 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9685 if (spec->jack_present)
9686 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009687 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009688 /* mute/unmute internal speaker */
9689 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9690 HDA_AMP_MUTE, mute);
9691 /* mute/unmute HP */
9692 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9693 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009694}
9695
9696/* unsolicited event for HP jack sensing */
9697static void alc262_ultra_unsol_event(struct hda_codec *codec,
9698 unsigned int res)
9699{
9700 if ((res >> 26) != ALC880_HP_EVENT)
9701 return;
9702 alc262_ultra_automute(codec);
9703}
9704
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009705static struct hda_input_mux alc262_ultra_capture_source = {
9706 .num_items = 2,
9707 .items = {
9708 { "Mic", 0x1 },
9709 { "Headphone", 0x7 },
9710 },
9711};
9712
9713static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9714 struct snd_ctl_elem_value *ucontrol)
9715{
9716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9717 struct alc_spec *spec = codec->spec;
9718 int ret;
9719
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009720 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009721 if (!ret)
9722 return 0;
9723 /* reprogram the HP pin as mic or HP according to the input source */
9724 snd_hda_codec_write_cache(codec, 0x15, 0,
9725 AC_VERB_SET_PIN_WIDGET_CONTROL,
9726 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9727 alc262_ultra_automute(codec); /* mute/unmute HP */
9728 return ret;
9729}
9730
9731static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9732 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9733 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9734 {
9735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9736 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009737 .info = alc_mux_enum_info,
9738 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009739 .put = alc262_ultra_mux_enum_put,
9740 },
9741 { } /* end */
9742};
9743
Kailang Yangdf694da2005-12-05 19:42:22 +01009744/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009745static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9746 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009747{
9748 hda_nid_t nid;
9749 int err;
9750
9751 spec->multiout.num_dacs = 1; /* only use one dac */
9752 spec->multiout.dac_nids = spec->private_dac_nids;
9753 spec->multiout.dac_nids[0] = 2;
9754
9755 nid = cfg->line_out_pins[0];
9756 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009757 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9758 "Front Playback Volume",
9759 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9760 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009761 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009762 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9763 "Front Playback Switch",
9764 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9765 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009766 return err;
9767 }
9768
Takashi Iwai82bc9552006-03-21 11:24:42 +01009769 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009770 if (nid) {
9771 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009772 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9773 "Speaker Playback Volume",
9774 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9775 HDA_OUTPUT));
9776 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009777 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009778 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9779 "Speaker Playback Switch",
9780 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9781 HDA_OUTPUT));
9782 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009783 return err;
9784 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009785 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9786 "Speaker Playback Switch",
9787 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9788 HDA_OUTPUT));
9789 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009790 return err;
9791 }
9792 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009793 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009794 if (nid) {
9795 /* spec->multiout.hp_nid = 2; */
9796 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009797 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9798 "Headphone Playback Volume",
9799 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9800 HDA_OUTPUT));
9801 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009803 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9804 "Headphone Playback Switch",
9805 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9806 HDA_OUTPUT));
9807 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009808 return err;
9809 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009810 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9811 "Headphone Playback Switch",
9812 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9813 HDA_OUTPUT));
9814 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009815 return err;
9816 }
9817 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009818 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009819}
9820
9821/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009822#define alc262_auto_create_analog_input_ctls \
9823 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009824
9825/*
9826 * generic initialization of ADC, input mixers and output mixers
9827 */
9828static struct hda_verb alc262_volume_init_verbs[] = {
9829 /*
9830 * Unmute ADC0-2 and set the default input to mic-in
9831 */
9832 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9838
Takashi Iwaicb53c622007-08-10 17:21:45 +02009839 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009840 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009841 * Note: PASD motherboards uses the Line In 2 as the input for
9842 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009843 */
9844 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009850
9851 /*
9852 * Set up output mixers (0x0c - 0x0f)
9853 */
9854 /* set vol=0 to output mixers */
9855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009858
Kailang Yangdf694da2005-12-05 19:42:22 +01009859 /* set up input amps for analog loopback */
9860 /* Amp Indices: DAC = 0, mixer = 1 */
9861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9867
9868 /* FIXME: use matrix-type input source selection */
9869 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9870 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9871 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9872 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9875 /* Input mixer2 */
9876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9878 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9880 /* Input mixer3 */
9881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9885
9886 { }
9887};
9888
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009889static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9890 /*
9891 * Unmute ADC0-2 and set the default input to mic-in
9892 */
9893 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9895 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9897 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9899
Takashi Iwaicb53c622007-08-10 17:21:45 +02009900 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009901 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009902 * Note: PASD motherboards uses the Line In 2 as the input for
9903 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009904 */
9905 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009913
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009914 /*
9915 * Set up output mixers (0x0c - 0x0e)
9916 */
9917 /* set vol=0 to output mixers */
9918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9921
9922 /* set up input amps for analog loopback */
9923 /* Amp Indices: DAC = 0, mixer = 1 */
9924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9927 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9929 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9930
Takashi Iwaice875f02008-01-28 18:17:43 +01009931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9933 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9934
9935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9937
9938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9940
9941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9946
9947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9949 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9951 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9952 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9953
9954
9955 /* FIXME: use matrix-type input source selection */
9956 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9957 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9962 /* Input mixer2 */
9963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9967 /* Input mixer3 */
9968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9972
Takashi Iwaice875f02008-01-28 18:17:43 +01009973 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9974
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009975 { }
9976};
9977
Kailang Yangcd7509a2007-01-26 18:33:17 +01009978static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9979 /*
9980 * Unmute ADC0-2 and set the default input to mic-in
9981 */
9982 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9986 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9988
Takashi Iwaicb53c622007-08-10 17:21:45 +02009989 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009990 * mixer widget
9991 * Note: PASD motherboards uses the Line In 2 as the input for front
9992 * panel mic (mic 2)
9993 */
9994 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9997 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010003 /*
10004 * Set up output mixers (0x0c - 0x0e)
10005 */
10006 /* set vol=0 to output mixers */
10007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10008 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10010
10011 /* set up input amps for analog loopback */
10012 /* Amp Indices: DAC = 0, mixer = 1 */
10013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10019
10020
10021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10022 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10024 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10025 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10028
10029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10031
10032 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10033 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10034
10035 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10039 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10040 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10041
10042 /* FIXME: use matrix-type input source selection */
10043 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10044 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10050 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10052 /* Input mixer2 */
10053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10058 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10060 /* Input mixer3 */
10061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10066 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10068
Takashi Iwaice875f02008-01-28 18:17:43 +010010069 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10070
Kailang Yangcd7509a2007-01-26 18:33:17 +010010071 { }
10072};
10073
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010074static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10075
10076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10078 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10079
10080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10084
10085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10087 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10088 {}
10089};
10090
10091
Takashi Iwaicb53c622007-08-10 17:21:45 +020010092#ifdef CONFIG_SND_HDA_POWER_SAVE
10093#define alc262_loopbacks alc880_loopbacks
10094#endif
10095
Kailang Yangdf694da2005-12-05 19:42:22 +010010096/* pcm configuration: identiacal with ALC880 */
10097#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10098#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10099#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10100#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10101
10102/*
10103 * BIOS auto configuration
10104 */
10105static int alc262_parse_auto_config(struct hda_codec *codec)
10106{
10107 struct alc_spec *spec = codec->spec;
10108 int err;
10109 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10110
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010111 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10112 alc262_ignore);
10113 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010114 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010115 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010116 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010117 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10118 if (err < 0)
10119 return err;
10120 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10121 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010122 return err;
10123
10124 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10125
10126 if (spec->autocfg.dig_out_pin)
10127 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10128 if (spec->autocfg.dig_in_pin)
10129 spec->dig_in_nid = ALC262_DIGIN_NID;
10130
Takashi Iwai603c4012008-07-30 15:01:44 +020010131 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010132 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010133
Takashi Iwaid88897e2008-10-31 15:01:37 +010010134 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010135 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010136 spec->input_mux = &spec->private_imux;
10137
Takashi Iwai776e1842007-08-29 15:07:11 +020010138 err = alc_auto_add_mic_boost(codec);
10139 if (err < 0)
10140 return err;
10141
Takashi Iwaie044c392008-10-27 16:56:24 +010010142 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010143 return 1;
10144}
10145
10146#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10147#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10148#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010149#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010150
10151
10152/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010153static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010154{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010155 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010156 alc262_auto_init_multi_out(codec);
10157 alc262_auto_init_hp_out(codec);
10158 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010159 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010160 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010161 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010162}
10163
10164/*
10165 * configuration and preset
10166 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010167static const char *alc262_models[ALC262_MODEL_LAST] = {
10168 [ALC262_BASIC] = "basic",
10169 [ALC262_HIPPO] = "hippo",
10170 [ALC262_HIPPO_1] = "hippo_1",
10171 [ALC262_FUJITSU] = "fujitsu",
10172 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010173 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010174 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010175 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010176 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010177 [ALC262_BENQ_T31] = "benq-t31",
10178 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010179 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010180 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010181 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010182 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010183 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010184 [ALC262_AUTO] = "auto",
10185};
10186
10187static struct snd_pci_quirk alc262_cfg_tbl[] = {
10188 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010189 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010190 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010191 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010192 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10193 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010194 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010195 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010196 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010197 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010198 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010199 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010200 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010201 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010202 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010203 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010204 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010205 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010206 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10207 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10208 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010209 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10210 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010211 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010212 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010213 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010214 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10215 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10216 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010217 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010218 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010219 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010220 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010221 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010222 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010223 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010224 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010225 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010226 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010227 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010228 {}
10229};
10230
10231static struct alc_config_preset alc262_presets[] = {
10232 [ALC262_BASIC] = {
10233 .mixers = { alc262_base_mixer },
10234 .init_verbs = { alc262_init_verbs },
10235 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10236 .dac_nids = alc262_dac_nids,
10237 .hp_nid = 0x03,
10238 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10239 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010240 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010241 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010242 [ALC262_HIPPO] = {
10243 .mixers = { alc262_base_mixer },
10244 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10245 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10246 .dac_nids = alc262_dac_nids,
10247 .hp_nid = 0x03,
10248 .dig_out_nid = ALC262_DIGOUT_NID,
10249 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10250 .channel_mode = alc262_modes,
10251 .input_mux = &alc262_capture_source,
10252 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010253 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010254 },
10255 [ALC262_HIPPO_1] = {
10256 .mixers = { alc262_hippo1_mixer },
10257 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10258 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10259 .dac_nids = alc262_dac_nids,
10260 .hp_nid = 0x02,
10261 .dig_out_nid = ALC262_DIGOUT_NID,
10262 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10263 .channel_mode = alc262_modes,
10264 .input_mux = &alc262_capture_source,
10265 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010266 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010267 },
Takashi Iwai834be882006-03-01 14:16:17 +010010268 [ALC262_FUJITSU] = {
10269 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010270 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10271 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010272 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10273 .dac_nids = alc262_dac_nids,
10274 .hp_nid = 0x03,
10275 .dig_out_nid = ALC262_DIGOUT_NID,
10276 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10277 .channel_mode = alc262_modes,
10278 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010279 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010280 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010281 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010282 [ALC262_HP_BPC] = {
10283 .mixers = { alc262_HP_BPC_mixer },
10284 .init_verbs = { alc262_HP_BPC_init_verbs },
10285 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10286 .dac_nids = alc262_dac_nids,
10287 .hp_nid = 0x03,
10288 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10289 .channel_mode = alc262_modes,
10290 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010291 .unsol_event = alc262_hp_bpc_unsol_event,
10292 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010293 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010294 [ALC262_HP_BPC_D7000_WF] = {
10295 .mixers = { alc262_HP_BPC_WildWest_mixer },
10296 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10297 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10298 .dac_nids = alc262_dac_nids,
10299 .hp_nid = 0x03,
10300 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10301 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010302 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010303 .unsol_event = alc262_hp_wildwest_unsol_event,
10304 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010305 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010306 [ALC262_HP_BPC_D7000_WL] = {
10307 .mixers = { alc262_HP_BPC_WildWest_mixer,
10308 alc262_HP_BPC_WildWest_option_mixer },
10309 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10310 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10311 .dac_nids = alc262_dac_nids,
10312 .hp_nid = 0x03,
10313 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10314 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010315 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010316 .unsol_event = alc262_hp_wildwest_unsol_event,
10317 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010318 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010319 [ALC262_HP_TC_T5735] = {
10320 .mixers = { alc262_hp_t5735_mixer },
10321 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10322 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10323 .dac_nids = alc262_dac_nids,
10324 .hp_nid = 0x03,
10325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10326 .channel_mode = alc262_modes,
10327 .input_mux = &alc262_capture_source,
10328 .unsol_event = alc262_hp_t5735_unsol_event,
10329 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010330 },
10331 [ALC262_HP_RP5700] = {
10332 .mixers = { alc262_hp_rp5700_mixer },
10333 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10334 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10335 .dac_nids = alc262_dac_nids,
10336 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10337 .channel_mode = alc262_modes,
10338 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010339 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010340 [ALC262_BENQ_ED8] = {
10341 .mixers = { alc262_base_mixer },
10342 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10343 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10344 .dac_nids = alc262_dac_nids,
10345 .hp_nid = 0x03,
10346 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10347 .channel_mode = alc262_modes,
10348 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010349 },
Kailang Yang272a5272007-05-14 11:00:38 +020010350 [ALC262_SONY_ASSAMD] = {
10351 .mixers = { alc262_sony_mixer },
10352 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10353 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10354 .dac_nids = alc262_dac_nids,
10355 .hp_nid = 0x02,
10356 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10357 .channel_mode = alc262_modes,
10358 .input_mux = &alc262_capture_source,
10359 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010360 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010361 },
10362 [ALC262_BENQ_T31] = {
10363 .mixers = { alc262_benq_t31_mixer },
10364 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10365 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10366 .dac_nids = alc262_dac_nids,
10367 .hp_nid = 0x03,
10368 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10369 .channel_mode = alc262_modes,
10370 .input_mux = &alc262_capture_source,
10371 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010372 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010373 },
Tobin Davisf651b502007-10-26 12:40:47 +020010374 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010375 .mixers = { alc262_ultra_mixer },
10376 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010377 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010378 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10379 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010380 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10381 .channel_mode = alc262_modes,
10382 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010383 .adc_nids = alc262_adc_nids, /* ADC0 */
10384 .capsrc_nids = alc262_capsrc_nids,
10385 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010386 .unsol_event = alc262_ultra_unsol_event,
10387 .init_hook = alc262_ultra_automute,
10388 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010389 [ALC262_LENOVO_3000] = {
10390 .mixers = { alc262_lenovo_3000_mixer },
10391 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10392 alc262_lenovo_3000_unsol_verbs },
10393 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10394 .dac_nids = alc262_dac_nids,
10395 .hp_nid = 0x03,
10396 .dig_out_nid = ALC262_DIGOUT_NID,
10397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10398 .channel_mode = alc262_modes,
10399 .input_mux = &alc262_fujitsu_capture_source,
10400 .unsol_event = alc262_lenovo_3000_unsol_event,
10401 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010402 [ALC262_NEC] = {
10403 .mixers = { alc262_nec_mixer },
10404 .init_verbs = { alc262_nec_verbs },
10405 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10406 .dac_nids = alc262_dac_nids,
10407 .hp_nid = 0x03,
10408 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10409 .channel_mode = alc262_modes,
10410 .input_mux = &alc262_capture_source,
10411 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010412 [ALC262_TOSHIBA_S06] = {
10413 .mixers = { alc262_toshiba_s06_mixer },
10414 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10415 alc262_eapd_verbs },
10416 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10417 .capsrc_nids = alc262_dmic_capsrc_nids,
10418 .dac_nids = alc262_dac_nids,
10419 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10420 .dig_out_nid = ALC262_DIGOUT_NID,
10421 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10422 .channel_mode = alc262_modes,
10423 .input_mux = &alc262_dmic_capture_source,
10424 .unsol_event = alc262_toshiba_s06_unsol_event,
10425 .init_hook = alc262_toshiba_s06_init_hook,
10426 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010427 [ALC262_TOSHIBA_RX1] = {
10428 .mixers = { alc262_toshiba_rx1_mixer },
10429 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10430 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10431 .dac_nids = alc262_dac_nids,
10432 .hp_nid = 0x03,
10433 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10434 .channel_mode = alc262_modes,
10435 .input_mux = &alc262_capture_source,
10436 .unsol_event = alc262_hippo_unsol_event,
10437 .init_hook = alc262_hippo_automute,
10438 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010439};
10440
10441static int patch_alc262(struct hda_codec *codec)
10442{
10443 struct alc_spec *spec;
10444 int board_config;
10445 int err;
10446
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010447 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010448 if (spec == NULL)
10449 return -ENOMEM;
10450
10451 codec->spec = spec;
10452#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010453 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10454 * under-run
10455 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010456 {
10457 int tmp;
10458 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10459 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10460 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10461 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10462 }
10463#endif
10464
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010465 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10466
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010467 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10468 alc262_models,
10469 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010470
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010471 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010472 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10473 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010474 board_config = ALC262_AUTO;
10475 }
10476
10477 if (board_config == ALC262_AUTO) {
10478 /* automatic parse from the BIOS config */
10479 err = alc262_parse_auto_config(codec);
10480 if (err < 0) {
10481 alc_free(codec);
10482 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010483 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010484 printk(KERN_INFO
10485 "hda_codec: Cannot set up configuration "
10486 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010487 board_config = ALC262_BASIC;
10488 }
10489 }
10490
10491 if (board_config != ALC262_AUTO)
10492 setup_preset(spec, &alc262_presets[board_config]);
10493
10494 spec->stream_name_analog = "ALC262 Analog";
10495 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10496 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010497
Kailang Yangdf694da2005-12-05 19:42:22 +010010498 spec->stream_name_digital = "ALC262 Digital";
10499 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10500 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10501
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010502 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010503 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010504 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010505 unsigned int wcap = get_wcaps(codec, 0x07);
10506
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010507 /* get type */
10508 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010509 if (wcap != AC_WID_AUD_IN) {
10510 spec->adc_nids = alc262_adc_nids_alt;
10511 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010512 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010513 } else {
10514 spec->adc_nids = alc262_adc_nids;
10515 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010516 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010517 }
10518 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010519 if (!spec->cap_mixer)
10520 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010521
Takashi Iwai2134ea42008-01-10 16:53:55 +010010522 spec->vmaster_nid = 0x0c;
10523
Kailang Yangdf694da2005-12-05 19:42:22 +010010524 codec->patch_ops = alc_patch_ops;
10525 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010526 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010527#ifdef CONFIG_SND_HDA_POWER_SAVE
10528 if (!spec->loopback.amplist)
10529 spec->loopback.amplist = alc262_loopbacks;
10530#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010531
Kailang Yangdf694da2005-12-05 19:42:22 +010010532 return 0;
10533}
10534
Kailang Yangdf694da2005-12-05 19:42:22 +010010535/*
Kailang Yanga361d842007-06-05 12:30:55 +020010536 * ALC268 channel source setting (2 channel)
10537 */
10538#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10539#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010540
Kailang Yanga361d842007-06-05 12:30:55 +020010541static hda_nid_t alc268_dac_nids[2] = {
10542 /* front, hp */
10543 0x02, 0x03
10544};
10545
10546static hda_nid_t alc268_adc_nids[2] = {
10547 /* ADC0-1 */
10548 0x08, 0x07
10549};
10550
10551static hda_nid_t alc268_adc_nids_alt[1] = {
10552 /* ADC0 */
10553 0x08
10554};
10555
Takashi Iwaie1406342008-02-11 18:32:32 +010010556static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10557
Kailang Yanga361d842007-06-05 12:30:55 +020010558static struct snd_kcontrol_new alc268_base_mixer[] = {
10559 /* output mixer control */
10560 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10561 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010564 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10565 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10566 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010567 { }
10568};
10569
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010570/* bind Beep switches of both NID 0x0f and 0x10 */
10571static struct hda_bind_ctls alc268_bind_beep_sw = {
10572 .ops = &snd_hda_bind_sw,
10573 .values = {
10574 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10575 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10576 0
10577 },
10578};
10579
10580static struct snd_kcontrol_new alc268_beep_mixer[] = {
10581 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10582 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10583 { }
10584};
10585
Kailang Yangd1a991a2007-08-15 16:21:59 +020010586static struct hda_verb alc268_eapd_verbs[] = {
10587 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10588 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10589 { }
10590};
10591
Takashi Iwaid2738092007-08-16 14:59:45 +020010592/* Toshiba specific */
10593#define alc268_toshiba_automute alc262_hippo_automute
10594
10595static struct hda_verb alc268_toshiba_verbs[] = {
10596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10597 { } /* end */
10598};
10599
Kailang Yang8ef355d2008-08-26 13:10:22 +020010600static struct hda_input_mux alc268_acer_lc_capture_source = {
10601 .num_items = 2,
10602 .items = {
10603 { "i-Mic", 0x6 },
10604 { "E-Mic", 0x0 },
10605 },
10606};
10607
Takashi Iwaid2738092007-08-16 14:59:45 +020010608/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010609/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010610static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10611 .ops = &snd_hda_bind_vol,
10612 .values = {
10613 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10614 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10615 0
10616 },
10617};
10618
Takashi Iwai889c4392007-08-23 18:56:52 +020010619/* mute/unmute internal speaker according to the hp jack and mute state */
10620static void alc268_acer_automute(struct hda_codec *codec, int force)
10621{
10622 struct alc_spec *spec = codec->spec;
10623 unsigned int mute;
10624
10625 if (force || !spec->sense_updated) {
10626 unsigned int present;
10627 present = snd_hda_codec_read(codec, 0x14, 0,
10628 AC_VERB_GET_PIN_SENSE, 0);
10629 spec->jack_present = (present & 0x80000000) != 0;
10630 spec->sense_updated = 1;
10631 }
10632 if (spec->jack_present)
10633 mute = HDA_AMP_MUTE; /* mute internal speaker */
10634 else /* unmute internal speaker if necessary */
10635 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10636 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10637 HDA_AMP_MUTE, mute);
10638}
10639
10640
10641/* bind hp and internal speaker mute (with plug check) */
10642static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10643 struct snd_ctl_elem_value *ucontrol)
10644{
10645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10646 long *valp = ucontrol->value.integer.value;
10647 int change;
10648
10649 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10650 HDA_AMP_MUTE,
10651 valp[0] ? 0 : HDA_AMP_MUTE);
10652 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10653 HDA_AMP_MUTE,
10654 valp[1] ? 0 : HDA_AMP_MUTE);
10655 if (change)
10656 alc268_acer_automute(codec, 0);
10657 return change;
10658}
Takashi Iwaid2738092007-08-16 14:59:45 +020010659
Kailang Yang8ef355d2008-08-26 13:10:22 +020010660static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10661 /* output mixer control */
10662 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10663 {
10664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10665 .name = "Master Playback Switch",
10666 .info = snd_hda_mixer_amp_switch_info,
10667 .get = snd_hda_mixer_amp_switch_get,
10668 .put = alc268_acer_master_sw_put,
10669 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10670 },
10671 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10672 { }
10673};
10674
Takashi Iwaid2738092007-08-16 14:59:45 +020010675static struct snd_kcontrol_new alc268_acer_mixer[] = {
10676 /* output mixer control */
10677 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10678 {
10679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10680 .name = "Master Playback Switch",
10681 .info = snd_hda_mixer_amp_switch_info,
10682 .get = snd_hda_mixer_amp_switch_get,
10683 .put = alc268_acer_master_sw_put,
10684 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10685 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10688 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010689 { }
10690};
10691
Kailang Yang8ef355d2008-08-26 13:10:22 +020010692static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10695 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10696 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10697 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10699 { }
10700};
10701
Takashi Iwaid2738092007-08-16 14:59:45 +020010702static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010703 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10704 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010709 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10710 { }
10711};
10712
10713/* unsolicited event for HP jack sensing */
10714static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10715 unsigned int res)
10716{
Takashi Iwai889c4392007-08-23 18:56:52 +020010717 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010718 return;
10719 alc268_toshiba_automute(codec);
10720}
10721
10722static void alc268_acer_unsol_event(struct hda_codec *codec,
10723 unsigned int res)
10724{
Takashi Iwai889c4392007-08-23 18:56:52 +020010725 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010726 return;
10727 alc268_acer_automute(codec, 1);
10728}
10729
Takashi Iwai889c4392007-08-23 18:56:52 +020010730static void alc268_acer_init_hook(struct hda_codec *codec)
10731{
10732 alc268_acer_automute(codec, 1);
10733}
10734
Kailang Yang8ef355d2008-08-26 13:10:22 +020010735/* toggle speaker-output according to the hp-jack state */
10736static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10737{
10738 unsigned int present;
10739 unsigned char bits;
10740
10741 present = snd_hda_codec_read(codec, 0x15, 0,
10742 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10743 bits = present ? AMP_IN_MUTE(0) : 0;
10744 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10745 AMP_IN_MUTE(0), bits);
10746 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10747 AMP_IN_MUTE(0), bits);
10748}
10749
10750
10751static void alc268_acer_mic_automute(struct hda_codec *codec)
10752{
10753 unsigned int present;
10754
10755 present = snd_hda_codec_read(codec, 0x18, 0,
10756 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10757 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10758 present ? 0x0 : 0x6);
10759}
10760
10761static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10762 unsigned int res)
10763{
10764 if ((res >> 26) == ALC880_HP_EVENT)
10765 alc268_aspire_one_speaker_automute(codec);
10766 if ((res >> 26) == ALC880_MIC_EVENT)
10767 alc268_acer_mic_automute(codec);
10768}
10769
10770static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10771{
10772 alc268_aspire_one_speaker_automute(codec);
10773 alc268_acer_mic_automute(codec);
10774}
10775
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010776static struct snd_kcontrol_new alc268_dell_mixer[] = {
10777 /* output mixer control */
10778 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10779 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10780 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10783 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10784 { }
10785};
10786
10787static struct hda_verb alc268_dell_verbs[] = {
10788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10790 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10791 { }
10792};
10793
10794/* mute/unmute internal speaker according to the hp jack and mute state */
10795static void alc268_dell_automute(struct hda_codec *codec)
10796{
10797 unsigned int present;
10798 unsigned int mute;
10799
10800 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10801 if (present & 0x80000000)
10802 mute = HDA_AMP_MUTE;
10803 else
10804 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10805 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10806 HDA_AMP_MUTE, mute);
10807}
10808
10809static void alc268_dell_unsol_event(struct hda_codec *codec,
10810 unsigned int res)
10811{
10812 if ((res >> 26) != ALC880_HP_EVENT)
10813 return;
10814 alc268_dell_automute(codec);
10815}
10816
10817#define alc268_dell_init_hook alc268_dell_automute
10818
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010819static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10820 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10821 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10822 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10824 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10825 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10826 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10827 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10828 { }
10829};
10830
10831static struct hda_verb alc267_quanta_il1_verbs[] = {
10832 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10834 { }
10835};
10836
10837static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10838{
10839 unsigned int present;
10840
10841 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10842 & AC_PINSENSE_PRESENCE;
10843 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10844 present ? 0 : PIN_OUT);
10845}
10846
10847static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10848{
10849 unsigned int present;
10850
10851 present = snd_hda_codec_read(codec, 0x18, 0,
10852 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10853 snd_hda_codec_write(codec, 0x23, 0,
10854 AC_VERB_SET_CONNECT_SEL,
10855 present ? 0x00 : 0x01);
10856}
10857
10858static void alc267_quanta_il1_automute(struct hda_codec *codec)
10859{
10860 alc267_quanta_il1_hp_automute(codec);
10861 alc267_quanta_il1_mic_automute(codec);
10862}
10863
10864static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10865 unsigned int res)
10866{
10867 switch (res >> 26) {
10868 case ALC880_HP_EVENT:
10869 alc267_quanta_il1_hp_automute(codec);
10870 break;
10871 case ALC880_MIC_EVENT:
10872 alc267_quanta_il1_mic_automute(codec);
10873 break;
10874 }
10875}
10876
Kailang Yanga361d842007-06-05 12:30:55 +020010877/*
10878 * generic initialization of ADC, input mixers and output mixers
10879 */
10880static struct hda_verb alc268_base_init_verbs[] = {
10881 /* Unmute DAC0-1 and set vol = 0 */
10882 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10883 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10884 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10885 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10887 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10888
10889 /*
10890 * Set up output mixers (0x0c - 0x0e)
10891 */
10892 /* set vol=0 to output mixers */
10893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10895 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10896 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10897
10898 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10899 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10900
10901 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10904 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10906 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10907 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10908 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10909
10910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10914 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10916 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010917
10918 /* set PCBEEP vol = 0, mute connections */
10919 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10921 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010922
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010923 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010924
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010925 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10927 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010929
Kailang Yanga361d842007-06-05 12:30:55 +020010930 { }
10931};
10932
10933/*
10934 * generic initialization of ADC, input mixers and output mixers
10935 */
10936static struct hda_verb alc268_volume_init_verbs[] = {
10937 /* set output DAC */
10938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10939 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10940 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10941 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10942
10943 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10947 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10948
10949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10953 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10954
10955 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10958 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10959
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010960 /* set PCBEEP vol = 0, mute connections */
10961 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10962 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10963 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010964
10965 { }
10966};
10967
Kailang Yanga361d842007-06-05 12:30:55 +020010968static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10969 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10970 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10971 {
10972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10973 /* The multiple "Capture Source" controls confuse alsamixer
10974 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010975 */
10976 /* .name = "Capture Source", */
10977 .name = "Input Source",
10978 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010979 .info = alc_mux_enum_info,
10980 .get = alc_mux_enum_get,
10981 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020010982 },
10983 { } /* end */
10984};
10985
10986static struct snd_kcontrol_new alc268_capture_mixer[] = {
10987 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10988 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10991 {
10992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10993 /* The multiple "Capture Source" controls confuse alsamixer
10994 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010995 */
10996 /* .name = "Capture Source", */
10997 .name = "Input Source",
10998 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010999 .info = alc_mux_enum_info,
11000 .get = alc_mux_enum_get,
11001 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011002 },
11003 { } /* end */
11004};
11005
11006static struct hda_input_mux alc268_capture_source = {
11007 .num_items = 4,
11008 .items = {
11009 { "Mic", 0x0 },
11010 { "Front Mic", 0x1 },
11011 { "Line", 0x2 },
11012 { "CD", 0x3 },
11013 },
11014};
11015
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011016static struct hda_input_mux alc268_acer_capture_source = {
11017 .num_items = 3,
11018 .items = {
11019 { "Mic", 0x0 },
11020 { "Internal Mic", 0x6 },
11021 { "Line", 0x2 },
11022 },
11023};
11024
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011025#ifdef CONFIG_SND_DEBUG
11026static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011027 /* Volume widgets */
11028 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11029 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11030 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11031 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11032 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11033 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11034 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11035 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11036 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11037 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11038 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11039 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11040 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011041 /* The below appears problematic on some hardwares */
11042 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011043 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11044 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11045 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11046 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11047
11048 /* Modes for retasking pin widgets */
11049 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11050 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11051 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11052 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11053
11054 /* Controls for GPIO pins, assuming they are configured as outputs */
11055 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11056 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11057 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11058 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11059
11060 /* Switches to allow the digital SPDIF output pin to be enabled.
11061 * The ALC268 does not have an SPDIF input.
11062 */
11063 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11064
11065 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11066 * this output to turn on an external amplifier.
11067 */
11068 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11069 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11070
11071 { } /* end */
11072};
11073#endif
11074
Kailang Yanga361d842007-06-05 12:30:55 +020011075/* create input playback/capture controls for the given pin */
11076static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11077 const char *ctlname, int idx)
11078{
11079 char name[32];
11080 int err;
11081
11082 sprintf(name, "%s Playback Volume", ctlname);
11083 if (nid == 0x14) {
11084 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11085 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11086 HDA_OUTPUT));
11087 if (err < 0)
11088 return err;
11089 } else if (nid == 0x15) {
11090 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11091 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11092 HDA_OUTPUT));
11093 if (err < 0)
11094 return err;
11095 } else
11096 return -1;
11097 sprintf(name, "%s Playback Switch", ctlname);
11098 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11099 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11100 if (err < 0)
11101 return err;
11102 return 0;
11103}
11104
11105/* add playback controls from the parsed DAC table */
11106static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11107 const struct auto_pin_cfg *cfg)
11108{
11109 hda_nid_t nid;
11110 int err;
11111
11112 spec->multiout.num_dacs = 2; /* only use one dac */
11113 spec->multiout.dac_nids = spec->private_dac_nids;
11114 spec->multiout.dac_nids[0] = 2;
11115 spec->multiout.dac_nids[1] = 3;
11116
11117 nid = cfg->line_out_pins[0];
11118 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011119 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011120
11121 nid = cfg->speaker_pins[0];
11122 if (nid == 0x1d) {
11123 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11124 "Speaker Playback Volume",
11125 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11126 if (err < 0)
11127 return err;
11128 }
11129 nid = cfg->hp_pins[0];
11130 if (nid)
11131 alc268_new_analog_output(spec, nid, "Headphone", 0);
11132
11133 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11134 if (nid == 0x16) {
11135 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11136 "Mono Playback Switch",
11137 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11138 if (err < 0)
11139 return err;
11140 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011141 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011142}
11143
11144/* create playback/capture controls for input pins */
11145static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11146 const struct auto_pin_cfg *cfg)
11147{
11148 struct hda_input_mux *imux = &spec->private_imux;
11149 int i, idx1;
11150
11151 for (i = 0; i < AUTO_PIN_LAST; i++) {
11152 switch(cfg->input_pins[i]) {
11153 case 0x18:
11154 idx1 = 0; /* Mic 1 */
11155 break;
11156 case 0x19:
11157 idx1 = 1; /* Mic 2 */
11158 break;
11159 case 0x1a:
11160 idx1 = 2; /* Line In */
11161 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011162 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011163 idx1 = 3; /* CD */
11164 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011165 case 0x12:
11166 case 0x13:
11167 idx1 = 6; /* digital mics */
11168 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011169 default:
11170 continue;
11171 }
11172 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11173 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011174 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011175 }
11176 return 0;
11177}
11178
11179static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11180{
11181 struct alc_spec *spec = codec->spec;
11182 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11183 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11184 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11185 unsigned int dac_vol1, dac_vol2;
11186
11187 if (speaker_nid) {
11188 snd_hda_codec_write(codec, speaker_nid, 0,
11189 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11190 snd_hda_codec_write(codec, 0x0f, 0,
11191 AC_VERB_SET_AMP_GAIN_MUTE,
11192 AMP_IN_UNMUTE(1));
11193 snd_hda_codec_write(codec, 0x10, 0,
11194 AC_VERB_SET_AMP_GAIN_MUTE,
11195 AMP_IN_UNMUTE(1));
11196 } else {
11197 snd_hda_codec_write(codec, 0x0f, 0,
11198 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11199 snd_hda_codec_write(codec, 0x10, 0,
11200 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11201 }
11202
11203 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011204 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011205 dac_vol2 = AMP_OUT_ZERO;
11206 else if (line_nid == 0x15)
11207 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011208 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011209 dac_vol2 = AMP_OUT_ZERO;
11210 else if (hp_nid == 0x15)
11211 dac_vol1 = AMP_OUT_ZERO;
11212 if (line_nid != 0x16 || hp_nid != 0x16 ||
11213 spec->autocfg.line_out_pins[1] != 0x16 ||
11214 spec->autocfg.line_out_pins[2] != 0x16)
11215 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11216
11217 snd_hda_codec_write(codec, 0x02, 0,
11218 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11219 snd_hda_codec_write(codec, 0x03, 0,
11220 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11221}
11222
11223/* pcm configuration: identiacal with ALC880 */
11224#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11225#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011226#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011227#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11228
11229/*
11230 * BIOS auto configuration
11231 */
11232static int alc268_parse_auto_config(struct hda_codec *codec)
11233{
11234 struct alc_spec *spec = codec->spec;
11235 int err;
11236 static hda_nid_t alc268_ignore[] = { 0 };
11237
11238 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11239 alc268_ignore);
11240 if (err < 0)
11241 return err;
11242 if (!spec->autocfg.line_outs)
11243 return 0; /* can't find valid BIOS pin config */
11244
11245 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11246 if (err < 0)
11247 return err;
11248 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11249 if (err < 0)
11250 return err;
11251
11252 spec->multiout.max_channels = 2;
11253
11254 /* digital only support output */
11255 if (spec->autocfg.dig_out_pin)
11256 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11257
Takashi Iwai603c4012008-07-30 15:01:44 +020011258 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011259 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011260
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011261 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011262 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011263
Takashi Iwaid88897e2008-10-31 15:01:37 +010011264 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011265 spec->num_mux_defs = 1;
11266 spec->input_mux = &spec->private_imux;
11267
Takashi Iwai776e1842007-08-29 15:07:11 +020011268 err = alc_auto_add_mic_boost(codec);
11269 if (err < 0)
11270 return err;
11271
Takashi Iwaie044c392008-10-27 16:56:24 +010011272 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011273 return 1;
11274}
11275
11276#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11277#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11278#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11279
11280/* init callback for auto-configuration model -- overriding the default init */
11281static void alc268_auto_init(struct hda_codec *codec)
11282{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011283 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011284 alc268_auto_init_multi_out(codec);
11285 alc268_auto_init_hp_out(codec);
11286 alc268_auto_init_mono_speaker_out(codec);
11287 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011288 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011289 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011290}
11291
11292/*
11293 * configuration and preset
11294 */
11295static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011296 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011297 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011298 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011299 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011300 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011301 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011302 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011303#ifdef CONFIG_SND_DEBUG
11304 [ALC268_TEST] = "test",
11305#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011306 [ALC268_AUTO] = "auto",
11307};
11308
11309static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011310 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011311 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011312 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011313 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011314 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011315 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11316 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011317 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011318 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011319 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011320 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011321 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011322 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011323 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011324 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011325 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011326 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011327 {}
11328};
11329
11330static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011331 [ALC267_QUANTA_IL1] = {
11332 .mixers = { alc267_quanta_il1_mixer },
11333 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11334 alc267_quanta_il1_verbs },
11335 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11336 .dac_nids = alc268_dac_nids,
11337 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11338 .adc_nids = alc268_adc_nids_alt,
11339 .hp_nid = 0x03,
11340 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11341 .channel_mode = alc268_modes,
11342 .input_mux = &alc268_capture_source,
11343 .unsol_event = alc267_quanta_il1_unsol_event,
11344 .init_hook = alc267_quanta_il1_automute,
11345 },
Kailang Yanga361d842007-06-05 12:30:55 +020011346 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011347 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11348 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011349 .init_verbs = { alc268_base_init_verbs },
11350 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11351 .dac_nids = alc268_dac_nids,
11352 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11353 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011354 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011355 .hp_nid = 0x03,
11356 .dig_out_nid = ALC268_DIGOUT_NID,
11357 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11358 .channel_mode = alc268_modes,
11359 .input_mux = &alc268_capture_source,
11360 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011361 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011362 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11363 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011364 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11365 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011366 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11367 .dac_nids = alc268_dac_nids,
11368 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11369 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011370 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011371 .hp_nid = 0x03,
11372 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11373 .channel_mode = alc268_modes,
11374 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011375 .unsol_event = alc268_toshiba_unsol_event,
11376 .init_hook = alc268_toshiba_automute,
11377 },
11378 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011379 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11380 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011381 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11382 alc268_acer_verbs },
11383 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11384 .dac_nids = alc268_dac_nids,
11385 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11386 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011387 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011388 .hp_nid = 0x02,
11389 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11390 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011391 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011392 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011393 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011394 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011395 [ALC268_ACER_ASPIRE_ONE] = {
11396 .mixers = { alc268_acer_aspire_one_mixer,
11397 alc268_capture_alt_mixer },
11398 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11399 alc268_acer_aspire_one_verbs },
11400 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11401 .dac_nids = alc268_dac_nids,
11402 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11403 .adc_nids = alc268_adc_nids_alt,
11404 .capsrc_nids = alc268_capsrc_nids,
11405 .hp_nid = 0x03,
11406 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11407 .channel_mode = alc268_modes,
11408 .input_mux = &alc268_acer_lc_capture_source,
11409 .unsol_event = alc268_acer_lc_unsol_event,
11410 .init_hook = alc268_acer_lc_init_hook,
11411 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011412 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011413 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011414 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11415 alc268_dell_verbs },
11416 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11417 .dac_nids = alc268_dac_nids,
11418 .hp_nid = 0x02,
11419 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11420 .channel_mode = alc268_modes,
11421 .unsol_event = alc268_dell_unsol_event,
11422 .init_hook = alc268_dell_init_hook,
11423 .input_mux = &alc268_capture_source,
11424 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011425 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011426 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11427 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011428 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11429 alc268_toshiba_verbs },
11430 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11431 .dac_nids = alc268_dac_nids,
11432 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11433 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011434 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011435 .hp_nid = 0x03,
11436 .dig_out_nid = ALC268_DIGOUT_NID,
11437 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11438 .channel_mode = alc268_modes,
11439 .input_mux = &alc268_capture_source,
11440 .unsol_event = alc268_toshiba_unsol_event,
11441 .init_hook = alc268_toshiba_automute
11442 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011443#ifdef CONFIG_SND_DEBUG
11444 [ALC268_TEST] = {
11445 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11446 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11447 alc268_volume_init_verbs },
11448 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11449 .dac_nids = alc268_dac_nids,
11450 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11451 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011452 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011453 .hp_nid = 0x03,
11454 .dig_out_nid = ALC268_DIGOUT_NID,
11455 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11456 .channel_mode = alc268_modes,
11457 .input_mux = &alc268_capture_source,
11458 },
11459#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011460};
11461
11462static int patch_alc268(struct hda_codec *codec)
11463{
11464 struct alc_spec *spec;
11465 int board_config;
11466 int err;
11467
11468 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11469 if (spec == NULL)
11470 return -ENOMEM;
11471
11472 codec->spec = spec;
11473
11474 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11475 alc268_models,
11476 alc268_cfg_tbl);
11477
11478 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11479 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11480 "trying auto-probe from BIOS...\n");
11481 board_config = ALC268_AUTO;
11482 }
11483
11484 if (board_config == ALC268_AUTO) {
11485 /* automatic parse from the BIOS config */
11486 err = alc268_parse_auto_config(codec);
11487 if (err < 0) {
11488 alc_free(codec);
11489 return err;
11490 } else if (!err) {
11491 printk(KERN_INFO
11492 "hda_codec: Cannot set up configuration "
11493 "from BIOS. Using base mode...\n");
11494 board_config = ALC268_3ST;
11495 }
11496 }
11497
11498 if (board_config != ALC268_AUTO)
11499 setup_preset(spec, &alc268_presets[board_config]);
11500
Kailang Yang2f893282008-05-27 12:14:47 +020011501 if (codec->vendor_id == 0x10ec0267) {
11502 spec->stream_name_analog = "ALC267 Analog";
11503 spec->stream_name_digital = "ALC267 Digital";
11504 } else {
11505 spec->stream_name_analog = "ALC268 Analog";
11506 spec->stream_name_digital = "ALC268 Digital";
11507 }
11508
Kailang Yanga361d842007-06-05 12:30:55 +020011509 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11510 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011511 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011512
Kailang Yanga361d842007-06-05 12:30:55 +020011513 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11514
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011515 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11516 /* override the amp caps for beep generator */
11517 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11518 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11519 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11520 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11521 (0 << AC_AMPCAP_MUTE_SHIFT));
11522
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011523 if (!spec->adc_nids && spec->input_mux) {
11524 /* check whether NID 0x07 is valid */
11525 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011526 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011527
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011528 /* get type */
11529 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011530 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011531 spec->adc_nids = alc268_adc_nids_alt;
11532 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011533 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011534 } else {
11535 spec->adc_nids = alc268_adc_nids;
11536 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011537 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011538 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011539 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011540 /* set default input source */
11541 for (i = 0; i < spec->num_adc_nids; i++)
11542 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11543 0, AC_VERB_SET_CONNECT_SEL,
11544 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011545 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011546
11547 spec->vmaster_nid = 0x02;
11548
Kailang Yanga361d842007-06-05 12:30:55 +020011549 codec->patch_ops = alc_patch_ops;
11550 if (board_config == ALC268_AUTO)
11551 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011552
Kailang Yanga361d842007-06-05 12:30:55 +020011553 return 0;
11554}
11555
11556/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011557 * ALC269 channel source setting (2 channel)
11558 */
11559#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11560
11561#define alc269_dac_nids alc260_dac_nids
11562
11563static hda_nid_t alc269_adc_nids[1] = {
11564 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011565 0x08,
11566};
11567
Takashi Iwaie01bf502008-08-21 16:25:07 +020011568static hda_nid_t alc269_capsrc_nids[1] = {
11569 0x23,
11570};
11571
11572/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11573 * not a mux!
11574 */
11575
Kailang Yangf53281e2008-07-18 12:36:43 +020011576static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11577 .num_items = 2,
11578 .items = {
11579 { "i-Mic", 0x5 },
11580 { "e-Mic", 0x0 },
11581 },
11582};
11583
11584static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11585 .num_items = 2,
11586 .items = {
11587 { "i-Mic", 0x1 },
11588 { "e-Mic", 0x0 },
11589 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011590};
11591
11592#define alc269_modes alc260_modes
11593#define alc269_capture_source alc880_lg_lw_capture_source
11594
11595static struct snd_kcontrol_new alc269_base_mixer[] = {
11596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11597 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11598 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11599 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011602 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11603 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011604 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11605 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11607 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11608 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11609 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11610 { } /* end */
11611};
11612
Kailang Yang60db6b52008-08-26 13:13:00 +020011613static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11614 /* output mixer control */
11615 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11616 {
11617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11618 .name = "Master Playback Switch",
11619 .info = snd_hda_mixer_amp_switch_info,
11620 .get = snd_hda_mixer_amp_switch_get,
11621 .put = alc268_acer_master_sw_put,
11622 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11623 },
11624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11626 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11627 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11628 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11629 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11630 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11631 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11632 { }
11633};
11634
Kailang Yangf53281e2008-07-18 12:36:43 +020011635/* bind volumes of both NID 0x0c and 0x0d */
11636static struct hda_bind_ctls alc269_epc_bind_vol = {
11637 .ops = &snd_hda_bind_vol,
11638 .values = {
11639 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11640 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11641 0
11642 },
11643};
11644
11645static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11646 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11647 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11648 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11649 { } /* end */
11650};
11651
Kailang Yangf6a92242007-12-13 16:52:54 +010011652/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020011653static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11654 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11655 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11656 { } /* end */
11657};
11658
Takashi Iwai2005af22008-08-20 18:38:26 +020011659/* beep control */
11660static struct snd_kcontrol_new alc269_beep_mixer[] = {
11661 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11662 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11663 { } /* end */
11664};
11665
Kailang Yang60db6b52008-08-26 13:13:00 +020011666static struct hda_verb alc269_quanta_fl1_verbs[] = {
11667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11668 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11670 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11671 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11672 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11673 { }
11674};
11675
11676/* toggle speaker-output according to the hp-jack state */
11677static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11678{
11679 unsigned int present;
11680 unsigned char bits;
11681
11682 present = snd_hda_codec_read(codec, 0x15, 0,
11683 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11684 bits = present ? AMP_IN_MUTE(0) : 0;
11685 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11686 AMP_IN_MUTE(0), bits);
11687 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11688 AMP_IN_MUTE(0), bits);
11689
11690 snd_hda_codec_write(codec, 0x20, 0,
11691 AC_VERB_SET_COEF_INDEX, 0x0c);
11692 snd_hda_codec_write(codec, 0x20, 0,
11693 AC_VERB_SET_PROC_COEF, 0x680);
11694
11695 snd_hda_codec_write(codec, 0x20, 0,
11696 AC_VERB_SET_COEF_INDEX, 0x0c);
11697 snd_hda_codec_write(codec, 0x20, 0,
11698 AC_VERB_SET_PROC_COEF, 0x480);
11699}
11700
11701static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11702{
11703 unsigned int present;
11704
11705 present = snd_hda_codec_read(codec, 0x18, 0,
11706 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11707 snd_hda_codec_write(codec, 0x23, 0,
11708 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11709}
11710
11711static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11712 unsigned int res)
11713{
11714 if ((res >> 26) == ALC880_HP_EVENT)
11715 alc269_quanta_fl1_speaker_automute(codec);
11716 if ((res >> 26) == ALC880_MIC_EVENT)
11717 alc269_quanta_fl1_mic_automute(codec);
11718}
11719
11720static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11721{
11722 alc269_quanta_fl1_speaker_automute(codec);
11723 alc269_quanta_fl1_mic_automute(codec);
11724}
11725
11726static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11728 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11729 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11731 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11732 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11733 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11734 {}
11735};
11736
11737static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11739 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11740 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11741 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11744 {}
11745};
11746
11747/* toggle speaker-output according to the hp-jack state */
11748static void alc269_speaker_automute(struct hda_codec *codec)
11749{
11750 unsigned int present;
11751 unsigned char bits;
11752
11753 present = snd_hda_codec_read(codec, 0x15, 0,
11754 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11755 bits = present ? AMP_IN_MUTE(0) : 0;
11756 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11757 AMP_IN_MUTE(0), bits);
11758 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11759 AMP_IN_MUTE(0), bits);
11760}
11761
11762static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11763{
11764 unsigned int present;
11765
11766 present = snd_hda_codec_read(codec, 0x18, 0,
11767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11768 snd_hda_codec_write(codec, 0x23, 0,
11769 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11770}
11771
11772static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11773{
11774 unsigned int present;
11775
11776 present = snd_hda_codec_read(codec, 0x18, 0,
11777 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11778 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11779 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11780 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11781 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11782}
11783
11784/* unsolicited event for HP jack sensing */
11785static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11786 unsigned int res)
11787{
11788 if ((res >> 26) == ALC880_HP_EVENT)
11789 alc269_speaker_automute(codec);
11790
11791 if ((res >> 26) == ALC880_MIC_EVENT)
11792 alc269_eeepc_dmic_automute(codec);
11793}
11794
11795static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11796{
11797 alc269_speaker_automute(codec);
11798 alc269_eeepc_dmic_automute(codec);
11799}
11800
11801/* unsolicited event for HP jack sensing */
11802static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11803 unsigned int res)
11804{
11805 if ((res >> 26) == ALC880_HP_EVENT)
11806 alc269_speaker_automute(codec);
11807
11808 if ((res >> 26) == ALC880_MIC_EVENT)
11809 alc269_eeepc_amic_automute(codec);
11810}
11811
11812static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11813{
11814 alc269_speaker_automute(codec);
11815 alc269_eeepc_amic_automute(codec);
11816}
11817
Kailang Yangf6a92242007-12-13 16:52:54 +010011818/*
11819 * generic initialization of ADC, input mixers and output mixers
11820 */
11821static struct hda_verb alc269_init_verbs[] = {
11822 /*
11823 * Unmute ADC0 and set the default input to mic-in
11824 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011826
11827 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11828 * analog-loopback mixer widget
11829 * Note: PASD motherboards uses the Line In 2 as the input for
11830 * front panel mic (mic 2)
11831 */
11832 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11838
11839 /*
11840 * Set up output mixers (0x0c - 0x0e)
11841 */
11842 /* set vol=0 to output mixers */
11843 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11844 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11845
11846 /* set up input amps for analog loopback */
11847 /* Amp Indices: DAC = 0, mixer = 1 */
11848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11854
11855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11860 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11862
11863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11870
11871 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11873
11874 /* FIXME: use matrix-type input source selection */
11875 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11876 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020011877 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11878 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011879 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11880 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11881
11882 /* set EAPD */
11883 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11884 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11885 { }
11886};
11887
11888/* add playback controls from the parsed DAC table */
11889static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11890 const struct auto_pin_cfg *cfg)
11891{
11892 hda_nid_t nid;
11893 int err;
11894
11895 spec->multiout.num_dacs = 1; /* only use one dac */
11896 spec->multiout.dac_nids = spec->private_dac_nids;
11897 spec->multiout.dac_nids[0] = 2;
11898
11899 nid = cfg->line_out_pins[0];
11900 if (nid) {
11901 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11902 "Front Playback Volume",
11903 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11904 if (err < 0)
11905 return err;
11906 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11907 "Front Playback Switch",
11908 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11909 if (err < 0)
11910 return err;
11911 }
11912
11913 nid = cfg->speaker_pins[0];
11914 if (nid) {
11915 if (!cfg->line_out_pins[0]) {
11916 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11917 "Speaker Playback Volume",
11918 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11919 HDA_OUTPUT));
11920 if (err < 0)
11921 return err;
11922 }
11923 if (nid == 0x16) {
11924 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11925 "Speaker Playback Switch",
11926 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11927 HDA_OUTPUT));
11928 if (err < 0)
11929 return err;
11930 } else {
11931 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11932 "Speaker Playback Switch",
11933 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11934 HDA_OUTPUT));
11935 if (err < 0)
11936 return err;
11937 }
11938 }
11939 nid = cfg->hp_pins[0];
11940 if (nid) {
11941 /* spec->multiout.hp_nid = 2; */
11942 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11943 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11944 "Headphone Playback Volume",
11945 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11946 HDA_OUTPUT));
11947 if (err < 0)
11948 return err;
11949 }
11950 if (nid == 0x16) {
11951 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11952 "Headphone Playback Switch",
11953 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11954 HDA_OUTPUT));
11955 if (err < 0)
11956 return err;
11957 } else {
11958 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11959 "Headphone Playback Switch",
11960 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11961 HDA_OUTPUT));
11962 if (err < 0)
11963 return err;
11964 }
11965 }
11966 return 0;
11967}
11968
Takashi Iwaiee956e02008-10-31 17:16:31 +010011969static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
11970 const struct auto_pin_cfg *cfg)
11971{
11972 int err;
11973
11974 err = alc880_auto_create_analog_input_ctls(spec, cfg);
11975 if (err < 0)
11976 return err;
11977 /* digital-mic input pin is excluded in alc880_auto_create..()
11978 * because it's under 0x18
11979 */
11980 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
11981 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
11982 struct hda_input_mux *imux = &spec->private_imux;
11983 imux->items[imux->num_items].label = "Int Mic";
11984 imux->items[imux->num_items].index = 0x05;
11985 imux->num_items++;
11986 }
11987 return 0;
11988}
Kailang Yangf6a92242007-12-13 16:52:54 +010011989
11990#ifdef CONFIG_SND_HDA_POWER_SAVE
11991#define alc269_loopbacks alc880_loopbacks
11992#endif
11993
11994/* pcm configuration: identiacal with ALC880 */
11995#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11996#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11997#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11998#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11999
12000/*
12001 * BIOS auto configuration
12002 */
12003static int alc269_parse_auto_config(struct hda_codec *codec)
12004{
12005 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012006 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012007 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12008
12009 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12010 alc269_ignore);
12011 if (err < 0)
12012 return err;
12013
12014 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12015 if (err < 0)
12016 return err;
12017 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12018 if (err < 0)
12019 return err;
12020
12021 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12022
12023 if (spec->autocfg.dig_out_pin)
12024 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12025
Takashi Iwai603c4012008-07-30 15:01:44 +020012026 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012027 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012028
Takashi Iwai2005af22008-08-20 18:38:26 +020012029 /* create a beep mixer control if the pin 0x1d isn't assigned */
12030 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12031 if (spec->autocfg.input_pins[i] == 0x1d)
12032 break;
12033 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012034 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012035
Takashi Iwaid88897e2008-10-31 15:01:37 +010012036 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012037 spec->num_mux_defs = 1;
12038 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012039 /* set default input source */
12040 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12041 0, AC_VERB_SET_CONNECT_SEL,
12042 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012043
12044 err = alc_auto_add_mic_boost(codec);
12045 if (err < 0)
12046 return err;
12047
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012048 if (!spec->cap_mixer)
12049 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012050
Takashi Iwaie044c392008-10-27 16:56:24 +010012051 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012052 return 1;
12053}
12054
12055#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12056#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12057#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12058
12059
12060/* init callback for auto-configuration model -- overriding the default init */
12061static void alc269_auto_init(struct hda_codec *codec)
12062{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012063 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012064 alc269_auto_init_multi_out(codec);
12065 alc269_auto_init_hp_out(codec);
12066 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012067 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012068 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012069}
12070
12071/*
12072 * configuration and preset
12073 */
12074static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012075 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012076 [ALC269_QUANTA_FL1] = "quanta",
12077 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12078 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901"
Kailang Yangf6a92242007-12-13 16:52:54 +010012079};
12080
12081static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012082 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012083 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12084 ALC269_ASUS_EEEPC_P703),
12085 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12086 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012087 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12088 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010012089 {}
12090};
12091
12092static struct alc_config_preset alc269_presets[] = {
12093 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012094 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012095 .init_verbs = { alc269_init_verbs },
12096 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12097 .dac_nids = alc269_dac_nids,
12098 .hp_nid = 0x03,
12099 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12100 .channel_mode = alc269_modes,
12101 .input_mux = &alc269_capture_source,
12102 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012103 [ALC269_QUANTA_FL1] = {
12104 .mixers = { alc269_quanta_fl1_mixer },
12105 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12106 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12107 .dac_nids = alc269_dac_nids,
12108 .hp_nid = 0x03,
12109 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12110 .channel_mode = alc269_modes,
12111 .input_mux = &alc269_capture_source,
12112 .unsol_event = alc269_quanta_fl1_unsol_event,
12113 .init_hook = alc269_quanta_fl1_init_hook,
12114 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012115 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012116 .mixers = { alc269_eeepc_mixer },
12117 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012118 .init_verbs = { alc269_init_verbs,
12119 alc269_eeepc_amic_init_verbs },
12120 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12121 .dac_nids = alc269_dac_nids,
12122 .hp_nid = 0x03,
12123 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12124 .channel_mode = alc269_modes,
12125 .input_mux = &alc269_eeepc_amic_capture_source,
12126 .unsol_event = alc269_eeepc_amic_unsol_event,
12127 .init_hook = alc269_eeepc_amic_inithook,
12128 },
12129 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012130 .mixers = { alc269_eeepc_mixer },
12131 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012132 .init_verbs = { alc269_init_verbs,
12133 alc269_eeepc_dmic_init_verbs },
12134 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12135 .dac_nids = alc269_dac_nids,
12136 .hp_nid = 0x03,
12137 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12138 .channel_mode = alc269_modes,
12139 .input_mux = &alc269_eeepc_dmic_capture_source,
12140 .unsol_event = alc269_eeepc_dmic_unsol_event,
12141 .init_hook = alc269_eeepc_dmic_inithook,
12142 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012143};
12144
12145static int patch_alc269(struct hda_codec *codec)
12146{
12147 struct alc_spec *spec;
12148 int board_config;
12149 int err;
12150
12151 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12152 if (spec == NULL)
12153 return -ENOMEM;
12154
12155 codec->spec = spec;
12156
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012157 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12158
Kailang Yangf6a92242007-12-13 16:52:54 +010012159 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12160 alc269_models,
12161 alc269_cfg_tbl);
12162
12163 if (board_config < 0) {
12164 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12165 "trying auto-probe from BIOS...\n");
12166 board_config = ALC269_AUTO;
12167 }
12168
12169 if (board_config == ALC269_AUTO) {
12170 /* automatic parse from the BIOS config */
12171 err = alc269_parse_auto_config(codec);
12172 if (err < 0) {
12173 alc_free(codec);
12174 return err;
12175 } else if (!err) {
12176 printk(KERN_INFO
12177 "hda_codec: Cannot set up configuration "
12178 "from BIOS. Using base mode...\n");
12179 board_config = ALC269_BASIC;
12180 }
12181 }
12182
12183 if (board_config != ALC269_AUTO)
12184 setup_preset(spec, &alc269_presets[board_config]);
12185
12186 spec->stream_name_analog = "ALC269 Analog";
12187 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12188 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12189
12190 spec->stream_name_digital = "ALC269 Digital";
12191 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12192 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12193
12194 spec->adc_nids = alc269_adc_nids;
12195 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012196 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012197 if (!spec->cap_mixer)
12198 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012199
12200 codec->patch_ops = alc_patch_ops;
12201 if (board_config == ALC269_AUTO)
12202 spec->init_hook = alc269_auto_init;
12203#ifdef CONFIG_SND_HDA_POWER_SAVE
12204 if (!spec->loopback.amplist)
12205 spec->loopback.amplist = alc269_loopbacks;
12206#endif
12207
12208 return 0;
12209}
12210
12211/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012212 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12213 */
12214
12215/*
12216 * set the path ways for 2 channel output
12217 * need to set the codec line out and mic 1 pin widgets to inputs
12218 */
12219static struct hda_verb alc861_threestack_ch2_init[] = {
12220 /* set pin widget 1Ah (line in) for input */
12221 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012222 /* set pin widget 18h (mic1/2) for input, for mic also enable
12223 * the vref
12224 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012225 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12226
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012227 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12228#if 0
12229 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12230 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12231#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 { } /* end */
12233};
12234/*
12235 * 6ch mode
12236 * need to set the codec line out and mic 1 pin widgets to outputs
12237 */
12238static struct hda_verb alc861_threestack_ch6_init[] = {
12239 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12240 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12241 /* set pin widget 18h (mic1) for output (CLFE)*/
12242 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12243
12244 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012245 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012246
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012247 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12248#if 0
12249 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12250 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12251#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012252 { } /* end */
12253};
12254
12255static struct hda_channel_mode alc861_threestack_modes[2] = {
12256 { 2, alc861_threestack_ch2_init },
12257 { 6, alc861_threestack_ch6_init },
12258};
Takashi Iwai22309c32006-08-09 16:57:28 +020012259/* Set mic1 as input and unmute the mixer */
12260static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12261 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12262 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12263 { } /* end */
12264};
12265/* Set mic1 as output and mute mixer */
12266static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12267 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12268 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12269 { } /* end */
12270};
12271
12272static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12273 { 2, alc861_uniwill_m31_ch2_init },
12274 { 4, alc861_uniwill_m31_ch4_init },
12275};
Kailang Yangdf694da2005-12-05 19:42:22 +010012276
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012277/* Set mic1 and line-in as input and unmute the mixer */
12278static struct hda_verb alc861_asus_ch2_init[] = {
12279 /* set pin widget 1Ah (line in) for input */
12280 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012281 /* set pin widget 18h (mic1/2) for input, for mic also enable
12282 * the vref
12283 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012284 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12285
12286 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12287#if 0
12288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12289 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12290#endif
12291 { } /* end */
12292};
12293/* Set mic1 nad line-in as output and mute mixer */
12294static struct hda_verb alc861_asus_ch6_init[] = {
12295 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12296 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12297 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12298 /* set pin widget 18h (mic1) for output (CLFE)*/
12299 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12300 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12301 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12302 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12303
12304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12305#if 0
12306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12308#endif
12309 { } /* end */
12310};
12311
12312static struct hda_channel_mode alc861_asus_modes[2] = {
12313 { 2, alc861_asus_ch2_init },
12314 { 6, alc861_asus_ch6_init },
12315};
12316
Kailang Yangdf694da2005-12-05 19:42:22 +010012317/* patch-ALC861 */
12318
12319static struct snd_kcontrol_new alc861_base_mixer[] = {
12320 /* output mixer control */
12321 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12322 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12323 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12324 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12325 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12326
12327 /*Input mixer control */
12328 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12329 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12330 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12331 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12332 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12333 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12335 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12336 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012338
Kailang Yangdf694da2005-12-05 19:42:22 +010012339 { } /* end */
12340};
12341
12342static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12343 /* output mixer control */
12344 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12345 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12346 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12347 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12348 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12349
12350 /* Input mixer control */
12351 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12352 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12353 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12354 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12355 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12356 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12358 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12359 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012361
Kailang Yangdf694da2005-12-05 19:42:22 +010012362 {
12363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12364 .name = "Channel Mode",
12365 .info = alc_ch_mode_info,
12366 .get = alc_ch_mode_get,
12367 .put = alc_ch_mode_put,
12368 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12369 },
12370 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012371};
12372
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012373static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012374 /* output mixer control */
12375 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12377 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012378
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012379 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012380};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012381
Takashi Iwai22309c32006-08-09 16:57:28 +020012382static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12383 /* output mixer control */
12384 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12385 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12386 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12387 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12388 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12389
12390 /* Input mixer control */
12391 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12392 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12393 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12394 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12395 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12396 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12398 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12399 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12400 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012401
Takashi Iwai22309c32006-08-09 16:57:28 +020012402 {
12403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12404 .name = "Channel Mode",
12405 .info = alc_ch_mode_info,
12406 .get = alc_ch_mode_get,
12407 .put = alc_ch_mode_put,
12408 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12409 },
12410 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012411};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012412
12413static struct snd_kcontrol_new alc861_asus_mixer[] = {
12414 /* output mixer control */
12415 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12416 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12417 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12418 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12419 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12420
12421 /* Input mixer control */
12422 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12423 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12424 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12425 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12426 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12427 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12429 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12430 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12432
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012433 {
12434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12435 .name = "Channel Mode",
12436 .info = alc_ch_mode_info,
12437 .get = alc_ch_mode_get,
12438 .put = alc_ch_mode_put,
12439 .private_value = ARRAY_SIZE(alc861_asus_modes),
12440 },
12441 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012442};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012443
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012444/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012445static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012446 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12447 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12448 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12449 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12450 { }
12451};
12452
Kailang Yangdf694da2005-12-05 19:42:22 +010012453/*
12454 * generic initialization of ADC, input mixers and output mixers
12455 */
12456static struct hda_verb alc861_base_init_verbs[] = {
12457 /*
12458 * Unmute ADC0 and set the default input to mic-in
12459 */
12460 /* port-A for surround (rear panel) */
12461 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12462 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12463 /* port-B for mic-in (rear panel) with vref */
12464 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12465 /* port-C for line-in (rear panel) */
12466 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12467 /* port-D for Front */
12468 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12469 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12470 /* port-E for HP out (front panel) */
12471 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12472 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012473 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012474 /* port-F for mic-in (front panel) with vref */
12475 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12476 /* port-G for CLFE (rear panel) */
12477 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12478 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12479 /* port-H for side (rear panel) */
12480 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12481 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12482 /* CD-in */
12483 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12484 /* route front mic to ADC1*/
12485 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012487
Kailang Yangdf694da2005-12-05 19:42:22 +010012488 /* Unmute DAC0~3 & spdif out*/
12489 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12490 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12491 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12492 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012494
Kailang Yangdf694da2005-12-05 19:42:22 +010012495 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12496 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12497 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12498 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12499 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012500
Kailang Yangdf694da2005-12-05 19:42:22 +010012501 /* Unmute Stereo Mixer 15 */
12502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012506
12507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012515 /* hp used DAC 3 (Front) */
12516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12518
12519 { }
12520};
12521
12522static struct hda_verb alc861_threestack_init_verbs[] = {
12523 /*
12524 * Unmute ADC0 and set the default input to mic-in
12525 */
12526 /* port-A for surround (rear panel) */
12527 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12528 /* port-B for mic-in (rear panel) with vref */
12529 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12530 /* port-C for line-in (rear panel) */
12531 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12532 /* port-D for Front */
12533 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12534 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12535 /* port-E for HP out (front panel) */
12536 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12537 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012538 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012539 /* port-F for mic-in (front panel) with vref */
12540 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12541 /* port-G for CLFE (rear panel) */
12542 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12543 /* port-H for side (rear panel) */
12544 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12545 /* CD-in */
12546 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12547 /* route front mic to ADC1*/
12548 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12550 /* Unmute DAC0~3 & spdif out*/
12551 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12552 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12553 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12554 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012556
Kailang Yangdf694da2005-12-05 19:42:22 +010012557 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12558 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12559 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12560 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12561 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012562
Kailang Yangdf694da2005-12-05 19:42:22 +010012563 /* Unmute Stereo Mixer 15 */
12564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012568
12569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12571 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12572 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12573 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012577 /* hp used DAC 3 (Front) */
12578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12580 { }
12581};
Takashi Iwai22309c32006-08-09 16:57:28 +020012582
12583static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12584 /*
12585 * Unmute ADC0 and set the default input to mic-in
12586 */
12587 /* port-A for surround (rear panel) */
12588 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12589 /* port-B for mic-in (rear panel) with vref */
12590 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12591 /* port-C for line-in (rear panel) */
12592 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12593 /* port-D for Front */
12594 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12595 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12596 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012597 /* this has to be set to VREF80 */
12598 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012599 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012600 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012601 /* port-F for mic-in (front panel) with vref */
12602 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12603 /* port-G for CLFE (rear panel) */
12604 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12605 /* port-H for side (rear panel) */
12606 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12607 /* CD-in */
12608 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12609 /* route front mic to ADC1*/
12610 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12612 /* Unmute DAC0~3 & spdif out*/
12613 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12615 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12616 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012618
Takashi Iwai22309c32006-08-09 16:57:28 +020012619 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12620 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12621 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12622 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12623 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012624
Takashi Iwai22309c32006-08-09 16:57:28 +020012625 /* Unmute Stereo Mixer 15 */
12626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012630
12631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12633 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12634 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12635 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012639 /* hp used DAC 3 (Front) */
12640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12642 { }
12643};
12644
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012645static struct hda_verb alc861_asus_init_verbs[] = {
12646 /*
12647 * Unmute ADC0 and set the default input to mic-in
12648 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012649 /* port-A for surround (rear panel)
12650 * according to codec#0 this is the HP jack
12651 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012652 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12653 /* route front PCM to HP */
12654 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12655 /* port-B for mic-in (rear panel) with vref */
12656 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12657 /* port-C for line-in (rear panel) */
12658 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12659 /* port-D for Front */
12660 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12661 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12662 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012663 /* this has to be set to VREF80 */
12664 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012665 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012666 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012667 /* port-F for mic-in (front panel) with vref */
12668 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12669 /* port-G for CLFE (rear panel) */
12670 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12671 /* port-H for side (rear panel) */
12672 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12673 /* CD-in */
12674 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12675 /* route front mic to ADC1*/
12676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12678 /* Unmute DAC0~3 & spdif out*/
12679 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12681 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12682 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12684 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12685 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12686 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12687 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12688 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012689
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012690 /* Unmute Stereo Mixer 15 */
12691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012695
12696 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12697 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12698 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12699 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12702 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012704 /* hp used DAC 3 (Front) */
12705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012706 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12707 { }
12708};
12709
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012710/* additional init verbs for ASUS laptops */
12711static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12712 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12713 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12714 { }
12715};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012716
Kailang Yangdf694da2005-12-05 19:42:22 +010012717/*
12718 * generic initialization of ADC, input mixers and output mixers
12719 */
12720static struct hda_verb alc861_auto_init_verbs[] = {
12721 /*
12722 * Unmute ADC0 and set the default input to mic-in
12723 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012724 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012726
Kailang Yangdf694da2005-12-05 19:42:22 +010012727 /* Unmute DAC0~3 & spdif out*/
12728 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12729 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12731 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012733
Kailang Yangdf694da2005-12-05 19:42:22 +010012734 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12735 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12736 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12737 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12738 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012739
Kailang Yangdf694da2005-12-05 19:42:22 +010012740 /* Unmute Stereo Mixer 15 */
12741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12745
12746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12749 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12752 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12754
12755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012759 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12760 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012763
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012764 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012765
12766 { }
12767};
12768
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012769static struct hda_verb alc861_toshiba_init_verbs[] = {
12770 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012771
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012772 { }
12773};
12774
12775/* toggle speaker-output according to the hp-jack state */
12776static void alc861_toshiba_automute(struct hda_codec *codec)
12777{
12778 unsigned int present;
12779
12780 present = snd_hda_codec_read(codec, 0x0f, 0,
12781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012782 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12783 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12784 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12785 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012786}
12787
12788static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12789 unsigned int res)
12790{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012791 if ((res >> 26) == ALC880_HP_EVENT)
12792 alc861_toshiba_automute(codec);
12793}
12794
Kailang Yangdf694da2005-12-05 19:42:22 +010012795/* pcm configuration: identiacal with ALC880 */
12796#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12797#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12798#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12799#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12800
12801
12802#define ALC861_DIGOUT_NID 0x07
12803
12804static struct hda_channel_mode alc861_8ch_modes[1] = {
12805 { 8, NULL }
12806};
12807
12808static hda_nid_t alc861_dac_nids[4] = {
12809 /* front, surround, clfe, side */
12810 0x03, 0x06, 0x05, 0x04
12811};
12812
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012813static hda_nid_t alc660_dac_nids[3] = {
12814 /* front, clfe, surround */
12815 0x03, 0x05, 0x06
12816};
12817
Kailang Yangdf694da2005-12-05 19:42:22 +010012818static hda_nid_t alc861_adc_nids[1] = {
12819 /* ADC0-2 */
12820 0x08,
12821};
12822
12823static struct hda_input_mux alc861_capture_source = {
12824 .num_items = 5,
12825 .items = {
12826 { "Mic", 0x0 },
12827 { "Front Mic", 0x3 },
12828 { "Line", 0x1 },
12829 { "CD", 0x4 },
12830 { "Mixer", 0x5 },
12831 },
12832};
12833
12834/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012835static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12836 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012837{
12838 int i;
12839 hda_nid_t nid;
12840
12841 spec->multiout.dac_nids = spec->private_dac_nids;
12842 for (i = 0; i < cfg->line_outs; i++) {
12843 nid = cfg->line_out_pins[i];
12844 if (nid) {
12845 if (i >= ARRAY_SIZE(alc861_dac_nids))
12846 continue;
12847 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12848 }
12849 }
12850 spec->multiout.num_dacs = cfg->line_outs;
12851 return 0;
12852}
12853
12854/* add playback controls from the parsed DAC table */
12855static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12856 const struct auto_pin_cfg *cfg)
12857{
12858 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012859 static const char *chname[4] = {
12860 "Front", "Surround", NULL /*CLFE*/, "Side"
12861 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012862 hda_nid_t nid;
12863 int i, idx, err;
12864
12865 for (i = 0; i < cfg->line_outs; i++) {
12866 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012867 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012868 continue;
12869 if (nid == 0x05) {
12870 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012871 err = add_control(spec, ALC_CTL_BIND_MUTE,
12872 "Center Playback Switch",
12873 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12874 HDA_OUTPUT));
12875 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012877 err = add_control(spec, ALC_CTL_BIND_MUTE,
12878 "LFE Playback Switch",
12879 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12880 HDA_OUTPUT));
12881 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012882 return err;
12883 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012884 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12885 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 if (nid == alc861_dac_nids[idx])
12887 break;
12888 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012889 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12890 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12891 HDA_OUTPUT));
12892 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012893 return err;
12894 }
12895 }
12896 return 0;
12897}
12898
12899static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12900{
12901 int err;
12902 hda_nid_t nid;
12903
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012904 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012905 return 0;
12906
12907 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12908 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012909 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12910 "Headphone Playback Switch",
12911 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12912 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012913 return err;
12914 spec->multiout.hp_nid = nid;
12915 }
12916 return 0;
12917}
12918
12919/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012920static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12921 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012922{
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 struct hda_input_mux *imux = &spec->private_imux;
12924 int i, err, idx, idx1;
12925
12926 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012927 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 case 0x0c:
12929 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012930 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012931 break;
12932 case 0x0f:
12933 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012934 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012935 break;
12936 case 0x0d:
12937 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012938 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012939 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012940 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012941 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012942 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012943 break;
12944 case 0x11:
12945 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012946 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012947 break;
12948 default:
12949 continue;
12950 }
12951
Takashi Iwai4a471b72005-12-07 13:56:29 +010012952 err = new_analog_input(spec, cfg->input_pins[i],
12953 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012954 if (err < 0)
12955 return err;
12956
Takashi Iwai4a471b72005-12-07 13:56:29 +010012957 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012958 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012959 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012960 }
12961 return 0;
12962}
12963
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012964static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12965 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012966 int pin_type, int dac_idx)
12967{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012968 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12969 pin_type);
12970 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12971 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012972}
12973
12974static void alc861_auto_init_multi_out(struct hda_codec *codec)
12975{
12976 struct alc_spec *spec = codec->spec;
12977 int i;
12978
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012979 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012980 for (i = 0; i < spec->autocfg.line_outs; i++) {
12981 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012982 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012983 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012984 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012985 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012986 }
12987}
12988
12989static void alc861_auto_init_hp_out(struct hda_codec *codec)
12990{
12991 struct alc_spec *spec = codec->spec;
12992 hda_nid_t pin;
12993
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012994 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012995 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012996 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12997 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012998 pin = spec->autocfg.speaker_pins[0];
12999 if (pin)
13000 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013001}
13002
13003static void alc861_auto_init_analog_input(struct hda_codec *codec)
13004{
13005 struct alc_spec *spec = codec->spec;
13006 int i;
13007
13008 for (i = 0; i < AUTO_PIN_LAST; i++) {
13009 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013010 if (nid >= 0x0c && nid <= 0x11) {
13011 snd_hda_codec_write(codec, nid, 0,
13012 AC_VERB_SET_PIN_WIDGET_CONTROL,
13013 i <= AUTO_PIN_FRONT_MIC ?
13014 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013015 }
13016 }
13017}
13018
13019/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013020/* return 1 if successful, 0 if the proper config is not found,
13021 * or a negative error code
13022 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013023static int alc861_parse_auto_config(struct hda_codec *codec)
13024{
13025 struct alc_spec *spec = codec->spec;
13026 int err;
13027 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13028
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013029 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13030 alc861_ignore);
13031 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013032 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013033 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013034 return 0; /* can't find valid BIOS pin config */
13035
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013036 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13037 if (err < 0)
13038 return err;
13039 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13040 if (err < 0)
13041 return err;
13042 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13043 if (err < 0)
13044 return err;
13045 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13046 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013047 return err;
13048
13049 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13050
13051 if (spec->autocfg.dig_out_pin)
13052 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13053
Takashi Iwai603c4012008-07-30 15:01:44 +020013054 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013055 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013056
Takashi Iwaid88897e2008-10-31 15:01:37 +010013057 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013058
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013059 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013060 spec->input_mux = &spec->private_imux;
13061
13062 spec->adc_nids = alc861_adc_nids;
13063 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013064 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013065
Takashi Iwaie044c392008-10-27 16:56:24 +010013066 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013067 return 1;
13068}
13069
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013070/* additional initialization for auto-configuration model */
13071static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013072{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013073 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013074 alc861_auto_init_multi_out(codec);
13075 alc861_auto_init_hp_out(codec);
13076 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013077 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013078 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013079}
13080
Takashi Iwaicb53c622007-08-10 17:21:45 +020013081#ifdef CONFIG_SND_HDA_POWER_SAVE
13082static struct hda_amp_list alc861_loopbacks[] = {
13083 { 0x15, HDA_INPUT, 0 },
13084 { 0x15, HDA_INPUT, 1 },
13085 { 0x15, HDA_INPUT, 2 },
13086 { 0x15, HDA_INPUT, 3 },
13087 { } /* end */
13088};
13089#endif
13090
Kailang Yangdf694da2005-12-05 19:42:22 +010013091
13092/*
13093 * configuration and preset
13094 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013095static const char *alc861_models[ALC861_MODEL_LAST] = {
13096 [ALC861_3ST] = "3stack",
13097 [ALC660_3ST] = "3stack-660",
13098 [ALC861_3ST_DIG] = "3stack-dig",
13099 [ALC861_6ST_DIG] = "6stack-dig",
13100 [ALC861_UNIWILL_M31] = "uniwill-m31",
13101 [ALC861_TOSHIBA] = "toshiba",
13102 [ALC861_ASUS] = "asus",
13103 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13104 [ALC861_AUTO] = "auto",
13105};
13106
13107static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013108 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013109 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13110 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13111 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013112 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013113 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013114 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013115 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13116 * Any other models that need this preset?
13117 */
13118 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013119 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13120 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013121 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13122 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13123 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13124 /* FIXME: the below seems conflict */
13125 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13126 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13127 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013128 {}
13129};
13130
13131static struct alc_config_preset alc861_presets[] = {
13132 [ALC861_3ST] = {
13133 .mixers = { alc861_3ST_mixer },
13134 .init_verbs = { alc861_threestack_init_verbs },
13135 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13136 .dac_nids = alc861_dac_nids,
13137 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13138 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013139 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013140 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13141 .adc_nids = alc861_adc_nids,
13142 .input_mux = &alc861_capture_source,
13143 },
13144 [ALC861_3ST_DIG] = {
13145 .mixers = { alc861_base_mixer },
13146 .init_verbs = { alc861_threestack_init_verbs },
13147 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13148 .dac_nids = alc861_dac_nids,
13149 .dig_out_nid = ALC861_DIGOUT_NID,
13150 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13151 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013152 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013153 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13154 .adc_nids = alc861_adc_nids,
13155 .input_mux = &alc861_capture_source,
13156 },
13157 [ALC861_6ST_DIG] = {
13158 .mixers = { alc861_base_mixer },
13159 .init_verbs = { alc861_base_init_verbs },
13160 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13161 .dac_nids = alc861_dac_nids,
13162 .dig_out_nid = ALC861_DIGOUT_NID,
13163 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13164 .channel_mode = alc861_8ch_modes,
13165 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13166 .adc_nids = alc861_adc_nids,
13167 .input_mux = &alc861_capture_source,
13168 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013169 [ALC660_3ST] = {
13170 .mixers = { alc861_3ST_mixer },
13171 .init_verbs = { alc861_threestack_init_verbs },
13172 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13173 .dac_nids = alc660_dac_nids,
13174 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13175 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013176 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013177 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13178 .adc_nids = alc861_adc_nids,
13179 .input_mux = &alc861_capture_source,
13180 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013181 [ALC861_UNIWILL_M31] = {
13182 .mixers = { alc861_uniwill_m31_mixer },
13183 .init_verbs = { alc861_uniwill_m31_init_verbs },
13184 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13185 .dac_nids = alc861_dac_nids,
13186 .dig_out_nid = ALC861_DIGOUT_NID,
13187 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13188 .channel_mode = alc861_uniwill_m31_modes,
13189 .need_dac_fix = 1,
13190 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13191 .adc_nids = alc861_adc_nids,
13192 .input_mux = &alc861_capture_source,
13193 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013194 [ALC861_TOSHIBA] = {
13195 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013196 .init_verbs = { alc861_base_init_verbs,
13197 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013198 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13199 .dac_nids = alc861_dac_nids,
13200 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13201 .channel_mode = alc883_3ST_2ch_modes,
13202 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13203 .adc_nids = alc861_adc_nids,
13204 .input_mux = &alc861_capture_source,
13205 .unsol_event = alc861_toshiba_unsol_event,
13206 .init_hook = alc861_toshiba_automute,
13207 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013208 [ALC861_ASUS] = {
13209 .mixers = { alc861_asus_mixer },
13210 .init_verbs = { alc861_asus_init_verbs },
13211 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13212 .dac_nids = alc861_dac_nids,
13213 .dig_out_nid = ALC861_DIGOUT_NID,
13214 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13215 .channel_mode = alc861_asus_modes,
13216 .need_dac_fix = 1,
13217 .hp_nid = 0x06,
13218 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13219 .adc_nids = alc861_adc_nids,
13220 .input_mux = &alc861_capture_source,
13221 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013222 [ALC861_ASUS_LAPTOP] = {
13223 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13224 .init_verbs = { alc861_asus_init_verbs,
13225 alc861_asus_laptop_init_verbs },
13226 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13227 .dac_nids = alc861_dac_nids,
13228 .dig_out_nid = ALC861_DIGOUT_NID,
13229 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13230 .channel_mode = alc883_3ST_2ch_modes,
13231 .need_dac_fix = 1,
13232 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13233 .adc_nids = alc861_adc_nids,
13234 .input_mux = &alc861_capture_source,
13235 },
13236};
Kailang Yangdf694da2005-12-05 19:42:22 +010013237
13238
13239static int patch_alc861(struct hda_codec *codec)
13240{
13241 struct alc_spec *spec;
13242 int board_config;
13243 int err;
13244
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013245 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013246 if (spec == NULL)
13247 return -ENOMEM;
13248
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013249 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013250
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013251 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13252 alc861_models,
13253 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013254
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013255 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013256 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13257 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013258 board_config = ALC861_AUTO;
13259 }
13260
13261 if (board_config == ALC861_AUTO) {
13262 /* automatic parse from the BIOS config */
13263 err = alc861_parse_auto_config(codec);
13264 if (err < 0) {
13265 alc_free(codec);
13266 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013267 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013268 printk(KERN_INFO
13269 "hda_codec: Cannot set up configuration "
13270 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 board_config = ALC861_3ST_DIG;
13272 }
13273 }
13274
13275 if (board_config != ALC861_AUTO)
13276 setup_preset(spec, &alc861_presets[board_config]);
13277
13278 spec->stream_name_analog = "ALC861 Analog";
13279 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13280 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13281
13282 spec->stream_name_digital = "ALC861 Digital";
13283 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13284 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13285
Takashi Iwai2134ea42008-01-10 16:53:55 +010013286 spec->vmaster_nid = 0x03;
13287
Kailang Yangdf694da2005-12-05 19:42:22 +010013288 codec->patch_ops = alc_patch_ops;
13289 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013290 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013291#ifdef CONFIG_SND_HDA_POWER_SAVE
13292 if (!spec->loopback.amplist)
13293 spec->loopback.amplist = alc861_loopbacks;
13294#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013295
Kailang Yangdf694da2005-12-05 19:42:22 +010013296 return 0;
13297}
13298
13299/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013300 * ALC861-VD support
13301 *
13302 * Based on ALC882
13303 *
13304 * In addition, an independent DAC
13305 */
13306#define ALC861VD_DIGOUT_NID 0x06
13307
13308static hda_nid_t alc861vd_dac_nids[4] = {
13309 /* front, surr, clfe, side surr */
13310 0x02, 0x03, 0x04, 0x05
13311};
13312
13313/* dac_nids for ALC660vd are in a different order - according to
13314 * Realtek's driver.
13315 * This should probably tesult in a different mixer for 6stack models
13316 * of ALC660vd codecs, but for now there is only 3stack mixer
13317 * - and it is the same as in 861vd.
13318 * adc_nids in ALC660vd are (is) the same as in 861vd
13319 */
13320static hda_nid_t alc660vd_dac_nids[3] = {
13321 /* front, rear, clfe, rear_surr */
13322 0x02, 0x04, 0x03
13323};
13324
13325static hda_nid_t alc861vd_adc_nids[1] = {
13326 /* ADC0 */
13327 0x09,
13328};
13329
Takashi Iwaie1406342008-02-11 18:32:32 +010013330static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13331
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013332/* input MUX */
13333/* FIXME: should be a matrix-type input source selection */
13334static struct hda_input_mux alc861vd_capture_source = {
13335 .num_items = 4,
13336 .items = {
13337 { "Mic", 0x0 },
13338 { "Front Mic", 0x1 },
13339 { "Line", 0x2 },
13340 { "CD", 0x4 },
13341 },
13342};
13343
Kailang Yang272a5272007-05-14 11:00:38 +020013344static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013345 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013346 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013347 { "Ext Mic", 0x0 },
13348 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013349 },
13350};
13351
Kailang Yangd1a991a2007-08-15 16:21:59 +020013352static struct hda_input_mux alc861vd_hp_capture_source = {
13353 .num_items = 2,
13354 .items = {
13355 { "Front Mic", 0x0 },
13356 { "ATAPI Mic", 0x1 },
13357 },
13358};
13359
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013360/*
13361 * 2ch mode
13362 */
13363static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13364 { 2, NULL }
13365};
13366
13367/*
13368 * 6ch mode
13369 */
13370static struct hda_verb alc861vd_6stack_ch6_init[] = {
13371 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13372 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13373 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13374 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13375 { } /* end */
13376};
13377
13378/*
13379 * 8ch mode
13380 */
13381static struct hda_verb alc861vd_6stack_ch8_init[] = {
13382 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13386 { } /* end */
13387};
13388
13389static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13390 { 6, alc861vd_6stack_ch6_init },
13391 { 8, alc861vd_6stack_ch8_init },
13392};
13393
13394static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13395 {
13396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13397 .name = "Channel Mode",
13398 .info = alc_ch_mode_info,
13399 .get = alc_ch_mode_get,
13400 .put = alc_ch_mode_put,
13401 },
13402 { } /* end */
13403};
13404
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013405/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13406 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13407 */
13408static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13409 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13411
13412 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13413 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13414
13415 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13416 HDA_OUTPUT),
13417 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13418 HDA_OUTPUT),
13419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13421
13422 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13423 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13424
13425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13426
13427 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13430
13431 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13432 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13433 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13434
13435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13437
13438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13440
13441 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13442 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13443
13444 { } /* end */
13445};
13446
13447static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13448 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13449 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13450
13451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13452
13453 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13456
13457 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13458 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13459 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13460
13461 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13462 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13463
13464 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13465 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13466
13467 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13468 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13469
13470 { } /* end */
13471};
13472
Kailang Yangbdd148a2007-05-08 15:19:08 +020013473static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13474 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13475 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13476 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13477
13478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13479
13480 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13483
13484 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13487
13488 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13489 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13490
13491 { } /* end */
13492};
13493
Tobin Davisb419f342008-03-07 11:57:51 +010013494/* Pin assignment: Speaker=0x14, HP = 0x15,
13495 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013496 */
13497static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013498 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13499 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13501 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013502 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13503 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13504 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13505 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13506 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13507 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13508 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13509 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013510 { } /* end */
13511};
13512
Kailang Yangd1a991a2007-08-15 16:21:59 +020013513/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13514 * Front Mic=0x18, ATAPI Mic = 0x19,
13515 */
13516static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13517 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13518 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13520 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13521 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13522 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13523 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13524 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013525
Kailang Yangd1a991a2007-08-15 16:21:59 +020013526 { } /* end */
13527};
13528
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013529/*
13530 * generic initialization of ADC, input mixers and output mixers
13531 */
13532static struct hda_verb alc861vd_volume_init_verbs[] = {
13533 /*
13534 * Unmute ADC0 and set the default input to mic-in
13535 */
13536 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13538
13539 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13540 * the analog-loopback mixer widget
13541 */
13542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013548
13549 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013554
13555 /*
13556 * Set up output mixers (0x02 - 0x05)
13557 */
13558 /* set vol=0 to output mixers */
13559 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13561 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13562 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13563
13564 /* set up input amps for analog loopback */
13565 /* Amp Indices: DAC = 0, mixer = 1 */
13566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13574
13575 { }
13576};
13577
13578/*
13579 * 3-stack pin configuration:
13580 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13581 */
13582static struct hda_verb alc861vd_3stack_init_verbs[] = {
13583 /*
13584 * Set pin mode and muting
13585 */
13586 /* set front pin widgets 0x14 for output */
13587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13589 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13590
13591 /* Mic (rear) pin: input vref at 80% */
13592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13594 /* Front Mic pin: input vref at 80% */
13595 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13597 /* Line In pin: input */
13598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13599 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13600 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13602 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13603 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13604 /* CD pin widget for input */
13605 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13606
13607 { }
13608};
13609
13610/*
13611 * 6-stack pin configuration:
13612 */
13613static struct hda_verb alc861vd_6stack_init_verbs[] = {
13614 /*
13615 * Set pin mode and muting
13616 */
13617 /* set front pin widgets 0x14 for output */
13618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13621
13622 /* Rear Pin: output 1 (0x0d) */
13623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13626 /* CLFE Pin: output 2 (0x0e) */
13627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13629 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13630 /* Side Pin: output 3 (0x0f) */
13631 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13633 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13634
13635 /* Mic (rear) pin: input vref at 80% */
13636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13638 /* Front Mic pin: input vref at 80% */
13639 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13641 /* Line In pin: input */
13642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13643 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13644 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13648 /* CD pin widget for input */
13649 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13650
13651 { }
13652};
13653
Kailang Yangbdd148a2007-05-08 15:19:08 +020013654static struct hda_verb alc861vd_eapd_verbs[] = {
13655 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13656 { }
13657};
13658
Kailang Yangf9423e72008-05-27 12:32:25 +020013659static struct hda_verb alc660vd_eapd_verbs[] = {
13660 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13661 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13662 { }
13663};
13664
Kailang Yangbdd148a2007-05-08 15:19:08 +020013665static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13669 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013670 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013671 {}
13672};
13673
13674/* toggle speaker-output according to the hp-jack state */
13675static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13676{
13677 unsigned int present;
13678 unsigned char bits;
13679
13680 present = snd_hda_codec_read(codec, 0x1b, 0,
13681 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013682 bits = present ? HDA_AMP_MUTE : 0;
13683 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13684 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013685}
13686
13687static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13688{
13689 unsigned int present;
13690 unsigned char bits;
13691
13692 present = snd_hda_codec_read(codec, 0x18, 0,
13693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013694 bits = present ? HDA_AMP_MUTE : 0;
13695 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13696 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013697}
13698
13699static void alc861vd_lenovo_automute(struct hda_codec *codec)
13700{
13701 alc861vd_lenovo_hp_automute(codec);
13702 alc861vd_lenovo_mic_automute(codec);
13703}
13704
13705static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13706 unsigned int res)
13707{
13708 switch (res >> 26) {
13709 case ALC880_HP_EVENT:
13710 alc861vd_lenovo_hp_automute(codec);
13711 break;
13712 case ALC880_MIC_EVENT:
13713 alc861vd_lenovo_mic_automute(codec);
13714 break;
13715 }
13716}
13717
Kailang Yang272a5272007-05-14 11:00:38 +020013718static struct hda_verb alc861vd_dallas_verbs[] = {
13719 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13720 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13722 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13723
13724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13731 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013732
Kailang Yang272a5272007-05-14 11:00:38 +020013733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13739 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13740 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13741
13742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13748 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13749 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13750
13751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13755
13756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013757 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013758 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13759
13760 { } /* end */
13761};
13762
13763/* toggle speaker-output according to the hp-jack state */
13764static void alc861vd_dallas_automute(struct hda_codec *codec)
13765{
13766 unsigned int present;
13767
13768 present = snd_hda_codec_read(codec, 0x15, 0,
13769 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013770 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013772}
13773
13774static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13775{
13776 if ((res >> 26) == ALC880_HP_EVENT)
13777 alc861vd_dallas_automute(codec);
13778}
13779
Takashi Iwaicb53c622007-08-10 17:21:45 +020013780#ifdef CONFIG_SND_HDA_POWER_SAVE
13781#define alc861vd_loopbacks alc880_loopbacks
13782#endif
13783
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013784/* pcm configuration: identiacal with ALC880 */
13785#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13786#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13787#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13788#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13789
13790/*
13791 * configuration and preset
13792 */
13793static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13794 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013795 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013796 [ALC861VD_3ST] = "3stack",
13797 [ALC861VD_3ST_DIG] = "3stack-digout",
13798 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013799 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013800 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013801 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013802 [ALC861VD_AUTO] = "auto",
13803};
13804
13805static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013806 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13807 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013808 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013809 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013810 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013811 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013812 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013813 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013814 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013815 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013816 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013817 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013818 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013819 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13820 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013821 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013822 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013823 {}
13824};
13825
13826static struct alc_config_preset alc861vd_presets[] = {
13827 [ALC660VD_3ST] = {
13828 .mixers = { alc861vd_3st_mixer },
13829 .init_verbs = { alc861vd_volume_init_verbs,
13830 alc861vd_3stack_init_verbs },
13831 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13832 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013833 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13834 .channel_mode = alc861vd_3stack_2ch_modes,
13835 .input_mux = &alc861vd_capture_source,
13836 },
Mike Crash6963f842007-06-25 12:12:51 +020013837 [ALC660VD_3ST_DIG] = {
13838 .mixers = { alc861vd_3st_mixer },
13839 .init_verbs = { alc861vd_volume_init_verbs,
13840 alc861vd_3stack_init_verbs },
13841 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13842 .dac_nids = alc660vd_dac_nids,
13843 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013844 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13845 .channel_mode = alc861vd_3stack_2ch_modes,
13846 .input_mux = &alc861vd_capture_source,
13847 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013848 [ALC861VD_3ST] = {
13849 .mixers = { alc861vd_3st_mixer },
13850 .init_verbs = { alc861vd_volume_init_verbs,
13851 alc861vd_3stack_init_verbs },
13852 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13853 .dac_nids = alc861vd_dac_nids,
13854 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13855 .channel_mode = alc861vd_3stack_2ch_modes,
13856 .input_mux = &alc861vd_capture_source,
13857 },
13858 [ALC861VD_3ST_DIG] = {
13859 .mixers = { alc861vd_3st_mixer },
13860 .init_verbs = { alc861vd_volume_init_verbs,
13861 alc861vd_3stack_init_verbs },
13862 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13863 .dac_nids = alc861vd_dac_nids,
13864 .dig_out_nid = ALC861VD_DIGOUT_NID,
13865 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13866 .channel_mode = alc861vd_3stack_2ch_modes,
13867 .input_mux = &alc861vd_capture_source,
13868 },
13869 [ALC861VD_6ST_DIG] = {
13870 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13871 .init_verbs = { alc861vd_volume_init_verbs,
13872 alc861vd_6stack_init_verbs },
13873 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13874 .dac_nids = alc861vd_dac_nids,
13875 .dig_out_nid = ALC861VD_DIGOUT_NID,
13876 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13877 .channel_mode = alc861vd_6stack_modes,
13878 .input_mux = &alc861vd_capture_source,
13879 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013880 [ALC861VD_LENOVO] = {
13881 .mixers = { alc861vd_lenovo_mixer },
13882 .init_verbs = { alc861vd_volume_init_verbs,
13883 alc861vd_3stack_init_verbs,
13884 alc861vd_eapd_verbs,
13885 alc861vd_lenovo_unsol_verbs },
13886 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13887 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013888 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13889 .channel_mode = alc861vd_3stack_2ch_modes,
13890 .input_mux = &alc861vd_capture_source,
13891 .unsol_event = alc861vd_lenovo_unsol_event,
13892 .init_hook = alc861vd_lenovo_automute,
13893 },
Kailang Yang272a5272007-05-14 11:00:38 +020013894 [ALC861VD_DALLAS] = {
13895 .mixers = { alc861vd_dallas_mixer },
13896 .init_verbs = { alc861vd_dallas_verbs },
13897 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13898 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013899 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13900 .channel_mode = alc861vd_3stack_2ch_modes,
13901 .input_mux = &alc861vd_dallas_capture_source,
13902 .unsol_event = alc861vd_dallas_unsol_event,
13903 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013904 },
13905 [ALC861VD_HP] = {
13906 .mixers = { alc861vd_hp_mixer },
13907 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13908 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13909 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013910 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013911 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13912 .channel_mode = alc861vd_3stack_2ch_modes,
13913 .input_mux = &alc861vd_hp_capture_source,
13914 .unsol_event = alc861vd_dallas_unsol_event,
13915 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013916 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013917};
13918
13919/*
13920 * BIOS auto configuration
13921 */
13922static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13923 hda_nid_t nid, int pin_type, int dac_idx)
13924{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013925 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013926}
13927
13928static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13929{
13930 struct alc_spec *spec = codec->spec;
13931 int i;
13932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013933 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013934 for (i = 0; i <= HDA_SIDE; i++) {
13935 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013936 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013937 if (nid)
13938 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013939 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013940 }
13941}
13942
13943
13944static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13945{
13946 struct alc_spec *spec = codec->spec;
13947 hda_nid_t pin;
13948
13949 pin = spec->autocfg.hp_pins[0];
13950 if (pin) /* connect to front and use dac 0 */
13951 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013952 pin = spec->autocfg.speaker_pins[0];
13953 if (pin)
13954 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013955}
13956
13957#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13958#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13959
13960static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13961{
13962 struct alc_spec *spec = codec->spec;
13963 int i;
13964
13965 for (i = 0; i < AUTO_PIN_LAST; i++) {
13966 hda_nid_t nid = spec->autocfg.input_pins[i];
13967 if (alc861vd_is_input_pin(nid)) {
13968 snd_hda_codec_write(codec, nid, 0,
13969 AC_VERB_SET_PIN_WIDGET_CONTROL,
13970 i <= AUTO_PIN_FRONT_MIC ?
13971 PIN_VREF80 : PIN_IN);
13972 if (nid != ALC861VD_PIN_CD_NID)
13973 snd_hda_codec_write(codec, nid, 0,
13974 AC_VERB_SET_AMP_GAIN_MUTE,
13975 AMP_OUT_MUTE);
13976 }
13977 }
13978}
13979
Takashi Iwaif511b012008-08-15 16:46:42 +020013980#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13981
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013982#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13983#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13984
13985/* add playback controls from the parsed DAC table */
13986/* Based on ALC880 version. But ALC861VD has separate,
13987 * different NIDs for mute/unmute switch and volume control */
13988static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13989 const struct auto_pin_cfg *cfg)
13990{
13991 char name[32];
13992 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13993 hda_nid_t nid_v, nid_s;
13994 int i, err;
13995
13996 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013997 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013998 continue;
13999 nid_v = alc861vd_idx_to_mixer_vol(
14000 alc880_dac_to_idx(
14001 spec->multiout.dac_nids[i]));
14002 nid_s = alc861vd_idx_to_mixer_switch(
14003 alc880_dac_to_idx(
14004 spec->multiout.dac_nids[i]));
14005
14006 if (i == 2) {
14007 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014008 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14009 "Center Playback Volume",
14010 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14011 HDA_OUTPUT));
14012 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014013 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014014 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14015 "LFE Playback Volume",
14016 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14017 HDA_OUTPUT));
14018 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014020 err = add_control(spec, ALC_CTL_BIND_MUTE,
14021 "Center Playback Switch",
14022 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14023 HDA_INPUT));
14024 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014025 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014026 err = add_control(spec, ALC_CTL_BIND_MUTE,
14027 "LFE Playback Switch",
14028 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14029 HDA_INPUT));
14030 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014031 return err;
14032 } else {
14033 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14035 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14036 HDA_OUTPUT));
14037 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014038 return err;
14039 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014040 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014041 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014042 HDA_INPUT));
14043 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014044 return err;
14045 }
14046 }
14047 return 0;
14048}
14049
14050/* add playback controls for speaker and HP outputs */
14051/* Based on ALC880 version. But ALC861VD has separate,
14052 * different NIDs for mute/unmute switch and volume control */
14053static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14054 hda_nid_t pin, const char *pfx)
14055{
14056 hda_nid_t nid_v, nid_s;
14057 int err;
14058 char name[32];
14059
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014060 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014061 return 0;
14062
14063 if (alc880_is_fixed_pin(pin)) {
14064 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14065 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014066 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014067 spec->multiout.hp_nid = nid_v;
14068 else
14069 spec->multiout.extra_out_nid[0] = nid_v;
14070 /* control HP volume/switch on the output mixer amp */
14071 nid_v = alc861vd_idx_to_mixer_vol(
14072 alc880_fixed_pin_idx(pin));
14073 nid_s = alc861vd_idx_to_mixer_switch(
14074 alc880_fixed_pin_idx(pin));
14075
14076 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014077 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14078 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14079 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014080 return err;
14081 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14083 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14084 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014085 return err;
14086 } else if (alc880_is_multi_pin(pin)) {
14087 /* set manual connection */
14088 /* we have only a switch on HP-out PIN */
14089 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014090 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14091 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14092 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014093 return err;
14094 }
14095 return 0;
14096}
14097
14098/* parse the BIOS configuration and set up the alc_spec
14099 * return 1 if successful, 0 if the proper config is not found,
14100 * or a negative error code
14101 * Based on ALC880 version - had to change it to override
14102 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14103static int alc861vd_parse_auto_config(struct hda_codec *codec)
14104{
14105 struct alc_spec *spec = codec->spec;
14106 int err;
14107 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14108
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14110 alc861vd_ignore);
14111 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014112 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014113 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014114 return 0; /* can't find valid BIOS pin config */
14115
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014116 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14117 if (err < 0)
14118 return err;
14119 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14120 if (err < 0)
14121 return err;
14122 err = alc861vd_auto_create_extra_out(spec,
14123 spec->autocfg.speaker_pins[0],
14124 "Speaker");
14125 if (err < 0)
14126 return err;
14127 err = alc861vd_auto_create_extra_out(spec,
14128 spec->autocfg.hp_pins[0],
14129 "Headphone");
14130 if (err < 0)
14131 return err;
14132 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14133 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014134 return err;
14135
14136 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14137
14138 if (spec->autocfg.dig_out_pin)
14139 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14140
Takashi Iwai603c4012008-07-30 15:01:44 +020014141 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014142 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014143
Takashi Iwaid88897e2008-10-31 15:01:37 +010014144 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014145
14146 spec->num_mux_defs = 1;
14147 spec->input_mux = &spec->private_imux;
14148
Takashi Iwai776e1842007-08-29 15:07:11 +020014149 err = alc_auto_add_mic_boost(codec);
14150 if (err < 0)
14151 return err;
14152
Takashi Iwaie044c392008-10-27 16:56:24 +010014153 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014154 return 1;
14155}
14156
14157/* additional initialization for auto-configuration model */
14158static void alc861vd_auto_init(struct hda_codec *codec)
14159{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014160 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014161 alc861vd_auto_init_multi_out(codec);
14162 alc861vd_auto_init_hp_out(codec);
14163 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014164 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014165 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014166 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014167}
14168
14169static int patch_alc861vd(struct hda_codec *codec)
14170{
14171 struct alc_spec *spec;
14172 int err, board_config;
14173
14174 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14175 if (spec == NULL)
14176 return -ENOMEM;
14177
14178 codec->spec = spec;
14179
14180 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14181 alc861vd_models,
14182 alc861vd_cfg_tbl);
14183
14184 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14185 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14186 "ALC861VD, trying auto-probe from BIOS...\n");
14187 board_config = ALC861VD_AUTO;
14188 }
14189
14190 if (board_config == ALC861VD_AUTO) {
14191 /* automatic parse from the BIOS config */
14192 err = alc861vd_parse_auto_config(codec);
14193 if (err < 0) {
14194 alc_free(codec);
14195 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014196 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014197 printk(KERN_INFO
14198 "hda_codec: Cannot set up configuration "
14199 "from BIOS. Using base mode...\n");
14200 board_config = ALC861VD_3ST;
14201 }
14202 }
14203
14204 if (board_config != ALC861VD_AUTO)
14205 setup_preset(spec, &alc861vd_presets[board_config]);
14206
Kailang Yang2f893282008-05-27 12:14:47 +020014207 if (codec->vendor_id == 0x10ec0660) {
14208 spec->stream_name_analog = "ALC660-VD Analog";
14209 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014210 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014211 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014212 } else {
14213 spec->stream_name_analog = "ALC861VD Analog";
14214 spec->stream_name_digital = "ALC861VD Digital";
14215 }
14216
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014217 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14218 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14219
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014220 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14221 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14222
14223 spec->adc_nids = alc861vd_adc_nids;
14224 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014225 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014226 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014227
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014228 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014229
Takashi Iwai2134ea42008-01-10 16:53:55 +010014230 spec->vmaster_nid = 0x02;
14231
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014232 codec->patch_ops = alc_patch_ops;
14233
14234 if (board_config == ALC861VD_AUTO)
14235 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014236#ifdef CONFIG_SND_HDA_POWER_SAVE
14237 if (!spec->loopback.amplist)
14238 spec->loopback.amplist = alc861vd_loopbacks;
14239#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014240
14241 return 0;
14242}
14243
14244/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014245 * ALC662 support
14246 *
14247 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14248 * configuration. Each pin widget can choose any input DACs and a mixer.
14249 * Each ADC is connected from a mixer of all inputs. This makes possible
14250 * 6-channel independent captures.
14251 *
14252 * In addition, an independent DAC for the multi-playback (not used in this
14253 * driver yet).
14254 */
14255#define ALC662_DIGOUT_NID 0x06
14256#define ALC662_DIGIN_NID 0x0a
14257
14258static hda_nid_t alc662_dac_nids[4] = {
14259 /* front, rear, clfe, rear_surr */
14260 0x02, 0x03, 0x04
14261};
14262
14263static hda_nid_t alc662_adc_nids[1] = {
14264 /* ADC1-2 */
14265 0x09,
14266};
Takashi Iwaie1406342008-02-11 18:32:32 +010014267
Kailang Yang77a261b2008-02-19 11:38:05 +010014268static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014269
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014270/* input MUX */
14271/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014272static struct hda_input_mux alc662_capture_source = {
14273 .num_items = 4,
14274 .items = {
14275 { "Mic", 0x0 },
14276 { "Front Mic", 0x1 },
14277 { "Line", 0x2 },
14278 { "CD", 0x4 },
14279 },
14280};
14281
14282static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14283 .num_items = 2,
14284 .items = {
14285 { "Mic", 0x1 },
14286 { "Line", 0x2 },
14287 },
14288};
Kailang Yang291702f2007-10-16 14:28:03 +020014289
14290static struct hda_input_mux alc662_eeepc_capture_source = {
14291 .num_items = 2,
14292 .items = {
14293 { "i-Mic", 0x1 },
14294 { "e-Mic", 0x0 },
14295 },
14296};
14297
Kailang Yang6dda9f42008-05-27 12:05:31 +020014298static struct hda_input_mux alc663_capture_source = {
14299 .num_items = 3,
14300 .items = {
14301 { "Mic", 0x0 },
14302 { "Front Mic", 0x1 },
14303 { "Line", 0x2 },
14304 },
14305};
14306
14307static struct hda_input_mux alc663_m51va_capture_source = {
14308 .num_items = 2,
14309 .items = {
14310 { "Ext-Mic", 0x0 },
14311 { "D-Mic", 0x9 },
14312 },
14313};
14314
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014315/*
14316 * 2ch mode
14317 */
14318static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14319 { 2, NULL }
14320};
14321
14322/*
14323 * 2ch mode
14324 */
14325static struct hda_verb alc662_3ST_ch2_init[] = {
14326 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14327 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14328 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14329 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14330 { } /* end */
14331};
14332
14333/*
14334 * 6ch mode
14335 */
14336static struct hda_verb alc662_3ST_ch6_init[] = {
14337 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14338 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14339 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14340 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14341 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14342 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14343 { } /* end */
14344};
14345
14346static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14347 { 2, alc662_3ST_ch2_init },
14348 { 6, alc662_3ST_ch6_init },
14349};
14350
14351/*
14352 * 2ch mode
14353 */
14354static struct hda_verb alc662_sixstack_ch6_init[] = {
14355 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14356 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14357 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14358 { } /* end */
14359};
14360
14361/*
14362 * 6ch mode
14363 */
14364static struct hda_verb alc662_sixstack_ch8_init[] = {
14365 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14366 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14367 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14368 { } /* end */
14369};
14370
14371static struct hda_channel_mode alc662_5stack_modes[2] = {
14372 { 2, alc662_sixstack_ch6_init },
14373 { 6, alc662_sixstack_ch8_init },
14374};
14375
14376/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14377 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14378 */
14379
14380static struct snd_kcontrol_new alc662_base_mixer[] = {
14381 /* output mixer control */
14382 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014383 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014384 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014385 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014386 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014388 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14389 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14391
14392 /*Input mixer control */
14393 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14394 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14395 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14396 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14397 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14398 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14399 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14400 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014401 { } /* end */
14402};
14403
14404static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14405 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014406 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14408 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14409 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14410 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14411 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14416 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14417 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014418 { } /* end */
14419};
14420
14421static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14422 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014423 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014424 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014425 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014426 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14427 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014428 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14429 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14431 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14432 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14433 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14434 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14437 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14438 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14439 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14440 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014441 { } /* end */
14442};
14443
14444static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14445 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14446 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014447 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14448 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014454 { } /* end */
14455};
14456
Kailang Yang291702f2007-10-16 14:28:03 +020014457static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014458 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014459
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014460 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14461 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014462
14463 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14464 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14465 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14466
14467 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14468 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14469 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14470 { } /* end */
14471};
14472
Kailang Yang8c427222008-01-10 13:03:59 +010014473static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014474 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14475 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14477 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14478 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14479 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14480 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14481 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014482 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014483 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14484 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14485 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14488 { } /* end */
14489};
14490
Kailang Yangf1d4e282008-08-26 14:03:29 +020014491static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14492 .ops = &snd_hda_bind_vol,
14493 .values = {
14494 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14495 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14496 0
14497 },
14498};
14499
14500static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14501 .ops = &snd_hda_bind_sw,
14502 .values = {
14503 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14504 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14505 0
14506 },
14507};
14508
Kailang Yang6dda9f42008-05-27 12:05:31 +020014509static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014510 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14511 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14514 { } /* end */
14515};
14516
14517static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14518 .ops = &snd_hda_bind_sw,
14519 .values = {
14520 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14521 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14522 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14523 0
14524 },
14525};
14526
14527static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14528 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14529 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14532 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14533 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14534
14535 { } /* end */
14536};
14537
14538static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14539 .ops = &snd_hda_bind_sw,
14540 .values = {
14541 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14542 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14543 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14544 0
14545 },
14546};
14547
14548static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14549 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14550 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14553 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14554 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14555 { } /* end */
14556};
14557
14558static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014559 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14560 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14563 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14564 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14565 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14566 { } /* end */
14567};
14568
14569static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14570 .ops = &snd_hda_bind_vol,
14571 .values = {
14572 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14573 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14574 0
14575 },
14576};
14577
14578static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14579 .ops = &snd_hda_bind_sw,
14580 .values = {
14581 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14582 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14583 0
14584 },
14585};
14586
14587static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14588 HDA_BIND_VOL("Master Playback Volume",
14589 &alc663_asus_two_bind_master_vol),
14590 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14591 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014595 { } /* end */
14596};
14597
14598static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14599 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14600 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14601 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14602 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014605 { } /* end */
14606};
14607
14608static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14609 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14610 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14611 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14612 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14614
14615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14617 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14618 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14619 { } /* end */
14620};
14621
14622static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14623 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14624 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14626
14627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14629 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14630 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14633 { } /* end */
14634};
14635
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014636static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14637 {
14638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14639 .name = "Channel Mode",
14640 .info = alc_ch_mode_info,
14641 .get = alc_ch_mode_get,
14642 .put = alc_ch_mode_put,
14643 },
14644 { } /* end */
14645};
14646
14647static struct hda_verb alc662_init_verbs[] = {
14648 /* ADC: mute amp left and right */
14649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14650 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14651 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14652
Takashi Iwaicb53c622007-08-10 17:21:45 +020014653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014658
Kailang Yangb60dd392007-09-20 12:50:29 +020014659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014665
14666 /* Front Pin: output 0 (0x0c) */
14667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14669
14670 /* Rear Pin: output 1 (0x0d) */
14671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14673
14674 /* CLFE Pin: output 2 (0x0e) */
14675 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14676 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14677
14678 /* Mic (rear) pin: input vref at 80% */
14679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14681 /* Front Mic pin: input vref at 80% */
14682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14684 /* Line In pin: input */
14685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14687 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14691 /* CD pin widget for input */
14692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14693
14694 /* FIXME: use matrix-type input source selection */
14695 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14696 /* Input mixer */
14697 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014701
14702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014706
14707 /* always trun on EAPD */
14708 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14709 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014711 { }
14712};
14713
14714static struct hda_verb alc662_sue_init_verbs[] = {
14715 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14716 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014717 {}
14718};
14719
14720static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14721 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14722 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14723 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014724};
14725
Kailang Yang8c427222008-01-10 13:03:59 +010014726/* Set Unsolicited Event*/
14727static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14728 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14729 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14730 {}
14731};
14732
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014733/*
14734 * generic initialization of ADC, input mixers and output mixers
14735 */
14736static struct hda_verb alc662_auto_init_verbs[] = {
14737 /*
14738 * Unmute ADC and set the default input to mic-in
14739 */
14740 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14742
14743 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14744 * mixer widget
14745 * Note: PASD motherboards uses the Line In 2 as the input for front
14746 * panel mic (mic 2)
14747 */
14748 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014749 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014754
14755 /*
14756 * Set up output mixers (0x0c - 0x0f)
14757 */
14758 /* set vol=0 to output mixers */
14759 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14760 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14761 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14762
14763 /* set up input amps for analog loopback */
14764 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014771
14772
14773 /* FIXME: use matrix-type input source selection */
14774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14775 /* Input mixer */
14776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014778 { }
14779};
14780
Takashi Iwai24fb9172008-09-02 14:48:20 +020014781/* additional verbs for ALC663 */
14782static struct hda_verb alc663_auto_init_verbs[] = {
14783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14784 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14785 { }
14786};
14787
Kailang Yang6dda9f42008-05-27 12:05:31 +020014788static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014791 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14792 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020014793 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14794 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14795 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014796 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14797 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14798 {}
14799};
14800
Kailang Yangf1d4e282008-08-26 14:03:29 +020014801static struct hda_verb alc663_21jd_amic_init_verbs[] = {
14802 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14803 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14804 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14807 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14808 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14809 {}
14810};
14811
14812static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
14813 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14814 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14815 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14816 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14820 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14821 {}
14822};
14823
14824static struct hda_verb alc663_15jd_amic_init_verbs[] = {
14825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14830 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14831 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14832 {}
14833};
14834
14835static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
14836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14837 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14838 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14839 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
14840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
14843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14845 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14846 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14847 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14848 {}
14849};
14850
14851static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
14852 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14853 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14855 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14858 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
14859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14861 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14862 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14864 {}
14865};
14866
Kailang Yang6dda9f42008-05-27 12:05:31 +020014867static struct hda_verb alc663_g71v_init_verbs[] = {
14868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14869 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14870 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14871
14872 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14873 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14874 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14875
14876 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14877 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14878 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14879 {}
14880};
14881
14882static struct hda_verb alc663_g50v_init_verbs[] = {
14883 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14884 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14885 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14886
14887 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14888 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14889 {}
14890};
14891
Kailang Yangf1d4e282008-08-26 14:03:29 +020014892static struct hda_verb alc662_ecs_init_verbs[] = {
14893 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
14894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14895 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14896 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14897 {}
14898};
14899
Kailang Yangf1d4e282008-08-26 14:03:29 +020014900static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
14901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14903 { } /* end */
14904};
14905
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014906static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14907{
14908 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014909 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014910
14911 present = snd_hda_codec_read(codec, 0x14, 0,
14912 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014913 bits = present ? HDA_AMP_MUTE : 0;
14914 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14915 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014916}
14917
14918static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14919{
14920 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014921 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014922
14923 present = snd_hda_codec_read(codec, 0x1b, 0,
14924 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014925 bits = present ? HDA_AMP_MUTE : 0;
14926 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14927 HDA_AMP_MUTE, bits);
14928 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14929 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014930}
14931
14932static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14933 unsigned int res)
14934{
14935 if ((res >> 26) == ALC880_HP_EVENT)
14936 alc662_lenovo_101e_all_automute(codec);
14937 if ((res >> 26) == ALC880_FRONT_EVENT)
14938 alc662_lenovo_101e_ispeaker_automute(codec);
14939}
14940
Kailang Yang291702f2007-10-16 14:28:03 +020014941static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14942{
14943 unsigned int present;
14944
14945 present = snd_hda_codec_read(codec, 0x18, 0,
14946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14947 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14948 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14949 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14950 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14951 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14952 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14953 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14954 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14955}
14956
14957/* unsolicited event for HP jack sensing */
14958static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14959 unsigned int res)
14960{
14961 if ((res >> 26) == ALC880_HP_EVENT)
14962 alc262_hippo1_automute( codec );
14963
14964 if ((res >> 26) == ALC880_MIC_EVENT)
14965 alc662_eeepc_mic_automute(codec);
14966}
14967
14968static void alc662_eeepc_inithook(struct hda_codec *codec)
14969{
14970 alc262_hippo1_automute( codec );
14971 alc662_eeepc_mic_automute(codec);
14972}
14973
Kailang Yang8c427222008-01-10 13:03:59 +010014974static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14975{
14976 unsigned int mute;
14977 unsigned int present;
14978
14979 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14980 present = snd_hda_codec_read(codec, 0x14, 0,
14981 AC_VERB_GET_PIN_SENSE, 0);
14982 present = (present & 0x80000000) != 0;
14983 if (present) {
14984 /* mute internal speaker */
14985 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014986 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010014987 } else {
14988 /* unmute internal speaker if necessary */
14989 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14990 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014991 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010014992 }
14993}
14994
14995/* unsolicited event for HP jack sensing */
14996static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14997 unsigned int res)
14998{
14999 if ((res >> 26) == ALC880_HP_EVENT)
15000 alc662_eeepc_ep20_automute(codec);
15001}
15002
15003static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15004{
15005 alc662_eeepc_ep20_automute(codec);
15006}
15007
Kailang Yang6dda9f42008-05-27 12:05:31 +020015008static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15009{
15010 unsigned int present;
15011 unsigned char bits;
15012
15013 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015014 AC_VERB_GET_PIN_SENSE, 0)
15015 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015016 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015017 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15018 AMP_IN_MUTE(0), bits);
15019 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15020 AMP_IN_MUTE(0), bits);
15021}
15022
15023static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15024{
15025 unsigned int present;
15026 unsigned char bits;
15027
15028 present = snd_hda_codec_read(codec, 0x21, 0,
15029 AC_VERB_GET_PIN_SENSE, 0)
15030 & AC_PINSENSE_PRESENCE;
15031 bits = present ? HDA_AMP_MUTE : 0;
15032 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15033 AMP_IN_MUTE(0), bits);
15034 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15035 AMP_IN_MUTE(0), bits);
15036 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15037 AMP_IN_MUTE(0), bits);
15038 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15039 AMP_IN_MUTE(0), bits);
15040}
15041
15042static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15043{
15044 unsigned int present;
15045 unsigned char bits;
15046
15047 present = snd_hda_codec_read(codec, 0x15, 0,
15048 AC_VERB_GET_PIN_SENSE, 0)
15049 & AC_PINSENSE_PRESENCE;
15050 bits = present ? HDA_AMP_MUTE : 0;
15051 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15052 AMP_IN_MUTE(0), bits);
15053 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15054 AMP_IN_MUTE(0), bits);
15055 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15056 AMP_IN_MUTE(0), bits);
15057 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15058 AMP_IN_MUTE(0), bits);
15059}
15060
15061static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15062{
15063 unsigned int present;
15064 unsigned char bits;
15065
15066 present = snd_hda_codec_read(codec, 0x1b, 0,
15067 AC_VERB_GET_PIN_SENSE, 0)
15068 & AC_PINSENSE_PRESENCE;
15069 bits = present ? 0 : PIN_OUT;
15070 snd_hda_codec_write(codec, 0x14, 0,
15071 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15072}
15073
15074static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15075{
15076 unsigned int present1, present2;
15077
15078 present1 = snd_hda_codec_read(codec, 0x21, 0,
15079 AC_VERB_GET_PIN_SENSE, 0)
15080 & AC_PINSENSE_PRESENCE;
15081 present2 = snd_hda_codec_read(codec, 0x15, 0,
15082 AC_VERB_GET_PIN_SENSE, 0)
15083 & AC_PINSENSE_PRESENCE;
15084
15085 if (present1 || present2) {
15086 snd_hda_codec_write_cache(codec, 0x14, 0,
15087 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15088 } else {
15089 snd_hda_codec_write_cache(codec, 0x14, 0,
15090 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15091 }
15092}
15093
15094static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15095{
15096 unsigned int present1, present2;
15097
15098 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15099 AC_VERB_GET_PIN_SENSE, 0)
15100 & AC_PINSENSE_PRESENCE;
15101 present2 = snd_hda_codec_read(codec, 0x15, 0,
15102 AC_VERB_GET_PIN_SENSE, 0)
15103 & AC_PINSENSE_PRESENCE;
15104
15105 if (present1 || present2) {
15106 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15107 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15108 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15109 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15110 } else {
15111 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15112 AMP_IN_MUTE(0), 0);
15113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15114 AMP_IN_MUTE(0), 0);
15115 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015116}
15117
15118static void alc663_m51va_mic_automute(struct hda_codec *codec)
15119{
15120 unsigned int present;
15121
15122 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015123 AC_VERB_GET_PIN_SENSE, 0)
15124 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015125 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015126 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015127 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015128 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015129 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015130 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015131 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015132 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015133}
15134
15135static void alc663_m51va_unsol_event(struct hda_codec *codec,
15136 unsigned int res)
15137{
15138 switch (res >> 26) {
15139 case ALC880_HP_EVENT:
15140 alc663_m51va_speaker_automute(codec);
15141 break;
15142 case ALC880_MIC_EVENT:
15143 alc663_m51va_mic_automute(codec);
15144 break;
15145 }
15146}
15147
15148static void alc663_m51va_inithook(struct hda_codec *codec)
15149{
15150 alc663_m51va_speaker_automute(codec);
15151 alc663_m51va_mic_automute(codec);
15152}
15153
Kailang Yangf1d4e282008-08-26 14:03:29 +020015154/* ***************** Mode1 ******************************/
15155static void alc663_mode1_unsol_event(struct hda_codec *codec,
15156 unsigned int res)
15157{
15158 switch (res >> 26) {
15159 case ALC880_HP_EVENT:
15160 alc663_m51va_speaker_automute(codec);
15161 break;
15162 case ALC880_MIC_EVENT:
15163 alc662_eeepc_mic_automute(codec);
15164 break;
15165 }
15166}
15167
15168static void alc663_mode1_inithook(struct hda_codec *codec)
15169{
15170 alc663_m51va_speaker_automute(codec);
15171 alc662_eeepc_mic_automute(codec);
15172}
15173/* ***************** Mode2 ******************************/
15174static void alc662_mode2_unsol_event(struct hda_codec *codec,
15175 unsigned int res)
15176{
15177 switch (res >> 26) {
15178 case ALC880_HP_EVENT:
15179 alc662_f5z_speaker_automute(codec);
15180 break;
15181 case ALC880_MIC_EVENT:
15182 alc662_eeepc_mic_automute(codec);
15183 break;
15184 }
15185}
15186
15187static void alc662_mode2_inithook(struct hda_codec *codec)
15188{
15189 alc662_f5z_speaker_automute(codec);
15190 alc662_eeepc_mic_automute(codec);
15191}
15192/* ***************** Mode3 ******************************/
15193static void alc663_mode3_unsol_event(struct hda_codec *codec,
15194 unsigned int res)
15195{
15196 switch (res >> 26) {
15197 case ALC880_HP_EVENT:
15198 alc663_two_hp_m1_speaker_automute(codec);
15199 break;
15200 case ALC880_MIC_EVENT:
15201 alc662_eeepc_mic_automute(codec);
15202 break;
15203 }
15204}
15205
15206static void alc663_mode3_inithook(struct hda_codec *codec)
15207{
15208 alc663_two_hp_m1_speaker_automute(codec);
15209 alc662_eeepc_mic_automute(codec);
15210}
15211/* ***************** Mode4 ******************************/
15212static void alc663_mode4_unsol_event(struct hda_codec *codec,
15213 unsigned int res)
15214{
15215 switch (res >> 26) {
15216 case ALC880_HP_EVENT:
15217 alc663_21jd_two_speaker_automute(codec);
15218 break;
15219 case ALC880_MIC_EVENT:
15220 alc662_eeepc_mic_automute(codec);
15221 break;
15222 }
15223}
15224
15225static void alc663_mode4_inithook(struct hda_codec *codec)
15226{
15227 alc663_21jd_two_speaker_automute(codec);
15228 alc662_eeepc_mic_automute(codec);
15229}
15230/* ***************** Mode5 ******************************/
15231static void alc663_mode5_unsol_event(struct hda_codec *codec,
15232 unsigned int res)
15233{
15234 switch (res >> 26) {
15235 case ALC880_HP_EVENT:
15236 alc663_15jd_two_speaker_automute(codec);
15237 break;
15238 case ALC880_MIC_EVENT:
15239 alc662_eeepc_mic_automute(codec);
15240 break;
15241 }
15242}
15243
15244static void alc663_mode5_inithook(struct hda_codec *codec)
15245{
15246 alc663_15jd_two_speaker_automute(codec);
15247 alc662_eeepc_mic_automute(codec);
15248}
15249/* ***************** Mode6 ******************************/
15250static void alc663_mode6_unsol_event(struct hda_codec *codec,
15251 unsigned int res)
15252{
15253 switch (res >> 26) {
15254 case ALC880_HP_EVENT:
15255 alc663_two_hp_m2_speaker_automute(codec);
15256 break;
15257 case ALC880_MIC_EVENT:
15258 alc662_eeepc_mic_automute(codec);
15259 break;
15260 }
15261}
15262
15263static void alc663_mode6_inithook(struct hda_codec *codec)
15264{
15265 alc663_two_hp_m2_speaker_automute(codec);
15266 alc662_eeepc_mic_automute(codec);
15267}
15268
Kailang Yang6dda9f42008-05-27 12:05:31 +020015269static void alc663_g71v_hp_automute(struct hda_codec *codec)
15270{
15271 unsigned int present;
15272 unsigned char bits;
15273
15274 present = snd_hda_codec_read(codec, 0x21, 0,
15275 AC_VERB_GET_PIN_SENSE, 0)
15276 & AC_PINSENSE_PRESENCE;
15277 bits = present ? HDA_AMP_MUTE : 0;
15278 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15279 HDA_AMP_MUTE, bits);
15280 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15281 HDA_AMP_MUTE, bits);
15282}
15283
15284static void alc663_g71v_front_automute(struct hda_codec *codec)
15285{
15286 unsigned int present;
15287 unsigned char bits;
15288
15289 present = snd_hda_codec_read(codec, 0x15, 0,
15290 AC_VERB_GET_PIN_SENSE, 0)
15291 & AC_PINSENSE_PRESENCE;
15292 bits = present ? HDA_AMP_MUTE : 0;
15293 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15294 HDA_AMP_MUTE, bits);
15295}
15296
15297static void alc663_g71v_unsol_event(struct hda_codec *codec,
15298 unsigned int res)
15299{
15300 switch (res >> 26) {
15301 case ALC880_HP_EVENT:
15302 alc663_g71v_hp_automute(codec);
15303 break;
15304 case ALC880_FRONT_EVENT:
15305 alc663_g71v_front_automute(codec);
15306 break;
15307 case ALC880_MIC_EVENT:
15308 alc662_eeepc_mic_automute(codec);
15309 break;
15310 }
15311}
15312
15313static void alc663_g71v_inithook(struct hda_codec *codec)
15314{
15315 alc663_g71v_front_automute(codec);
15316 alc663_g71v_hp_automute(codec);
15317 alc662_eeepc_mic_automute(codec);
15318}
15319
15320static void alc663_g50v_unsol_event(struct hda_codec *codec,
15321 unsigned int res)
15322{
15323 switch (res >> 26) {
15324 case ALC880_HP_EVENT:
15325 alc663_m51va_speaker_automute(codec);
15326 break;
15327 case ALC880_MIC_EVENT:
15328 alc662_eeepc_mic_automute(codec);
15329 break;
15330 }
15331}
15332
15333static void alc663_g50v_inithook(struct hda_codec *codec)
15334{
15335 alc663_m51va_speaker_automute(codec);
15336 alc662_eeepc_mic_automute(codec);
15337}
15338
Kailang Yangf1d4e282008-08-26 14:03:29 +020015339/* bind hp and internal speaker mute (with plug check) */
15340static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15341 struct snd_ctl_elem_value *ucontrol)
15342{
15343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15344 long *valp = ucontrol->value.integer.value;
15345 int change;
15346
15347 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15348 HDA_AMP_MUTE,
15349 valp[0] ? 0 : HDA_AMP_MUTE);
15350 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15351 HDA_AMP_MUTE,
15352 valp[1] ? 0 : HDA_AMP_MUTE);
15353 if (change)
15354 alc262_hippo1_automute(codec);
15355 return change;
15356}
15357
15358static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15359 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15360 {
15361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15362 .name = "Master Playback Switch",
15363 .info = snd_hda_mixer_amp_switch_info,
15364 .get = snd_hda_mixer_amp_switch_get,
15365 .put = alc662_ecs_master_sw_put,
15366 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15367 },
15368
15369 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15370 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15371 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15372
15373 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15374 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15375 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15376 { } /* end */
15377};
15378
Takashi Iwaicb53c622007-08-10 17:21:45 +020015379#ifdef CONFIG_SND_HDA_POWER_SAVE
15380#define alc662_loopbacks alc880_loopbacks
15381#endif
15382
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015383
15384/* pcm configuration: identiacal with ALC880 */
15385#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15386#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15387#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15388#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15389
15390/*
15391 * configuration and preset
15392 */
15393static const char *alc662_models[ALC662_MODEL_LAST] = {
15394 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15395 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15396 [ALC662_3ST_6ch] = "3stack-6ch",
15397 [ALC662_5ST_DIG] = "6stack-dig",
15398 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015399 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015400 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015401 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015402 [ALC663_ASUS_M51VA] = "m51va",
15403 [ALC663_ASUS_G71V] = "g71v",
15404 [ALC663_ASUS_H13] = "h13",
15405 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015406 [ALC663_ASUS_MODE1] = "asus-mode1",
15407 [ALC662_ASUS_MODE2] = "asus-mode2",
15408 [ALC663_ASUS_MODE3] = "asus-mode3",
15409 [ALC663_ASUS_MODE4] = "asus-mode4",
15410 [ALC663_ASUS_MODE5] = "asus-mode5",
15411 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015412 [ALC662_AUTO] = "auto",
15413};
15414
15415static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015416 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015417 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015418 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015419 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015420 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015421 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15422 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15423 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15424 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15425 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15426 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15427 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15428 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15429 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015430 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015431 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15432 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15433 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15434 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15435 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15436 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15437 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15438 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15439 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15440 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15441 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15442 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15443 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15444 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15445 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15446 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15447 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15448 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15449 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15450 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15451 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15452 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015453 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15454 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015455 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015456 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15457 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015458 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15459 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015460 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015461 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015462 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015463 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15464 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15465 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015466 {}
15467};
15468
15469static struct alc_config_preset alc662_presets[] = {
15470 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015471 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015472 .init_verbs = { alc662_init_verbs },
15473 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15474 .dac_nids = alc662_dac_nids,
15475 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015476 .dig_in_nid = ALC662_DIGIN_NID,
15477 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15478 .channel_mode = alc662_3ST_2ch_modes,
15479 .input_mux = &alc662_capture_source,
15480 },
15481 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015482 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015483 .init_verbs = { alc662_init_verbs },
15484 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15485 .dac_nids = alc662_dac_nids,
15486 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015487 .dig_in_nid = ALC662_DIGIN_NID,
15488 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15489 .channel_mode = alc662_3ST_6ch_modes,
15490 .need_dac_fix = 1,
15491 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015492 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015493 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015494 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015495 .init_verbs = { alc662_init_verbs },
15496 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15497 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015498 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15499 .channel_mode = alc662_3ST_6ch_modes,
15500 .need_dac_fix = 1,
15501 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015502 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015503 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015504 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505 .init_verbs = { alc662_init_verbs },
15506 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15507 .dac_nids = alc662_dac_nids,
15508 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015509 .dig_in_nid = ALC662_DIGIN_NID,
15510 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15511 .channel_mode = alc662_5stack_modes,
15512 .input_mux = &alc662_capture_source,
15513 },
15514 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015515 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015516 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15517 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15518 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015519 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15520 .channel_mode = alc662_3ST_2ch_modes,
15521 .input_mux = &alc662_lenovo_101e_capture_source,
15522 .unsol_event = alc662_lenovo_101e_unsol_event,
15523 .init_hook = alc662_lenovo_101e_all_automute,
15524 },
Kailang Yang291702f2007-10-16 14:28:03 +020015525 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015526 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020015527 .init_verbs = { alc662_init_verbs,
15528 alc662_eeepc_sue_init_verbs },
15529 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15530 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015531 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15532 .channel_mode = alc662_3ST_2ch_modes,
15533 .input_mux = &alc662_eeepc_capture_source,
15534 .unsol_event = alc662_eeepc_unsol_event,
15535 .init_hook = alc662_eeepc_inithook,
15536 },
Kailang Yang8c427222008-01-10 13:03:59 +010015537 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015538 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010015539 alc662_chmode_mixer },
15540 .init_verbs = { alc662_init_verbs,
15541 alc662_eeepc_ep20_sue_init_verbs },
15542 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15543 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15545 .channel_mode = alc662_3ST_6ch_modes,
15546 .input_mux = &alc662_lenovo_101e_capture_source,
15547 .unsol_event = alc662_eeepc_ep20_unsol_event,
15548 .init_hook = alc662_eeepc_ep20_inithook,
15549 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015550 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015551 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015552 .init_verbs = { alc662_init_verbs,
15553 alc662_ecs_init_verbs },
15554 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15555 .dac_nids = alc662_dac_nids,
15556 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15557 .channel_mode = alc662_3ST_2ch_modes,
15558 .input_mux = &alc662_eeepc_capture_source,
15559 .unsol_event = alc662_eeepc_unsol_event,
15560 .init_hook = alc662_eeepc_inithook,
15561 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015562 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015563 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015564 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15565 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15566 .dac_nids = alc662_dac_nids,
15567 .dig_out_nid = ALC662_DIGOUT_NID,
15568 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15569 .channel_mode = alc662_3ST_2ch_modes,
15570 .input_mux = &alc663_m51va_capture_source,
15571 .unsol_event = alc663_m51va_unsol_event,
15572 .init_hook = alc663_m51va_inithook,
15573 },
15574 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015575 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015576 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15577 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15578 .dac_nids = alc662_dac_nids,
15579 .dig_out_nid = ALC662_DIGOUT_NID,
15580 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15581 .channel_mode = alc662_3ST_2ch_modes,
15582 .input_mux = &alc662_eeepc_capture_source,
15583 .unsol_event = alc663_g71v_unsol_event,
15584 .init_hook = alc663_g71v_inithook,
15585 },
15586 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015587 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015588 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15589 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15590 .dac_nids = alc662_dac_nids,
15591 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15592 .channel_mode = alc662_3ST_2ch_modes,
15593 .input_mux = &alc663_m51va_capture_source,
15594 .unsol_event = alc663_m51va_unsol_event,
15595 .init_hook = alc663_m51va_inithook,
15596 },
15597 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015598 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015599 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15600 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15601 .dac_nids = alc662_dac_nids,
15602 .dig_out_nid = ALC662_DIGOUT_NID,
15603 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15604 .channel_mode = alc662_3ST_6ch_modes,
15605 .input_mux = &alc663_capture_source,
15606 .unsol_event = alc663_g50v_unsol_event,
15607 .init_hook = alc663_g50v_inithook,
15608 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015609 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015610 .mixers = { alc663_m51va_mixer },
15611 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015612 .init_verbs = { alc662_init_verbs,
15613 alc663_21jd_amic_init_verbs },
15614 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15615 .hp_nid = 0x03,
15616 .dac_nids = alc662_dac_nids,
15617 .dig_out_nid = ALC662_DIGOUT_NID,
15618 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15619 .channel_mode = alc662_3ST_2ch_modes,
15620 .input_mux = &alc662_eeepc_capture_source,
15621 .unsol_event = alc663_mode1_unsol_event,
15622 .init_hook = alc663_mode1_inithook,
15623 },
15624 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015625 .mixers = { alc662_1bjd_mixer },
15626 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015627 .init_verbs = { alc662_init_verbs,
15628 alc662_1bjd_amic_init_verbs },
15629 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15630 .dac_nids = alc662_dac_nids,
15631 .dig_out_nid = ALC662_DIGOUT_NID,
15632 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15633 .channel_mode = alc662_3ST_2ch_modes,
15634 .input_mux = &alc662_eeepc_capture_source,
15635 .unsol_event = alc662_mode2_unsol_event,
15636 .init_hook = alc662_mode2_inithook,
15637 },
15638 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015639 .mixers = { alc663_two_hp_m1_mixer },
15640 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015641 .init_verbs = { alc662_init_verbs,
15642 alc663_two_hp_amic_m1_init_verbs },
15643 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15644 .hp_nid = 0x03,
15645 .dac_nids = alc662_dac_nids,
15646 .dig_out_nid = ALC662_DIGOUT_NID,
15647 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15648 .channel_mode = alc662_3ST_2ch_modes,
15649 .input_mux = &alc662_eeepc_capture_source,
15650 .unsol_event = alc663_mode3_unsol_event,
15651 .init_hook = alc663_mode3_inithook,
15652 },
15653 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015654 .mixers = { alc663_asus_21jd_clfe_mixer },
15655 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015656 .init_verbs = { alc662_init_verbs,
15657 alc663_21jd_amic_init_verbs},
15658 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15659 .hp_nid = 0x03,
15660 .dac_nids = alc662_dac_nids,
15661 .dig_out_nid = ALC662_DIGOUT_NID,
15662 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15663 .channel_mode = alc662_3ST_2ch_modes,
15664 .input_mux = &alc662_eeepc_capture_source,
15665 .unsol_event = alc663_mode4_unsol_event,
15666 .init_hook = alc663_mode4_inithook,
15667 },
15668 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015669 .mixers = { alc663_asus_15jd_clfe_mixer },
15670 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015671 .init_verbs = { alc662_init_verbs,
15672 alc663_15jd_amic_init_verbs },
15673 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15674 .hp_nid = 0x03,
15675 .dac_nids = alc662_dac_nids,
15676 .dig_out_nid = ALC662_DIGOUT_NID,
15677 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15678 .channel_mode = alc662_3ST_2ch_modes,
15679 .input_mux = &alc662_eeepc_capture_source,
15680 .unsol_event = alc663_mode5_unsol_event,
15681 .init_hook = alc663_mode5_inithook,
15682 },
15683 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015684 .mixers = { alc663_two_hp_m2_mixer },
15685 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015686 .init_verbs = { alc662_init_verbs,
15687 alc663_two_hp_amic_m2_init_verbs },
15688 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15689 .hp_nid = 0x03,
15690 .dac_nids = alc662_dac_nids,
15691 .dig_out_nid = ALC662_DIGOUT_NID,
15692 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15693 .channel_mode = alc662_3ST_2ch_modes,
15694 .input_mux = &alc662_eeepc_capture_source,
15695 .unsol_event = alc663_mode6_unsol_event,
15696 .init_hook = alc663_mode6_inithook,
15697 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015698};
15699
15700
15701/*
15702 * BIOS auto configuration
15703 */
15704
15705/* add playback controls from the parsed DAC table */
15706static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15707 const struct auto_pin_cfg *cfg)
15708{
15709 char name[32];
15710 static const char *chname[4] = {
15711 "Front", "Surround", NULL /*CLFE*/, "Side"
15712 };
15713 hda_nid_t nid;
15714 int i, err;
15715
15716 for (i = 0; i < cfg->line_outs; i++) {
15717 if (!spec->multiout.dac_nids[i])
15718 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015719 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015720 if (i == 2) {
15721 /* Center/LFE */
15722 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15723 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015724 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15725 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015726 if (err < 0)
15727 return err;
15728 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15729 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015730 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15731 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015732 if (err < 0)
15733 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015734 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015735 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015736 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015737 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738 if (err < 0)
15739 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015740 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015741 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015742 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015743 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015744 if (err < 0)
15745 return err;
15746 } else {
15747 sprintf(name, "%s Playback Volume", chname[i]);
15748 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015749 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15750 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015751 if (err < 0)
15752 return err;
15753 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030015754 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15755 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
15756 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015757 if (err < 0)
15758 return err;
15759 }
15760 }
15761 return 0;
15762}
15763
15764/* add playback controls for speaker and HP outputs */
15765static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
15766 const char *pfx)
15767{
15768 hda_nid_t nid;
15769 int err;
15770 char name[32];
15771
15772 if (!pin)
15773 return 0;
15774
Takashi Iwai24fb9172008-09-02 14:48:20 +020015775 if (pin == 0x17) {
15776 /* ALC663 has a mono output pin on 0x17 */
15777 sprintf(name, "%s Playback Switch", pfx);
15778 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15779 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
15780 return err;
15781 }
15782
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015783 if (alc880_is_fixed_pin(pin)) {
15784 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15785 /* printk("DAC nid=%x\n",nid); */
15786 /* specify the DAC as the extra output */
15787 if (!spec->multiout.hp_nid)
15788 spec->multiout.hp_nid = nid;
15789 else
15790 spec->multiout.extra_out_nid[0] = nid;
15791 /* control HP volume/switch on the output mixer amp */
15792 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15793 sprintf(name, "%s Playback Volume", pfx);
15794 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15795 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
15796 if (err < 0)
15797 return err;
15798 sprintf(name, "%s Playback Switch", pfx);
15799 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15800 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
15801 if (err < 0)
15802 return err;
15803 } else if (alc880_is_multi_pin(pin)) {
15804 /* set manual connection */
15805 /* we have only a switch on HP-out PIN */
15806 sprintf(name, "%s Playback Switch", pfx);
15807 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15808 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15809 if (err < 0)
15810 return err;
15811 }
15812 return 0;
15813}
15814
15815/* create playback/capture controls for input pins */
15816static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
15817 const struct auto_pin_cfg *cfg)
15818{
15819 struct hda_input_mux *imux = &spec->private_imux;
15820 int i, err, idx;
15821
15822 for (i = 0; i < AUTO_PIN_LAST; i++) {
15823 if (alc880_is_input_pin(cfg->input_pins[i])) {
15824 idx = alc880_input_pin_idx(cfg->input_pins[i]);
15825 err = new_analog_input(spec, cfg->input_pins[i],
15826 auto_pin_cfg_labels[i],
15827 idx, 0x0b);
15828 if (err < 0)
15829 return err;
15830 imux->items[imux->num_items].label =
15831 auto_pin_cfg_labels[i];
15832 imux->items[imux->num_items].index =
15833 alc880_input_pin_idx(cfg->input_pins[i]);
15834 imux->num_items++;
15835 }
15836 }
15837 return 0;
15838}
15839
15840static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
15841 hda_nid_t nid, int pin_type,
15842 int dac_idx)
15843{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015844 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015845 /* need the manual connection? */
15846 if (alc880_is_multi_pin(nid)) {
15847 struct alc_spec *spec = codec->spec;
15848 int idx = alc880_multi_pin_idx(nid);
15849 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
15850 AC_VERB_SET_CONNECT_SEL,
15851 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
15852 }
15853}
15854
15855static void alc662_auto_init_multi_out(struct hda_codec *codec)
15856{
15857 struct alc_spec *spec = codec->spec;
15858 int i;
15859
Kailang Yang8c427222008-01-10 13:03:59 +010015860 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015861 for (i = 0; i <= HDA_SIDE; i++) {
15862 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015863 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015864 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015865 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015866 i);
15867 }
15868}
15869
15870static void alc662_auto_init_hp_out(struct hda_codec *codec)
15871{
15872 struct alc_spec *spec = codec->spec;
15873 hda_nid_t pin;
15874
15875 pin = spec->autocfg.hp_pins[0];
15876 if (pin) /* connect to front */
15877 /* use dac 0 */
15878 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015879 pin = spec->autocfg.speaker_pins[0];
15880 if (pin)
15881 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015882}
15883
15884#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
15885#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
15886
15887static void alc662_auto_init_analog_input(struct hda_codec *codec)
15888{
15889 struct alc_spec *spec = codec->spec;
15890 int i;
15891
15892 for (i = 0; i < AUTO_PIN_LAST; i++) {
15893 hda_nid_t nid = spec->autocfg.input_pins[i];
15894 if (alc662_is_input_pin(nid)) {
15895 snd_hda_codec_write(codec, nid, 0,
15896 AC_VERB_SET_PIN_WIDGET_CONTROL,
15897 (i <= AUTO_PIN_FRONT_MIC ?
15898 PIN_VREF80 : PIN_IN));
15899 if (nid != ALC662_PIN_CD_NID)
15900 snd_hda_codec_write(codec, nid, 0,
15901 AC_VERB_SET_AMP_GAIN_MUTE,
15902 AMP_OUT_MUTE);
15903 }
15904 }
15905}
15906
Takashi Iwaif511b012008-08-15 16:46:42 +020015907#define alc662_auto_init_input_src alc882_auto_init_input_src
15908
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015909static int alc662_parse_auto_config(struct hda_codec *codec)
15910{
15911 struct alc_spec *spec = codec->spec;
15912 int err;
15913 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
15914
15915 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15916 alc662_ignore);
15917 if (err < 0)
15918 return err;
15919 if (!spec->autocfg.line_outs)
15920 return 0; /* can't find valid BIOS pin config */
15921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015922 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15923 if (err < 0)
15924 return err;
15925 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
15926 if (err < 0)
15927 return err;
15928 err = alc662_auto_create_extra_out(spec,
15929 spec->autocfg.speaker_pins[0],
15930 "Speaker");
15931 if (err < 0)
15932 return err;
15933 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
15934 "Headphone");
15935 if (err < 0)
15936 return err;
15937 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
15938 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015939 return err;
15940
15941 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15942
15943 if (spec->autocfg.dig_out_pin)
15944 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
15945
Takashi Iwai603c4012008-07-30 15:01:44 +020015946 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015947 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015948
15949 spec->num_mux_defs = 1;
15950 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020015951
Takashi Iwaid88897e2008-10-31 15:01:37 +010015952 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020015953 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015954 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020015955
15956 err = alc_auto_add_mic_boost(codec);
15957 if (err < 0)
15958 return err;
15959
Takashi Iwaie044c392008-10-27 16:56:24 +010015960 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015961 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015962}
15963
15964/* additional initialization for auto-configuration model */
15965static void alc662_auto_init(struct hda_codec *codec)
15966{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015967 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015968 alc662_auto_init_multi_out(codec);
15969 alc662_auto_init_hp_out(codec);
15970 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015971 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015972 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015973 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015974}
15975
15976static int patch_alc662(struct hda_codec *codec)
15977{
15978 struct alc_spec *spec;
15979 int err, board_config;
15980
15981 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15982 if (!spec)
15983 return -ENOMEM;
15984
15985 codec->spec = spec;
15986
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020015987 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15988
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015989 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
15990 alc662_models,
15991 alc662_cfg_tbl);
15992 if (board_config < 0) {
15993 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
15994 "trying auto-probe from BIOS...\n");
15995 board_config = ALC662_AUTO;
15996 }
15997
15998 if (board_config == ALC662_AUTO) {
15999 /* automatic parse from the BIOS config */
16000 err = alc662_parse_auto_config(codec);
16001 if (err < 0) {
16002 alc_free(codec);
16003 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016004 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016005 printk(KERN_INFO
16006 "hda_codec: Cannot set up configuration "
16007 "from BIOS. Using base mode...\n");
16008 board_config = ALC662_3ST_2ch_DIG;
16009 }
16010 }
16011
16012 if (board_config != ALC662_AUTO)
16013 setup_preset(spec, &alc662_presets[board_config]);
16014
Kailang Yang6dda9f42008-05-27 12:05:31 +020016015 if (codec->vendor_id == 0x10ec0663) {
16016 spec->stream_name_analog = "ALC663 Analog";
16017 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016018 } else if (codec->vendor_id == 0x10ec0272) {
16019 spec->stream_name_analog = "ALC272 Analog";
16020 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016021 } else {
16022 spec->stream_name_analog = "ALC662 Analog";
16023 spec->stream_name_digital = "ALC662 Digital";
16024 }
16025
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016026 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16027 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16028
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016029 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16030 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16031
Takashi Iwaie1406342008-02-11 18:32:32 +010016032 spec->adc_nids = alc662_adc_nids;
16033 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16034 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016035 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016036
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016037 if (!spec->cap_mixer)
16038 set_capture_mixer(spec);
16039
Takashi Iwai2134ea42008-01-10 16:53:55 +010016040 spec->vmaster_nid = 0x02;
16041
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016042 codec->patch_ops = alc_patch_ops;
16043 if (board_config == ALC662_AUTO)
16044 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016045#ifdef CONFIG_SND_HDA_POWER_SAVE
16046 if (!spec->loopback.amplist)
16047 spec->loopback.amplist = alc662_loopbacks;
16048#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016049
16050 return 0;
16051}
16052
16053/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016054 * patch entries
16055 */
16056struct hda_codec_preset snd_hda_preset_realtek[] = {
16057 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016058 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016059 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016060 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016061 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016062 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016063 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016064 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016065 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16066 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16067 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016068 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16069 .patch = patch_alc883 },
16070 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16071 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016072 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016073 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016074 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016075 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016076 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16077 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016078 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016079 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016080 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016081 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016082 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016083 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16084 .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016085 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016086 {} /* terminator */
16087};