blob: 4fdae06162ed608ece0b3815c8b0b5ee9cfe27de [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"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020062 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020074 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200103 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200104 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200105 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100116 ALC268_ACER_DMIC,
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,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100133 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000134 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100135 ALC269_AUTO,
136 ALC269_MODEL_LAST /* last tag */
137};
138
Kailang Yangdf694da2005-12-05 19:42:22 +0100139/* ALC861 models */
140enum {
141 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200142 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100143 ALC861_3ST_DIG,
144 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200145 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200146 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200147 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100148 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 ALC861_AUTO,
150 ALC861_MODEL_LAST,
151};
152
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153/* ALC861-VD models */
154enum {
155 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200156 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100157 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158 ALC861VD_3ST,
159 ALC861VD_3ST_DIG,
160 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200161 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200162 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200163 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100164 ALC861VD_AUTO,
165 ALC861VD_MODEL_LAST,
166};
167
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200168/* ALC662 models */
169enum {
170 ALC662_3ST_2ch_DIG,
171 ALC662_3ST_6ch_DIG,
172 ALC662_3ST_6ch,
173 ALC662_5ST_DIG,
174 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200175 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100176 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200177 ALC663_ASUS_M51VA,
178 ALC663_ASUS_G71V,
179 ALC663_ASUS_H13,
180 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200181 ALC662_ECS,
182 ALC663_ASUS_MODE1,
183 ALC662_ASUS_MODE2,
184 ALC663_ASUS_MODE3,
185 ALC663_ASUS_MODE4,
186 ALC663_ASUS_MODE5,
187 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200188 ALC662_AUTO,
189 ALC662_MODEL_LAST,
190};
191
Kailang Yangdf694da2005-12-05 19:42:22 +0100192/* ALC882 models */
193enum {
194 ALC882_3ST_DIG,
195 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200196 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200197 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200198 ALC882_TARGA,
199 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200200 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100201 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200202 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200203 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100205 ALC882_MODEL_LAST,
206};
207
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200208/* ALC883 models */
209enum {
210 ALC883_3ST_2ch_DIG,
211 ALC883_3ST_6ch_DIG,
212 ALC883_3ST_6ch,
213 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200214 ALC883_TARGA_DIG,
215 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200216 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200217 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800218 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200219 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200220 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100221 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200222 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200223 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200224 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200225 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200227 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100228 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100229 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100230 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100231 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800232 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200233 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200234 ALC888_ASUS_M90V,
235 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100236 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200237 ALC883_AUTO,
238 ALC883_MODEL_LAST,
239};
240
Kailang Yangdf694da2005-12-05 19:42:22 +0100241/* for GPIO Poll */
242#define GPIO_MASK 0x03
243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244struct alc_spec {
245 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200251 * don't forget NULL
252 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200253 */
254 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
Takashi Iwai16ded522005-06-10 19:58:24 +0200256 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 struct hda_pcm_stream *stream_analog_playback;
258 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100259 struct hda_pcm_stream *stream_analog_alt_playback;
260 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200262 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 struct hda_pcm_stream *stream_digital_playback;
264 struct hda_pcm_stream *stream_digital_capture;
265
266 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 struct hda_multi_out multiout; /* playback set-up
268 * max_channels, dacs must be set
269 * dig_out_nid and hp_nid are optional
270 */
Takashi Iwai63300792008-01-24 15:31:36 +0100271 hda_nid_t alt_dac_nid;
Takashi Iwai8c441982009-01-20 18:30:20 +0100272 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274 /* capture */
275 unsigned int num_adc_nids;
276 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100277 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100279 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200282 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 const struct hda_input_mux *input_mux;
284 unsigned int cur_mux[3];
285
286 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100287 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200289 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
291 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100292 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200293
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200294 /* dynamic controls, init_verbs and input_mux */
295 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200296 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200297 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200298 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100299
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100300 /* hooks */
301 void (*init_hook)(struct hda_codec *codec);
302 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
303
Takashi Iwai834be882006-03-01 14:16:17 +0100304 /* for pin sensing */
305 unsigned int sense_updated: 1;
306 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100307 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200308
Takashi Iwai2134ea42008-01-10 16:53:55 +0100309 /* for virtual master */
310 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200311#ifdef CONFIG_SND_HDA_POWER_SAVE
312 struct hda_loopback_check loopback;
313#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200314
315 /* for PLL fix */
316 hda_nid_t pll_nid;
317 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100318
319#ifdef SND_HDA_NEEDS_RESUME
320#define ALC_MAX_PINS 16
321 unsigned int num_pins;
322 hda_nid_t pin_nids[ALC_MAX_PINS];
323 unsigned int pin_cfgs[ALC_MAX_PINS];
324#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100325};
326
327/*
328 * configuration template - to be copied to the spec instance
329 */
330struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200331 struct snd_kcontrol_new *mixers[5]; /* should be identical size
332 * with spec
333 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100334 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100335 const struct hda_verb *init_verbs[5];
336 unsigned int num_dacs;
337 hda_nid_t *dac_nids;
338 hda_nid_t dig_out_nid; /* optional */
339 hda_nid_t hp_nid; /* optional */
340 unsigned int num_adc_nids;
341 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100342 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100343 hda_nid_t dig_in_nid;
344 unsigned int num_channel_mode;
345 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200346 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100348 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100349 void (*unsol_event)(struct hda_codec *, unsigned int);
350 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200351#ifdef CONFIG_SND_HDA_POWER_SAVE
352 struct hda_amp_list *loopbacks;
353#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354};
355
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357/*
358 * input MUX handling
359 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200360static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
361 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
364 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200365 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
366 if (mux_idx >= spec->num_mux_defs)
367 mux_idx = 0;
368 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200371static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373{
374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
375 struct alc_spec *spec = codec->spec;
376 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
377
378 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
379 return 0;
380}
381
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200382static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100387 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100389 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100390 hda_nid_t nid = spec->capsrc_nids ?
391 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Takashi Iwaicd896c32008-11-18 12:36:33 +0100393 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
394 imux = &spec->input_mux[mux_idx];
395
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100396 if (spec->is_mix_capture) {
397 /* Matrix-mixer style (e.g. ALC882) */
398 unsigned int *cur_val = &spec->cur_mux[adc_idx];
399 unsigned int i, idx;
400
401 idx = ucontrol->value.enumerated.item[0];
402 if (idx >= imux->num_items)
403 idx = imux->num_items - 1;
404 if (*cur_val == idx)
405 return 0;
406 for (i = 0; i < imux->num_items; i++) {
407 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
408 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
409 imux->items[i].index,
410 HDA_AMP_MUTE, v);
411 }
412 *cur_val = idx;
413 return 1;
414 } else {
415 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100416 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100417 &spec->cur_mux[adc_idx]);
418 }
419}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421/*
422 * channel mode setting
423 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200424static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100429 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
430 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100438 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439 spec->num_channel_mode,
440 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200448 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
449 spec->num_channel_mode,
450 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200451 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200452 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
453 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100457 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200458 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100459 * being part of a format specifier. Maximum allowed length of a value is
460 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100461 *
462 * Note: some retasking pin complexes seem to ignore requests for input
463 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
464 * are requested. Therefore order this list so that this behaviour will not
465 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200466 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
467 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200468 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100470 "Mic 50pc bias", "Mic 80pc bias",
471 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472};
473static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100474 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100475};
476/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200477 * in the pin being assumed to be exclusively an input or an output pin. In
478 * addition, "input" pins may or may not process the mic bias option
479 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
480 * accept requests for bias as of chip versions up to March 2006) and/or
481 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200483#define ALC_PIN_DIR_IN 0x00
484#define ALC_PIN_DIR_OUT 0x01
485#define ALC_PIN_DIR_INOUT 0x02
486#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
487#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100488
Kailang Yangea1fb292008-08-26 12:58:38 +0200489/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100490 * For each direction the minimum and maximum values are given.
491 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200492static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493 { 0, 2 }, /* ALC_PIN_DIR_IN */
494 { 3, 4 }, /* ALC_PIN_DIR_OUT */
495 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200496 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
497 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498};
499#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
500#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
501#define alc_pin_mode_n_items(_dir) \
502 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
503
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200504static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200506{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507 unsigned int item_num = uinfo->value.enumerated.item;
508 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
509
510 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200511 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
513
514 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
515 item_num = alc_pin_mode_min(dir);
516 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200517 return 0;
518}
519
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200522{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
525 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
529 AC_VERB_GET_PIN_WIDGET_CONTROL,
530 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200531
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532 /* Find enumerated value for current pinctl setting */
533 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 return 0;
538}
539
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542{
543 signed int change;
544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
545 hda_nid_t nid = kcontrol->private_value & 0xffff;
546 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
547 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
549 AC_VERB_GET_PIN_WIDGET_CONTROL,
550 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200552 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 val = alc_pin_mode_min(dir);
554
555 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100556 if (change) {
557 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200558 snd_hda_codec_write_cache(codec, nid, 0,
559 AC_VERB_SET_PIN_WIDGET_CONTROL,
560 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100561
Kailang Yangea1fb292008-08-26 12:58:38 +0200562 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100563 * for the requested pin mode. Enum values of 2 or less are
564 * input modes.
565 *
566 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200567 * reduces noise slightly (particularly on input) so we'll
568 * do it. However, having both input and output buffers
569 * enabled simultaneously doesn't seem to be problematic if
570 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571 */
572 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200573 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
574 HDA_AMP_MUTE, HDA_AMP_MUTE);
575 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
576 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100577 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200578 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
579 HDA_AMP_MUTE, HDA_AMP_MUTE);
580 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
581 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100582 }
583 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200584 return change;
585}
586
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200588 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589 .info = alc_pin_mode_info, \
590 .get = alc_pin_mode_get, \
591 .put = alc_pin_mode_put, \
592 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100593
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100594/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
595 * together using a mask with more than one bit set. This control is
596 * currently used only by the ALC260 test model. At this stage they are not
597 * needed for any "production" models.
598 */
599#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200600#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200601
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 hda_nid_t nid = kcontrol->private_value & 0xffff;
607 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
608 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 unsigned int val = snd_hda_codec_read(codec, nid, 0,
610 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100611
612 *valp = (val & mask) != 0;
613 return 0;
614}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100617{
618 signed int change;
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
621 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
622 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_GPIO_DATA,
625 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100626
627 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200628 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
629 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100630 gpio_data &= ~mask;
631 else
632 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200633 snd_hda_codec_write_cache(codec, nid, 0,
634 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100635
636 return change;
637}
638#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
639 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
640 .info = alc_gpio_data_info, \
641 .get = alc_gpio_data_get, \
642 .put = alc_gpio_data_put, \
643 .private_value = nid | (mask<<16) }
644#endif /* CONFIG_SND_DEBUG */
645
Jonathan Woithe92621f12006-02-28 11:47:47 +0100646/* A switch control to allow the enabling of the digital IO pins on the
647 * ALC260. This is incredibly simplistic; the intention of this control is
648 * to provide something in the test model allowing digital outputs to be
649 * identified if present. If models are found which can utilise these
650 * outputs a more complete mixer control can be devised for those models if
651 * necessary.
652 */
653#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200654#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200655
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
657 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100658{
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 hda_nid_t nid = kcontrol->private_value & 0xffff;
661 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
662 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100664 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100665
666 *valp = (val & mask) != 0;
667 return 0;
668}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200669static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
670 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100671{
672 signed int change;
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 hda_nid_t nid = kcontrol->private_value & 0xffff;
675 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
676 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200677 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100678 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100680
681 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200682 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683 if (val==0)
684 ctrl_data &= ~mask;
685 else
686 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200687 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
688 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100689
690 return change;
691}
692#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
693 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
694 .info = alc_spdif_ctrl_info, \
695 .get = alc_spdif_ctrl_get, \
696 .put = alc_spdif_ctrl_put, \
697 .private_value = nid | (mask<<16) }
698#endif /* CONFIG_SND_DEBUG */
699
Jonathan Woithef8225f62008-01-08 12:16:54 +0100700/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
701 * Again, this is only used in the ALC26x test models to help identify when
702 * the EAPD line must be asserted for features to work.
703 */
704#ifdef CONFIG_SND_DEBUG
705#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
706
707static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
708 struct snd_ctl_elem_value *ucontrol)
709{
710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
711 hda_nid_t nid = kcontrol->private_value & 0xffff;
712 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
713 long *valp = ucontrol->value.integer.value;
714 unsigned int val = snd_hda_codec_read(codec, nid, 0,
715 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
716
717 *valp = (val & mask) != 0;
718 return 0;
719}
720
721static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
723{
724 int change;
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 hda_nid_t nid = kcontrol->private_value & 0xffff;
727 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
728 long val = *ucontrol->value.integer.value;
729 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_EAPD_BTLENABLE,
731 0x00);
732
733 /* Set/unset the masked control bit(s) as needed */
734 change = (!val ? 0 : mask) != (ctrl_data & mask);
735 if (!val)
736 ctrl_data &= ~mask;
737 else
738 ctrl_data |= mask;
739 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
740 ctrl_data);
741
742 return change;
743}
744
745#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
746 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
747 .info = alc_eapd_ctrl_info, \
748 .get = alc_eapd_ctrl_get, \
749 .put = alc_eapd_ctrl_put, \
750 .private_value = nid | (mask<<16) }
751#endif /* CONFIG_SND_DEBUG */
752
Kailang Yangdf694da2005-12-05 19:42:22 +0100753/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100754 */
755static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
756{
757 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
758 return;
759 spec->mixers[spec->num_mixers++] = mix;
760}
761
762static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
763{
764 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
765 return;
766 spec->init_verbs[spec->num_init_verbs++] = verb;
767}
768
Takashi Iwaidaead532008-11-28 12:55:36 +0100769#ifdef CONFIG_PROC_FS
770/*
771 * hook for proc
772 */
773static void print_realtek_coef(struct snd_info_buffer *buffer,
774 struct hda_codec *codec, hda_nid_t nid)
775{
776 int coeff;
777
778 if (nid != 0x20)
779 return;
780 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
781 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
782 coeff = snd_hda_codec_read(codec, nid, 0,
783 AC_VERB_GET_COEF_INDEX, 0);
784 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
785}
786#else
787#define print_realtek_coef NULL
788#endif
789
Takashi Iwaid88897e2008-10-31 15:01:37 +0100790/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100791 * set up from the preset table
792 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200793static void setup_preset(struct alc_spec *spec,
794 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100795{
796 int i;
797
798 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100799 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100800 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200801 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
802 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100803 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200804
Kailang Yangdf694da2005-12-05 19:42:22 +0100805 spec->channel_mode = preset->channel_mode;
806 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200807 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100808
809 spec->multiout.max_channels = spec->channel_mode[0].channels;
810
811 spec->multiout.num_dacs = preset->num_dacs;
812 spec->multiout.dac_nids = preset->dac_nids;
813 spec->multiout.dig_out_nid = preset->dig_out_nid;
814 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200815
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200816 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200817 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200818 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100819 spec->input_mux = preset->input_mux;
820
821 spec->num_adc_nids = preset->num_adc_nids;
822 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100823 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100824 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100825
826 spec->unsol_event = preset->unsol_event;
827 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200828#ifdef CONFIG_SND_HDA_POWER_SAVE
829 spec->loopback.amplist = preset->loopbacks;
830#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100831}
832
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200833/* Enable GPIO mask and set output */
834static struct hda_verb alc_gpio1_init_verbs[] = {
835 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
836 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
837 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
838 { }
839};
840
841static struct hda_verb alc_gpio2_init_verbs[] = {
842 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
843 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
844 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
845 { }
846};
847
Kailang Yangbdd148a2007-05-08 15:19:08 +0200848static struct hda_verb alc_gpio3_init_verbs[] = {
849 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
850 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
851 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
852 { }
853};
854
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200855/*
856 * Fix hardware PLL issue
857 * On some codecs, the analog PLL gating control must be off while
858 * the default value is 1.
859 */
860static void alc_fix_pll(struct hda_codec *codec)
861{
862 struct alc_spec *spec = codec->spec;
863 unsigned int val;
864
865 if (!spec->pll_nid)
866 return;
867 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
868 spec->pll_coef_idx);
869 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
870 AC_VERB_GET_PROC_COEF, 0);
871 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
872 spec->pll_coef_idx);
873 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
874 val & ~(1 << spec->pll_coef_bit));
875}
876
877static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
878 unsigned int coef_idx, unsigned int coef_bit)
879{
880 struct alc_spec *spec = codec->spec;
881 spec->pll_nid = nid;
882 spec->pll_coef_idx = coef_idx;
883 spec->pll_coef_bit = coef_bit;
884 alc_fix_pll(codec);
885}
886
Kailang Yangc9b58002007-10-16 14:30:01 +0200887static void alc_sku_automute(struct hda_codec *codec)
888{
889 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200890 unsigned int present;
891 unsigned int hp_nid = spec->autocfg.hp_pins[0];
892 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
893
894 /* need to execute and sync at first */
895 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
896 present = snd_hda_codec_read(codec, hp_nid, 0,
897 AC_VERB_GET_PIN_SENSE, 0);
898 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100899 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
900 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200901}
902
Takashi Iwai4605b712008-10-31 14:18:24 +0100903#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200904static void alc_mic_automute(struct hda_codec *codec)
905{
906 struct alc_spec *spec = codec->spec;
907 unsigned int present;
908 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
909 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
910 unsigned int mix_nid = spec->capsrc_nids[0];
911 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
912
913 capsrc_idx_mic = mic_nid - 0x18;
914 capsrc_idx_fmic = fmic_nid - 0x18;
915 present = snd_hda_codec_read(codec, mic_nid, 0,
916 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
917 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
918 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
919 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
920 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
921 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
922 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
923}
Takashi Iwai4605b712008-10-31 14:18:24 +0100924#else
925#define alc_mic_automute(codec) /* NOP */
926#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200927
Kailang Yangc9b58002007-10-16 14:30:01 +0200928/* unsolicited event for HP jack sensing */
929static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
930{
931 if (codec->vendor_id == 0x10ec0880)
932 res >>= 28;
933 else
934 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200935 if (res == ALC880_HP_EVENT)
936 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200937
Kailang Yang7fb0d782008-10-15 11:12:35 +0200938 if (res == ALC880_MIC_EVENT)
939 alc_mic_automute(codec);
940}
941
942static void alc_inithook(struct hda_codec *codec)
943{
Kailang Yangc9b58002007-10-16 14:30:01 +0200944 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200945 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200946}
947
Kailang Yangf9423e72008-05-27 12:32:25 +0200948/* additional initialization for ALC888 variants */
949static void alc888_coef_init(struct hda_codec *codec)
950{
951 unsigned int tmp;
952
953 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
954 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
955 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
956 if ((tmp & 0xf0) == 2)
957 /* alc888S-VC */
958 snd_hda_codec_read(codec, 0x20, 0,
959 AC_VERB_SET_PROC_COEF, 0x830);
960 else
961 /* alc888-VB */
962 snd_hda_codec_read(codec, 0x20, 0,
963 AC_VERB_SET_PROC_COEF, 0x3030);
964}
965
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200966/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
967 * 31 ~ 16 : Manufacture ID
968 * 15 ~ 8 : SKU ID
969 * 7 ~ 0 : Assembly ID
970 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
971 */
972static void alc_subsystem_id(struct hda_codec *codec,
973 unsigned int porta, unsigned int porte,
974 unsigned int portd)
975{
Kailang Yangc9b58002007-10-16 14:30:01 +0200976 unsigned int ass, tmp, i;
977 unsigned nid;
978 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200979
Kailang Yangc9b58002007-10-16 14:30:01 +0200980 ass = codec->subsystem_id & 0xffff;
981 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
982 goto do_sku;
983
Kailang Yangea1fb292008-08-26 12:58:38 +0200984 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200985 * 31~30 : port conetcivity
986 * 29~21 : reserve
987 * 20 : PCBEEP input
988 * 19~16 : Check sum (15:1)
989 * 15~1 : Custom
990 * 0 : override
991 */
992 nid = 0x1d;
993 if (codec->vendor_id == 0x10ec0260)
994 nid = 0x17;
995 ass = snd_hda_codec_read(codec, nid, 0,
996 AC_VERB_GET_CONFIG_DEFAULT, 0);
997 if (!(ass & 1) && !(ass & 0x100000))
998 return;
999 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001000 return;
1001
Kailang Yangc9b58002007-10-16 14:30:01 +02001002 /* check sum */
1003 tmp = 0;
1004 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001005 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001006 tmp++;
1007 }
1008 if (((ass >> 16) & 0xf) != tmp)
1009 return;
1010do_sku:
1011 /*
1012 * 0 : override
1013 * 1 : Swap Jack
1014 * 2 : 0 --> Desktop, 1 --> Laptop
1015 * 3~5 : External Amplifier control
1016 * 7~6 : Reserved
1017 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001018 tmp = (ass & 0x38) >> 3; /* external Amp control */
1019 switch (tmp) {
1020 case 1:
1021 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1022 break;
1023 case 3:
1024 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1025 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001026 case 7:
1027 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1028 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001029 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001030 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001031 case 0x10ec0260:
1032 snd_hda_codec_write(codec, 0x0f, 0,
1033 AC_VERB_SET_EAPD_BTLENABLE, 2);
1034 snd_hda_codec_write(codec, 0x10, 0,
1035 AC_VERB_SET_EAPD_BTLENABLE, 2);
1036 break;
1037 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001038 case 0x10ec0267:
1039 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001040 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001041 case 0x10ec0660:
1042 case 0x10ec0662:
1043 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001044 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001045 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001046 snd_hda_codec_write(codec, 0x14, 0,
1047 AC_VERB_SET_EAPD_BTLENABLE, 2);
1048 snd_hda_codec_write(codec, 0x15, 0,
1049 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001050 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001051 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001052 switch (codec->vendor_id) {
1053 case 0x10ec0260:
1054 snd_hda_codec_write(codec, 0x1a, 0,
1055 AC_VERB_SET_COEF_INDEX, 7);
1056 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1057 AC_VERB_GET_PROC_COEF, 0);
1058 snd_hda_codec_write(codec, 0x1a, 0,
1059 AC_VERB_SET_COEF_INDEX, 7);
1060 snd_hda_codec_write(codec, 0x1a, 0,
1061 AC_VERB_SET_PROC_COEF,
1062 tmp | 0x2010);
1063 break;
1064 case 0x10ec0262:
1065 case 0x10ec0880:
1066 case 0x10ec0882:
1067 case 0x10ec0883:
1068 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001069 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001070 snd_hda_codec_write(codec, 0x20, 0,
1071 AC_VERB_SET_COEF_INDEX, 7);
1072 tmp = snd_hda_codec_read(codec, 0x20, 0,
1073 AC_VERB_GET_PROC_COEF, 0);
1074 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001075 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001076 snd_hda_codec_write(codec, 0x20, 0,
1077 AC_VERB_SET_PROC_COEF,
1078 tmp | 0x2010);
1079 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001080 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001081 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001082 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001083 case 0x10ec0267:
1084 case 0x10ec0268:
1085 snd_hda_codec_write(codec, 0x20, 0,
1086 AC_VERB_SET_COEF_INDEX, 7);
1087 tmp = snd_hda_codec_read(codec, 0x20, 0,
1088 AC_VERB_GET_PROC_COEF, 0);
1089 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001090 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001091 snd_hda_codec_write(codec, 0x20, 0,
1092 AC_VERB_SET_PROC_COEF,
1093 tmp | 0x3000);
1094 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001096 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097 break;
1098 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001099
Kailang Yang8c427222008-01-10 13:03:59 +01001100 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001101 * when the external headphone out jack is plugged"
1102 */
Kailang Yang8c427222008-01-10 13:03:59 +01001103 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 return;
1105 /*
1106 * 10~8 : Jack location
1107 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1108 * 14~13: Resvered
1109 * 15 : 1 --> enable the function "Mute internal speaker
1110 * when the external headphone out jack is plugged"
1111 */
1112 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001113 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001114 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001115 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 else
1117 return;
1118 }
1119
1120 if (!spec->autocfg.hp_pins[0]) {
1121 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1122 if (tmp == 0)
1123 spec->autocfg.hp_pins[0] = porta;
1124 else if (tmp == 1)
1125 spec->autocfg.hp_pins[0] = porte;
1126 else if (tmp == 2)
1127 spec->autocfg.hp_pins[0] = portd;
1128 else
1129 return;
1130 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001131 if (spec->autocfg.hp_pins[0])
1132 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1133 AC_VERB_SET_UNSOLICITED_ENABLE,
1134 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001135
Takashi Iwai4605b712008-10-31 14:18:24 +01001136#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001137 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1138 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1139 snd_hda_codec_write(codec,
1140 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1141 AC_VERB_SET_UNSOLICITED_ENABLE,
1142 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001143#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001144
Kailang Yangc9b58002007-10-16 14:30:01 +02001145 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001146}
1147
Takashi Iwai41e41f12005-06-08 14:48:49 +02001148/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001149 * Fix-up pin default configurations
1150 */
1151
1152struct alc_pincfg {
1153 hda_nid_t nid;
1154 u32 val;
1155};
1156
1157static void alc_fix_pincfg(struct hda_codec *codec,
1158 const struct snd_pci_quirk *quirk,
1159 const struct alc_pincfg **pinfix)
1160{
1161 const struct alc_pincfg *cfg;
1162
1163 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1164 if (!quirk)
1165 return;
1166
1167 cfg = pinfix[quirk->value];
1168 for (; cfg->nid; cfg++) {
1169 int i;
1170 u32 val = cfg->val;
1171 for (i = 0; i < 4; i++) {
1172 snd_hda_codec_write(codec, cfg->nid, 0,
1173 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1174 val & 0xff);
1175 val >>= 8;
1176 }
1177 }
1178}
1179
1180/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001181 * ALC888
1182 */
1183
1184/*
1185 * 2ch mode
1186 */
1187static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1188/* Mic-in jack as mic in */
1189 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1190 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1191/* Line-in jack as Line in */
1192 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1193 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1194/* Line-Out as Front */
1195 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1196 { } /* end */
1197};
1198
1199/*
1200 * 4ch mode
1201 */
1202static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1203/* Mic-in jack as mic in */
1204 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1205 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1206/* Line-in jack as Surround */
1207 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1208 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1209/* Line-Out as Front */
1210 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1211 { } /* end */
1212};
1213
1214/*
1215 * 6ch mode
1216 */
1217static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1218/* Mic-in jack as CLFE */
1219 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1220 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1221/* Line-in jack as Surround */
1222 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1223 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1224/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1225 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1226 { } /* end */
1227};
1228
1229/*
1230 * 8ch mode
1231 */
1232static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1233/* Mic-in jack as CLFE */
1234 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1235 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1236/* Line-in jack as Surround */
1237 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1238 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1239/* Line-Out as Side */
1240 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1241 { } /* end */
1242};
1243
1244static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1245 { 2, alc888_4ST_ch2_intel_init },
1246 { 4, alc888_4ST_ch4_intel_init },
1247 { 6, alc888_4ST_ch6_intel_init },
1248 { 8, alc888_4ST_ch8_intel_init },
1249};
1250
1251/*
1252 * ALC888 Fujitsu Siemens Amillo xa3530
1253 */
1254
1255static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1256/* Front Mic: set to PIN_IN (empty by default) */
1257 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1258/* Connect Internal HP to Front */
1259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1260 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1261 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1262/* Connect Bass HP to Front */
1263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1266/* Connect Line-Out side jack (SPDIF) to Side */
1267 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1268 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1269 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1270/* Connect Mic jack to CLFE */
1271 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1274/* Connect Line-in jack to Surround */
1275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1277 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1278/* Connect HP out jack to Front */
1279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1282/* Enable unsolicited event for HP jack and Line-out jack */
1283 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1284 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1285 {}
1286};
1287
1288static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1289{
1290 unsigned int present;
1291 unsigned int bits;
1292 /* Line out presence */
1293 present = snd_hda_codec_read(codec, 0x17, 0,
1294 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1295 /* HP out presence */
1296 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1297 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1298 bits = present ? HDA_AMP_MUTE : 0;
1299 /* Toggle internal speakers muting */
1300 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1301 HDA_AMP_MUTE, bits);
1302 /* Toggle internal bass muting */
1303 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1304 HDA_AMP_MUTE, bits);
1305}
1306
1307static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1308 unsigned int res)
1309{
1310 if (res >> 26 == ALC880_HP_EVENT)
1311 alc888_fujitsu_xa3530_automute(codec);
1312}
1313
1314
1315/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001316 * ALC888 Acer Aspire 4930G model
1317 */
1318
1319static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1320/* Front Mic: set to PIN_IN (empty by default) */
1321 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1322/* Unselect Front Mic by default in input mixer 3 */
1323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001324/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001325 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1326/* Connect Internal HP to front */
1327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1330/* Connect HP out to front */
1331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1333 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1334 { }
1335};
1336
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001337static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001338 /* Front mic only available on one ADC */
1339 {
1340 .num_items = 4,
1341 .items = {
1342 { "Mic", 0x0 },
1343 { "Line", 0x2 },
1344 { "CD", 0x4 },
1345 { "Front Mic", 0xb },
1346 },
1347 },
1348 {
1349 .num_items = 3,
1350 .items = {
1351 { "Mic", 0x0 },
1352 { "Line", 0x2 },
1353 { "CD", 0x4 },
1354 },
1355 }
1356};
1357
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001358static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001359 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1360 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1361 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1362 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1363 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1364 HDA_OUTPUT),
1365 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1366 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1367 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1368 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1369 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1375 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1377 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1378 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1379 { } /* end */
1380};
1381
1382static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1383{
1384 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001385 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001386 present = snd_hda_codec_read(codec, 0x15, 0,
1387 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001388 bits = present ? HDA_AMP_MUTE : 0;
1389 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1390 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001391}
1392
1393static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1394 unsigned int res)
1395{
1396 if (res >> 26 == ALC880_HP_EVENT)
1397 alc888_acer_aspire_4930g_automute(codec);
1398}
1399
1400/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401 * ALC880 3-stack model
1402 *
1403 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001404 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1405 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 */
1407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001408static hda_nid_t alc880_dac_nids[4] = {
1409 /* front, rear, clfe, rear_surr */
1410 0x02, 0x05, 0x04, 0x03
1411};
1412
1413static hda_nid_t alc880_adc_nids[3] = {
1414 /* ADC0-2 */
1415 0x07, 0x08, 0x09,
1416};
1417
1418/* The datasheet says the node 0x07 is connected from inputs,
1419 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001420 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001422static hda_nid_t alc880_adc_nids_alt[2] = {
1423 /* ADC1-2 */
1424 0x08, 0x09,
1425};
1426
1427#define ALC880_DIGOUT_NID 0x06
1428#define ALC880_DIGIN_NID 0x0a
1429
1430static struct hda_input_mux alc880_capture_source = {
1431 .num_items = 4,
1432 .items = {
1433 { "Mic", 0x0 },
1434 { "Front Mic", 0x3 },
1435 { "Line", 0x2 },
1436 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438};
1439
1440/* channel source setting (2/6 channel selection for 3-stack) */
1441/* 2ch mode */
1442static struct hda_verb alc880_threestack_ch2_init[] = {
1443 /* set line-in to input, mute it */
1444 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1445 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1446 /* set mic-in to input vref 80%, mute it */
1447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 { } /* end */
1450};
1451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001452/* 6ch mode */
1453static struct hda_verb alc880_threestack_ch6_init[] = {
1454 /* set line-in to output, unmute it */
1455 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1456 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1457 /* set mic-in to output, unmute it */
1458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1460 { } /* end */
1461};
1462
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001463static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001464 { 2, alc880_threestack_ch2_init },
1465 { 6, alc880_threestack_ch6_init },
1466};
1467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001468static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001472 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1485 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1486 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001488 {
1489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1490 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001491 .info = alc_ch_mode_info,
1492 .get = alc_ch_mode_get,
1493 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001494 },
1495 { } /* end */
1496};
1497
1498/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001499static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1500 struct snd_ctl_elem_info *uinfo)
1501{
1502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1503 struct alc_spec *spec = codec->spec;
1504 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001505
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001506 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001507 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1508 HDA_INPUT);
1509 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001510 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001511 return err;
1512}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001514static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1515 unsigned int size, unsigned int __user *tlv)
1516{
1517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1518 struct alc_spec *spec = codec->spec;
1519 int err;
1520
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001521 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001522 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1523 HDA_INPUT);
1524 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001525 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001526 return err;
1527}
1528
1529typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1530 struct snd_ctl_elem_value *ucontrol);
1531
1532static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1533 struct snd_ctl_elem_value *ucontrol,
1534 getput_call_t func)
1535{
1536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1537 struct alc_spec *spec = codec->spec;
1538 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1539 int err;
1540
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001541 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001542 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1543 3, 0, HDA_INPUT);
1544 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001545 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001546 return err;
1547}
1548
1549static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1550 struct snd_ctl_elem_value *ucontrol)
1551{
1552 return alc_cap_getput_caller(kcontrol, ucontrol,
1553 snd_hda_mixer_amp_volume_get);
1554}
1555
1556static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1557 struct snd_ctl_elem_value *ucontrol)
1558{
1559 return alc_cap_getput_caller(kcontrol, ucontrol,
1560 snd_hda_mixer_amp_volume_put);
1561}
1562
1563/* capture mixer elements */
1564#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1565
1566static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1567 struct snd_ctl_elem_value *ucontrol)
1568{
1569 return alc_cap_getput_caller(kcontrol, ucontrol,
1570 snd_hda_mixer_amp_switch_get);
1571}
1572
1573static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1574 struct snd_ctl_elem_value *ucontrol)
1575{
1576 return alc_cap_getput_caller(kcontrol, ucontrol,
1577 snd_hda_mixer_amp_switch_put);
1578}
1579
1580#define DEFINE_CAPMIX(num) \
1581static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1582 { \
1583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1584 .name = "Capture Switch", \
1585 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1586 .count = num, \
1587 .info = alc_cap_sw_info, \
1588 .get = alc_cap_sw_get, \
1589 .put = alc_cap_sw_put, \
1590 }, \
1591 { \
1592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1593 .name = "Capture Volume", \
1594 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1595 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1596 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1597 .count = num, \
1598 .info = alc_cap_vol_info, \
1599 .get = alc_cap_vol_get, \
1600 .put = alc_cap_vol_put, \
1601 .tlv = { .c = alc_cap_vol_tlv }, \
1602 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001603 { \
1604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1605 /* .name = "Capture Source", */ \
1606 .name = "Input Source", \
1607 .count = num, \
1608 .info = alc_mux_enum_info, \
1609 .get = alc_mux_enum_get, \
1610 .put = alc_mux_enum_put, \
1611 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001612 { } /* end */ \
1613}
1614
1615/* up to three ADCs */
1616DEFINE_CAPMIX(1);
1617DEFINE_CAPMIX(2);
1618DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001619
1620
1621/*
1622 * ALC880 5-stack model
1623 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001624 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1625 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001626 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1627 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1628 */
1629
1630/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001631static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001632 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001633 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 { } /* end */
1635};
1636
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001637/* channel source setting (6/8 channel selection for 5-stack) */
1638/* 6ch mode */
1639static struct hda_verb alc880_fivestack_ch6_init[] = {
1640 /* set line-in to input, mute it */
1641 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1642 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001643 { } /* end */
1644};
1645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646/* 8ch mode */
1647static struct hda_verb alc880_fivestack_ch8_init[] = {
1648 /* set line-in to output, unmute it */
1649 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1650 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1651 { } /* end */
1652};
1653
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001654static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 { 6, alc880_fivestack_ch6_init },
1656 { 8, alc880_fivestack_ch8_init },
1657};
1658
1659
1660/*
1661 * ALC880 6-stack model
1662 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001663 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1664 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001665 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1666 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1667 */
1668
1669static hda_nid_t alc880_6st_dac_nids[4] = {
1670 /* front, rear, clfe, rear_surr */
1671 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001672};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001673
1674static struct hda_input_mux alc880_6stack_capture_source = {
1675 .num_items = 4,
1676 .items = {
1677 { "Mic", 0x0 },
1678 { "Front Mic", 0x1 },
1679 { "Line", 0x2 },
1680 { "CD", 0x4 },
1681 },
1682};
1683
1684/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001685static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001686 { 8, NULL },
1687};
1688
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001689static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001691 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001692 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001693 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001694 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1695 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001696 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1697 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001698 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001699 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001700 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1701 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1705 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1706 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1707 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1708 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1709 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001710 {
1711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1712 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001713 .info = alc_ch_mode_info,
1714 .get = alc_ch_mode_get,
1715 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001716 },
1717 { } /* end */
1718};
1719
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001720
1721/*
1722 * ALC880 W810 model
1723 *
1724 * W810 has rear IO for:
1725 * Front (DAC 02)
1726 * Surround (DAC 03)
1727 * Center/LFE (DAC 04)
1728 * Digital out (06)
1729 *
1730 * The system also has a pair of internal speakers, and a headphone jack.
1731 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001732 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733 * There is a variable resistor to control the speaker or headphone
1734 * volume. This is a hardware-only device without a software API.
1735 *
1736 * Plugging headphones in will disable the internal speakers. This is
1737 * implemented in hardware, not via the driver using jack sense. In
1738 * a similar fashion, plugging into the rear socket marked "front" will
1739 * disable both the speakers and headphones.
1740 *
1741 * For input, there's a microphone jack, and an "audio in" jack.
1742 * These may not do anything useful with this driver yet, because I
1743 * haven't setup any initialization verbs for these yet...
1744 */
1745
1746static hda_nid_t alc880_w810_dac_nids[3] = {
1747 /* front, rear/surround, clfe */
1748 0x02, 0x03, 0x04
1749};
1750
1751/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001752static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001753 { 6, NULL }
1754};
1755
1756/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001757static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1763 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001764 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1765 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1767 { } /* end */
1768};
1769
1770
1771/*
1772 * Z710V model
1773 *
1774 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001775 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1776 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001777 */
1778
1779static hda_nid_t alc880_z71v_dac_nids[1] = {
1780 0x02
1781};
1782#define ALC880_Z71V_HP_DAC 0x03
1783
1784/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001785static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001786 { 2, NULL }
1787};
1788
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001789static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001793 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1798 { } /* end */
1799};
1800
1801
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802/*
1803 * ALC880 F1734 model
1804 *
1805 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1806 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1807 */
1808
1809static hda_nid_t alc880_f1734_dac_nids[1] = {
1810 0x03
1811};
1812#define ALC880_F1734_HP_DAC 0x02
1813
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001814static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001816 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001817 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1818 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 { } /* end */
1824};
1825
Takashi Iwai937b4162008-02-11 14:52:36 +01001826static struct hda_input_mux alc880_f1734_capture_source = {
1827 .num_items = 2,
1828 .items = {
1829 { "Mic", 0x1 },
1830 { "CD", 0x4 },
1831 },
1832};
1833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835/*
1836 * ALC880 ASUS model
1837 *
1838 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1839 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1840 * Mic = 0x18, Line = 0x1a
1841 */
1842
1843#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1844#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1845
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001846static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001847 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001848 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001849 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001850 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001851 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1852 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001853 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1854 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001855 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1856 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1857 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1858 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001861 {
1862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1863 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001864 .info = alc_ch_mode_info,
1865 .get = alc_ch_mode_get,
1866 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001867 },
1868 { } /* end */
1869};
1870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001871/*
1872 * ALC880 ASUS W1V model
1873 *
1874 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1875 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1876 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1877 */
1878
1879/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001880static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001881 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1882 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001883 { } /* end */
1884};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001886/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001887static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001888 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1889 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1890 { } /* end */
1891};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001892
Kailang Yangdf694da2005-12-05 19:42:22 +01001893/* TCL S700 */
1894static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1896 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1899 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1902 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1903 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001904 { } /* end */
1905};
1906
Kailang Yangccc656c2006-10-17 12:32:26 +02001907/* Uniwill */
1908static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1912 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001913 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1914 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1915 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1916 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1917 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1918 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1919 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1920 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1923 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1925 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1926 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1927 {
1928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1929 .name = "Channel Mode",
1930 .info = alc_ch_mode_info,
1931 .get = alc_ch_mode_get,
1932 .put = alc_ch_mode_put,
1933 },
1934 { } /* end */
1935};
1936
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001937static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1938 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1939 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1940 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1941 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1945 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1947 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1948 { } /* end */
1949};
1950
Kailang Yangccc656c2006-10-17 12:32:26 +02001951static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001952 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1953 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1954 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1955 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1958 { } /* end */
1959};
1960
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001962 * virtual master controls
1963 */
1964
1965/*
1966 * slave controls for virtual master
1967 */
1968static const char *alc_slave_vols[] = {
1969 "Front Playback Volume",
1970 "Surround Playback Volume",
1971 "Center Playback Volume",
1972 "LFE Playback Volume",
1973 "Side Playback Volume",
1974 "Headphone Playback Volume",
1975 "Speaker Playback Volume",
1976 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001977 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001978 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001979 NULL,
1980};
1981
1982static const char *alc_slave_sws[] = {
1983 "Front Playback Switch",
1984 "Surround Playback Switch",
1985 "Center Playback Switch",
1986 "LFE Playback Switch",
1987 "Side Playback Switch",
1988 "Headphone Playback Switch",
1989 "Speaker Playback Switch",
1990 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001991 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001992 NULL,
1993};
1994
1995/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001996 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001998
1999static void alc_free_kctls(struct hda_codec *codec);
2000
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001static int alc_build_controls(struct hda_codec *codec)
2002{
2003 struct alc_spec *spec = codec->spec;
2004 int err;
2005 int i;
2006
2007 for (i = 0; i < spec->num_mixers; i++) {
2008 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2009 if (err < 0)
2010 return err;
2011 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002012 if (spec->cap_mixer) {
2013 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2014 if (err < 0)
2015 return err;
2016 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002018 err = snd_hda_create_spdif_out_ctls(codec,
2019 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 if (err < 0)
2021 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01002022 err = snd_hda_create_spdif_share_sw(codec,
2023 &spec->multiout);
2024 if (err < 0)
2025 return err;
2026 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 }
2028 if (spec->dig_in_nid) {
2029 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2030 if (err < 0)
2031 return err;
2032 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002033
2034 /* if we have no master control, let's create it */
2035 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002036 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002037 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002038 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002039 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002040 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002041 if (err < 0)
2042 return err;
2043 }
2044 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2045 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2046 NULL, alc_slave_sws);
2047 if (err < 0)
2048 return err;
2049 }
2050
Takashi Iwai603c4012008-07-30 15:01:44 +02002051 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 return 0;
2053}
2054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056/*
2057 * initialize the codec volumes, etc
2058 */
2059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060/*
2061 * generic initialization of ADC, input mixers and output mixers
2062 */
2063static struct hda_verb alc880_volume_init_verbs[] = {
2064 /*
2065 * Unmute ADC0-2 and set the default input to mic-in
2066 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002067 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002069 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2075 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002076 * Note: PASD motherboards uses the Line In 2 as the input for front
2077 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 /*
2089 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002091 /* set vol=0 to output mixers */
2092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2093 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2096 /* set up input amps for analog loopback */
2097 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2101 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106
2107 { }
2108};
2109
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002110/*
2111 * 3-stack pin configuration:
2112 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2113 */
2114static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2115 /*
2116 * preset connection lists of input pins
2117 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2118 */
2119 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2120 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2121 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2122
2123 /*
2124 * Set pin mode and muting
2125 */
2126 /* set front pin widgets 0x14 for output */
2127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2128 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2131 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2132 /* Mic2 (as headphone out) for HP output */
2133 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2135 /* Line In pin widget for input */
2136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2138 /* Line2 (as front mic) pin widget for input and vref at 80% */
2139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2141 /* CD pin widget for input */
2142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2143
2144 { }
2145};
2146
2147/*
2148 * 5-stack pin configuration:
2149 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2150 * line-in/side = 0x1a, f-mic = 0x1b
2151 */
2152static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2153 /*
2154 * preset connection lists of input pins
2155 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2156 */
2157 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2158 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2159
2160 /*
2161 * Set pin mode and muting
2162 */
2163 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2167 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 /* unmute pins for output (no gain on this amp) */
2169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2171 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2172 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2173
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2177 /* Mic2 (as headphone out) for HP output */
2178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002180 /* Line In pin widget for input */
2181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2183 /* Line2 (as front mic) pin widget for input and vref at 80% */
2184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2186 /* CD pin widget for input */
2187 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188
2189 { }
2190};
2191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192/*
2193 * W810 pin configuration:
2194 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2195 */
2196static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 /* hphone/speaker input selector: front DAC */
2198 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2199
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2205 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2206
2207 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002208 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 { }
2211};
2212
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213/*
2214 * Z71V pin configuration:
2215 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2216 */
2217static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002222
Takashi Iwai16ded522005-06-10 19:58:24 +02002223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002224 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002227
2228 { }
2229};
2230
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231/*
2232 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002233 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2234 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 */
2236static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2237 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2238
Takashi Iwai16ded522005-06-10 19:58:24 +02002239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002243 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002245 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2247
Takashi Iwai16ded522005-06-10 19:58:24 +02002248 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258 { }
2259};
Takashi Iwai16ded522005-06-10 19:58:24 +02002260
Kailang Yangccc656c2006-10-17 12:32:26 +02002261/*
2262 * Uniwill pin configuration:
2263 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2264 * line = 0x1a
2265 */
2266static struct hda_verb alc880_uniwill_init_verbs[] = {
2267 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2268
2269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2276 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2283
2284 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2286 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2290 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2291 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2292 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2293
2294 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2295 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2296
2297 { }
2298};
2299
2300/*
2301* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002302* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002303 */
2304static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2305 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2306
2307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2319
2320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2321 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2326
2327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2328 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2329
2330 { }
2331};
2332
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002333static struct hda_verb alc880_beep_init_verbs[] = {
2334 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2335 { }
2336};
2337
Kailang Yangccc656c2006-10-17 12:32:26 +02002338/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002339static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002340{
2341 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002342 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002343
2344 present = snd_hda_codec_read(codec, 0x14, 0,
2345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002346 bits = present ? HDA_AMP_MUTE : 0;
2347 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2348 HDA_AMP_MUTE, bits);
2349 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2350 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002351}
2352
2353/* auto-toggle front mic */
2354static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2355{
2356 unsigned int present;
2357 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002358
2359 present = snd_hda_codec_read(codec, 0x18, 0,
2360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002361 bits = present ? HDA_AMP_MUTE : 0;
2362 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002363}
2364
2365static void alc880_uniwill_automute(struct hda_codec *codec)
2366{
2367 alc880_uniwill_hp_automute(codec);
2368 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002369}
2370
2371static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2372 unsigned int res)
2373{
2374 /* Looks like the unsol event is incompatible with the standard
2375 * definition. 4bit tag is placed at 28 bit!
2376 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002377 switch (res >> 28) {
2378 case ALC880_HP_EVENT:
2379 alc880_uniwill_hp_automute(codec);
2380 break;
2381 case ALC880_MIC_EVENT:
2382 alc880_uniwill_mic_automute(codec);
2383 break;
2384 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002385}
2386
2387static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2388{
2389 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002390 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002391
2392 present = snd_hda_codec_read(codec, 0x14, 0,
2393 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002394 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002395 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002396}
2397
2398static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2399{
2400 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002401
Kailang Yangccc656c2006-10-17 12:32:26 +02002402 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002403 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2404 present &= HDA_AMP_VOLMASK;
2405 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2406 HDA_AMP_VOLMASK, present);
2407 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2408 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002409}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002410
Kailang Yangccc656c2006-10-17 12:32:26 +02002411static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2412 unsigned int res)
2413{
2414 /* Looks like the unsol event is incompatible with the standard
2415 * definition. 4bit tag is placed at 28 bit!
2416 */
2417 if ((res >> 28) == ALC880_HP_EVENT)
2418 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002419 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002420 alc880_uniwill_p53_dcvol_automute(codec);
2421}
2422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002423/*
2424 * F1734 pin configuration:
2425 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2426 */
2427static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002428 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002429 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2430 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2431 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2432 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2433
2434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2438
2439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002441 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2443 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2444 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2445 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2446 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2447 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002448
Takashi Iwai937b4162008-02-11 14:52:36 +01002449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2450 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2451
Takashi Iwai16ded522005-06-10 19:58:24 +02002452 { }
2453};
2454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002455/*
2456 * ASUS pin configuration:
2457 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2458 */
2459static struct hda_verb alc880_pin_asus_init_verbs[] = {
2460 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2461 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2462 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2464
2465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473
2474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484 { }
2485};
2486
2487/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002488#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2489#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002490
Kailang Yangdf694da2005-12-05 19:42:22 +01002491/* Clevo m520g init */
2492static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2493 /* headphone output */
2494 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2495 /* line-out */
2496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498 /* Line-in */
2499 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2500 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 /* CD */
2502 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2503 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 /* Mic1 (rear panel) */
2505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2507 /* Mic2 (front panel) */
2508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2510 /* headphone */
2511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2513 /* change to EAPD mode */
2514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2515 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2516
2517 { }
2518};
2519
2520static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002521 /* change to EAPD mode */
2522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2524
Kailang Yangdf694da2005-12-05 19:42:22 +01002525 /* Headphone output */
2526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2527 /* Front output*/
2528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2529 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2530
2531 /* Line In pin widget for input */
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 /* CD pin widget for input */
2534 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2535 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2537
2538 /* change to EAPD mode */
2539 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2540 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2541
2542 { }
2543};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544
2545/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002546 * LG m1 express dual
2547 *
2548 * Pin assignment:
2549 * Rear Line-In/Out (blue): 0x14
2550 * Build-in Mic-In: 0x15
2551 * Speaker-out: 0x17
2552 * HP-Out (green): 0x1b
2553 * Mic-In/Out (red): 0x19
2554 * SPDIF-Out: 0x1e
2555 */
2556
2557/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2558static hda_nid_t alc880_lg_dac_nids[3] = {
2559 0x05, 0x02, 0x03
2560};
2561
2562/* seems analog CD is not working */
2563static struct hda_input_mux alc880_lg_capture_source = {
2564 .num_items = 3,
2565 .items = {
2566 { "Mic", 0x1 },
2567 { "Line", 0x5 },
2568 { "Internal Mic", 0x6 },
2569 },
2570};
2571
2572/* 2,4,6 channel modes */
2573static struct hda_verb alc880_lg_ch2_init[] = {
2574 /* set line-in and mic-in to input */
2575 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2576 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2577 { }
2578};
2579
2580static struct hda_verb alc880_lg_ch4_init[] = {
2581 /* set line-in to out and mic-in to input */
2582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2583 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2584 { }
2585};
2586
2587static struct hda_verb alc880_lg_ch6_init[] = {
2588 /* set line-in and mic-in to output */
2589 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2590 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2591 { }
2592};
2593
2594static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2595 { 2, alc880_lg_ch2_init },
2596 { 4, alc880_lg_ch4_init },
2597 { 6, alc880_lg_ch6_init },
2598};
2599
2600static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2602 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2604 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2607 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2608 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2611 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2612 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2613 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2614 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2615 {
2616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2617 .name = "Channel Mode",
2618 .info = alc_ch_mode_info,
2619 .get = alc_ch_mode_get,
2620 .put = alc_ch_mode_put,
2621 },
2622 { } /* end */
2623};
2624
2625static struct hda_verb alc880_lg_init_verbs[] = {
2626 /* set capture source to mic-in */
2627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2628 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2630 /* mute all amp mixer inputs */
2631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002634 /* line-in to input */
2635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2637 /* built-in mic */
2638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 /* speaker-out */
2641 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2642 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2643 /* mic-in to input */
2644 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2647 /* HP-out */
2648 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2651 /* jack sense */
2652 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2653 { }
2654};
2655
2656/* toggle speaker-output according to the hp-jack state */
2657static void alc880_lg_automute(struct hda_codec *codec)
2658{
2659 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002660 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002661
2662 present = snd_hda_codec_read(codec, 0x1b, 0,
2663 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002664 bits = present ? HDA_AMP_MUTE : 0;
2665 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2666 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002667}
2668
2669static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2670{
2671 /* Looks like the unsol event is incompatible with the standard
2672 * definition. 4bit tag is placed at 28 bit!
2673 */
2674 if ((res >> 28) == 0x01)
2675 alc880_lg_automute(codec);
2676}
2677
2678/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002679 * LG LW20
2680 *
2681 * Pin assignment:
2682 * Speaker-out: 0x14
2683 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002684 * Built-in Mic-In: 0x19
2685 * Line-In: 0x1b
2686 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002687 * SPDIF-Out: 0x1e
2688 */
2689
Takashi Iwaid6815182006-03-23 16:06:23 +01002690static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002691 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002692 .items = {
2693 { "Mic", 0x0 },
2694 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002695 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002696 },
2697};
2698
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002699#define alc880_lg_lw_modes alc880_threestack_modes
2700
Takashi Iwaid6815182006-03-23 16:06:23 +01002701static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2703 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2704 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2705 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2706 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2707 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2708 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2709 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2710 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2711 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2715 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002716 {
2717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2718 .name = "Channel Mode",
2719 .info = alc_ch_mode_info,
2720 .get = alc_ch_mode_get,
2721 .put = alc_ch_mode_put,
2722 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002723 { } /* end */
2724};
2725
2726static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2728 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2729 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2730
Takashi Iwaid6815182006-03-23 16:06:23 +01002731 /* set capture source to mic-in */
2732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002736 /* speaker-out */
2737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002740 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2741 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2742 /* mic-in to input */
2743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2745 /* built-in mic */
2746 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2748 /* jack sense */
2749 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2750 { }
2751};
2752
2753/* toggle speaker-output according to the hp-jack state */
2754static void alc880_lg_lw_automute(struct hda_codec *codec)
2755{
2756 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002757 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002758
2759 present = snd_hda_codec_read(codec, 0x1b, 0,
2760 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002761 bits = present ? HDA_AMP_MUTE : 0;
2762 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2763 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002764}
2765
2766static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2767{
2768 /* Looks like the unsol event is incompatible with the standard
2769 * definition. 4bit tag is placed at 28 bit!
2770 */
2771 if ((res >> 28) == 0x01)
2772 alc880_lg_lw_automute(codec);
2773}
2774
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002775static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2776 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2777 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2780 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2781 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2782 { } /* end */
2783};
2784
2785static struct hda_input_mux alc880_medion_rim_capture_source = {
2786 .num_items = 2,
2787 .items = {
2788 { "Mic", 0x0 },
2789 { "Internal Mic", 0x1 },
2790 },
2791};
2792
2793static struct hda_verb alc880_medion_rim_init_verbs[] = {
2794 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2795
2796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2798
2799 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2800 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2802 /* Mic2 (as headphone out) for HP output */
2803 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2805 /* Internal Speaker */
2806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2808
2809 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2810 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2811
2812 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2813 { }
2814};
2815
2816/* toggle speaker-output according to the hp-jack state */
2817static void alc880_medion_rim_automute(struct hda_codec *codec)
2818{
2819 unsigned int present;
2820 unsigned char bits;
2821
2822 present = snd_hda_codec_read(codec, 0x14, 0,
2823 AC_VERB_GET_PIN_SENSE, 0)
2824 & AC_PINSENSE_PRESENCE;
2825 bits = present ? HDA_AMP_MUTE : 0;
2826 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2827 HDA_AMP_MUTE, bits);
2828 if (present)
2829 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2830 else
2831 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2832}
2833
2834static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2835 unsigned int res)
2836{
2837 /* Looks like the unsol event is incompatible with the standard
2838 * definition. 4bit tag is placed at 28 bit!
2839 */
2840 if ((res >> 28) == ALC880_HP_EVENT)
2841 alc880_medion_rim_automute(codec);
2842}
2843
Takashi Iwaicb53c622007-08-10 17:21:45 +02002844#ifdef CONFIG_SND_HDA_POWER_SAVE
2845static struct hda_amp_list alc880_loopbacks[] = {
2846 { 0x0b, HDA_INPUT, 0 },
2847 { 0x0b, HDA_INPUT, 1 },
2848 { 0x0b, HDA_INPUT, 2 },
2849 { 0x0b, HDA_INPUT, 3 },
2850 { 0x0b, HDA_INPUT, 4 },
2851 { } /* end */
2852};
2853
2854static struct hda_amp_list alc880_lg_loopbacks[] = {
2855 { 0x0b, HDA_INPUT, 1 },
2856 { 0x0b, HDA_INPUT, 6 },
2857 { 0x0b, HDA_INPUT, 7 },
2858 { } /* end */
2859};
2860#endif
2861
Takashi Iwaid6815182006-03-23 16:06:23 +01002862/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002863 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002865
Linus Torvalds1da177e2005-04-16 15:20:36 -07002866static int alc_init(struct hda_codec *codec)
2867{
2868 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002869 unsigned int i;
2870
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002871 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002872 if (codec->vendor_id == 0x10ec0888)
2873 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002874
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002875 for (i = 0; i < spec->num_init_verbs; i++)
2876 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002877
2878 if (spec->init_hook)
2879 spec->init_hook(codec);
2880
Linus Torvalds1da177e2005-04-16 15:20:36 -07002881 return 0;
2882}
2883
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002884static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2885{
2886 struct alc_spec *spec = codec->spec;
2887
2888 if (spec->unsol_event)
2889 spec->unsol_event(codec, res);
2890}
2891
Takashi Iwaicb53c622007-08-10 17:21:45 +02002892#ifdef CONFIG_SND_HDA_POWER_SAVE
2893static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2894{
2895 struct alc_spec *spec = codec->spec;
2896 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2897}
2898#endif
2899
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900/*
2901 * Analog playback callbacks
2902 */
2903static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2904 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002905 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002906{
2907 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002908 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2909 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910}
2911
2912static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2913 struct hda_codec *codec,
2914 unsigned int stream_tag,
2915 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002916 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917{
2918 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002919 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2920 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921}
2922
2923static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2924 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002925 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926{
2927 struct alc_spec *spec = codec->spec;
2928 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2929}
2930
2931/*
2932 * Digital out
2933 */
2934static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2935 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002936 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937{
2938 struct alc_spec *spec = codec->spec;
2939 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2940}
2941
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002942static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2943 struct hda_codec *codec,
2944 unsigned int stream_tag,
2945 unsigned int format,
2946 struct snd_pcm_substream *substream)
2947{
2948 struct alc_spec *spec = codec->spec;
2949 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2950 stream_tag, format, substream);
2951}
2952
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2954 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002955 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002956{
2957 struct alc_spec *spec = codec->spec;
2958 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2959}
2960
2961/*
2962 * Analog capture
2963 */
Takashi Iwai63300792008-01-24 15:31:36 +01002964static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965 struct hda_codec *codec,
2966 unsigned int stream_tag,
2967 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002968 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002969{
2970 struct alc_spec *spec = codec->spec;
2971
Takashi Iwai63300792008-01-24 15:31:36 +01002972 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973 stream_tag, 0, format);
2974 return 0;
2975}
2976
Takashi Iwai63300792008-01-24 15:31:36 +01002977static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002979 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980{
2981 struct alc_spec *spec = codec->spec;
2982
Takashi Iwai888afa12008-03-18 09:57:50 +01002983 snd_hda_codec_cleanup_stream(codec,
2984 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985 return 0;
2986}
2987
2988
2989/*
2990 */
2991static struct hda_pcm_stream alc880_pcm_analog_playback = {
2992 .substreams = 1,
2993 .channels_min = 2,
2994 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002995 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002996 .ops = {
2997 .open = alc880_playback_pcm_open,
2998 .prepare = alc880_playback_pcm_prepare,
2999 .cleanup = alc880_playback_pcm_cleanup
3000 },
3001};
3002
3003static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003004 .substreams = 1,
3005 .channels_min = 2,
3006 .channels_max = 2,
3007 /* NID is set in alc_build_pcms */
3008};
3009
3010static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3011 .substreams = 1,
3012 .channels_min = 2,
3013 .channels_max = 2,
3014 /* NID is set in alc_build_pcms */
3015};
3016
3017static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3018 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019 .channels_min = 2,
3020 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003022 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003023 .prepare = alc880_alt_capture_pcm_prepare,
3024 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 },
3026};
3027
3028static struct hda_pcm_stream alc880_pcm_digital_playback = {
3029 .substreams = 1,
3030 .channels_min = 2,
3031 .channels_max = 2,
3032 /* NID is set in alc_build_pcms */
3033 .ops = {
3034 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003035 .close = alc880_dig_playback_pcm_close,
3036 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07003037 },
3038};
3039
3040static struct hda_pcm_stream alc880_pcm_digital_capture = {
3041 .substreams = 1,
3042 .channels_min = 2,
3043 .channels_max = 2,
3044 /* NID is set in alc_build_pcms */
3045};
3046
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003047/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003048static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003049 .substreams = 0,
3050 .channels_min = 0,
3051 .channels_max = 0,
3052};
3053
Linus Torvalds1da177e2005-04-16 15:20:36 -07003054static int alc_build_pcms(struct hda_codec *codec)
3055{
3056 struct alc_spec *spec = codec->spec;
3057 struct hda_pcm *info = spec->pcm_rec;
3058 int i;
3059
3060 codec->num_pcms = 1;
3061 codec->pcm_info = info;
3062
3063 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003064 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003065 if (snd_BUG_ON(!spec->multiout.dac_nids))
3066 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003067 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3068 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3069 }
3070 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003071 if (snd_BUG_ON(!spec->adc_nids))
3072 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003073 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3074 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3075 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003076
Takashi Iwai4a471b72005-12-07 13:56:29 +01003077 if (spec->channel_mode) {
3078 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3079 for (i = 0; i < spec->num_channel_mode; i++) {
3080 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3081 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3082 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003083 }
3084 }
3085
Takashi Iwaie08a0072006-09-07 17:52:14 +02003086 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003087 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003088 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003089 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003091 if (spec->dig_out_type)
3092 info->pcm_type = spec->dig_out_type;
3093 else
3094 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003095 if (spec->multiout.dig_out_nid &&
3096 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003097 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3098 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3099 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003100 if (spec->dig_in_nid &&
3101 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003102 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3103 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3104 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003105 /* FIXME: do we need this for all Realtek codec models? */
3106 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 }
3108
Takashi Iwaie08a0072006-09-07 17:52:14 +02003109 /* If the use of more than one ADC is requested for the current
3110 * model, configure a second analog capture-only PCM.
3111 */
3112 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003113 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3114 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003115 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003116 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003117 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003118 if (spec->alt_dac_nid) {
3119 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3120 *spec->stream_analog_alt_playback;
3121 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3122 spec->alt_dac_nid;
3123 } else {
3124 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3125 alc_pcm_null_stream;
3126 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3127 }
3128 if (spec->num_adc_nids > 1) {
3129 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3130 *spec->stream_analog_alt_capture;
3131 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3132 spec->adc_nids[1];
3133 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3134 spec->num_adc_nids - 1;
3135 } else {
3136 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3137 alc_pcm_null_stream;
3138 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003139 }
3140 }
3141
Linus Torvalds1da177e2005-04-16 15:20:36 -07003142 return 0;
3143}
3144
Takashi Iwai603c4012008-07-30 15:01:44 +02003145static void alc_free_kctls(struct hda_codec *codec)
3146{
3147 struct alc_spec *spec = codec->spec;
3148
3149 if (spec->kctls.list) {
3150 struct snd_kcontrol_new *kctl = spec->kctls.list;
3151 int i;
3152 for (i = 0; i < spec->kctls.used; i++)
3153 kfree(kctl[i].name);
3154 }
3155 snd_array_free(&spec->kctls);
3156}
3157
Linus Torvalds1da177e2005-04-16 15:20:36 -07003158static void alc_free(struct hda_codec *codec)
3159{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003160 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003162 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163 return;
3164
Takashi Iwai603c4012008-07-30 15:01:44 +02003165 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003166 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02003167 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003168}
3169
Takashi Iwaie044c392008-10-27 16:56:24 +01003170#ifdef SND_HDA_NEEDS_RESUME
3171static void store_pin_configs(struct hda_codec *codec)
3172{
3173 struct alc_spec *spec = codec->spec;
3174 hda_nid_t nid, end_nid;
3175
3176 end_nid = codec->start_nid + codec->num_nodes;
3177 for (nid = codec->start_nid; nid < end_nid; nid++) {
3178 unsigned int wid_caps = get_wcaps(codec, nid);
3179 unsigned int wid_type =
3180 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3181 if (wid_type != AC_WID_PIN)
3182 continue;
3183 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3184 break;
3185 spec->pin_nids[spec->num_pins] = nid;
3186 spec->pin_cfgs[spec->num_pins] =
3187 snd_hda_codec_read(codec, nid, 0,
3188 AC_VERB_GET_CONFIG_DEFAULT, 0);
3189 spec->num_pins++;
3190 }
3191}
3192
3193static void resume_pin_configs(struct hda_codec *codec)
3194{
3195 struct alc_spec *spec = codec->spec;
3196 int i;
3197
3198 for (i = 0; i < spec->num_pins; i++) {
3199 hda_nid_t pin_nid = spec->pin_nids[i];
3200 unsigned int pin_config = spec->pin_cfgs[i];
3201 snd_hda_codec_write(codec, pin_nid, 0,
3202 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3203 pin_config & 0x000000ff);
3204 snd_hda_codec_write(codec, pin_nid, 0,
3205 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3206 (pin_config & 0x0000ff00) >> 8);
3207 snd_hda_codec_write(codec, pin_nid, 0,
3208 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3209 (pin_config & 0x00ff0000) >> 16);
3210 snd_hda_codec_write(codec, pin_nid, 0,
3211 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3212 pin_config >> 24);
3213 }
3214}
3215
3216static int alc_resume(struct hda_codec *codec)
3217{
3218 resume_pin_configs(codec);
3219 codec->patch_ops.init(codec);
3220 snd_hda_codec_resume_amp(codec);
3221 snd_hda_codec_resume_cache(codec);
3222 return 0;
3223}
3224#else
3225#define store_pin_configs(codec)
3226#endif
3227
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228/*
3229 */
3230static struct hda_codec_ops alc_patch_ops = {
3231 .build_controls = alc_build_controls,
3232 .build_pcms = alc_build_pcms,
3233 .init = alc_init,
3234 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003235 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003236#ifdef SND_HDA_NEEDS_RESUME
3237 .resume = alc_resume,
3238#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003239#ifdef CONFIG_SND_HDA_POWER_SAVE
3240 .check_power_status = alc_check_power_status,
3241#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242};
3243
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003244
3245/*
3246 * Test configuration for debugging
3247 *
3248 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3249 * enum controls.
3250 */
3251#ifdef CONFIG_SND_DEBUG
3252static hda_nid_t alc880_test_dac_nids[4] = {
3253 0x02, 0x03, 0x04, 0x05
3254};
3255
3256static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003257 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003258 .items = {
3259 { "In-1", 0x0 },
3260 { "In-2", 0x1 },
3261 { "In-3", 0x2 },
3262 { "In-4", 0x3 },
3263 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003264 { "Front", 0x5 },
3265 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003266 },
3267};
3268
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003269static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003270 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003271 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003272 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003273 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003274};
3275
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003276static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3277 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003278{
3279 static char *texts[] = {
3280 "N/A", "Line Out", "HP Out",
3281 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3282 };
3283 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3284 uinfo->count = 1;
3285 uinfo->value.enumerated.items = 8;
3286 if (uinfo->value.enumerated.item >= 8)
3287 uinfo->value.enumerated.item = 7;
3288 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3289 return 0;
3290}
3291
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003292static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3293 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003294{
3295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3296 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3297 unsigned int pin_ctl, item = 0;
3298
3299 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3300 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3301 if (pin_ctl & AC_PINCTL_OUT_EN) {
3302 if (pin_ctl & AC_PINCTL_HP_EN)
3303 item = 2;
3304 else
3305 item = 1;
3306 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3307 switch (pin_ctl & AC_PINCTL_VREFEN) {
3308 case AC_PINCTL_VREF_HIZ: item = 3; break;
3309 case AC_PINCTL_VREF_50: item = 4; break;
3310 case AC_PINCTL_VREF_GRD: item = 5; break;
3311 case AC_PINCTL_VREF_80: item = 6; break;
3312 case AC_PINCTL_VREF_100: item = 7; break;
3313 }
3314 }
3315 ucontrol->value.enumerated.item[0] = item;
3316 return 0;
3317}
3318
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003319static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3320 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003321{
3322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3323 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3324 static unsigned int ctls[] = {
3325 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3331 };
3332 unsigned int old_ctl, new_ctl;
3333
3334 old_ctl = snd_hda_codec_read(codec, nid, 0,
3335 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3336 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3337 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003338 int val;
3339 snd_hda_codec_write_cache(codec, nid, 0,
3340 AC_VERB_SET_PIN_WIDGET_CONTROL,
3341 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003342 val = ucontrol->value.enumerated.item[0] >= 3 ?
3343 HDA_AMP_MUTE : 0;
3344 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3345 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003346 return 1;
3347 }
3348 return 0;
3349}
3350
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003351static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3352 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003353{
3354 static char *texts[] = {
3355 "Front", "Surround", "CLFE", "Side"
3356 };
3357 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3358 uinfo->count = 1;
3359 uinfo->value.enumerated.items = 4;
3360 if (uinfo->value.enumerated.item >= 4)
3361 uinfo->value.enumerated.item = 3;
3362 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3363 return 0;
3364}
3365
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003366static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3367 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003368{
3369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3370 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3371 unsigned int sel;
3372
3373 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3374 ucontrol->value.enumerated.item[0] = sel & 3;
3375 return 0;
3376}
3377
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003378static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3379 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003380{
3381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3382 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3383 unsigned int sel;
3384
3385 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3386 if (ucontrol->value.enumerated.item[0] != sel) {
3387 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003388 snd_hda_codec_write_cache(codec, nid, 0,
3389 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003390 return 1;
3391 }
3392 return 0;
3393}
3394
3395#define PIN_CTL_TEST(xname,nid) { \
3396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3397 .name = xname, \
3398 .info = alc_test_pin_ctl_info, \
3399 .get = alc_test_pin_ctl_get, \
3400 .put = alc_test_pin_ctl_put, \
3401 .private_value = nid \
3402 }
3403
3404#define PIN_SRC_TEST(xname,nid) { \
3405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3406 .name = xname, \
3407 .info = alc_test_pin_src_info, \
3408 .get = alc_test_pin_src_get, \
3409 .put = alc_test_pin_src_put, \
3410 .private_value = nid \
3411 }
3412
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003413static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3415 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3416 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3417 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3419 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3420 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3421 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003422 PIN_CTL_TEST("Front Pin Mode", 0x14),
3423 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3424 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3425 PIN_CTL_TEST("Side Pin Mode", 0x17),
3426 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3427 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3428 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3429 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3430 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3431 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3432 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3433 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3434 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3435 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3436 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3437 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3438 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3439 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3440 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3441 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003444 {
3445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3446 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003447 .info = alc_ch_mode_info,
3448 .get = alc_ch_mode_get,
3449 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003450 },
3451 { } /* end */
3452};
3453
3454static struct hda_verb alc880_test_init_verbs[] = {
3455 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3462 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3463 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003464 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3468 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003469 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3473 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003474 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003479 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3481 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003482 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3484 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003485 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003486 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003490 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003492 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003494 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003496 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003497 /* Analog input/passthru */
3498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003503 { }
3504};
3505#endif
3506
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507/*
3508 */
3509
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003510static const char *alc880_models[ALC880_MODEL_LAST] = {
3511 [ALC880_3ST] = "3stack",
3512 [ALC880_TCL_S700] = "tcl",
3513 [ALC880_3ST_DIG] = "3stack-digout",
3514 [ALC880_CLEVO] = "clevo",
3515 [ALC880_5ST] = "5stack",
3516 [ALC880_5ST_DIG] = "5stack-digout",
3517 [ALC880_W810] = "w810",
3518 [ALC880_Z71V] = "z71v",
3519 [ALC880_6ST] = "6stack",
3520 [ALC880_6ST_DIG] = "6stack-digout",
3521 [ALC880_ASUS] = "asus",
3522 [ALC880_ASUS_W1V] = "asus-w1v",
3523 [ALC880_ASUS_DIG] = "asus-dig",
3524 [ALC880_ASUS_DIG2] = "asus-dig2",
3525 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003526 [ALC880_UNIWILL_P53] = "uniwill-p53",
3527 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003528 [ALC880_F1734] = "F1734",
3529 [ALC880_LG] = "lg",
3530 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003531 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003532#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003533 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003534#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003535 [ALC880_AUTO] = "auto",
3536};
3537
3538static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003539 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003540 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3541 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3542 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3543 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3544 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3545 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3546 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3547 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003548 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3549 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003550 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3551 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3552 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3553 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3554 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3555 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3556 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3557 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3558 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3559 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003560 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003561 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3562 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3563 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003564 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003565 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003566 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3567 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003568 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3569 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003570 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3571 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3572 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3573 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003574 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3575 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003576 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003577 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003578 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003579 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003580 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3581 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003582 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003583 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003584 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003585 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003586 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003587 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003588 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003589 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003590 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003591 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3592 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003593 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003594 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3595 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3596 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3597 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003598 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3599 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003600 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003602 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3603 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003604 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3605 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3606 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003607 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3608 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3609 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610 {}
3611};
3612
Takashi Iwai16ded522005-06-10 19:58:24 +02003613/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003614 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003615 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003616static struct alc_config_preset alc880_presets[] = {
3617 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003618 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003619 .init_verbs = { alc880_volume_init_verbs,
3620 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003621 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003622 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003623 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3624 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003625 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003626 .input_mux = &alc880_capture_source,
3627 },
3628 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003630 .init_verbs = { alc880_volume_init_verbs,
3631 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003632 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003633 .dac_nids = alc880_dac_nids,
3634 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003635 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3636 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003637 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003638 .input_mux = &alc880_capture_source,
3639 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003640 [ALC880_TCL_S700] = {
3641 .mixers = { alc880_tcl_s700_mixer },
3642 .init_verbs = { alc880_volume_init_verbs,
3643 alc880_pin_tcl_S700_init_verbs,
3644 alc880_gpio2_init_verbs },
3645 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3646 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003647 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3648 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003649 .hp_nid = 0x03,
3650 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3651 .channel_mode = alc880_2_jack_modes,
3652 .input_mux = &alc880_capture_source,
3653 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003654 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003655 .mixers = { alc880_three_stack_mixer,
3656 alc880_five_stack_mixer},
3657 .init_verbs = { alc880_volume_init_verbs,
3658 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003659 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3660 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003661 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3662 .channel_mode = alc880_fivestack_modes,
3663 .input_mux = &alc880_capture_source,
3664 },
3665 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003666 .mixers = { alc880_three_stack_mixer,
3667 alc880_five_stack_mixer },
3668 .init_verbs = { alc880_volume_init_verbs,
3669 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3671 .dac_nids = alc880_dac_nids,
3672 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003673 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3674 .channel_mode = alc880_fivestack_modes,
3675 .input_mux = &alc880_capture_source,
3676 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003677 [ALC880_6ST] = {
3678 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003679 .init_verbs = { alc880_volume_init_verbs,
3680 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003681 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3682 .dac_nids = alc880_6st_dac_nids,
3683 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3684 .channel_mode = alc880_sixstack_modes,
3685 .input_mux = &alc880_6stack_capture_source,
3686 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003689 .init_verbs = { alc880_volume_init_verbs,
3690 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003691 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3692 .dac_nids = alc880_6st_dac_nids,
3693 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003694 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3695 .channel_mode = alc880_sixstack_modes,
3696 .input_mux = &alc880_6stack_capture_source,
3697 },
3698 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003699 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003700 .init_verbs = { alc880_volume_init_verbs,
3701 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003702 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003703 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3704 .dac_nids = alc880_w810_dac_nids,
3705 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3707 .channel_mode = alc880_w810_modes,
3708 .input_mux = &alc880_capture_source,
3709 },
3710 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003712 .init_verbs = { alc880_volume_init_verbs,
3713 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003714 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3715 .dac_nids = alc880_z71v_dac_nids,
3716 .dig_out_nid = ALC880_DIGOUT_NID,
3717 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003718 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3719 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003720 .input_mux = &alc880_capture_source,
3721 },
3722 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003723 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003724 .init_verbs = { alc880_volume_init_verbs,
3725 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3727 .dac_nids = alc880_f1734_dac_nids,
3728 .hp_nid = 0x02,
3729 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3730 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003731 .input_mux = &alc880_f1734_capture_source,
3732 .unsol_event = alc880_uniwill_p53_unsol_event,
3733 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003734 },
3735 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003739 alc880_gpio1_init_verbs },
3740 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3741 .dac_nids = alc880_asus_dac_nids,
3742 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3743 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003744 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003745 .input_mux = &alc880_capture_source,
3746 },
3747 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003749 .init_verbs = { alc880_volume_init_verbs,
3750 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 alc880_gpio1_init_verbs },
3752 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3753 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003754 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003755 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3756 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003757 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003758 .input_mux = &alc880_capture_source,
3759 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003760 [ALC880_ASUS_DIG2] = {
3761 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 .init_verbs = { alc880_volume_init_verbs,
3763 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003764 alc880_gpio2_init_verbs }, /* use GPIO2 */
3765 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3766 .dac_nids = alc880_asus_dac_nids,
3767 .dig_out_nid = ALC880_DIGOUT_NID,
3768 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3769 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003770 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003771 .input_mux = &alc880_capture_source,
3772 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003773 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003774 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003775 .init_verbs = { alc880_volume_init_verbs,
3776 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 alc880_gpio1_init_verbs },
3778 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3779 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003780 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003781 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3782 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003783 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003784 .input_mux = &alc880_capture_source,
3785 },
3786 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003787 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003788 .init_verbs = { alc880_volume_init_verbs,
3789 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003790 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3791 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003792 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3794 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003795 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003796 .input_mux = &alc880_capture_source,
3797 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003798 [ALC880_UNIWILL] = {
3799 .mixers = { alc880_uniwill_mixer },
3800 .init_verbs = { alc880_volume_init_verbs,
3801 alc880_uniwill_init_verbs },
3802 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3803 .dac_nids = alc880_asus_dac_nids,
3804 .dig_out_nid = ALC880_DIGOUT_NID,
3805 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3806 .channel_mode = alc880_threestack_modes,
3807 .need_dac_fix = 1,
3808 .input_mux = &alc880_capture_source,
3809 .unsol_event = alc880_uniwill_unsol_event,
3810 .init_hook = alc880_uniwill_automute,
3811 },
3812 [ALC880_UNIWILL_P53] = {
3813 .mixers = { alc880_uniwill_p53_mixer },
3814 .init_verbs = { alc880_volume_init_verbs,
3815 alc880_uniwill_p53_init_verbs },
3816 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3817 .dac_nids = alc880_asus_dac_nids,
3818 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003819 .channel_mode = alc880_threestack_modes,
3820 .input_mux = &alc880_capture_source,
3821 .unsol_event = alc880_uniwill_p53_unsol_event,
3822 .init_hook = alc880_uniwill_p53_hp_automute,
3823 },
3824 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003825 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003826 alc880_pcbeep_mixer, },
3827 .init_verbs = { alc880_volume_init_verbs,
3828 alc880_uniwill_p53_init_verbs,
3829 alc880_beep_init_verbs },
3830 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3831 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003832 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003833 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3834 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003835 .input_mux = &alc880_capture_source,
3836 .unsol_event = alc880_uniwill_p53_unsol_event,
3837 .init_hook = alc880_uniwill_p53_hp_automute,
3838 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003839 [ALC880_CLEVO] = {
3840 .mixers = { alc880_three_stack_mixer },
3841 .init_verbs = { alc880_volume_init_verbs,
3842 alc880_pin_clevo_init_verbs },
3843 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3844 .dac_nids = alc880_dac_nids,
3845 .hp_nid = 0x03,
3846 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3847 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003848 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003849 .input_mux = &alc880_capture_source,
3850 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003851 [ALC880_LG] = {
3852 .mixers = { alc880_lg_mixer },
3853 .init_verbs = { alc880_volume_init_verbs,
3854 alc880_lg_init_verbs },
3855 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3856 .dac_nids = alc880_lg_dac_nids,
3857 .dig_out_nid = ALC880_DIGOUT_NID,
3858 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3859 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003860 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003861 .input_mux = &alc880_lg_capture_source,
3862 .unsol_event = alc880_lg_unsol_event,
3863 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003864#ifdef CONFIG_SND_HDA_POWER_SAVE
3865 .loopbacks = alc880_lg_loopbacks,
3866#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003867 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003868 [ALC880_LG_LW] = {
3869 .mixers = { alc880_lg_lw_mixer },
3870 .init_verbs = { alc880_volume_init_verbs,
3871 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003872 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003873 .dac_nids = alc880_dac_nids,
3874 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003875 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3876 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003877 .input_mux = &alc880_lg_lw_capture_source,
3878 .unsol_event = alc880_lg_lw_unsol_event,
3879 .init_hook = alc880_lg_lw_automute,
3880 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003881 [ALC880_MEDION_RIM] = {
3882 .mixers = { alc880_medion_rim_mixer },
3883 .init_verbs = { alc880_volume_init_verbs,
3884 alc880_medion_rim_init_verbs,
3885 alc_gpio2_init_verbs },
3886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3887 .dac_nids = alc880_dac_nids,
3888 .dig_out_nid = ALC880_DIGOUT_NID,
3889 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3890 .channel_mode = alc880_2_jack_modes,
3891 .input_mux = &alc880_medion_rim_capture_source,
3892 .unsol_event = alc880_medion_rim_unsol_event,
3893 .init_hook = alc880_medion_rim_automute,
3894 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003895#ifdef CONFIG_SND_DEBUG
3896 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003897 .mixers = { alc880_test_mixer },
3898 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003899 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3900 .dac_nids = alc880_test_dac_nids,
3901 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003902 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3903 .channel_mode = alc880_test_modes,
3904 .input_mux = &alc880_test_capture_source,
3905 },
3906#endif
3907};
3908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003909/*
3910 * Automatic parse of I/O pins from the BIOS configuration
3911 */
3912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003913enum {
3914 ALC_CTL_WIDGET_VOL,
3915 ALC_CTL_WIDGET_MUTE,
3916 ALC_CTL_BIND_MUTE,
3917};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003918static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003919 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3920 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003921 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003922};
3923
3924/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003925static int add_control(struct alc_spec *spec, int type, const char *name,
3926 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003927{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003928 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929
Takashi Iwai603c4012008-07-30 15:01:44 +02003930 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3931 knew = snd_array_new(&spec->kctls);
3932 if (!knew)
3933 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003934 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003935 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003936 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003937 return -ENOMEM;
3938 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003939 return 0;
3940}
3941
3942#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3943#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3944#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3945#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3946#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3947#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3948#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3949#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3950#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3951#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3952#define ALC880_PIN_CD_NID 0x1c
3953
3954/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003955static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3956 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003957{
3958 hda_nid_t nid;
3959 int assigned[4];
3960 int i, j;
3961
3962 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003963 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003964
3965 /* check the pins hardwired to audio widget */
3966 for (i = 0; i < cfg->line_outs; i++) {
3967 nid = cfg->line_out_pins[i];
3968 if (alc880_is_fixed_pin(nid)) {
3969 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003970 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003971 assigned[idx] = 1;
3972 }
3973 }
3974 /* left pins can be connect to any audio widget */
3975 for (i = 0; i < cfg->line_outs; i++) {
3976 nid = cfg->line_out_pins[i];
3977 if (alc880_is_fixed_pin(nid))
3978 continue;
3979 /* search for an empty channel */
3980 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003981 if (!assigned[j]) {
3982 spec->multiout.dac_nids[i] =
3983 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 assigned[j] = 1;
3985 break;
3986 }
3987 }
3988 }
3989 spec->multiout.num_dacs = cfg->line_outs;
3990 return 0;
3991}
3992
3993/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003994static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3995 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003996{
3997 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998 static const char *chname[4] = {
3999 "Front", "Surround", NULL /*CLFE*/, "Side"
4000 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001 hda_nid_t nid;
4002 int i, err;
4003
4004 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004005 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006 continue;
4007 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4008 if (i == 2) {
4009 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004010 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4011 "Center Playback Volume",
4012 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4013 HDA_OUTPUT));
4014 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004015 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4017 "LFE Playback Volume",
4018 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4019 HDA_OUTPUT));
4020 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004022 err = add_control(spec, ALC_CTL_BIND_MUTE,
4023 "Center Playback Switch",
4024 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4025 HDA_INPUT));
4026 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004027 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028 err = add_control(spec, ALC_CTL_BIND_MUTE,
4029 "LFE Playback Switch",
4030 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4031 HDA_INPUT));
4032 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004033 return err;
4034 } else {
4035 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004036 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4037 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4038 HDA_OUTPUT));
4039 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004040 return err;
4041 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004042 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4043 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4044 HDA_INPUT));
4045 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004046 return err;
4047 }
4048 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004049 return 0;
4050}
4051
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004052/* add playback controls for speaker and HP outputs */
4053static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4054 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055{
4056 hda_nid_t nid;
4057 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004058 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004059
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004060 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004061 return 0;
4062
4063 if (alc880_is_fixed_pin(pin)) {
4064 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004065 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004066 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004068 else
4069 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004070 /* control HP volume/switch on the output mixer amp */
4071 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004072 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004073 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4074 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4075 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004076 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004077 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004078 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4079 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4080 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 return err;
4082 } else if (alc880_is_multi_pin(pin)) {
4083 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004084 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004085 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004086 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4087 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4088 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004089 return err;
4090 }
4091 return 0;
4092}
4093
4094/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004095static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4096 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004097 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098{
4099 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004100 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004101
4102 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004103 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4104 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4105 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 return err;
4107 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4109 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4110 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004111 return err;
4112 return 0;
4113}
4114
4115/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004116static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4117 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01004120 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121
4122 for (i = 0; i < AUTO_PIN_LAST; i++) {
4123 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004124 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004125 err = new_analog_input(spec, cfg->input_pins[i],
4126 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004127 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 if (err < 0)
4129 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004130 imux->items[imux->num_items].label =
4131 auto_pin_cfg_labels[i];
4132 imux->items[imux->num_items].index =
4133 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134 imux->num_items++;
4135 }
4136 }
4137 return 0;
4138}
4139
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004140static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4141 unsigned int pin_type)
4142{
4143 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4144 pin_type);
4145 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004146 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4147 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004148}
4149
Kailang Yangdf694da2005-12-05 19:42:22 +01004150static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4151 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004152 int dac_idx)
4153{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004154 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 /* need the manual connection? */
4156 if (alc880_is_multi_pin(nid)) {
4157 struct alc_spec *spec = codec->spec;
4158 int idx = alc880_multi_pin_idx(nid);
4159 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4160 AC_VERB_SET_CONNECT_SEL,
4161 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4162 }
4163}
4164
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004165static int get_pin_type(int line_out_type)
4166{
4167 if (line_out_type == AUTO_PIN_HP_OUT)
4168 return PIN_HP;
4169 else
4170 return PIN_OUT;
4171}
4172
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173static void alc880_auto_init_multi_out(struct hda_codec *codec)
4174{
4175 struct alc_spec *spec = codec->spec;
4176 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004177
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004178 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 for (i = 0; i < spec->autocfg.line_outs; i++) {
4180 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004181 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4182 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 }
4184}
4185
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004186static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187{
4188 struct alc_spec *spec = codec->spec;
4189 hda_nid_t pin;
4190
Takashi Iwai82bc9552006-03-21 11:24:42 +01004191 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004192 if (pin) /* connect to front */
4193 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004194 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004195 if (pin) /* connect to front */
4196 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4197}
4198
4199static void alc880_auto_init_analog_input(struct hda_codec *codec)
4200{
4201 struct alc_spec *spec = codec->spec;
4202 int i;
4203
4204 for (i = 0; i < AUTO_PIN_LAST; i++) {
4205 hda_nid_t nid = spec->autocfg.input_pins[i];
4206 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004207 snd_hda_codec_write(codec, nid, 0,
4208 AC_VERB_SET_PIN_WIDGET_CONTROL,
4209 i <= AUTO_PIN_FRONT_MIC ?
4210 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004211 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004212 snd_hda_codec_write(codec, nid, 0,
4213 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214 AMP_OUT_MUTE);
4215 }
4216 }
4217}
4218
4219/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220/* return 1 if successful, 0 if the proper config is not found,
4221 * or a negative error code
4222 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223static int alc880_parse_auto_config(struct hda_codec *codec)
4224{
4225 struct alc_spec *spec = codec->spec;
4226 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004227 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004229 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4230 alc880_ignore);
4231 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004232 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004233 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004234 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004236 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4237 if (err < 0)
4238 return err;
4239 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4240 if (err < 0)
4241 return err;
4242 err = alc880_auto_create_extra_out(spec,
4243 spec->autocfg.speaker_pins[0],
4244 "Speaker");
4245 if (err < 0)
4246 return err;
4247 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4248 "Headphone");
4249 if (err < 0)
4250 return err;
4251 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4252 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004253 return err;
4254
4255 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4256
4257 if (spec->autocfg.dig_out_pin)
4258 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4259 if (spec->autocfg.dig_in_pin)
4260 spec->dig_in_nid = ALC880_DIGIN_NID;
4261
Takashi Iwai603c4012008-07-30 15:01:44 +02004262 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004263 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264
Takashi Iwaid88897e2008-10-31 15:01:37 +01004265 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004267 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 spec->input_mux = &spec->private_imux;
4269
Takashi Iwaie044c392008-10-27 16:56:24 +01004270 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 return 1;
4272}
4273
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004274/* additional initialization for auto-configuration model */
4275static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004277 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004279 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004281 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004282 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283}
4284
4285/*
4286 * OK, here we have finally the patch for ALC880
4287 */
4288
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004289static void set_capture_mixer(struct alc_spec *spec)
4290{
4291 static struct snd_kcontrol_new *caps[3] = {
4292 alc_capture_mixer1,
4293 alc_capture_mixer2,
4294 alc_capture_mixer3,
4295 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004296 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004297 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4298}
4299
Linus Torvalds1da177e2005-04-16 15:20:36 -07004300static int patch_alc880(struct hda_codec *codec)
4301{
4302 struct alc_spec *spec;
4303 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004304 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004305
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004306 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307 if (spec == NULL)
4308 return -ENOMEM;
4309
4310 codec->spec = spec;
4311
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004312 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4313 alc880_models,
4314 alc880_cfg_tbl);
4315 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004316 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4317 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004319 }
4320
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 if (board_config == ALC880_AUTO) {
4322 /* automatic parse from the BIOS config */
4323 err = alc880_parse_auto_config(codec);
4324 if (err < 0) {
4325 alc_free(codec);
4326 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004327 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004328 printk(KERN_INFO
4329 "hda_codec: Cannot set up configuration "
4330 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331 board_config = ALC880_3ST;
4332 }
4333 }
4334
Kailang Yangdf694da2005-12-05 19:42:22 +01004335 if (board_config != ALC880_AUTO)
4336 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004337
4338 spec->stream_name_analog = "ALC880 Analog";
4339 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4340 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004341 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004342
4343 spec->stream_name_digital = "ALC880 Digital";
4344 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4345 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4346
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004347 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004349 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004350 /* get type */
4351 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 if (wcap != AC_WID_AUD_IN) {
4353 spec->adc_nids = alc880_adc_nids_alt;
4354 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355 } else {
4356 spec->adc_nids = alc880_adc_nids;
4357 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004358 }
4359 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004360 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361
Takashi Iwai2134ea42008-01-10 16:53:55 +01004362 spec->vmaster_nid = 0x0c;
4363
Linus Torvalds1da177e2005-04-16 15:20:36 -07004364 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004366 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004367#ifdef CONFIG_SND_HDA_POWER_SAVE
4368 if (!spec->loopback.amplist)
4369 spec->loopback.amplist = alc880_loopbacks;
4370#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004371 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004372
4373 return 0;
4374}
4375
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004376
Linus Torvalds1da177e2005-04-16 15:20:36 -07004377/*
4378 * ALC260 support
4379 */
4380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381static hda_nid_t alc260_dac_nids[1] = {
4382 /* front */
4383 0x02,
4384};
4385
4386static hda_nid_t alc260_adc_nids[1] = {
4387 /* ADC0 */
4388 0x04,
4389};
4390
Kailang Yangdf694da2005-12-05 19:42:22 +01004391static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004392 /* ADC1 */
4393 0x05,
4394};
4395
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004396/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4397 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4398 */
4399static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004400 /* ADC0, ADC1 */
4401 0x04, 0x05
4402};
4403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404#define ALC260_DIGOUT_NID 0x03
4405#define ALC260_DIGIN_NID 0x06
4406
4407static struct hda_input_mux alc260_capture_source = {
4408 .num_items = 4,
4409 .items = {
4410 { "Mic", 0x0 },
4411 { "Front Mic", 0x1 },
4412 { "Line", 0x2 },
4413 { "CD", 0x4 },
4414 },
4415};
4416
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004417/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004418 * headphone jack and the internal CD lines since these are the only pins at
4419 * which audio can appear. For flexibility, also allow the option of
4420 * recording the mixer output on the second ADC (ADC0 doesn't have a
4421 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004422 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004423static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4424 {
4425 .num_items = 3,
4426 .items = {
4427 { "Mic/Line", 0x0 },
4428 { "CD", 0x4 },
4429 { "Headphone", 0x2 },
4430 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004431 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004432 {
4433 .num_items = 4,
4434 .items = {
4435 { "Mic/Line", 0x0 },
4436 { "CD", 0x4 },
4437 { "Headphone", 0x2 },
4438 { "Mixer", 0x5 },
4439 },
4440 },
4441
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004442};
4443
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004444/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4445 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004446 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004447static struct hda_input_mux alc260_acer_capture_sources[2] = {
4448 {
4449 .num_items = 4,
4450 .items = {
4451 { "Mic", 0x0 },
4452 { "Line", 0x2 },
4453 { "CD", 0x4 },
4454 { "Headphone", 0x5 },
4455 },
4456 },
4457 {
4458 .num_items = 5,
4459 .items = {
4460 { "Mic", 0x0 },
4461 { "Line", 0x2 },
4462 { "CD", 0x4 },
4463 { "Headphone", 0x6 },
4464 { "Mixer", 0x5 },
4465 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004466 },
4467};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004468/*
4469 * This is just place-holder, so there's something for alc_build_pcms to look
4470 * at when it calculates the maximum number of channels. ALC260 has no mixer
4471 * element which allows changing the channel mode, so the verb list is
4472 * never used.
4473 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004474static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004475 { 2, NULL },
4476};
4477
Kailang Yangdf694da2005-12-05 19:42:22 +01004478
4479/* Mixer combinations
4480 *
4481 * basic: base_output + input + pc_beep + capture
4482 * HP: base_output + input + capture_alt
4483 * HP_3013: hp_3013 + input + capture
4484 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004485 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004486 */
4487
4488static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004489 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004490 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4492 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4493 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4494 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4495 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004496};
Kailang Yangdf694da2005-12-05 19:42:22 +01004497
4498static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004499 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4500 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4501 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4502 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4504 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004507 { } /* end */
4508};
4509
Kailang Yangdf694da2005-12-05 19:42:22 +01004510static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4511 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4512 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4513 { } /* end */
4514};
4515
Takashi Iwaibec15c32008-01-28 18:16:30 +01004516/* update HP, line and mono out pins according to the master switch */
4517static void alc260_hp_master_update(struct hda_codec *codec,
4518 hda_nid_t hp, hda_nid_t line,
4519 hda_nid_t mono)
4520{
4521 struct alc_spec *spec = codec->spec;
4522 unsigned int val = spec->master_sw ? PIN_HP : 0;
4523 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004524 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004525 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004526 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004527 val);
4528 /* mono (speaker) depending on the HP jack sense */
4529 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004530 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004531 val);
4532}
4533
4534static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4535 struct snd_ctl_elem_value *ucontrol)
4536{
4537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4538 struct alc_spec *spec = codec->spec;
4539 *ucontrol->value.integer.value = spec->master_sw;
4540 return 0;
4541}
4542
4543static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4544 struct snd_ctl_elem_value *ucontrol)
4545{
4546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4547 struct alc_spec *spec = codec->spec;
4548 int val = !!*ucontrol->value.integer.value;
4549 hda_nid_t hp, line, mono;
4550
4551 if (val == spec->master_sw)
4552 return 0;
4553 spec->master_sw = val;
4554 hp = (kcontrol->private_value >> 16) & 0xff;
4555 line = (kcontrol->private_value >> 8) & 0xff;
4556 mono = kcontrol->private_value & 0xff;
4557 alc260_hp_master_update(codec, hp, line, mono);
4558 return 1;
4559}
4560
4561static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4562 {
4563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4564 .name = "Master Playback Switch",
4565 .info = snd_ctl_boolean_mono_info,
4566 .get = alc260_hp_master_sw_get,
4567 .put = alc260_hp_master_sw_put,
4568 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4569 },
4570 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4571 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4573 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4574 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4575 HDA_OUTPUT),
4576 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4577 { } /* end */
4578};
4579
4580static struct hda_verb alc260_hp_unsol_verbs[] = {
4581 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4582 {},
4583};
4584
4585static void alc260_hp_automute(struct hda_codec *codec)
4586{
4587 struct alc_spec *spec = codec->spec;
4588 unsigned int present;
4589
4590 present = snd_hda_codec_read(codec, 0x10, 0,
4591 AC_VERB_GET_PIN_SENSE, 0);
4592 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4593 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4594}
4595
4596static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4597{
4598 if ((res >> 26) == ALC880_HP_EVENT)
4599 alc260_hp_automute(codec);
4600}
4601
Kailang Yangdf694da2005-12-05 19:42:22 +01004602static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004603 {
4604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4605 .name = "Master Playback Switch",
4606 .info = snd_ctl_boolean_mono_info,
4607 .get = alc260_hp_master_sw_get,
4608 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004609 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004610 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004611 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4612 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4613 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4614 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004617 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4618 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004619 { } /* end */
4620};
4621
Kailang Yang3f878302008-08-26 13:02:23 +02004622static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4623 .ops = &snd_hda_bind_vol,
4624 .values = {
4625 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4626 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4627 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4628 0
4629 },
4630};
4631
4632static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4633 .ops = &snd_hda_bind_sw,
4634 .values = {
4635 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4636 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4637 0
4638 },
4639};
4640
4641static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4642 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4643 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4644 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4645 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4646 { } /* end */
4647};
4648
Takashi Iwaibec15c32008-01-28 18:16:30 +01004649static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4650 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4651 {},
4652};
4653
4654static void alc260_hp_3013_automute(struct hda_codec *codec)
4655{
4656 struct alc_spec *spec = codec->spec;
4657 unsigned int present;
4658
4659 present = snd_hda_codec_read(codec, 0x15, 0,
4660 AC_VERB_GET_PIN_SENSE, 0);
4661 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004662 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004663}
4664
4665static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4666 unsigned int res)
4667{
4668 if ((res >> 26) == ALC880_HP_EVENT)
4669 alc260_hp_3013_automute(codec);
4670}
4671
Kailang Yang3f878302008-08-26 13:02:23 +02004672static void alc260_hp_3012_automute(struct hda_codec *codec)
4673{
4674 unsigned int present, bits;
4675
4676 present = snd_hda_codec_read(codec, 0x10, 0,
4677 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4678
4679 bits = present ? 0 : PIN_OUT;
4680 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4681 bits);
4682 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4683 bits);
4684 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4685 bits);
4686}
4687
4688static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4689 unsigned int res)
4690{
4691 if ((res >> 26) == ALC880_HP_EVENT)
4692 alc260_hp_3012_automute(codec);
4693}
4694
4695/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004696 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4697 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004698static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004699 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004700 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004701 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004702 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4703 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4704 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4705 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004706 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004707 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4708 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4710 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004711 { } /* end */
4712};
4713
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004714/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4715 * versions of the ALC260 don't act on requests to enable mic bias from NID
4716 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4717 * datasheet doesn't mention this restriction. At this stage it's not clear
4718 * whether this behaviour is intentional or is a hardware bug in chip
4719 * revisions available in early 2006. Therefore for now allow the
4720 * "Headphone Jack Mode" control to span all choices, but if it turns out
4721 * that the lack of mic bias for this NID is intentional we could change the
4722 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4723 *
4724 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4725 * don't appear to make the mic bias available from the "line" jack, even
4726 * though the NID used for this jack (0x14) can supply it. The theory is
4727 * that perhaps Acer have included blocking capacitors between the ALC260
4728 * and the output jack. If this turns out to be the case for all such
4729 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4730 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004731 *
4732 * The C20x Tablet series have a mono internal speaker which is controlled
4733 * via the chip's Mono sum widget and pin complex, so include the necessary
4734 * controls for such models. On models without a "mono speaker" the control
4735 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004736 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004737static struct snd_kcontrol_new alc260_acer_mixer[] = {
4738 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4739 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004740 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004741 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004742 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004743 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004744 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004745 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4746 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4747 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4748 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4749 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4750 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4751 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4752 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4753 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4754 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4755 { } /* end */
4756};
4757
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004758/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4759 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4760 */
4761static struct snd_kcontrol_new alc260_will_mixer[] = {
4762 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4763 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4765 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4766 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4767 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4768 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4769 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4770 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4771 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4772 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4773 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4774 { } /* end */
4775};
4776
4777/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4778 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4779 */
4780static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4781 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4782 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4784 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4785 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4786 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4787 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4788 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4789 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4790 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4791 { } /* end */
4792};
4793
Kailang Yangdf694da2005-12-05 19:42:22 +01004794/*
4795 * initialization verbs
4796 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004797static struct hda_verb alc260_init_verbs[] = {
4798 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004799 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004803 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004804 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004805 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004806 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004809 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004811 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004813 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004815 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4816 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004817 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004818 /* set connection select to line in (default select for this ADC) */
4819 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004820 /* mute capture amp left and right */
4821 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4822 /* set connection select to line in (default select for this ADC) */
4823 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004824 /* set vol=0 Line-Out mixer amp left and right */
4825 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4826 /* unmute pin widget amp left and right (no gain on this amp) */
4827 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4828 /* set vol=0 HP mixer amp left and right */
4829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4830 /* unmute pin widget amp left and right (no gain on this amp) */
4831 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4832 /* set vol=0 Mono mixer amp left and right */
4833 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4834 /* unmute pin widget amp left and right (no gain on this amp) */
4835 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4836 /* unmute LINE-2 out pin */
4837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004838 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4839 * Line In 2 = 0x03
4840 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004841 /* mute analog inputs */
4842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004848 /* mute Front out path */
4849 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4851 /* mute Headphone out path */
4852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4854 /* mute Mono out path */
4855 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4856 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004857 { }
4858};
4859
Takashi Iwai474167d2006-05-17 17:17:43 +02004860#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004861static struct hda_verb alc260_hp_init_verbs[] = {
4862 /* Headphone and output */
4863 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4864 /* mono output */
4865 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4866 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4867 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4868 /* Mic2 (front panel) pin widget for input and vref at 80% */
4869 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4870 /* Line In pin widget for input */
4871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4872 /* Line-2 pin widget for output */
4873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4874 /* CD pin widget for input */
4875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4876 /* unmute amp left and right */
4877 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4878 /* set connection select to line in (default select for this ADC) */
4879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4880 /* unmute Line-Out mixer amp left and right (volume = 0) */
4881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4882 /* mute pin widget amp left and right (no gain on this amp) */
4883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4884 /* unmute HP mixer amp left and right (volume = 0) */
4885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4886 /* mute pin widget amp left and right (no gain on this amp) */
4887 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004888 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4889 * Line In 2 = 0x03
4890 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004891 /* mute analog inputs */
4892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004897 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4898 /* Unmute Front out path */
4899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4901 /* Unmute Headphone out path */
4902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4904 /* Unmute Mono out path */
4905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4907 { }
4908};
Takashi Iwai474167d2006-05-17 17:17:43 +02004909#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004910
4911static struct hda_verb alc260_hp_3013_init_verbs[] = {
4912 /* Line out and output */
4913 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4914 /* mono output */
4915 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4916 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4917 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4918 /* Mic2 (front panel) pin widget for input and vref at 80% */
4919 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4920 /* Line In pin widget for input */
4921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4922 /* Headphone pin widget for output */
4923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4924 /* CD pin widget for input */
4925 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4926 /* unmute amp left and right */
4927 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4928 /* set connection select to line in (default select for this ADC) */
4929 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4930 /* unmute Line-Out mixer amp left and right (volume = 0) */
4931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4932 /* mute pin widget amp left and right (no gain on this amp) */
4933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4934 /* unmute HP mixer amp left and right (volume = 0) */
4935 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4936 /* mute pin widget amp left and right (no gain on this amp) */
4937 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4939 * Line In 2 = 0x03
4940 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004941 /* mute analog inputs */
4942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004947 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4948 /* Unmute Front out path */
4949 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4951 /* Unmute Headphone out path */
4952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4953 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4954 /* Unmute Mono out path */
4955 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4956 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4957 { }
4958};
4959
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004960/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004961 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4962 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004963 */
4964static struct hda_verb alc260_fujitsu_init_verbs[] = {
4965 /* Disable all GPIOs */
4966 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4967 /* Internal speaker is connected to headphone pin */
4968 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4969 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004971 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4972 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4973 /* Ensure all other unused pins are disabled and muted. */
4974 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4975 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004976 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004977 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004978 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004979 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004982
Jonathan Woithef7ace402006-02-28 11:46:14 +01004983 /* Disable digital (SPDIF) pins */
4984 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4985 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004986
Kailang Yangea1fb292008-08-26 12:58:38 +02004987 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004988 * when acting as an output.
4989 */
4990 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4991
4992 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4995 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4997 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4999 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5000 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5001 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005002
Jonathan Woithef7ace402006-02-28 11:46:14 +01005003 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5004 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5005 /* Unmute Line1 pin widget output buffer since it starts as an output.
5006 * If the pin mode is changed by the user the pin mode control will
5007 * take care of enabling the pin's input/output buffers as needed.
5008 * Therefore there's no need to enable the input buffer at this
5009 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005010 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005012 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005013 * mixer ctrl)
5014 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005015 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005016
Jonathan Woithef7ace402006-02-28 11:46:14 +01005017 /* Mute capture amp left and right */
5018 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005019 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005020 * in (on mic1 pin)
5021 */
5022 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005023
Jonathan Woithef7ace402006-02-28 11:46:14 +01005024 /* Do the same for the second ADC: mute capture input amp and
5025 * set ADC connection to line in (on mic1 pin)
5026 */
5027 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5028 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005029
Jonathan Woithef7ace402006-02-28 11:46:14 +01005030 /* Mute all inputs to mixer widget (even unconnected ones) */
5031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005039
5040 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005041};
5042
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005043/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5044 * similar laptops (adapted from Fujitsu init verbs).
5045 */
5046static struct hda_verb alc260_acer_init_verbs[] = {
5047 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5048 * the headphone jack. Turn this on and rely on the standard mute
5049 * methods whenever the user wants to turn these outputs off.
5050 */
5051 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5052 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5053 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5054 /* Internal speaker/Headphone jack is connected to Line-out pin */
5055 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5056 /* Internal microphone/Mic jack is connected to Mic1 pin */
5057 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5058 /* Line In jack is connected to Line1 pin */
5059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005060 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5061 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005062 /* Ensure all other unused pins are disabled and muted. */
5063 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5064 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005065 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5066 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5069 /* Disable digital (SPDIF) pins */
5070 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5071 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5072
Kailang Yangea1fb292008-08-26 12:58:38 +02005073 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005074 * bus when acting as outputs.
5075 */
5076 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5077 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5078
5079 /* Start with output sum widgets muted and their output gains at min */
5080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5081 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5082 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5084 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5085 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5086 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5087 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5088 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5089
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005090 /* Unmute Line-out pin widget amp left and right
5091 * (no equiv mixer ctrl)
5092 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005094 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5095 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005096 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5097 * inputs. If the pin mode is changed by the user the pin mode control
5098 * will take care of enabling the pin's input/output buffers as needed.
5099 * Therefore there's no need to enable the input buffer at this
5100 * stage.
5101 */
5102 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5104
5105 /* Mute capture amp left and right */
5106 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5107 /* Set ADC connection select to match default mixer setting - mic
5108 * (on mic1 pin)
5109 */
5110 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5111
5112 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005113 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005114 */
5115 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005116 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005117
5118 /* Mute all inputs to mixer widget (even unconnected ones) */
5119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5123 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5127
5128 { }
5129};
5130
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005131static struct hda_verb alc260_will_verbs[] = {
5132 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5133 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5134 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5135 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5136 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5137 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5138 {}
5139};
5140
5141static struct hda_verb alc260_replacer_672v_verbs[] = {
5142 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5143 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5144 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5145
5146 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5147 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5148 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5149
5150 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5151 {}
5152};
5153
5154/* toggle speaker-output according to the hp-jack state */
5155static void alc260_replacer_672v_automute(struct hda_codec *codec)
5156{
5157 unsigned int present;
5158
5159 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5160 present = snd_hda_codec_read(codec, 0x0f, 0,
5161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5162 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005163 snd_hda_codec_write_cache(codec, 0x01, 0,
5164 AC_VERB_SET_GPIO_DATA, 1);
5165 snd_hda_codec_write_cache(codec, 0x0f, 0,
5166 AC_VERB_SET_PIN_WIDGET_CONTROL,
5167 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005168 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005169 snd_hda_codec_write_cache(codec, 0x01, 0,
5170 AC_VERB_SET_GPIO_DATA, 0);
5171 snd_hda_codec_write_cache(codec, 0x0f, 0,
5172 AC_VERB_SET_PIN_WIDGET_CONTROL,
5173 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005174 }
5175}
5176
5177static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5178 unsigned int res)
5179{
5180 if ((res >> 26) == ALC880_HP_EVENT)
5181 alc260_replacer_672v_automute(codec);
5182}
5183
Kailang Yang3f878302008-08-26 13:02:23 +02005184static struct hda_verb alc260_hp_dc7600_verbs[] = {
5185 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5187 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5188 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5189 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5191 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5192 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5193 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5195 {}
5196};
5197
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005198/* Test configuration for debugging, modelled after the ALC880 test
5199 * configuration.
5200 */
5201#ifdef CONFIG_SND_DEBUG
5202static hda_nid_t alc260_test_dac_nids[1] = {
5203 0x02,
5204};
5205static hda_nid_t alc260_test_adc_nids[2] = {
5206 0x04, 0x05,
5207};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005208/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005209 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005210 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005211 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005212static struct hda_input_mux alc260_test_capture_sources[2] = {
5213 {
5214 .num_items = 7,
5215 .items = {
5216 { "MIC1 pin", 0x0 },
5217 { "MIC2 pin", 0x1 },
5218 { "LINE1 pin", 0x2 },
5219 { "LINE2 pin", 0x3 },
5220 { "CD pin", 0x4 },
5221 { "LINE-OUT pin", 0x5 },
5222 { "HP-OUT pin", 0x6 },
5223 },
5224 },
5225 {
5226 .num_items = 8,
5227 .items = {
5228 { "MIC1 pin", 0x0 },
5229 { "MIC2 pin", 0x1 },
5230 { "LINE1 pin", 0x2 },
5231 { "LINE2 pin", 0x3 },
5232 { "CD pin", 0x4 },
5233 { "Mixer", 0x5 },
5234 { "LINE-OUT pin", 0x6 },
5235 { "HP-OUT pin", 0x7 },
5236 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005237 },
5238};
5239static struct snd_kcontrol_new alc260_test_mixer[] = {
5240 /* Output driver widgets */
5241 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5242 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5243 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5244 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5245 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5246 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5247
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005248 /* Modes for retasking pin widgets
5249 * Note: the ALC260 doesn't seem to act on requests to enable mic
5250 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5251 * mention this restriction. At this stage it's not clear whether
5252 * this behaviour is intentional or is a hardware bug in chip
5253 * revisions available at least up until early 2006. Therefore for
5254 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5255 * choices, but if it turns out that the lack of mic bias for these
5256 * NIDs is intentional we could change their modes from
5257 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5258 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005259 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5260 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5261 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5262 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5263 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5264 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5265
5266 /* Loopback mixer controls */
5267 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5268 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5269 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5270 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5271 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5272 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5273 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5274 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5275 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5276 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5277 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5278 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5279 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5280 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5281 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5282 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005283
5284 /* Controls for GPIO pins, assuming they are configured as outputs */
5285 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5286 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5287 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5288 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5289
Jonathan Woithe92621f12006-02-28 11:47:47 +01005290 /* Switches to allow the digital IO pins to be enabled. The datasheet
5291 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005292 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005293 */
5294 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5295 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5296
Jonathan Woithef8225f62008-01-08 12:16:54 +01005297 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5298 * this output to turn on an external amplifier.
5299 */
5300 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5301 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5302
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005303 { } /* end */
5304};
5305static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005306 /* Enable all GPIOs as outputs with an initial value of 0 */
5307 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5308 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5309 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5310
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005311 /* Enable retasking pins as output, initially without power amp */
5312 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5313 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5316 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5317 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5318
Jonathan Woithe92621f12006-02-28 11:47:47 +01005319 /* Disable digital (SPDIF) pins initially, but users can enable
5320 * them via a mixer switch. In the case of SPDIF-out, this initverb
5321 * payload also sets the generation to 0, output to be in "consumer"
5322 * PCM format, copyright asserted, no pre-emphasis and no validity
5323 * control.
5324 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005325 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5326 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5327
Kailang Yangea1fb292008-08-26 12:58:38 +02005328 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005329 * OUT1 sum bus when acting as an output.
5330 */
5331 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5332 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5333 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5334 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5335
5336 /* Start with output sum widgets muted and their output gains at min */
5337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5346
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005347 /* Unmute retasking pin widget output buffers since the default
5348 * state appears to be output. As the pin mode is changed by the
5349 * user the pin mode control will take care of enabling the pin's
5350 * input/output buffers as needed.
5351 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5353 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5356 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5357 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5358 /* Also unmute the mono-out pin widget */
5359 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5360
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005361 /* Mute capture amp left and right */
5362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005363 /* Set ADC connection select to match default mixer setting (mic1
5364 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005365 */
5366 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5367
5368 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005369 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005370 */
5371 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5372 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5373
5374 /* Mute all inputs to mixer widget (even unconnected ones) */
5375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5383
5384 { }
5385};
5386#endif
5387
Takashi Iwai63300792008-01-24 15:31:36 +01005388#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5389#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005390
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005391#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5392#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5393
Kailang Yangdf694da2005-12-05 19:42:22 +01005394/*
5395 * for BIOS auto-configuration
5396 */
5397
5398static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005399 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005400{
5401 hda_nid_t nid_vol;
5402 unsigned long vol_val, sw_val;
5403 char name[32];
5404 int err;
5405
5406 if (nid >= 0x0f && nid < 0x11) {
5407 nid_vol = nid - 0x7;
5408 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5409 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5410 } else if (nid == 0x11) {
5411 nid_vol = nid - 0x7;
5412 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5413 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5414 } else if (nid >= 0x12 && nid <= 0x15) {
5415 nid_vol = 0x08;
5416 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5417 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5418 } else
5419 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005420
Takashi Iwai863b4512008-10-21 17:01:47 +02005421 if (!(*vol_bits & (1 << nid_vol))) {
5422 /* first control for the volume widget */
5423 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5424 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5425 if (err < 0)
5426 return err;
5427 *vol_bits |= (1 << nid_vol);
5428 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005429 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005430 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5431 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005432 return err;
5433 return 1;
5434}
5435
5436/* add playback controls from the parsed DAC table */
5437static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5438 const struct auto_pin_cfg *cfg)
5439{
5440 hda_nid_t nid;
5441 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005442 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005443
5444 spec->multiout.num_dacs = 1;
5445 spec->multiout.dac_nids = spec->private_dac_nids;
5446 spec->multiout.dac_nids[0] = 0x02;
5447
5448 nid = cfg->line_out_pins[0];
5449 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005450 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005451 if (err < 0)
5452 return err;
5453 }
5454
Takashi Iwai82bc9552006-03-21 11:24:42 +01005455 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005456 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005457 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005458 if (err < 0)
5459 return err;
5460 }
5461
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005462 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005463 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005464 err = alc260_add_playback_controls(spec, nid, "Headphone",
5465 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005466 if (err < 0)
5467 return err;
5468 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005469 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005470}
5471
5472/* create playback/capture controls for input pins */
5473static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5474 const struct auto_pin_cfg *cfg)
5475{
Kailang Yangdf694da2005-12-05 19:42:22 +01005476 struct hda_input_mux *imux = &spec->private_imux;
5477 int i, err, idx;
5478
5479 for (i = 0; i < AUTO_PIN_LAST; i++) {
5480 if (cfg->input_pins[i] >= 0x12) {
5481 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005482 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005483 auto_pin_cfg_labels[i], idx,
5484 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005485 if (err < 0)
5486 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005487 imux->items[imux->num_items].label =
5488 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 imux->items[imux->num_items].index = idx;
5490 imux->num_items++;
5491 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005492 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005493 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005494 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005495 auto_pin_cfg_labels[i], idx,
5496 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005497 if (err < 0)
5498 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005499 imux->items[imux->num_items].label =
5500 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005501 imux->items[imux->num_items].index = idx;
5502 imux->num_items++;
5503 }
5504 }
5505 return 0;
5506}
5507
5508static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5509 hda_nid_t nid, int pin_type,
5510 int sel_idx)
5511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005512 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005513 /* need the manual connection? */
5514 if (nid >= 0x12) {
5515 int idx = nid - 0x12;
5516 snd_hda_codec_write(codec, idx + 0x0b, 0,
5517 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005518 }
5519}
5520
5521static void alc260_auto_init_multi_out(struct hda_codec *codec)
5522{
5523 struct alc_spec *spec = codec->spec;
5524 hda_nid_t nid;
5525
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005526 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005527 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005528 if (nid) {
5529 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5530 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5531 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005532
Takashi Iwai82bc9552006-03-21 11:24:42 +01005533 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 if (nid)
5535 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5536
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005537 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005538 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005539 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005540}
Kailang Yangdf694da2005-12-05 19:42:22 +01005541
5542#define ALC260_PIN_CD_NID 0x16
5543static void alc260_auto_init_analog_input(struct hda_codec *codec)
5544{
5545 struct alc_spec *spec = codec->spec;
5546 int i;
5547
5548 for (i = 0; i < AUTO_PIN_LAST; i++) {
5549 hda_nid_t nid = spec->autocfg.input_pins[i];
5550 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005551 snd_hda_codec_write(codec, nid, 0,
5552 AC_VERB_SET_PIN_WIDGET_CONTROL,
5553 i <= AUTO_PIN_FRONT_MIC ?
5554 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005556 snd_hda_codec_write(codec, nid, 0,
5557 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005558 AMP_OUT_MUTE);
5559 }
5560 }
5561}
5562
5563/*
5564 * generic initialization of ADC, input mixers and output mixers
5565 */
5566static struct hda_verb alc260_volume_init_verbs[] = {
5567 /*
5568 * Unmute ADC0-1 and set the default input to mic-in
5569 */
5570 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5571 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5572 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5573 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005574
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5576 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005577 * Note: PASD motherboards uses the Line In 2 as the input for
5578 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005579 */
5580 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005581 /* mute analog inputs */
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005587
5588 /*
5589 * Set up output mixers (0x08 - 0x0a)
5590 */
5591 /* set vol=0 to output mixers */
5592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5595 /* set up input amps for analog loopback */
5596 /* Amp Indices: DAC = 0, mixer = 1 */
5597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5600 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5601 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5602 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005603
Kailang Yangdf694da2005-12-05 19:42:22 +01005604 { }
5605};
5606
5607static int alc260_parse_auto_config(struct hda_codec *codec)
5608{
5609 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005610 int err;
5611 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5612
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005613 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5614 alc260_ignore);
5615 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005616 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005617 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5618 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005619 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005620 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005621 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005622 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005624 return err;
5625
5626 spec->multiout.max_channels = 2;
5627
5628 if (spec->autocfg.dig_out_pin)
5629 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005630 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005631 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005632
Takashi Iwaid88897e2008-10-31 15:01:37 +01005633 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005634
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005635 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005636 spec->input_mux = &spec->private_imux;
5637
Takashi Iwaie044c392008-10-27 16:56:24 +01005638 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005639 return 1;
5640}
5641
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005642/* additional initialization for auto-configuration model */
5643static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005644{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005645 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005646 alc260_auto_init_multi_out(codec);
5647 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005648 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005649 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005650}
5651
Takashi Iwaicb53c622007-08-10 17:21:45 +02005652#ifdef CONFIG_SND_HDA_POWER_SAVE
5653static struct hda_amp_list alc260_loopbacks[] = {
5654 { 0x07, HDA_INPUT, 0 },
5655 { 0x07, HDA_INPUT, 1 },
5656 { 0x07, HDA_INPUT, 2 },
5657 { 0x07, HDA_INPUT, 3 },
5658 { 0x07, HDA_INPUT, 4 },
5659 { } /* end */
5660};
5661#endif
5662
Kailang Yangdf694da2005-12-05 19:42:22 +01005663/*
5664 * ALC260 configurations
5665 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005666static const char *alc260_models[ALC260_MODEL_LAST] = {
5667 [ALC260_BASIC] = "basic",
5668 [ALC260_HP] = "hp",
5669 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005670 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005671 [ALC260_FUJITSU_S702X] = "fujitsu",
5672 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005673 [ALC260_WILL] = "will",
5674 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005675#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005676 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005677#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005678 [ALC260_AUTO] = "auto",
5679};
5680
5681static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005682 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005683 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005684 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005685 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005686 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005687 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005688 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005689 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5690 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5691 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5692 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5693 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5694 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5695 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5696 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5697 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005698 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005699 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005700 {}
5701};
5702
Kailang Yangdf694da2005-12-05 19:42:22 +01005703static struct alc_config_preset alc260_presets[] = {
5704 [ALC260_BASIC] = {
5705 .mixers = { alc260_base_output_mixer,
5706 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005707 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 .init_verbs = { alc260_init_verbs },
5709 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5710 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005711 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 .adc_nids = alc260_adc_nids,
5713 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5714 .channel_mode = alc260_modes,
5715 .input_mux = &alc260_capture_source,
5716 },
5717 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005718 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005719 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005720 .init_verbs = { alc260_init_verbs,
5721 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5723 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005724 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5725 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005726 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5727 .channel_mode = alc260_modes,
5728 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005729 .unsol_event = alc260_hp_unsol_event,
5730 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 },
Kailang Yang3f878302008-08-26 13:02:23 +02005732 [ALC260_HP_DC7600] = {
5733 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005734 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005735 .init_verbs = { alc260_init_verbs,
5736 alc260_hp_dc7600_verbs },
5737 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5738 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005739 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5740 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005741 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5742 .channel_mode = alc260_modes,
5743 .input_mux = &alc260_capture_source,
5744 .unsol_event = alc260_hp_3012_unsol_event,
5745 .init_hook = alc260_hp_3012_automute,
5746 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005747 [ALC260_HP_3013] = {
5748 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005749 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005750 .init_verbs = { alc260_hp_3013_init_verbs,
5751 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005752 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5753 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005754 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5755 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005756 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5757 .channel_mode = alc260_modes,
5758 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005759 .unsol_event = alc260_hp_3013_unsol_event,
5760 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005761 },
5762 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005763 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005764 .init_verbs = { alc260_fujitsu_init_verbs },
5765 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5766 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005767 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5768 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005769 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5770 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005771 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5772 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005773 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005774 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005775 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005776 .init_verbs = { alc260_acer_init_verbs },
5777 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5778 .dac_nids = alc260_dac_nids,
5779 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5780 .adc_nids = alc260_dual_adc_nids,
5781 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5782 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005783 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5784 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005785 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005786 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005787 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005788 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5789 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5790 .dac_nids = alc260_dac_nids,
5791 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5792 .adc_nids = alc260_adc_nids,
5793 .dig_out_nid = ALC260_DIGOUT_NID,
5794 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5795 .channel_mode = alc260_modes,
5796 .input_mux = &alc260_capture_source,
5797 },
5798 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005799 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005800 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5801 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5802 .dac_nids = alc260_dac_nids,
5803 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5804 .adc_nids = alc260_adc_nids,
5805 .dig_out_nid = ALC260_DIGOUT_NID,
5806 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5807 .channel_mode = alc260_modes,
5808 .input_mux = &alc260_capture_source,
5809 .unsol_event = alc260_replacer_672v_unsol_event,
5810 .init_hook = alc260_replacer_672v_automute,
5811 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005812#ifdef CONFIG_SND_DEBUG
5813 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005814 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005815 .init_verbs = { alc260_test_init_verbs },
5816 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5817 .dac_nids = alc260_test_dac_nids,
5818 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5819 .adc_nids = alc260_test_adc_nids,
5820 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5821 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005822 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5823 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005824 },
5825#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005826};
5827
Linus Torvalds1da177e2005-04-16 15:20:36 -07005828static int patch_alc260(struct hda_codec *codec)
5829{
5830 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005831 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005832
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005833 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005834 if (spec == NULL)
5835 return -ENOMEM;
5836
5837 codec->spec = spec;
5838
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005839 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5840 alc260_models,
5841 alc260_cfg_tbl);
5842 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005843 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5844 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005845 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005846 }
5847
Kailang Yangdf694da2005-12-05 19:42:22 +01005848 if (board_config == ALC260_AUTO) {
5849 /* automatic parse from the BIOS config */
5850 err = alc260_parse_auto_config(codec);
5851 if (err < 0) {
5852 alc_free(codec);
5853 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005854 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005855 printk(KERN_INFO
5856 "hda_codec: Cannot set up configuration "
5857 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005858 board_config = ALC260_BASIC;
5859 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005860 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005861
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 if (board_config != ALC260_AUTO)
5863 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005864
5865 spec->stream_name_analog = "ALC260 Analog";
5866 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5867 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5868
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005869 spec->stream_name_digital = "ALC260 Digital";
5870 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5871 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5872
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005873 if (!spec->adc_nids && spec->input_mux) {
5874 /* check whether NID 0x04 is valid */
5875 unsigned int wcap = get_wcaps(codec, 0x04);
5876 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5877 /* get type */
5878 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5879 spec->adc_nids = alc260_adc_nids_alt;
5880 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5881 } else {
5882 spec->adc_nids = alc260_adc_nids;
5883 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5884 }
5885 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005886 set_capture_mixer(spec);
5887
Takashi Iwai2134ea42008-01-10 16:53:55 +01005888 spec->vmaster_nid = 0x08;
5889
Linus Torvalds1da177e2005-04-16 15:20:36 -07005890 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005891 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005892 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005893#ifdef CONFIG_SND_HDA_POWER_SAVE
5894 if (!spec->loopback.amplist)
5895 spec->loopback.amplist = alc260_loopbacks;
5896#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005897 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005898
5899 return 0;
5900}
5901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005902
Linus Torvalds1da177e2005-04-16 15:20:36 -07005903/*
5904 * ALC882 support
5905 *
5906 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5907 * configuration. Each pin widget can choose any input DACs and a mixer.
5908 * Each ADC is connected from a mixer of all inputs. This makes possible
5909 * 6-channel independent captures.
5910 *
5911 * In addition, an independent DAC for the multi-playback (not used in this
5912 * driver yet).
5913 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005914#define ALC882_DIGOUT_NID 0x06
5915#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005916
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005917static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005918 { 8, NULL }
5919};
5920
5921static hda_nid_t alc882_dac_nids[4] = {
5922 /* front, rear, clfe, rear_surr */
5923 0x02, 0x03, 0x04, 0x05
5924};
5925
Kailang Yangdf694da2005-12-05 19:42:22 +01005926/* identical with ALC880 */
5927#define alc882_adc_nids alc880_adc_nids
5928#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005929
Takashi Iwaie1406342008-02-11 18:32:32 +01005930static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5931static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5932
Linus Torvalds1da177e2005-04-16 15:20:36 -07005933/* input MUX */
5934/* FIXME: should be a matrix-type input source selection */
5935
5936static struct hda_input_mux alc882_capture_source = {
5937 .num_items = 4,
5938 .items = {
5939 { "Mic", 0x0 },
5940 { "Front Mic", 0x1 },
5941 { "Line", 0x2 },
5942 { "CD", 0x4 },
5943 },
5944};
Kailang Yangdf694da2005-12-05 19:42:22 +01005945/*
Kailang Yang272a5272007-05-14 11:00:38 +02005946 * 2ch mode
5947 */
5948static struct hda_verb alc882_3ST_ch2_init[] = {
5949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5951 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5952 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5953 { } /* end */
5954};
5955
5956/*
5957 * 6ch mode
5958 */
5959static struct hda_verb alc882_3ST_ch6_init[] = {
5960 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5961 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5962 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5963 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5964 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5965 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5966 { } /* end */
5967};
5968
5969static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5970 { 2, alc882_3ST_ch2_init },
5971 { 6, alc882_3ST_ch6_init },
5972};
5973
5974/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005975 * 6ch mode
5976 */
5977static struct hda_verb alc882_sixstack_ch6_init[] = {
5978 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5979 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5980 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5981 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5982 { } /* end */
5983};
5984
5985/*
5986 * 8ch mode
5987 */
5988static struct hda_verb alc882_sixstack_ch8_init[] = {
5989 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5990 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5991 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5992 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5993 { } /* end */
5994};
5995
5996static struct hda_channel_mode alc882_sixstack_modes[2] = {
5997 { 6, alc882_sixstack_ch6_init },
5998 { 8, alc882_sixstack_ch8_init },
5999};
6000
Takashi Iwai87350ad2007-08-16 18:19:38 +02006001/*
6002 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6003 */
6004
6005/*
6006 * 2ch mode
6007 */
6008static struct hda_verb alc885_mbp_ch2_init[] = {
6009 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6010 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6011 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6012 { } /* end */
6013};
6014
6015/*
6016 * 6ch mode
6017 */
6018static struct hda_verb alc885_mbp_ch6_init[] = {
6019 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6020 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6021 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6022 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6023 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6024 { } /* end */
6025};
6026
6027static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6028 { 2, alc885_mbp_ch2_init },
6029 { 6, alc885_mbp_ch6_init },
6030};
6031
6032
Linus Torvalds1da177e2005-04-16 15:20:36 -07006033/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6034 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6035 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006036static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006040 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006043 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6044 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006045 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006046 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6055 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006056 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6058 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6059 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006060 { } /* end */
6061};
6062
Takashi Iwai87350ad2007-08-16 18:19:38 +02006063static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006064 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6065 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6066 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6067 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6069 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6071 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006072 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6074 { } /* end */
6075};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006076static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6079 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6080 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6086 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6087 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6088 { } /* end */
6089};
6090
Kailang Yang272a5272007-05-14 11:00:38 +02006091static struct snd_kcontrol_new alc882_targa_mixer[] = {
6092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006101 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006104 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006105 { } /* end */
6106};
6107
6108/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6109 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6110 */
6111static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6112 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6113 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6115 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6120 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6121 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006124 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006125 { } /* end */
6126};
6127
Takashi Iwai914759b2007-09-06 14:52:04 +02006128static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6139 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6140 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6141 { } /* end */
6142};
6143
Kailang Yangdf694da2005-12-05 19:42:22 +01006144static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6145 {
6146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6147 .name = "Channel Mode",
6148 .info = alc_ch_mode_info,
6149 .get = alc_ch_mode_get,
6150 .put = alc_ch_mode_put,
6151 },
6152 { } /* end */
6153};
6154
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155static struct hda_verb alc882_init_verbs[] = {
6156 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006164 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6170 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006172
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006173 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006176 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006177 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006181 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006183 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006185 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006189 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006190 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6192 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6195 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006196 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006197 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6198 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006202 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006204
6205 /* FIXME: use matrix-type input source selection */
6206 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6207 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006212 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006217 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6222 /* ADC1: mute amp left and right */
6223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006224 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006225 /* ADC2: mute amp left and right */
6226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006227 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006228 /* ADC3: mute amp left and right */
6229 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006230 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006231
6232 { }
6233};
6234
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006235static struct hda_verb alc882_eapd_verbs[] = {
6236 /* change to EAPD mode */
6237 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006238 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006240};
6241
Tobin Davis9102cd12006-12-15 10:02:12 +01006242/* Mac Pro test */
6243static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6244 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6245 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6247 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6248 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6249 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6250 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6251 { } /* end */
6252};
6253
6254static struct hda_verb alc882_macpro_init_verbs[] = {
6255 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6259 /* Front Pin: output 0 (0x0c) */
6260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6262 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6263 /* Front Mic pin: input vref at 80% */
6264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6266 /* Speaker: output */
6267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6269 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6270 /* Headphone output (output 0 - 0x0c) */
6271 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6272 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6273 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6274
6275 /* FIXME: use matrix-type input source selection */
6276 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6277 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6282 /* Input mixer2 */
6283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6287 /* Input mixer3 */
6288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6292 /* ADC1: mute amp left and right */
6293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6294 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6295 /* ADC2: mute amp left and right */
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6297 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6298 /* ADC3: mute amp left and right */
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6301
6302 { }
6303};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006304
Takashi Iwai87350ad2007-08-16 18:19:38 +02006305/* Macbook Pro rev3 */
6306static struct hda_verb alc885_mbp3_init_verbs[] = {
6307 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6311 /* Rear mixer */
6312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6315 /* Front Pin: output 0 (0x0c) */
6316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6318 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6319 /* HP Pin: output 0 (0x0d) */
6320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6323 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6324 /* Mic (rear) pin: input vref at 80% */
6325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6327 /* Front Mic pin: input vref at 80% */
6328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6329 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6330 /* Line In pin: use output 1 when in LineOut mode */
6331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6333 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6334
6335 /* FIXME: use matrix-type input source selection */
6336 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6337 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6342 /* Input mixer2 */
6343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6347 /* Input mixer3 */
6348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6352 /* ADC1: mute amp left and right */
6353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6354 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6355 /* ADC2: mute amp left and right */
6356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6358 /* ADC3: mute amp left and right */
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6361
6362 { }
6363};
6364
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006365/* iMac 24 mixer. */
6366static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6367 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6368 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6369 { } /* end */
6370};
6371
6372/* iMac 24 init verbs. */
6373static struct hda_verb alc885_imac24_init_verbs[] = {
6374 /* Internal speakers: output 0 (0x0c) */
6375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6377 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6378 /* Internal speakers: output 0 (0x0c) */
6379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6381 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6382 /* Headphone: output 0 (0x0c) */
6383 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6384 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6385 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6386 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6387 /* Front Mic: input vref at 80% */
6388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6390 { }
6391};
6392
6393/* Toggle speaker-output according to the hp-jack state */
6394static void alc885_imac24_automute(struct hda_codec *codec)
6395{
6396 unsigned int present;
6397
6398 present = snd_hda_codec_read(codec, 0x14, 0,
6399 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006400 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6401 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6402 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6403 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006404}
6405
6406/* Processes unsolicited events. */
6407static void alc885_imac24_unsol_event(struct hda_codec *codec,
6408 unsigned int res)
6409{
6410 /* Headphone insertion or removal. */
6411 if ((res >> 26) == ALC880_HP_EVENT)
6412 alc885_imac24_automute(codec);
6413}
6414
Takashi Iwai87350ad2007-08-16 18:19:38 +02006415static void alc885_mbp3_automute(struct hda_codec *codec)
6416{
6417 unsigned int present;
6418
6419 present = snd_hda_codec_read(codec, 0x15, 0,
6420 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6421 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6422 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6423 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6424 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6425
6426}
6427static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6428 unsigned int res)
6429{
6430 /* Headphone insertion or removal. */
6431 if ((res >> 26) == ALC880_HP_EVENT)
6432 alc885_mbp3_automute(codec);
6433}
6434
6435
Kailang Yang272a5272007-05-14 11:00:38 +02006436static struct hda_verb alc882_targa_verbs[] = {
6437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6439
6440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006442
Kailang Yang272a5272007-05-14 11:00:38 +02006443 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6444 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6445 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6446
6447 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6448 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6449 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6450 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6451 { } /* end */
6452};
6453
6454/* toggle speaker-output according to the hp-jack state */
6455static void alc882_targa_automute(struct hda_codec *codec)
6456{
6457 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006458
Kailang Yang272a5272007-05-14 11:00:38 +02006459 present = snd_hda_codec_read(codec, 0x14, 0,
6460 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006461 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006463 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6464 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006465}
6466
6467static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6468{
6469 /* Looks like the unsol event is incompatible with the standard
6470 * definition. 4bit tag is placed at 26 bit!
6471 */
6472 if (((res >> 26) == ALC880_HP_EVENT)) {
6473 alc882_targa_automute(codec);
6474 }
6475}
6476
6477static struct hda_verb alc882_asus_a7j_verbs[] = {
6478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6480
6481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006484
Kailang Yang272a5272007-05-14 11:00:38 +02006485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6486 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6487 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6488
6489 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6490 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6491 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6492 { } /* end */
6493};
6494
Takashi Iwai914759b2007-09-06 14:52:04 +02006495static struct hda_verb alc882_asus_a7m_verbs[] = {
6496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6498
6499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6501 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006502
Takashi Iwai914759b2007-09-06 14:52:04 +02006503 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6505 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6506
6507 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6510 { } /* end */
6511};
6512
Tobin Davis9102cd12006-12-15 10:02:12 +01006513static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6514{
6515 unsigned int gpiostate, gpiomask, gpiodir;
6516
6517 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6518 AC_VERB_GET_GPIO_DATA, 0);
6519
6520 if (!muted)
6521 gpiostate |= (1 << pin);
6522 else
6523 gpiostate &= ~(1 << pin);
6524
6525 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6526 AC_VERB_GET_GPIO_MASK, 0);
6527 gpiomask |= (1 << pin);
6528
6529 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6530 AC_VERB_GET_GPIO_DIRECTION, 0);
6531 gpiodir |= (1 << pin);
6532
6533
6534 snd_hda_codec_write(codec, codec->afg, 0,
6535 AC_VERB_SET_GPIO_MASK, gpiomask);
6536 snd_hda_codec_write(codec, codec->afg, 0,
6537 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6538
6539 msleep(1);
6540
6541 snd_hda_codec_write(codec, codec->afg, 0,
6542 AC_VERB_SET_GPIO_DATA, gpiostate);
6543}
6544
Takashi Iwai7debbe52007-08-16 15:01:03 +02006545/* set up GPIO at initialization */
6546static void alc885_macpro_init_hook(struct hda_codec *codec)
6547{
6548 alc882_gpio_mute(codec, 0, 0);
6549 alc882_gpio_mute(codec, 1, 0);
6550}
6551
6552/* set up GPIO and update auto-muting at initialization */
6553static void alc885_imac24_init_hook(struct hda_codec *codec)
6554{
6555 alc885_macpro_init_hook(codec);
6556 alc885_imac24_automute(codec);
6557}
6558
Kailang Yangdf694da2005-12-05 19:42:22 +01006559/*
6560 * generic initialization of ADC, input mixers and output mixers
6561 */
6562static struct hda_verb alc882_auto_init_verbs[] = {
6563 /*
6564 * Unmute ADC0-2 and set the default input to mic-in
6565 */
6566 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6568 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6570 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6571 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6572
Takashi Iwaicb53c622007-08-10 17:21:45 +02006573 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006574 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006575 * Note: PASD motherboards uses the Line In 2 as the input for
6576 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006577 */
6578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006584
6585 /*
6586 * Set up output mixers (0x0c - 0x0f)
6587 */
6588 /* set vol=0 to output mixers */
6589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6593 /* set up input amps for analog loopback */
6594 /* Amp Indices: DAC = 0, mixer = 1 */
6595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6603 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6604 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6605
6606 /* FIXME: use matrix-type input source selection */
6607 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6613 /* Input mixer2 */
6614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6618 /* Input mixer3 */
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6623
6624 { }
6625};
6626
Takashi Iwaicb53c622007-08-10 17:21:45 +02006627#ifdef CONFIG_SND_HDA_POWER_SAVE
6628#define alc882_loopbacks alc880_loopbacks
6629#endif
6630
Kailang Yangdf694da2005-12-05 19:42:22 +01006631/* pcm configuration: identiacal with ALC880 */
6632#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6633#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6634#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6635#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6636
6637/*
6638 * configuration and preset
6639 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006640static const char *alc882_models[ALC882_MODEL_LAST] = {
6641 [ALC882_3ST_DIG] = "3stack-dig",
6642 [ALC882_6ST_DIG] = "6stack-dig",
6643 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006644 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006645 [ALC882_TARGA] = "targa",
6646 [ALC882_ASUS_A7J] = "asus-a7j",
6647 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006648 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006649 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006650 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006651 [ALC882_AUTO] = "auto",
6652};
6653
6654static struct snd_pci_quirk alc882_cfg_tbl[] = {
6655 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006656 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006657 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006658 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006659 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006660 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006661 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006662 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006663 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006664 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6665 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6666 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006667 {}
6668};
6669
6670static struct alc_config_preset alc882_presets[] = {
6671 [ALC882_3ST_DIG] = {
6672 .mixers = { alc882_base_mixer },
6673 .init_verbs = { alc882_init_verbs },
6674 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6675 .dac_nids = alc882_dac_nids,
6676 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 .dig_in_nid = ALC882_DIGIN_NID,
6678 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6679 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006680 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006681 .input_mux = &alc882_capture_source,
6682 },
6683 [ALC882_6ST_DIG] = {
6684 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6685 .init_verbs = { alc882_init_verbs },
6686 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6687 .dac_nids = alc882_dac_nids,
6688 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 .dig_in_nid = ALC882_DIGIN_NID,
6690 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6691 .channel_mode = alc882_sixstack_modes,
6692 .input_mux = &alc882_capture_source,
6693 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006694 [ALC882_ARIMA] = {
6695 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6696 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6697 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6698 .dac_nids = alc882_dac_nids,
6699 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6700 .channel_mode = alc882_sixstack_modes,
6701 .input_mux = &alc882_capture_source,
6702 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006703 [ALC882_W2JC] = {
6704 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6705 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6706 alc880_gpio1_init_verbs },
6707 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6708 .dac_nids = alc882_dac_nids,
6709 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6710 .channel_mode = alc880_threestack_modes,
6711 .need_dac_fix = 1,
6712 .input_mux = &alc882_capture_source,
6713 .dig_out_nid = ALC882_DIGOUT_NID,
6714 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006715 [ALC885_MBP3] = {
6716 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6717 .init_verbs = { alc885_mbp3_init_verbs,
6718 alc880_gpio1_init_verbs },
6719 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6720 .dac_nids = alc882_dac_nids,
6721 .channel_mode = alc885_mbp_6ch_modes,
6722 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6723 .input_mux = &alc882_capture_source,
6724 .dig_out_nid = ALC882_DIGOUT_NID,
6725 .dig_in_nid = ALC882_DIGIN_NID,
6726 .unsol_event = alc885_mbp3_unsol_event,
6727 .init_hook = alc885_mbp3_automute,
6728 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006729 [ALC885_MACPRO] = {
6730 .mixers = { alc882_macpro_mixer },
6731 .init_verbs = { alc882_macpro_init_verbs },
6732 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6733 .dac_nids = alc882_dac_nids,
6734 .dig_out_nid = ALC882_DIGOUT_NID,
6735 .dig_in_nid = ALC882_DIGIN_NID,
6736 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6737 .channel_mode = alc882_ch_modes,
6738 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006739 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006740 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006741 [ALC885_IMAC24] = {
6742 .mixers = { alc885_imac24_mixer },
6743 .init_verbs = { alc885_imac24_init_verbs },
6744 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6745 .dac_nids = alc882_dac_nids,
6746 .dig_out_nid = ALC882_DIGOUT_NID,
6747 .dig_in_nid = ALC882_DIGIN_NID,
6748 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6749 .channel_mode = alc882_ch_modes,
6750 .input_mux = &alc882_capture_source,
6751 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006752 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006753 },
Kailang Yang272a5272007-05-14 11:00:38 +02006754 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006755 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006756 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6757 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6758 .dac_nids = alc882_dac_nids,
6759 .dig_out_nid = ALC882_DIGOUT_NID,
6760 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6761 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006762 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006763 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6764 .channel_mode = alc882_3ST_6ch_modes,
6765 .need_dac_fix = 1,
6766 .input_mux = &alc882_capture_source,
6767 .unsol_event = alc882_targa_unsol_event,
6768 .init_hook = alc882_targa_automute,
6769 },
6770 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006771 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006772 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6773 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6774 .dac_nids = alc882_dac_nids,
6775 .dig_out_nid = ALC882_DIGOUT_NID,
6776 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6777 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006778 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006779 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6780 .channel_mode = alc882_3ST_6ch_modes,
6781 .need_dac_fix = 1,
6782 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006783 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006784 [ALC882_ASUS_A7M] = {
6785 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6786 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6787 alc880_gpio1_init_verbs,
6788 alc882_asus_a7m_verbs },
6789 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6790 .dac_nids = alc882_dac_nids,
6791 .dig_out_nid = ALC882_DIGOUT_NID,
6792 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6793 .channel_mode = alc880_threestack_modes,
6794 .need_dac_fix = 1,
6795 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006796 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006797};
6798
6799
6800/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006801 * Pin config fixes
6802 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006803enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006804 PINFIX_ABIT_AW9D_MAX
6805};
6806
6807static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6808 { 0x15, 0x01080104 }, /* side */
6809 { 0x16, 0x01011012 }, /* rear */
6810 { 0x17, 0x01016011 }, /* clfe */
6811 { }
6812};
6813
6814static const struct alc_pincfg *alc882_pin_fixes[] = {
6815 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6816};
6817
6818static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6819 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6820 {}
6821};
6822
6823/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 * BIOS auto configuration
6825 */
6826static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6827 hda_nid_t nid, int pin_type,
6828 int dac_idx)
6829{
6830 /* set as output */
6831 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006832 int idx;
6833
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006834 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006835 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6836 idx = 4;
6837 else
6838 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006839 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6840
6841}
6842
6843static void alc882_auto_init_multi_out(struct hda_codec *codec)
6844{
6845 struct alc_spec *spec = codec->spec;
6846 int i;
6847
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006848 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006850 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006851 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006852 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006853 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006854 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006855 }
6856}
6857
6858static void alc882_auto_init_hp_out(struct hda_codec *codec)
6859{
6860 struct alc_spec *spec = codec->spec;
6861 hda_nid_t pin;
6862
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006863 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006864 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006865 /* use dac 0 */
6866 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006867 pin = spec->autocfg.speaker_pins[0];
6868 if (pin)
6869 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006870}
6871
6872#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6873#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6874
6875static void alc882_auto_init_analog_input(struct hda_codec *codec)
6876{
6877 struct alc_spec *spec = codec->spec;
6878 int i;
6879
6880 for (i = 0; i < AUTO_PIN_LAST; i++) {
6881 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006882 unsigned int vref;
6883 if (!nid)
6884 continue;
6885 vref = PIN_IN;
6886 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006887 unsigned int pincap;
6888 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6889 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006890 AC_PINCAP_VREF_80)
6891 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006892 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006893 snd_hda_codec_write(codec, nid, 0,
6894 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6895 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6896 snd_hda_codec_write(codec, nid, 0,
6897 AC_VERB_SET_AMP_GAIN_MUTE,
6898 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 }
6900}
6901
Takashi Iwaif511b012008-08-15 16:46:42 +02006902static void alc882_auto_init_input_src(struct hda_codec *codec)
6903{
6904 struct alc_spec *spec = codec->spec;
6905 const struct hda_input_mux *imux = spec->input_mux;
6906 int c;
6907
6908 for (c = 0; c < spec->num_adc_nids; c++) {
6909 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6910 hda_nid_t nid = spec->capsrc_nids[c];
6911 int conns, mute, idx, item;
6912
6913 conns = snd_hda_get_connections(codec, nid, conn_list,
6914 ARRAY_SIZE(conn_list));
6915 if (conns < 0)
6916 continue;
6917 for (idx = 0; idx < conns; idx++) {
6918 /* if the current connection is the selected one,
6919 * unmute it as default - otherwise mute it
6920 */
6921 mute = AMP_IN_MUTE(idx);
6922 for (item = 0; item < imux->num_items; item++) {
6923 if (imux->items[item].index == idx) {
6924 if (spec->cur_mux[c] == item)
6925 mute = AMP_IN_UNMUTE(idx);
6926 break;
6927 }
6928 }
6929 snd_hda_codec_write(codec, nid, 0,
6930 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6931 }
6932 }
6933}
6934
Takashi Iwai776e1842007-08-29 15:07:11 +02006935/* add mic boosts if needed */
6936static int alc_auto_add_mic_boost(struct hda_codec *codec)
6937{
6938 struct alc_spec *spec = codec->spec;
6939 int err;
6940 hda_nid_t nid;
6941
6942 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006943 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006944 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6945 "Mic Boost",
6946 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6947 if (err < 0)
6948 return err;
6949 }
6950 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006951 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006952 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6953 "Front Mic Boost",
6954 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6955 if (err < 0)
6956 return err;
6957 }
6958 return 0;
6959}
6960
Kailang Yangdf694da2005-12-05 19:42:22 +01006961/* almost identical with ALC880 parser... */
6962static int alc882_parse_auto_config(struct hda_codec *codec)
6963{
6964 struct alc_spec *spec = codec->spec;
6965 int err = alc880_parse_auto_config(codec);
6966
6967 if (err < 0)
6968 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006969 else if (!err)
6970 return 0; /* no config found */
6971
6972 err = alc_auto_add_mic_boost(codec);
6973 if (err < 0)
6974 return err;
6975
6976 /* hack - override the init verbs */
6977 spec->init_verbs[0] = alc882_auto_init_verbs;
6978
6979 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006980}
6981
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006982/* additional initialization for auto-configuration model */
6983static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006984{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006985 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006986 alc882_auto_init_multi_out(codec);
6987 alc882_auto_init_hp_out(codec);
6988 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006989 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006990 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006991 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006992}
6993
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006994static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6995
Linus Torvalds1da177e2005-04-16 15:20:36 -07006996static int patch_alc882(struct hda_codec *codec)
6997{
6998 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006999 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007000
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007001 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007002 if (spec == NULL)
7003 return -ENOMEM;
7004
Linus Torvalds1da177e2005-04-16 15:20:36 -07007005 codec->spec = spec;
7006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007007 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7008 alc882_models,
7009 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007010
Kailang Yangdf694da2005-12-05 19:42:22 +01007011 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007012 /* Pick up systems that don't supply PCI SSID */
7013 switch (codec->subsystem_id) {
7014 case 0x106b0c00: /* Mac Pro */
7015 board_config = ALC885_MACPRO;
7016 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007017 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007018 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007019 board_config = ALC885_IMAC24;
7020 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007021 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007022 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007023 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007024 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007025 board_config = ALC885_MBP3;
7026 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007027 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007028 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007029 if (codec->revision_id == 0x100101 ||
7030 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007031 alc_free(codec);
7032 return patch_alc883(codec);
7033 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007034 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7035 "trying auto-probe from BIOS...\n");
7036 board_config = ALC882_AUTO;
7037 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007039
Takashi Iwaif95474e2007-07-10 00:47:43 +02007040 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7041
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 if (board_config == ALC882_AUTO) {
7043 /* automatic parse from the BIOS config */
7044 err = alc882_parse_auto_config(codec);
7045 if (err < 0) {
7046 alc_free(codec);
7047 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007048 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007049 printk(KERN_INFO
7050 "hda_codec: Cannot set up configuration "
7051 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007052 board_config = ALC882_3ST_DIG;
7053 }
7054 }
7055
7056 if (board_config != ALC882_AUTO)
7057 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007058
Kailang Yang2f893282008-05-27 12:14:47 +02007059 if (codec->vendor_id == 0x10ec0885) {
7060 spec->stream_name_analog = "ALC885 Analog";
7061 spec->stream_name_digital = "ALC885 Digital";
7062 } else {
7063 spec->stream_name_analog = "ALC882 Analog";
7064 spec->stream_name_digital = "ALC882 Digital";
7065 }
7066
Kailang Yangdf694da2005-12-05 19:42:22 +01007067 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7068 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007069 /* FIXME: setup DAC5 */
7070 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7071 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7074 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007075
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007076 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007077 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007078 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007079 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007080 /* get type */
7081 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 if (wcap != AC_WID_AUD_IN) {
7083 spec->adc_nids = alc882_adc_nids_alt;
7084 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007085 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 } else {
7087 spec->adc_nids = alc882_adc_nids;
7088 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007089 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007090 }
7091 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007092 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007093
Takashi Iwai2134ea42008-01-10 16:53:55 +01007094 spec->vmaster_nid = 0x0c;
7095
Linus Torvalds1da177e2005-04-16 15:20:36 -07007096 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007097 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007098 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007099#ifdef CONFIG_SND_HDA_POWER_SAVE
7100 if (!spec->loopback.amplist)
7101 spec->loopback.amplist = alc882_loopbacks;
7102#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007103 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007104
7105 return 0;
7106}
7107
7108/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007109 * ALC883 support
7110 *
7111 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7112 * configuration. Each pin widget can choose any input DACs and a mixer.
7113 * Each ADC is connected from a mixer of all inputs. This makes possible
7114 * 6-channel independent captures.
7115 *
7116 * In addition, an independent DAC for the multi-playback (not used in this
7117 * driver yet).
7118 */
7119#define ALC883_DIGOUT_NID 0x06
7120#define ALC883_DIGIN_NID 0x0a
7121
Wu Fengguang3ab90932008-11-17 09:51:09 +01007122#define ALC1200_DIGOUT_NID 0x10
7123
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007124static hda_nid_t alc883_dac_nids[4] = {
7125 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007126 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007127};
7128
7129static hda_nid_t alc883_adc_nids[2] = {
7130 /* ADC1-2 */
7131 0x08, 0x09,
7132};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007133
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007134static hda_nid_t alc883_adc_nids_alt[1] = {
7135 /* ADC1 */
7136 0x08,
7137};
7138
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007139static hda_nid_t alc883_adc_nids_rev[2] = {
7140 /* ADC2-1 */
7141 0x09, 0x08
7142};
7143
Takashi Iwaie1406342008-02-11 18:32:32 +01007144static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7145
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007146static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7147
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007148/* input MUX */
7149/* FIXME: should be a matrix-type input source selection */
7150
7151static struct hda_input_mux alc883_capture_source = {
7152 .num_items = 4,
7153 .items = {
7154 { "Mic", 0x0 },
7155 { "Front Mic", 0x1 },
7156 { "Line", 0x2 },
7157 { "CD", 0x4 },
7158 },
7159};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007160
Jiang zhe17bba1b2008-06-04 12:11:07 +02007161static struct hda_input_mux alc883_3stack_6ch_intel = {
7162 .num_items = 4,
7163 .items = {
7164 { "Mic", 0x1 },
7165 { "Front Mic", 0x0 },
7166 { "Line", 0x2 },
7167 { "CD", 0x4 },
7168 },
7169};
7170
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007171static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7172 .num_items = 2,
7173 .items = {
7174 { "Mic", 0x1 },
7175 { "Line", 0x2 },
7176 },
7177};
7178
Kailang Yang272a5272007-05-14 11:00:38 +02007179static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7180 .num_items = 4,
7181 .items = {
7182 { "Mic", 0x0 },
7183 { "iMic", 0x1 },
7184 { "Line", 0x2 },
7185 { "CD", 0x4 },
7186 },
7187};
7188
Jiang zhefb97dc62008-03-06 11:07:11 +01007189static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7190 .num_items = 2,
7191 .items = {
7192 { "Mic", 0x0 },
7193 { "Int Mic", 0x1 },
7194 },
7195};
7196
Kailang Yange2757d52008-08-26 13:17:46 +02007197static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7198 .num_items = 3,
7199 .items = {
7200 { "Mic", 0x0 },
7201 { "Front Mic", 0x1 },
7202 { "Line", 0x4 },
7203 },
7204};
7205
7206static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7207 .num_items = 2,
7208 .items = {
7209 { "Mic", 0x0 },
7210 { "Line", 0x2 },
7211 },
7212};
7213
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007214/*
7215 * 2ch mode
7216 */
7217static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7218 { 2, NULL }
7219};
7220
7221/*
7222 * 2ch mode
7223 */
7224static struct hda_verb alc883_3ST_ch2_init[] = {
7225 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7226 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7227 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7228 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7229 { } /* end */
7230};
7231
7232/*
Tobin Davisb2011312007-09-17 12:45:11 +02007233 * 4ch mode
7234 */
7235static struct hda_verb alc883_3ST_ch4_init[] = {
7236 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7237 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7238 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7239 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7240 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7241 { } /* end */
7242};
7243
7244/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007245 * 6ch mode
7246 */
7247static struct hda_verb alc883_3ST_ch6_init[] = {
7248 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7249 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7250 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7251 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7252 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7253 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7254 { } /* end */
7255};
7256
Tobin Davisb2011312007-09-17 12:45:11 +02007257static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007258 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007259 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007260 { 6, alc883_3ST_ch6_init },
7261};
7262
7263/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007264 * 2ch mode
7265 */
7266static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7267 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7268 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7269 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7270 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7271 { } /* end */
7272};
7273
7274/*
7275 * 4ch mode
7276 */
7277static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7278 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7279 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7280 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7281 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7282 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7283 { } /* end */
7284};
7285
7286/*
7287 * 6ch mode
7288 */
7289static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7290 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7291 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7292 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7293 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7294 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7295 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7296 { } /* end */
7297};
7298
7299static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7300 { 2, alc883_3ST_ch2_intel_init },
7301 { 4, alc883_3ST_ch4_intel_init },
7302 { 6, alc883_3ST_ch6_intel_init },
7303};
7304
7305/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007306 * 6ch mode
7307 */
7308static struct hda_verb alc883_sixstack_ch6_init[] = {
7309 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7310 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7311 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7312 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7313 { } /* end */
7314};
7315
7316/*
7317 * 8ch mode
7318 */
7319static struct hda_verb alc883_sixstack_ch8_init[] = {
7320 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7321 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7322 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7323 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7324 { } /* end */
7325};
7326
7327static struct hda_channel_mode alc883_sixstack_modes[2] = {
7328 { 6, alc883_sixstack_ch6_init },
7329 { 8, alc883_sixstack_ch8_init },
7330};
7331
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007332static struct hda_verb alc883_medion_eapd_verbs[] = {
7333 /* eanable EAPD on medion laptop */
7334 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7335 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7336 { }
7337};
7338
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007339/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7340 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7341 */
7342
7343static struct snd_kcontrol_new alc883_base_mixer[] = {
7344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7346 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7347 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7348 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7349 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7350 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7351 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7352 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7353 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7355 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7356 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_VOLUME("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),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007363 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007364 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7365 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7366 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007367 { } /* end */
7368};
7369
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007370static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7371 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7372 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7379 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7381 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7382 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007384 { } /* end */
7385};
7386
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007387static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007388 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7389 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7390 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7391 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7395 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7396 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7397 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007398 { } /* end */
7399};
7400
Jiang zhefb97dc62008-03-06 11:07:11 +01007401static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7403 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7404 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7405 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7409 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7410 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7411 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007412 { } /* end */
7413};
7414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007415static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7417 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007424 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007427 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7429 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7430 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007431 { } /* end */
7432};
7433
7434static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7435 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7436 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7437 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7438 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7439 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7440 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7441 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7442 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7451 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007452 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7454 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7455 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007456 { } /* end */
7457};
7458
Jiang zhe17bba1b2008-06-04 12:11:07 +02007459static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7460 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7462 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7463 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7464 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7465 HDA_OUTPUT),
7466 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7467 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7468 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7473 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7475 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7476 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7477 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7478 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7479 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7480 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7481 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007482 { } /* end */
7483};
7484
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007485static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007487 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007488 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007489 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007490 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7491 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007492 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7493 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7499 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007500 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7502 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007503 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7505 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7506 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007507 { } /* end */
7508};
7509
Kailang Yangccc656c2006-10-17 12:32:26 +02007510static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7513 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7514 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7515 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7516 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7517 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7518 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7519 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7520 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7521 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007525 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007526 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007527 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007528};
Kailang Yangccc656c2006-10-17 12:32:26 +02007529
7530static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7531 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7533 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7534 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7535 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007537 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007539 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7540 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7541 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007542 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007543};
Kailang Yangccc656c2006-10-17 12:32:26 +02007544
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007545static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7547 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7549 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007554 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007555};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007556
Kailang Yang272a5272007-05-14 11:00:38 +02007557static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7558 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7559 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7565 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7566 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007567 { } /* end */
7568};
7569
7570static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7571 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7573 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007580 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007581};
Kailang Yang272a5272007-05-14 11:00:38 +02007582
Tobin Davis2880a862007-08-07 11:50:26 +02007583static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7585 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007592 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007593};
Tobin Davis2880a862007-08-07 11:50:26 +02007594
Kailang Yange2757d52008-08-26 13:17:46 +02007595static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7596 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7597 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7598 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7599 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7600 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7601 0x0d, 1, 0x0, HDA_OUTPUT),
7602 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7603 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7604 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7605 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7606 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7608 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7609 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7610 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7611 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7612 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7614 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7616 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7617 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7618 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007619 { } /* end */
7620};
7621
7622static struct hda_bind_ctls alc883_bind_cap_vol = {
7623 .ops = &snd_hda_bind_vol,
7624 .values = {
7625 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7626 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7627 0
7628 },
7629};
7630
7631static struct hda_bind_ctls alc883_bind_cap_switch = {
7632 .ops = &snd_hda_bind_sw,
7633 .values = {
7634 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7635 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7636 0
7637 },
7638};
7639
7640static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7641 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7642 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7647 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007649 { } /* end */
7650};
7651
7652static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007653 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7654 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7655 {
7656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7657 /* .name = "Capture Source", */
7658 .name = "Input Source",
7659 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007660 .info = alc_mux_enum_info,
7661 .get = alc_mux_enum_get,
7662 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007663 },
7664 { } /* end */
7665};
7666
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007667static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7668 {
7669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7670 .name = "Channel Mode",
7671 .info = alc_ch_mode_info,
7672 .get = alc_ch_mode_get,
7673 .put = alc_ch_mode_put,
7674 },
7675 { } /* end */
7676};
7677
7678static struct hda_verb alc883_init_verbs[] = {
7679 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7682 /* ADC2: mute amp left and right */
7683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7689 /* Rear mixer */
7690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7692 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7693 /* CLFE mixer */
7694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7697 /* Side mixer */
7698 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7700 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7701
Takashi Iwaicb53c622007-08-10 17:21:45 +02007702 /* mute analog input loopbacks */
7703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007708
7709 /* Front Pin: output 0 (0x0c) */
7710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7712 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7713 /* Rear Pin: output 1 (0x0d) */
7714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7717 /* CLFE Pin: output 2 (0x0e) */
7718 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7720 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7721 /* Side Pin: output 3 (0x0f) */
7722 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7724 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7725 /* Mic (rear) pin: input vref at 80% */
7726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7728 /* Front Mic pin: input vref at 80% */
7729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7731 /* Line In pin: input */
7732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7734 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7737 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7738 /* CD pin widget for input */
7739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7740
7741 /* FIXME: use matrix-type input source selection */
7742 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7743 /* Input mixer2 */
7744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007745 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7746 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007748 /* Input mixer3 */
7749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007753 { }
7754};
7755
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007756/* toggle speaker-output according to the hp-jack state */
7757static void alc883_mitac_hp_automute(struct hda_codec *codec)
7758{
7759 unsigned int present;
7760
7761 present = snd_hda_codec_read(codec, 0x15, 0,
7762 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7763 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7764 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7765 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7766 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7767}
7768
7769/* auto-toggle front mic */
7770/*
7771static void alc883_mitac_mic_automute(struct hda_codec *codec)
7772{
7773 unsigned int present;
7774 unsigned char bits;
7775
7776 present = snd_hda_codec_read(codec, 0x18, 0,
7777 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7778 bits = present ? HDA_AMP_MUTE : 0;
7779 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7780}
7781*/
7782
7783static void alc883_mitac_automute(struct hda_codec *codec)
7784{
7785 alc883_mitac_hp_automute(codec);
7786 /* alc883_mitac_mic_automute(codec); */
7787}
7788
7789static void alc883_mitac_unsol_event(struct hda_codec *codec,
7790 unsigned int res)
7791{
7792 switch (res >> 26) {
7793 case ALC880_HP_EVENT:
7794 alc883_mitac_hp_automute(codec);
7795 break;
7796 case ALC880_MIC_EVENT:
7797 /* alc883_mitac_mic_automute(codec); */
7798 break;
7799 }
7800}
7801
7802static struct hda_verb alc883_mitac_verbs[] = {
7803 /* HP */
7804 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7806 /* Subwoofer */
7807 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7808 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7809
7810 /* enable unsolicited event */
7811 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7812 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7813
7814 { } /* end */
7815};
7816
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007817static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007818 /* HP */
7819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7821 /* Int speaker */
7822 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7824
7825 /* enable unsolicited event */
7826 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007827 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007828
7829 { } /* end */
7830};
7831
Jiang zhefb97dc62008-03-06 11:07:11 +01007832static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7833 /* HP */
7834 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7836 /* Subwoofer */
7837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7838 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7839
7840 /* enable unsolicited event */
7841 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7842
7843 { } /* end */
7844};
7845
Kailang Yangccc656c2006-10-17 12:32:26 +02007846static struct hda_verb alc883_tagra_verbs[] = {
7847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7849
7850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7851 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007852
Kailang Yangccc656c2006-10-17 12:32:26 +02007853 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7854 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7855 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7856
7857 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007858 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7859 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7860 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007861
7862 { } /* end */
7863};
7864
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007865static struct hda_verb alc883_lenovo_101e_verbs[] = {
7866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7867 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7868 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7869 { } /* end */
7870};
7871
Kailang Yang272a5272007-05-14 11:00:38 +02007872static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7873 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7876 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7877 { } /* end */
7878};
7879
7880static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7885 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7886 { } /* end */
7887};
7888
Kailang Yang189609a2007-08-20 11:31:23 +02007889static struct hda_verb alc883_haier_w66_verbs[] = {
7890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7892
7893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7894
7895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7896 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7897 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7899 { } /* end */
7900};
7901
Kailang Yange2757d52008-08-26 13:17:46 +02007902static struct hda_verb alc888_lenovo_sky_verbs[] = {
7903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7908 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7909 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7910 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7911 { } /* end */
7912};
7913
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007914static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007915 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007916 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7917 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007918 { }
7919};
7920
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007921static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007922 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7923 { }
7924};
7925
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007926static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007927 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7928 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7929 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7930 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7931 { }
7932};
7933
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007934static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007935 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7936 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7937 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7938 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7939 { }
7940};
7941
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007942static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7943 { 2, alc888_3st_hp_2ch_init },
7944 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007945};
7946
Kailang Yang272a5272007-05-14 11:00:38 +02007947/* toggle front-jack and RCA according to the hp-jack state */
7948static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7949{
7950 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007951
Kailang Yang272a5272007-05-14 11:00:38 +02007952 present = snd_hda_codec_read(codec, 0x1b, 0,
7953 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007954 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7955 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7956 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7957 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007958}
7959
7960/* toggle RCA according to the front-jack state */
7961static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7962{
7963 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007964
Kailang Yang272a5272007-05-14 11:00:38 +02007965 present = snd_hda_codec_read(codec, 0x14, 0,
7966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007967 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7968 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007969}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007970
Kailang Yang272a5272007-05-14 11:00:38 +02007971static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7972 unsigned int res)
7973{
7974 if ((res >> 26) == ALC880_HP_EVENT)
7975 alc888_lenovo_ms7195_front_automute(codec);
7976 if ((res >> 26) == ALC880_FRONT_EVENT)
7977 alc888_lenovo_ms7195_rca_automute(codec);
7978}
7979
7980static struct hda_verb alc883_medion_md2_verbs[] = {
7981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7983
7984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7985
7986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7987 { } /* end */
7988};
7989
7990/* toggle speaker-output according to the hp-jack state */
7991static void alc883_medion_md2_automute(struct hda_codec *codec)
7992{
7993 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007994
Kailang Yang272a5272007-05-14 11:00:38 +02007995 present = snd_hda_codec_read(codec, 0x14, 0,
7996 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007997 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7998 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007999}
8000
8001static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8002 unsigned int res)
8003{
8004 if ((res >> 26) == ALC880_HP_EVENT)
8005 alc883_medion_md2_automute(codec);
8006}
8007
Kailang Yangccc656c2006-10-17 12:32:26 +02008008/* toggle speaker-output according to the hp-jack state */
8009static void alc883_tagra_automute(struct hda_codec *codec)
8010{
8011 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008012 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008013
8014 present = snd_hda_codec_read(codec, 0x14, 0,
8015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008016 bits = present ? HDA_AMP_MUTE : 0;
8017 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8018 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008019 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8020 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008021}
8022
8023static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8024{
8025 if ((res >> 26) == ALC880_HP_EVENT)
8026 alc883_tagra_automute(codec);
8027}
8028
Jiang zhe368c7a92008-03-04 11:20:33 +01008029/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008030static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008031{
8032 unsigned int present;
8033 unsigned char bits;
8034
8035 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8036 & AC_PINSENSE_PRESENCE;
8037 bits = present ? HDA_AMP_MUTE : 0;
8038 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8039 HDA_AMP_MUTE, bits);
8040}
8041
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008042static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8043{
8044 unsigned int present;
8045
8046 present = snd_hda_codec_read(codec, 0x18, 0,
8047 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8048 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8049 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8050}
8051
8052static void alc883_clevo_m720_automute(struct hda_codec *codec)
8053{
8054 alc883_clevo_m720_hp_automute(codec);
8055 alc883_clevo_m720_mic_automute(codec);
8056}
8057
8058static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008059 unsigned int res)
8060{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008061 switch (res >> 26) {
8062 case ALC880_HP_EVENT:
8063 alc883_clevo_m720_hp_automute(codec);
8064 break;
8065 case ALC880_MIC_EVENT:
8066 alc883_clevo_m720_mic_automute(codec);
8067 break;
8068 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008069}
8070
Jiang zhefb97dc62008-03-06 11:07:11 +01008071/* toggle speaker-output according to the hp-jack state */
8072static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8073{
8074 unsigned int present;
8075 unsigned char bits;
8076
8077 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8078 & AC_PINSENSE_PRESENCE;
8079 bits = present ? HDA_AMP_MUTE : 0;
8080 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8081 HDA_AMP_MUTE, bits);
8082}
8083
8084static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8085 unsigned int res)
8086{
8087 if ((res >> 26) == ALC880_HP_EVENT)
8088 alc883_2ch_fujitsu_pi2515_automute(codec);
8089}
8090
Kailang Yang189609a2007-08-20 11:31:23 +02008091static void alc883_haier_w66_automute(struct hda_codec *codec)
8092{
8093 unsigned int present;
8094 unsigned char bits;
8095
8096 present = snd_hda_codec_read(codec, 0x1b, 0,
8097 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8098 bits = present ? 0x80 : 0;
8099 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8100 0x80, bits);
8101}
8102
8103static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8104 unsigned int res)
8105{
8106 if ((res >> 26) == ALC880_HP_EVENT)
8107 alc883_haier_w66_automute(codec);
8108}
8109
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008110static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8111{
8112 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008113 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008114
8115 present = snd_hda_codec_read(codec, 0x14, 0,
8116 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008117 bits = present ? HDA_AMP_MUTE : 0;
8118 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8119 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008120}
8121
8122static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8123{
8124 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008125 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008126
8127 present = snd_hda_codec_read(codec, 0x1b, 0,
8128 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008129 bits = present ? HDA_AMP_MUTE : 0;
8130 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8131 HDA_AMP_MUTE, bits);
8132 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8133 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008134}
8135
8136static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8137 unsigned int res)
8138{
8139 if ((res >> 26) == ALC880_HP_EVENT)
8140 alc883_lenovo_101e_all_automute(codec);
8141 if ((res >> 26) == ALC880_FRONT_EVENT)
8142 alc883_lenovo_101e_ispeaker_automute(codec);
8143}
8144
Takashi Iwai676a9b52007-08-16 15:23:35 +02008145/* toggle speaker-output according to the hp-jack state */
8146static void alc883_acer_aspire_automute(struct hda_codec *codec)
8147{
8148 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008149
Takashi Iwai676a9b52007-08-16 15:23:35 +02008150 present = snd_hda_codec_read(codec, 0x14, 0,
8151 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8152 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8153 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8154 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8155 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8156}
8157
8158static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8159 unsigned int res)
8160{
8161 if ((res >> 26) == ALC880_HP_EVENT)
8162 alc883_acer_aspire_automute(codec);
8163}
8164
Kailang Yangd1a991a2007-08-15 16:21:59 +02008165static struct hda_verb alc883_acer_eapd_verbs[] = {
8166 /* HP Pin: output 0 (0x0c) */
8167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8169 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8170 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8172 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008174 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8175 /* eanable EAPD on medion laptop */
8176 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8177 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008178 /* enable unsolicited event */
8179 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008180 { }
8181};
8182
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008183static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8184{
8185 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008186
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008187 present = snd_hda_codec_read(codec, 0x1b, 0,
8188 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8189 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8190 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8191 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8192 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8193 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8194 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8195 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8196 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8197}
8198
8199static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8200 unsigned int res)
8201{
8202 switch (res >> 26) {
8203 case ALC880_HP_EVENT:
8204 printk("hp_event\n");
8205 alc888_6st_dell_front_automute(codec);
8206 break;
8207 }
8208}
8209
Kailang Yange2757d52008-08-26 13:17:46 +02008210static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8211{
8212 unsigned int mute;
8213 unsigned int present;
8214
8215 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8216 present = snd_hda_codec_read(codec, 0x1b, 0,
8217 AC_VERB_GET_PIN_SENSE, 0);
8218 present = (present & 0x80000000) != 0;
8219 if (present) {
8220 /* mute internal speaker */
8221 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8222 HDA_AMP_MUTE, HDA_AMP_MUTE);
8223 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8224 HDA_AMP_MUTE, HDA_AMP_MUTE);
8225 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8226 HDA_AMP_MUTE, HDA_AMP_MUTE);
8227 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8228 HDA_AMP_MUTE, HDA_AMP_MUTE);
8229 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8230 HDA_AMP_MUTE, HDA_AMP_MUTE);
8231 } else {
8232 /* unmute internal speaker if necessary */
8233 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8234 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8235 HDA_AMP_MUTE, mute);
8236 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8237 HDA_AMP_MUTE, mute);
8238 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8239 HDA_AMP_MUTE, mute);
8240 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8241 HDA_AMP_MUTE, mute);
8242 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8243 HDA_AMP_MUTE, mute);
8244 }
8245}
8246
8247static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8248 unsigned int res)
8249{
8250 if ((res >> 26) == ALC880_HP_EVENT)
8251 alc888_lenovo_sky_front_automute(codec);
8252}
8253
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008254/*
8255 * generic initialization of ADC, input mixers and output mixers
8256 */
8257static struct hda_verb alc883_auto_init_verbs[] = {
8258 /*
8259 * Unmute ADC0-2 and set the default input to mic-in
8260 */
8261 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8265
Takashi Iwaicb53c622007-08-10 17:21:45 +02008266 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008267 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008268 * Note: PASD motherboards uses the Line In 2 as the input for
8269 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008270 */
8271 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008277
8278 /*
8279 * Set up output mixers (0x0c - 0x0f)
8280 */
8281 /* set vol=0 to output mixers */
8282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8286 /* set up input amps for analog loopback */
8287 /* Amp Indices: DAC = 0, mixer = 1 */
8288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8296 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8298
8299 /* FIXME: use matrix-type input source selection */
8300 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8301 /* Input mixer1 */
8302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008305 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8307 /* Input mixer2 */
8308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008311 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008313
8314 { }
8315};
8316
Kailang Yange2757d52008-08-26 13:17:46 +02008317static struct hda_verb alc888_asus_m90v_verbs[] = {
8318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8321 /* enable unsolicited event */
8322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8323 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8324 { } /* end */
8325};
8326
8327static void alc883_nb_mic_automute(struct hda_codec *codec)
8328{
8329 unsigned int present;
8330
8331 present = snd_hda_codec_read(codec, 0x18, 0,
8332 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8333 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8334 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8335 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8336 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8337}
8338
8339static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8340{
8341 unsigned int present;
8342 unsigned char bits;
8343
8344 present = snd_hda_codec_read(codec, 0x1b, 0,
8345 AC_VERB_GET_PIN_SENSE, 0)
8346 & AC_PINSENSE_PRESENCE;
8347 bits = present ? 0 : PIN_OUT;
8348 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8349 bits);
8350 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8351 bits);
8352 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8353 bits);
8354}
8355
8356static void alc883_mode2_unsol_event(struct hda_codec *codec,
8357 unsigned int res)
8358{
8359 switch (res >> 26) {
8360 case ALC880_HP_EVENT:
8361 alc883_M90V_speaker_automute(codec);
8362 break;
8363 case ALC880_MIC_EVENT:
8364 alc883_nb_mic_automute(codec);
8365 break;
8366 }
8367}
8368
8369static void alc883_mode2_inithook(struct hda_codec *codec)
8370{
8371 alc883_M90V_speaker_automute(codec);
8372 alc883_nb_mic_automute(codec);
8373}
8374
8375static struct hda_verb alc888_asus_eee1601_verbs[] = {
8376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8381 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8382 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8383 /* enable unsolicited event */
8384 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8385 { } /* end */
8386};
8387
8388static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8389{
8390 unsigned int present;
8391 unsigned char bits;
8392
8393 present = snd_hda_codec_read(codec, 0x14, 0,
8394 AC_VERB_GET_PIN_SENSE, 0)
8395 & AC_PINSENSE_PRESENCE;
8396 bits = present ? 0 : PIN_OUT;
8397 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8398 bits);
8399}
8400
8401static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8402 unsigned int res)
8403{
8404 switch (res >> 26) {
8405 case ALC880_HP_EVENT:
8406 alc883_eee1601_speaker_automute(codec);
8407 break;
8408 }
8409}
8410
8411static void alc883_eee1601_inithook(struct hda_codec *codec)
8412{
8413 alc883_eee1601_speaker_automute(codec);
8414}
8415
Takashi Iwaicb53c622007-08-10 17:21:45 +02008416#ifdef CONFIG_SND_HDA_POWER_SAVE
8417#define alc883_loopbacks alc880_loopbacks
8418#endif
8419
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008420/* pcm configuration: identiacal with ALC880 */
8421#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8422#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008423#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008424#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8425#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8426
8427/*
8428 * configuration and preset
8429 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008430static const char *alc883_models[ALC883_MODEL_LAST] = {
8431 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8432 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8433 [ALC883_3ST_6ch] = "3stack-6ch",
8434 [ALC883_6ST_DIG] = "6stack-dig",
8435 [ALC883_TARGA_DIG] = "targa-dig",
8436 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008437 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008438 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008439 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008440 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008441 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008442 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008443 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008444 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8445 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008446 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008447 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008448 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008449 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008450 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008451 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008452 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008453 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008454 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008455 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008456 [ALC883_AUTO] = "auto",
8457};
8458
8459static struct snd_pci_quirk alc883_cfg_tbl[] = {
8460 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008461 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008462 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008463 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8464 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008465 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008466 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8467 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008468 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8469 ALC888_ACER_ASPIRE_4930G),
8470 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8471 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008472 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008473 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008474 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008475 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8476 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008477 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008478 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008479 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008480 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008481 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008482 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008483 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008484 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008485 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008486 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8487 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008488 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008489 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008490 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008491 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8492 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8493 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008494 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008495 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008496 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008497 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8498 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8499 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8500 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8501 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8502 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8503 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8504 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8505 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008506 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8507 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008508 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008509 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008510 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008511 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008512 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008513 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008514 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008515 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8516 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008517 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008518 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008519 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008520 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008521 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8522 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008523 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008524 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008525 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8526 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008527 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008528 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008529 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008530 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008531 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008532 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8533 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008534 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008535 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008536 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008537 {}
8538};
8539
8540static struct alc_config_preset alc883_presets[] = {
8541 [ALC883_3ST_2ch_DIG] = {
8542 .mixers = { alc883_3ST_2ch_mixer },
8543 .init_verbs = { alc883_init_verbs },
8544 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8545 .dac_nids = alc883_dac_nids,
8546 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008547 .dig_in_nid = ALC883_DIGIN_NID,
8548 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8549 .channel_mode = alc883_3ST_2ch_modes,
8550 .input_mux = &alc883_capture_source,
8551 },
8552 [ALC883_3ST_6ch_DIG] = {
8553 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8554 .init_verbs = { alc883_init_verbs },
8555 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8556 .dac_nids = alc883_dac_nids,
8557 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008558 .dig_in_nid = ALC883_DIGIN_NID,
8559 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8560 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008561 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008562 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008563 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008564 [ALC883_3ST_6ch] = {
8565 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8566 .init_verbs = { alc883_init_verbs },
8567 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8568 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008569 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8570 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008571 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008572 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008573 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008574 [ALC883_3ST_6ch_INTEL] = {
8575 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8576 .init_verbs = { alc883_init_verbs },
8577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8578 .dac_nids = alc883_dac_nids,
8579 .dig_out_nid = ALC883_DIGOUT_NID,
8580 .dig_in_nid = ALC883_DIGIN_NID,
8581 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8582 .channel_mode = alc883_3ST_6ch_intel_modes,
8583 .need_dac_fix = 1,
8584 .input_mux = &alc883_3stack_6ch_intel,
8585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586 [ALC883_6ST_DIG] = {
8587 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8588 .init_verbs = { alc883_init_verbs },
8589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8590 .dac_nids = alc883_dac_nids,
8591 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008592 .dig_in_nid = ALC883_DIGIN_NID,
8593 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8594 .channel_mode = alc883_sixstack_modes,
8595 .input_mux = &alc883_capture_source,
8596 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008597 [ALC883_TARGA_DIG] = {
8598 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8599 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8600 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8601 .dac_nids = alc883_dac_nids,
8602 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008603 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8604 .channel_mode = alc883_3ST_6ch_modes,
8605 .need_dac_fix = 1,
8606 .input_mux = &alc883_capture_source,
8607 .unsol_event = alc883_tagra_unsol_event,
8608 .init_hook = alc883_tagra_automute,
8609 },
8610 [ALC883_TARGA_2ch_DIG] = {
8611 .mixers = { alc883_tagra_2ch_mixer},
8612 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8614 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008615 .adc_nids = alc883_adc_nids_alt,
8616 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008617 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8619 .channel_mode = alc883_3ST_2ch_modes,
8620 .input_mux = &alc883_capture_source,
8621 .unsol_event = alc883_tagra_unsol_event,
8622 .init_hook = alc883_tagra_automute,
8623 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008624 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008625 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008626 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8627 * and the headphone jack. Turn this on and rely on the
8628 * standard mute methods whenever the user wants to turn
8629 * these outputs off.
8630 */
8631 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8632 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8633 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008634 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8635 .channel_mode = alc883_3ST_2ch_modes,
8636 .input_mux = &alc883_capture_source,
8637 },
Tobin Davis2880a862007-08-07 11:50:26 +02008638 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008639 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008640 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008641 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8642 .dac_nids = alc883_dac_nids,
8643 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008644 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8645 .channel_mode = alc883_3ST_2ch_modes,
8646 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008647 .unsol_event = alc883_acer_aspire_unsol_event,
8648 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008649 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008650 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008651 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008652 alc883_chmode_mixer },
8653 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8654 alc888_acer_aspire_4930g_verbs },
8655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8656 .dac_nids = alc883_dac_nids,
8657 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8658 .adc_nids = alc883_adc_nids_rev,
8659 .capsrc_nids = alc883_capsrc_nids_rev,
8660 .dig_out_nid = ALC883_DIGOUT_NID,
8661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8662 .channel_mode = alc883_3ST_6ch_modes,
8663 .need_dac_fix = 1,
8664 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008665 ARRAY_SIZE(alc888_2_capture_sources),
8666 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008667 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8668 .init_hook = alc888_acer_aspire_4930g_automute,
8669 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008670 [ALC883_MEDION] = {
8671 .mixers = { alc883_fivestack_mixer,
8672 alc883_chmode_mixer },
8673 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008674 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008675 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8676 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008677 .adc_nids = alc883_adc_nids_alt,
8678 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008679 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8680 .channel_mode = alc883_sixstack_modes,
8681 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008682 },
Kailang Yang272a5272007-05-14 11:00:38 +02008683 [ALC883_MEDION_MD2] = {
8684 .mixers = { alc883_medion_md2_mixer},
8685 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8687 .dac_nids = alc883_dac_nids,
8688 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008689 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8690 .channel_mode = alc883_3ST_2ch_modes,
8691 .input_mux = &alc883_capture_source,
8692 .unsol_event = alc883_medion_md2_unsol_event,
8693 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008694 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008695 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008696 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008697 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8698 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8699 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008700 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8701 .channel_mode = alc883_3ST_2ch_modes,
8702 .input_mux = &alc883_capture_source,
8703 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008704 [ALC883_CLEVO_M720] = {
8705 .mixers = { alc883_clevo_m720_mixer },
8706 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8708 .dac_nids = alc883_dac_nids,
8709 .dig_out_nid = ALC883_DIGOUT_NID,
8710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8711 .channel_mode = alc883_3ST_2ch_modes,
8712 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008713 .unsol_event = alc883_clevo_m720_unsol_event,
8714 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008715 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008716 [ALC883_LENOVO_101E_2ch] = {
8717 .mixers = { alc883_lenovo_101e_2ch_mixer},
8718 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8719 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8720 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008721 .adc_nids = alc883_adc_nids_alt,
8722 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008723 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8724 .channel_mode = alc883_3ST_2ch_modes,
8725 .input_mux = &alc883_lenovo_101e_capture_source,
8726 .unsol_event = alc883_lenovo_101e_unsol_event,
8727 .init_hook = alc883_lenovo_101e_all_automute,
8728 },
Kailang Yang272a5272007-05-14 11:00:38 +02008729 [ALC883_LENOVO_NB0763] = {
8730 .mixers = { alc883_lenovo_nb0763_mixer },
8731 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8732 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8733 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8735 .channel_mode = alc883_3ST_2ch_modes,
8736 .need_dac_fix = 1,
8737 .input_mux = &alc883_lenovo_nb0763_capture_source,
8738 .unsol_event = alc883_medion_md2_unsol_event,
8739 .init_hook = alc883_medion_md2_automute,
8740 },
8741 [ALC888_LENOVO_MS7195_DIG] = {
8742 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8743 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
8746 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8748 .channel_mode = alc883_3ST_6ch_modes,
8749 .need_dac_fix = 1,
8750 .input_mux = &alc883_capture_source,
8751 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8752 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008753 },
8754 [ALC883_HAIER_W66] = {
8755 .mixers = { alc883_tagra_2ch_mixer},
8756 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8757 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8758 .dac_nids = alc883_dac_nids,
8759 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008760 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8761 .channel_mode = alc883_3ST_2ch_modes,
8762 .input_mux = &alc883_capture_source,
8763 .unsol_event = alc883_haier_w66_unsol_event,
8764 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008765 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008766 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008767 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008768 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008769 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8770 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008771 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8772 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008773 .need_dac_fix = 1,
8774 .input_mux = &alc883_capture_source,
8775 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008776 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008777 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008778 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8780 .dac_nids = alc883_dac_nids,
8781 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008782 .dig_in_nid = ALC883_DIGIN_NID,
8783 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8784 .channel_mode = alc883_sixstack_modes,
8785 .input_mux = &alc883_capture_source,
8786 .unsol_event = alc888_6st_dell_unsol_event,
8787 .init_hook = alc888_6st_dell_front_automute,
8788 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008789 [ALC883_MITAC] = {
8790 .mixers = { alc883_mitac_mixer },
8791 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8793 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8795 .channel_mode = alc883_3ST_2ch_modes,
8796 .input_mux = &alc883_capture_source,
8797 .unsol_event = alc883_mitac_unsol_event,
8798 .init_hook = alc883_mitac_automute,
8799 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008800 [ALC883_FUJITSU_PI2515] = {
8801 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8802 .init_verbs = { alc883_init_verbs,
8803 alc883_2ch_fujitsu_pi2515_verbs},
8804 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8805 .dac_nids = alc883_dac_nids,
8806 .dig_out_nid = ALC883_DIGOUT_NID,
8807 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8808 .channel_mode = alc883_3ST_2ch_modes,
8809 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8810 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8811 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8812 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008813 [ALC888_FUJITSU_XA3530] = {
8814 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8815 .init_verbs = { alc883_init_verbs,
8816 alc888_fujitsu_xa3530_verbs },
8817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8818 .dac_nids = alc883_dac_nids,
8819 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8820 .adc_nids = alc883_adc_nids_rev,
8821 .capsrc_nids = alc883_capsrc_nids_rev,
8822 .dig_out_nid = ALC883_DIGOUT_NID,
8823 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8824 .channel_mode = alc888_4ST_8ch_intel_modes,
8825 .num_mux_defs =
8826 ARRAY_SIZE(alc888_2_capture_sources),
8827 .input_mux = alc888_2_capture_sources,
8828 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8829 .init_hook = alc888_fujitsu_xa3530_automute,
8830 },
Kailang Yange2757d52008-08-26 13:17:46 +02008831 [ALC888_LENOVO_SKY] = {
8832 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8833 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8834 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8835 .dac_nids = alc883_dac_nids,
8836 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008837 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8838 .channel_mode = alc883_sixstack_modes,
8839 .need_dac_fix = 1,
8840 .input_mux = &alc883_lenovo_sky_capture_source,
8841 .unsol_event = alc883_lenovo_sky_unsol_event,
8842 .init_hook = alc888_lenovo_sky_front_automute,
8843 },
8844 [ALC888_ASUS_M90V] = {
8845 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8846 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8847 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8848 .dac_nids = alc883_dac_nids,
8849 .dig_out_nid = ALC883_DIGOUT_NID,
8850 .dig_in_nid = ALC883_DIGIN_NID,
8851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8852 .channel_mode = alc883_3ST_6ch_modes,
8853 .need_dac_fix = 1,
8854 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8855 .unsol_event = alc883_mode2_unsol_event,
8856 .init_hook = alc883_mode2_inithook,
8857 },
8858 [ALC888_ASUS_EEE1601] = {
8859 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008860 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008861 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8863 .dac_nids = alc883_dac_nids,
8864 .dig_out_nid = ALC883_DIGOUT_NID,
8865 .dig_in_nid = ALC883_DIGIN_NID,
8866 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8867 .channel_mode = alc883_3ST_2ch_modes,
8868 .need_dac_fix = 1,
8869 .input_mux = &alc883_asus_eee1601_capture_source,
8870 .unsol_event = alc883_eee1601_unsol_event,
8871 .init_hook = alc883_eee1601_inithook,
8872 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008873 [ALC1200_ASUS_P5Q] = {
8874 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8875 .init_verbs = { alc883_init_verbs },
8876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8877 .dac_nids = alc883_dac_nids,
8878 .dig_out_nid = ALC1200_DIGOUT_NID,
8879 .dig_in_nid = ALC883_DIGIN_NID,
8880 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8881 .channel_mode = alc883_sixstack_modes,
8882 .input_mux = &alc883_capture_source,
8883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884};
8885
8886
8887/*
8888 * BIOS auto configuration
8889 */
8890static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8891 hda_nid_t nid, int pin_type,
8892 int dac_idx)
8893{
8894 /* set as output */
8895 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008896 int idx;
8897
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008898 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008899 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8900 idx = 4;
8901 else
8902 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8904
8905}
8906
8907static void alc883_auto_init_multi_out(struct hda_codec *codec)
8908{
8909 struct alc_spec *spec = codec->spec;
8910 int i;
8911
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008912 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008913 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008914 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008915 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008916 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008917 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008918 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008919 }
8920}
8921
8922static void alc883_auto_init_hp_out(struct hda_codec *codec)
8923{
8924 struct alc_spec *spec = codec->spec;
8925 hda_nid_t pin;
8926
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008927 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008928 if (pin) /* connect to front */
8929 /* use dac 0 */
8930 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008931 pin = spec->autocfg.speaker_pins[0];
8932 if (pin)
8933 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008934}
8935
8936#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8937#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8938
8939static void alc883_auto_init_analog_input(struct hda_codec *codec)
8940{
8941 struct alc_spec *spec = codec->spec;
8942 int i;
8943
8944 for (i = 0; i < AUTO_PIN_LAST; i++) {
8945 hda_nid_t nid = spec->autocfg.input_pins[i];
8946 if (alc883_is_input_pin(nid)) {
8947 snd_hda_codec_write(codec, nid, 0,
8948 AC_VERB_SET_PIN_WIDGET_CONTROL,
8949 (i <= AUTO_PIN_FRONT_MIC ?
8950 PIN_VREF80 : PIN_IN));
8951 if (nid != ALC883_PIN_CD_NID)
8952 snd_hda_codec_write(codec, nid, 0,
8953 AC_VERB_SET_AMP_GAIN_MUTE,
8954 AMP_OUT_MUTE);
8955 }
8956 }
8957}
8958
Takashi Iwaif511b012008-08-15 16:46:42 +02008959#define alc883_auto_init_input_src alc882_auto_init_input_src
8960
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008961/* almost identical with ALC880 parser... */
8962static int alc883_parse_auto_config(struct hda_codec *codec)
8963{
8964 struct alc_spec *spec = codec->spec;
8965 int err = alc880_parse_auto_config(codec);
8966
8967 if (err < 0)
8968 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008969 else if (!err)
8970 return 0; /* no config found */
8971
8972 err = alc_auto_add_mic_boost(codec);
8973 if (err < 0)
8974 return err;
8975
8976 /* hack - override the init verbs */
8977 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008978
8979 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008980}
8981
8982/* additional initialization for auto-configuration model */
8983static void alc883_auto_init(struct hda_codec *codec)
8984{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008985 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008986 alc883_auto_init_multi_out(codec);
8987 alc883_auto_init_hp_out(codec);
8988 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008989 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008990 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008991 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008992}
8993
8994static int patch_alc883(struct hda_codec *codec)
8995{
8996 struct alc_spec *spec;
8997 int err, board_config;
8998
8999 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9000 if (spec == NULL)
9001 return -ENOMEM;
9002
9003 codec->spec = spec;
9004
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009005 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9006
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009007 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9008 alc883_models,
9009 alc883_cfg_tbl);
9010 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009011 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9012 "trying auto-probe from BIOS...\n");
9013 board_config = ALC883_AUTO;
9014 }
9015
9016 if (board_config == ALC883_AUTO) {
9017 /* automatic parse from the BIOS config */
9018 err = alc883_parse_auto_config(codec);
9019 if (err < 0) {
9020 alc_free(codec);
9021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009022 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009023 printk(KERN_INFO
9024 "hda_codec: Cannot set up configuration "
9025 "from BIOS. Using base mode...\n");
9026 board_config = ALC883_3ST_2ch_DIG;
9027 }
9028 }
9029
9030 if (board_config != ALC883_AUTO)
9031 setup_preset(spec, &alc883_presets[board_config]);
9032
Kailang Yang2f893282008-05-27 12:14:47 +02009033 switch (codec->vendor_id) {
9034 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009035 if (codec->revision_id == 0x100101) {
9036 spec->stream_name_analog = "ALC1200 Analog";
9037 spec->stream_name_digital = "ALC1200 Digital";
9038 } else {
9039 spec->stream_name_analog = "ALC888 Analog";
9040 spec->stream_name_digital = "ALC888 Digital";
9041 }
Kailang Yang2f893282008-05-27 12:14:47 +02009042 break;
9043 case 0x10ec0889:
9044 spec->stream_name_analog = "ALC889 Analog";
9045 spec->stream_name_digital = "ALC889 Digital";
9046 break;
9047 default:
9048 spec->stream_name_analog = "ALC883 Analog";
9049 spec->stream_name_digital = "ALC883 Digital";
9050 break;
9051 }
9052
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009053 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9054 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009055 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009056
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009057 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9058 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9059
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009060 if (!spec->num_adc_nids) {
9061 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9062 spec->adc_nids = alc883_adc_nids;
9063 }
9064 if (!spec->capsrc_nids)
9065 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009066 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009067 if (!spec->cap_mixer)
9068 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009069
Takashi Iwai2134ea42008-01-10 16:53:55 +01009070 spec->vmaster_nid = 0x0c;
9071
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 codec->patch_ops = alc_patch_ops;
9073 if (board_config == ALC883_AUTO)
9074 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009075
Takashi Iwaicb53c622007-08-10 17:21:45 +02009076#ifdef CONFIG_SND_HDA_POWER_SAVE
9077 if (!spec->loopback.amplist)
9078 spec->loopback.amplist = alc883_loopbacks;
9079#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009080 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009081
9082 return 0;
9083}
9084
9085/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009086 * ALC262 support
9087 */
9088
9089#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9090#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9091
9092#define alc262_dac_nids alc260_dac_nids
9093#define alc262_adc_nids alc882_adc_nids
9094#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009095#define alc262_capsrc_nids alc882_capsrc_nids
9096#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009097
9098#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009099#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009100
Kailang Yang4e555fe2008-08-26 13:05:55 +02009101static hda_nid_t alc262_dmic_adc_nids[1] = {
9102 /* ADC0 */
9103 0x09
9104};
9105
9106static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9107
Kailang Yangdf694da2005-12-05 19:42:22 +01009108static struct snd_kcontrol_new alc262_base_mixer[] = {
9109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9110 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9111 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9112 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009118 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9119 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009120 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009121 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009122 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01009123 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9125 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9126 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009127 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009128};
9129
Kailang Yangccc656c2006-10-17 12:32:26 +02009130static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9132 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009139 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009140 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009142 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009143 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009144 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02009145 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9146 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9147 { } /* end */
9148};
9149
Takashi Iwaice875f02008-01-28 18:17:43 +01009150/* update HP, line and mono-out pins according to the master switch */
9151static void alc262_hp_master_update(struct hda_codec *codec)
9152{
9153 struct alc_spec *spec = codec->spec;
9154 int val = spec->master_sw;
9155
9156 /* HP & line-out */
9157 snd_hda_codec_write_cache(codec, 0x1b, 0,
9158 AC_VERB_SET_PIN_WIDGET_CONTROL,
9159 val ? PIN_HP : 0);
9160 snd_hda_codec_write_cache(codec, 0x15, 0,
9161 AC_VERB_SET_PIN_WIDGET_CONTROL,
9162 val ? PIN_HP : 0);
9163 /* mono (speaker) depending on the HP jack sense */
9164 val = val && !spec->jack_present;
9165 snd_hda_codec_write_cache(codec, 0x16, 0,
9166 AC_VERB_SET_PIN_WIDGET_CONTROL,
9167 val ? PIN_OUT : 0);
9168}
9169
9170static void alc262_hp_bpc_automute(struct hda_codec *codec)
9171{
9172 struct alc_spec *spec = codec->spec;
9173 unsigned int presence;
9174 presence = snd_hda_codec_read(codec, 0x1b, 0,
9175 AC_VERB_GET_PIN_SENSE, 0);
9176 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9177 alc262_hp_master_update(codec);
9178}
9179
9180static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9181{
9182 if ((res >> 26) != ALC880_HP_EVENT)
9183 return;
9184 alc262_hp_bpc_automute(codec);
9185}
9186
9187static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9188{
9189 struct alc_spec *spec = codec->spec;
9190 unsigned int presence;
9191 presence = snd_hda_codec_read(codec, 0x15, 0,
9192 AC_VERB_GET_PIN_SENSE, 0);
9193 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9194 alc262_hp_master_update(codec);
9195}
9196
9197static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9198 unsigned int res)
9199{
9200 if ((res >> 26) != ALC880_HP_EVENT)
9201 return;
9202 alc262_hp_wildwest_automute(codec);
9203}
9204
9205static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9206 struct snd_ctl_elem_value *ucontrol)
9207{
9208 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9209 struct alc_spec *spec = codec->spec;
9210 *ucontrol->value.integer.value = spec->master_sw;
9211 return 0;
9212}
9213
9214static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9215 struct snd_ctl_elem_value *ucontrol)
9216{
9217 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9218 struct alc_spec *spec = codec->spec;
9219 int val = !!*ucontrol->value.integer.value;
9220
9221 if (val == spec->master_sw)
9222 return 0;
9223 spec->master_sw = val;
9224 alc262_hp_master_update(codec);
9225 return 1;
9226}
9227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009229 {
9230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9231 .name = "Master Playback Switch",
9232 .info = snd_ctl_boolean_mono_info,
9233 .get = alc262_hp_master_sw_get,
9234 .put = alc262_hp_master_sw_put,
9235 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9237 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009239 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9240 HDA_OUTPUT),
9241 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9242 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009248 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9253 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9254 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9255 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9256 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9257 { } /* end */
9258};
9259
Kailang Yangcd7509a2007-01-26 18:33:17 +01009260static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009261 {
9262 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9263 .name = "Master Playback Switch",
9264 .info = snd_ctl_boolean_mono_info,
9265 .get = alc262_hp_master_sw_get,
9266 .put = alc262_hp_master_sw_put,
9267 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9269 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009272 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9273 HDA_OUTPUT),
9274 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9275 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009276 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009278 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9280 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9281 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9282 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9283 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9284 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9285 { } /* end */
9286};
9287
9288static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9289 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9290 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009291 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009292 { } /* end */
9293};
9294
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009295/* mute/unmute internal speaker according to the hp jack and mute state */
9296static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9297{
9298 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009299
9300 if (force || !spec->sense_updated) {
9301 unsigned int present;
9302 present = snd_hda_codec_read(codec, 0x15, 0,
9303 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009304 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009305 spec->sense_updated = 1;
9306 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009307 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9308 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009309}
9310
9311static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9312 unsigned int res)
9313{
9314 if ((res >> 26) != ALC880_HP_EVENT)
9315 return;
9316 alc262_hp_t5735_automute(codec, 1);
9317}
9318
9319static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9320{
9321 alc262_hp_t5735_automute(codec, 1);
9322}
9323
9324static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9326 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9331 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9332 { } /* end */
9333};
9334
9335static struct hda_verb alc262_hp_t5735_verbs[] = {
9336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9338
9339 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9340 { }
9341};
9342
Kailang Yang8c427222008-01-10 13:03:59 +01009343static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009344 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9347 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9350 { } /* end */
9351};
9352
9353static struct hda_verb alc262_hp_rp5700_verbs[] = {
9354 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9355 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9356 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9357 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9359 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9364 {}
9365};
9366
9367static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9368 .num_items = 1,
9369 .items = {
9370 { "Line", 0x1 },
9371 },
9372};
9373
Takashi Iwai0724ea22007-08-23 00:31:43 +02009374/* bind hp and internal speaker mute (with plug check) */
9375static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9376 struct snd_ctl_elem_value *ucontrol)
9377{
9378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9379 long *valp = ucontrol->value.integer.value;
9380 int change;
9381
9382 /* change hp mute */
9383 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9384 HDA_AMP_MUTE,
9385 valp[0] ? 0 : HDA_AMP_MUTE);
9386 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9387 HDA_AMP_MUTE,
9388 valp[1] ? 0 : HDA_AMP_MUTE);
9389 if (change) {
9390 /* change speaker according to HP jack state */
9391 struct alc_spec *spec = codec->spec;
9392 unsigned int mute;
9393 if (spec->jack_present)
9394 mute = HDA_AMP_MUTE;
9395 else
9396 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9397 HDA_OUTPUT, 0);
9398 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9399 HDA_AMP_MUTE, mute);
9400 }
9401 return change;
9402}
Takashi Iwai5b319542007-07-26 11:49:22 +02009403
Kailang Yang272a5272007-05-14 11:00:38 +02009404static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009405 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9406 {
9407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9408 .name = "Master Playback Switch",
9409 .info = snd_hda_mixer_amp_switch_info,
9410 .get = snd_hda_mixer_amp_switch_get,
9411 .put = alc262_sony_master_sw_put,
9412 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9413 },
Kailang Yang272a5272007-05-14 11:00:38 +02009414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9416 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9417 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9418 { } /* end */
9419};
9420
Kailang Yang83c34212007-07-05 11:43:05 +02009421static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9422 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9423 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9427 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9428 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9429 { } /* end */
9430};
Kailang Yang272a5272007-05-14 11:00:38 +02009431
Kailang Yangdf694da2005-12-05 19:42:22 +01009432#define alc262_capture_mixer alc882_capture_mixer
9433#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9434
9435/*
9436 * generic initialization of ADC, input mixers and output mixers
9437 */
9438static struct hda_verb alc262_init_verbs[] = {
9439 /*
9440 * Unmute ADC0-2 and set the default input to mic-in
9441 */
9442 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9444 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9446 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9448
Takashi Iwaicb53c622007-08-10 17:21:45 +02009449 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009450 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009451 * Note: PASD motherboards uses the Line In 2 as the input for
9452 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009453 */
9454 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009460
9461 /*
9462 * Set up output mixers (0x0c - 0x0e)
9463 */
9464 /* set vol=0 to output mixers */
9465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9468 /* set up input amps for analog loopback */
9469 /* Amp Indices: DAC = 0, mixer = 1 */
9470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9476
9477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9483
9484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9486 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009489
Kailang Yangdf694da2005-12-05 19:42:22 +01009490 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9491 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009492
Kailang Yangdf694da2005-12-05 19:42:22 +01009493 /* FIXME: use matrix-type input source selection */
9494 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9495 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9500 /* Input mixer2 */
9501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9505 /* Input mixer3 */
9506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009510
9511 { }
9512};
9513
Kailang Yang4e555fe2008-08-26 13:05:55 +02009514static struct hda_verb alc262_eapd_verbs[] = {
9515 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9516 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9517 { }
9518};
9519
Kailang Yangccc656c2006-10-17 12:32:26 +02009520static struct hda_verb alc262_hippo_unsol_verbs[] = {
9521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9523 {}
9524};
9525
9526static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9528 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9529 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9530
9531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9533 {}
9534};
9535
Kailang Yang272a5272007-05-14 11:00:38 +02009536static struct hda_verb alc262_sony_unsol_verbs[] = {
9537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9538 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9539 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9540
9541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009543 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009544};
9545
Kailang Yang4e555fe2008-08-26 13:05:55 +02009546static struct hda_input_mux alc262_dmic_capture_source = {
9547 .num_items = 2,
9548 .items = {
9549 { "Int DMic", 0x9 },
9550 { "Mic", 0x0 },
9551 },
9552};
9553
9554static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9556 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009560 { } /* end */
9561};
9562
9563static struct hda_verb alc262_toshiba_s06_verbs[] = {
9564 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9568 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9570 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9571 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9572 {}
9573};
9574
9575static void alc262_dmic_automute(struct hda_codec *codec)
9576{
9577 unsigned int present;
9578
9579 present = snd_hda_codec_read(codec, 0x18, 0,
9580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9581 snd_hda_codec_write(codec, 0x22, 0,
9582 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9583}
9584
9585/* toggle speaker-output according to the hp-jack state */
9586static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9587{
9588 unsigned int present;
9589 unsigned char bits;
9590
9591 present = snd_hda_codec_read(codec, 0x15, 0,
9592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9593 bits = present ? 0 : PIN_OUT;
9594 snd_hda_codec_write(codec, 0x14, 0,
9595 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9596}
9597
9598
9599
9600/* unsolicited event for HP jack sensing */
9601static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9602 unsigned int res)
9603{
9604 if ((res >> 26) == ALC880_HP_EVENT)
9605 alc262_toshiba_s06_speaker_automute(codec);
9606 if ((res >> 26) == ALC880_MIC_EVENT)
9607 alc262_dmic_automute(codec);
9608
9609}
9610
9611static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9612{
9613 alc262_toshiba_s06_speaker_automute(codec);
9614 alc262_dmic_automute(codec);
9615}
9616
Kailang Yangccc656c2006-10-17 12:32:26 +02009617/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009618static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009619{
9620 struct alc_spec *spec = codec->spec;
9621 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009622 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009623
Takashi Iwai5b319542007-07-26 11:49:22 +02009624 /* need to execute and sync at first */
9625 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9626 present = snd_hda_codec_read(codec, 0x15, 0,
9627 AC_VERB_GET_PIN_SENSE, 0);
9628 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009629 if (spec->jack_present) {
9630 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009631 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9632 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009633 } else {
9634 /* unmute internal speaker if necessary */
9635 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009636 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9637 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009638 }
9639}
9640
9641/* unsolicited event for HP jack sensing */
9642static void alc262_hippo_unsol_event(struct hda_codec *codec,
9643 unsigned int res)
9644{
9645 if ((res >> 26) != ALC880_HP_EVENT)
9646 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009647 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009648}
9649
Takashi Iwai5b319542007-07-26 11:49:22 +02009650static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009651{
Kailang Yangccc656c2006-10-17 12:32:26 +02009652 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009653 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009654
Takashi Iwai5b319542007-07-26 11:49:22 +02009655 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9656 present = snd_hda_codec_read(codec, 0x1b, 0,
9657 AC_VERB_GET_PIN_SENSE, 0);
9658 present = (present & 0x80000000) != 0;
9659 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009660 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009661 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9662 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009663 } else {
9664 /* unmute internal speaker if necessary */
9665 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9667 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009668 }
9669}
9670
9671/* unsolicited event for HP jack sensing */
9672static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9673 unsigned int res)
9674{
9675 if ((res >> 26) != ALC880_HP_EVENT)
9676 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009677 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009678}
9679
Takashi Iwai834be882006-03-01 14:16:17 +01009680/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009681 * nec model
9682 * 0x15 = headphone
9683 * 0x16 = internal speaker
9684 * 0x18 = external mic
9685 */
9686
9687static struct snd_kcontrol_new alc262_nec_mixer[] = {
9688 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9689 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9690
9691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9693 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9694
9695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9697 { } /* end */
9698};
9699
9700static struct hda_verb alc262_nec_verbs[] = {
9701 /* Unmute Speaker */
9702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9703
9704 /* Headphone */
9705 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9707
9708 /* External mic to headphone */
9709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9710 /* External mic to speaker */
9711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9712 {}
9713};
9714
9715/*
Takashi Iwai834be882006-03-01 14:16:17 +01009716 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009717 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9718 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009719 */
9720
9721#define ALC_HP_EVENT 0x37
9722
9723static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9724 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009726 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009728 {}
9729};
9730
Jiang zhe0e31daf2008-03-20 12:12:39 +01009731static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9732 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9734 {}
9735};
9736
Takashi Iwai834be882006-03-01 14:16:17 +01009737static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009738 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009739 .items = {
9740 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009741 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009742 { "CD", 0x4 },
9743 },
9744};
9745
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009746static struct hda_input_mux alc262_HP_capture_source = {
9747 .num_items = 5,
9748 .items = {
9749 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009750 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751 { "Line", 0x2 },
9752 { "CD", 0x4 },
9753 { "AUX IN", 0x6 },
9754 },
9755};
9756
zhejiangaccbe492007-08-31 12:36:05 +02009757static struct hda_input_mux alc262_HP_D7000_capture_source = {
9758 .num_items = 4,
9759 .items = {
9760 { "Mic", 0x0 },
9761 { "Front Mic", 0x2 },
9762 { "Line", 0x1 },
9763 { "CD", 0x4 },
9764 },
9765};
9766
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009767/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009768static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9769{
9770 struct alc_spec *spec = codec->spec;
9771 unsigned int mute;
9772
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009773 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009774 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009775 /* need to execute and sync at first */
9776 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009777 /* check laptop HP jack */
9778 present = snd_hda_codec_read(codec, 0x14, 0,
9779 AC_VERB_GET_PIN_SENSE, 0);
9780 /* need to execute and sync at first */
9781 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9782 /* check docking HP jack */
9783 present |= snd_hda_codec_read(codec, 0x1b, 0,
9784 AC_VERB_GET_PIN_SENSE, 0);
9785 if (present & AC_PINSENSE_PRESENCE)
9786 spec->jack_present = 1;
9787 else
9788 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009789 spec->sense_updated = 1;
9790 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009791 /* unmute internal speaker only if both HPs are unplugged and
9792 * master switch is on
9793 */
9794 if (spec->jack_present)
9795 mute = HDA_AMP_MUTE;
9796 else
Takashi Iwai834be882006-03-01 14:16:17 +01009797 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009798 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9799 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009800}
9801
9802/* unsolicited event for HP jack sensing */
9803static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9804 unsigned int res)
9805{
9806 if ((res >> 26) != ALC_HP_EVENT)
9807 return;
9808 alc262_fujitsu_automute(codec, 1);
9809}
9810
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009811static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9812{
9813 alc262_fujitsu_automute(codec, 1);
9814}
9815
Takashi Iwai834be882006-03-01 14:16:17 +01009816/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009817static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9818 .ops = &snd_hda_bind_vol,
9819 .values = {
9820 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9821 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9822 0
9823 },
9824};
Takashi Iwai834be882006-03-01 14:16:17 +01009825
Jiang zhe0e31daf2008-03-20 12:12:39 +01009826/* mute/unmute internal speaker according to the hp jack and mute state */
9827static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9828{
9829 struct alc_spec *spec = codec->spec;
9830 unsigned int mute;
9831
9832 if (force || !spec->sense_updated) {
9833 unsigned int present_int_hp;
9834 /* need to execute and sync at first */
9835 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9836 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9837 AC_VERB_GET_PIN_SENSE, 0);
9838 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9839 spec->sense_updated = 1;
9840 }
9841 if (spec->jack_present) {
9842 /* mute internal speaker */
9843 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9844 HDA_AMP_MUTE, HDA_AMP_MUTE);
9845 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9846 HDA_AMP_MUTE, HDA_AMP_MUTE);
9847 } else {
9848 /* unmute internal speaker if necessary */
9849 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9850 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9851 HDA_AMP_MUTE, mute);
9852 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9853 HDA_AMP_MUTE, mute);
9854 }
9855}
9856
9857/* unsolicited event for HP jack sensing */
9858static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9859 unsigned int res)
9860{
9861 if ((res >> 26) != ALC_HP_EVENT)
9862 return;
9863 alc262_lenovo_3000_automute(codec, 1);
9864}
9865
Takashi Iwai834be882006-03-01 14:16:17 +01009866/* bind hp and internal speaker mute (with plug check) */
9867static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9868 struct snd_ctl_elem_value *ucontrol)
9869{
9870 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9871 long *valp = ucontrol->value.integer.value;
9872 int change;
9873
Tony Vroon5d9fab22008-03-14 17:09:18 +01009874 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9875 HDA_AMP_MUTE,
9876 valp ? 0 : HDA_AMP_MUTE);
9877 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9878 HDA_AMP_MUTE,
9879 valp ? 0 : HDA_AMP_MUTE);
9880
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009881 if (change)
9882 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009883 return change;
9884}
9885
9886static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009887 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009888 {
9889 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9890 .name = "Master Playback Switch",
9891 .info = snd_hda_mixer_amp_switch_info,
9892 .get = snd_hda_mixer_amp_switch_get,
9893 .put = alc262_fujitsu_master_sw_put,
9894 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9895 },
9896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009898 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9899 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009900 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009903 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9904 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9905 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009906 { } /* end */
9907};
9908
Jiang zhe0e31daf2008-03-20 12:12:39 +01009909/* bind hp and internal speaker mute (with plug check) */
9910static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9911 struct snd_ctl_elem_value *ucontrol)
9912{
9913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9914 long *valp = ucontrol->value.integer.value;
9915 int change;
9916
9917 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9918 HDA_AMP_MUTE,
9919 valp ? 0 : HDA_AMP_MUTE);
9920
9921 if (change)
9922 alc262_lenovo_3000_automute(codec, 0);
9923 return change;
9924}
9925
9926static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9927 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9928 {
9929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9930 .name = "Master Playback Switch",
9931 .info = snd_hda_mixer_amp_switch_info,
9932 .get = snd_hda_mixer_amp_switch_get,
9933 .put = alc262_lenovo_3000_master_sw_put,
9934 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9935 },
9936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9941 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9942 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9943 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9944 { } /* end */
9945};
9946
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009947static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9948 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9949 {
9950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9951 .name = "Master Playback Switch",
9952 .info = snd_hda_mixer_amp_switch_info,
9953 .get = snd_hda_mixer_amp_switch_get,
9954 .put = alc262_sony_master_sw_put,
9955 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9956 },
9957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9960 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9963 { } /* end */
9964};
9965
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009966/* additional init verbs for Benq laptops */
9967static struct hda_verb alc262_EAPD_verbs[] = {
9968 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9969 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9970 {}
9971};
9972
Kailang Yang83c34212007-07-05 11:43:05 +02009973static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9974 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9976
9977 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9978 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9979 {}
9980};
9981
Tobin Davisf651b502007-10-26 12:40:47 +02009982/* Samsung Q1 Ultra Vista model setup */
9983static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009984 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9985 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9988 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009989 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009990 { } /* end */
9991};
9992
9993static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009994 /* output mixer */
9995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9998 /* speaker */
9999 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10000 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10002 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10003 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10009 /* internal mic */
10010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10012 /* ADC, choose mic */
10013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10016 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10017 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10018 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10019 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10020 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10021 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10022 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010023 {}
10024};
10025
Tobin Davisf651b502007-10-26 12:40:47 +020010026/* mute/unmute internal speaker according to the hp jack and mute state */
10027static void alc262_ultra_automute(struct hda_codec *codec)
10028{
10029 struct alc_spec *spec = codec->spec;
10030 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010031
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010032 mute = 0;
10033 /* auto-mute only when HP is used as HP */
10034 if (!spec->cur_mux[0]) {
10035 unsigned int present;
10036 /* need to execute and sync at first */
10037 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10038 present = snd_hda_codec_read(codec, 0x15, 0,
10039 AC_VERB_GET_PIN_SENSE, 0);
10040 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10041 if (spec->jack_present)
10042 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010043 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010044 /* mute/unmute internal speaker */
10045 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10046 HDA_AMP_MUTE, mute);
10047 /* mute/unmute HP */
10048 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10049 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010050}
10051
10052/* unsolicited event for HP jack sensing */
10053static void alc262_ultra_unsol_event(struct hda_codec *codec,
10054 unsigned int res)
10055{
10056 if ((res >> 26) != ALC880_HP_EVENT)
10057 return;
10058 alc262_ultra_automute(codec);
10059}
10060
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010061static struct hda_input_mux alc262_ultra_capture_source = {
10062 .num_items = 2,
10063 .items = {
10064 { "Mic", 0x1 },
10065 { "Headphone", 0x7 },
10066 },
10067};
10068
10069static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10070 struct snd_ctl_elem_value *ucontrol)
10071{
10072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10073 struct alc_spec *spec = codec->spec;
10074 int ret;
10075
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010076 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010077 if (!ret)
10078 return 0;
10079 /* reprogram the HP pin as mic or HP according to the input source */
10080 snd_hda_codec_write_cache(codec, 0x15, 0,
10081 AC_VERB_SET_PIN_WIDGET_CONTROL,
10082 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10083 alc262_ultra_automute(codec); /* mute/unmute HP */
10084 return ret;
10085}
10086
10087static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10088 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10089 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10090 {
10091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10092 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010093 .info = alc_mux_enum_info,
10094 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010095 .put = alc262_ultra_mux_enum_put,
10096 },
10097 { } /* end */
10098};
10099
Kailang Yangdf694da2005-12-05 19:42:22 +010010100/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010101static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10102 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010103{
10104 hda_nid_t nid;
10105 int err;
10106
10107 spec->multiout.num_dacs = 1; /* only use one dac */
10108 spec->multiout.dac_nids = spec->private_dac_nids;
10109 spec->multiout.dac_nids[0] = 2;
10110
10111 nid = cfg->line_out_pins[0];
10112 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010113 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10114 "Front Playback Volume",
10115 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10116 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010117 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010118 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10119 "Front Playback Switch",
10120 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10121 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010122 return err;
10123 }
10124
Takashi Iwai82bc9552006-03-21 11:24:42 +010010125 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010126 if (nid) {
10127 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010128 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10129 "Speaker Playback Volume",
10130 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10131 HDA_OUTPUT));
10132 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010133 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010134 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10135 "Speaker Playback Switch",
10136 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10137 HDA_OUTPUT));
10138 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010139 return err;
10140 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010141 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10142 "Speaker Playback Switch",
10143 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10144 HDA_OUTPUT));
10145 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010146 return err;
10147 }
10148 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010149 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010150 if (nid) {
10151 /* spec->multiout.hp_nid = 2; */
10152 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010153 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10154 "Headphone Playback Volume",
10155 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10156 HDA_OUTPUT));
10157 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010158 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010159 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10160 "Headphone Playback Switch",
10161 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10162 HDA_OUTPUT));
10163 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010164 return err;
10165 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010166 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10167 "Headphone Playback Switch",
10168 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10169 HDA_OUTPUT));
10170 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010171 return err;
10172 }
10173 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010174 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010175}
10176
10177/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010178#define alc262_auto_create_analog_input_ctls \
10179 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010180
10181/*
10182 * generic initialization of ADC, input mixers and output mixers
10183 */
10184static struct hda_verb alc262_volume_init_verbs[] = {
10185 /*
10186 * Unmute ADC0-2 and set the default input to mic-in
10187 */
10188 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10190 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10192 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10194
Takashi Iwaicb53c622007-08-10 17:21:45 +020010195 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010196 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010197 * Note: PASD motherboards uses the Line In 2 as the input for
10198 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010199 */
10200 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010206
10207 /*
10208 * Set up output mixers (0x0c - 0x0f)
10209 */
10210 /* set vol=0 to output mixers */
10211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10213 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010214
Kailang Yangdf694da2005-12-05 19:42:22 +010010215 /* set up input amps for analog loopback */
10216 /* Amp Indices: DAC = 0, mixer = 1 */
10217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10222 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10223
10224 /* FIXME: use matrix-type input source selection */
10225 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10226 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10231 /* Input mixer2 */
10232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10236 /* Input mixer3 */
10237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10241
10242 { }
10243};
10244
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010245static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10246 /*
10247 * Unmute ADC0-2 and set the default input to mic-in
10248 */
10249 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10251 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10253 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10255
Takashi Iwaicb53c622007-08-10 17:21:45 +020010256 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010257 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010258 * Note: PASD motherboards uses the Line In 2 as the input for
10259 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010260 */
10261 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010269
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010270 /*
10271 * Set up output mixers (0x0c - 0x0e)
10272 */
10273 /* set vol=0 to output mixers */
10274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10277
10278 /* set up input amps for analog loopback */
10279 /* Amp Indices: DAC = 0, mixer = 1 */
10280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10286
Takashi Iwaice875f02008-01-28 18:17:43 +010010287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10290
10291 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10293
10294 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10296
10297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10300 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10301 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10302
10303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10307 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10308 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10309
10310
10311 /* FIXME: use matrix-type input source selection */
10312 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10313 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10318 /* Input mixer2 */
10319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10323 /* Input mixer3 */
10324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10328
Takashi Iwaice875f02008-01-28 18:17:43 +010010329 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10330
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010331 { }
10332};
10333
Kailang Yangcd7509a2007-01-26 18:33:17 +010010334static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10335 /*
10336 * Unmute ADC0-2 and set the default input to mic-in
10337 */
10338 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10340 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10342 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10344
Takashi Iwaicb53c622007-08-10 17:21:45 +020010345 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010346 * mixer widget
10347 * Note: PASD motherboards uses the Line In 2 as the input for front
10348 * panel mic (mic 2)
10349 */
10350 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010359 /*
10360 * Set up output mixers (0x0c - 0x0e)
10361 */
10362 /* set vol=0 to output mixers */
10363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10366
10367 /* set up input amps for analog loopback */
10368 /* Amp Indices: DAC = 0, mixer = 1 */
10369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10375
10376
10377 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10378 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10380 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10381 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10382 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10383 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10384
10385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10387
10388 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10390
10391 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10393 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10394 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10395 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10396 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10397
10398 /* FIXME: use matrix-type input source selection */
10399 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10400 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10406 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10408 /* Input mixer2 */
10409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10414 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10416 /* Input mixer3 */
10417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10422 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10424
Takashi Iwaice875f02008-01-28 18:17:43 +010010425 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10426
Kailang Yangcd7509a2007-01-26 18:33:17 +010010427 { }
10428};
10429
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010430static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10431
10432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10433 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10434 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10435
10436 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10440
10441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10443 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10444 {}
10445};
10446
10447
Takashi Iwaicb53c622007-08-10 17:21:45 +020010448#ifdef CONFIG_SND_HDA_POWER_SAVE
10449#define alc262_loopbacks alc880_loopbacks
10450#endif
10451
Kailang Yangdf694da2005-12-05 19:42:22 +010010452/* pcm configuration: identiacal with ALC880 */
10453#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10454#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10455#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10456#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10457
10458/*
10459 * BIOS auto configuration
10460 */
10461static int alc262_parse_auto_config(struct hda_codec *codec)
10462{
10463 struct alc_spec *spec = codec->spec;
10464 int err;
10465 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010467 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10468 alc262_ignore);
10469 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010470 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010471 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010472 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010473 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10474 if (err < 0)
10475 return err;
10476 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10477 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010478 return err;
10479
10480 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10481
10482 if (spec->autocfg.dig_out_pin)
10483 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10484 if (spec->autocfg.dig_in_pin)
10485 spec->dig_in_nid = ALC262_DIGIN_NID;
10486
Takashi Iwai603c4012008-07-30 15:01:44 +020010487 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010488 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010489
Takashi Iwaid88897e2008-10-31 15:01:37 +010010490 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010491 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010492 spec->input_mux = &spec->private_imux;
10493
Takashi Iwai776e1842007-08-29 15:07:11 +020010494 err = alc_auto_add_mic_boost(codec);
10495 if (err < 0)
10496 return err;
10497
Takashi Iwaie044c392008-10-27 16:56:24 +010010498 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010499 return 1;
10500}
10501
10502#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10503#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10504#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010505#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010506
10507
10508/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010509static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010510{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010511 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010512 alc262_auto_init_multi_out(codec);
10513 alc262_auto_init_hp_out(codec);
10514 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010515 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010517 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010518}
10519
10520/*
10521 * configuration and preset
10522 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010523static const char *alc262_models[ALC262_MODEL_LAST] = {
10524 [ALC262_BASIC] = "basic",
10525 [ALC262_HIPPO] = "hippo",
10526 [ALC262_HIPPO_1] = "hippo_1",
10527 [ALC262_FUJITSU] = "fujitsu",
10528 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010529 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010530 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010531 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010532 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010533 [ALC262_BENQ_T31] = "benq-t31",
10534 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010535 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010536 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010537 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010538 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010539 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010540 [ALC262_AUTO] = "auto",
10541};
10542
10543static struct snd_pci_quirk alc262_cfg_tbl[] = {
10544 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010545 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010546 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010547 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010548 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10549 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010550 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010551 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010552 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010553 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010554 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010555 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010556 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010557 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010558 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010559 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010560 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010561 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010562 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10563 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10564 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010565 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10566 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010567 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010568 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010569 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010570 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10571 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10572 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010573 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10574 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010575 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010576 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010577 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010578 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010579 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010580 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010581 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010582 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010583 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010584 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010585 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010586 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010587 {}
10588};
10589
10590static struct alc_config_preset alc262_presets[] = {
10591 [ALC262_BASIC] = {
10592 .mixers = { alc262_base_mixer },
10593 .init_verbs = { alc262_init_verbs },
10594 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10595 .dac_nids = alc262_dac_nids,
10596 .hp_nid = 0x03,
10597 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10598 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010599 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010600 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010601 [ALC262_HIPPO] = {
10602 .mixers = { alc262_base_mixer },
10603 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10604 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10605 .dac_nids = alc262_dac_nids,
10606 .hp_nid = 0x03,
10607 .dig_out_nid = ALC262_DIGOUT_NID,
10608 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10609 .channel_mode = alc262_modes,
10610 .input_mux = &alc262_capture_source,
10611 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010612 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010613 },
10614 [ALC262_HIPPO_1] = {
10615 .mixers = { alc262_hippo1_mixer },
10616 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10617 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10618 .dac_nids = alc262_dac_nids,
10619 .hp_nid = 0x02,
10620 .dig_out_nid = ALC262_DIGOUT_NID,
10621 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10622 .channel_mode = alc262_modes,
10623 .input_mux = &alc262_capture_source,
10624 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010625 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010626 },
Takashi Iwai834be882006-03-01 14:16:17 +010010627 [ALC262_FUJITSU] = {
10628 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010629 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10630 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010631 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10632 .dac_nids = alc262_dac_nids,
10633 .hp_nid = 0x03,
10634 .dig_out_nid = ALC262_DIGOUT_NID,
10635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10636 .channel_mode = alc262_modes,
10637 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010638 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010639 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010640 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010641 [ALC262_HP_BPC] = {
10642 .mixers = { alc262_HP_BPC_mixer },
10643 .init_verbs = { alc262_HP_BPC_init_verbs },
10644 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10645 .dac_nids = alc262_dac_nids,
10646 .hp_nid = 0x03,
10647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10648 .channel_mode = alc262_modes,
10649 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010650 .unsol_event = alc262_hp_bpc_unsol_event,
10651 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010652 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010653 [ALC262_HP_BPC_D7000_WF] = {
10654 .mixers = { alc262_HP_BPC_WildWest_mixer },
10655 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10657 .dac_nids = alc262_dac_nids,
10658 .hp_nid = 0x03,
10659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10660 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010661 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010662 .unsol_event = alc262_hp_wildwest_unsol_event,
10663 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010664 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010665 [ALC262_HP_BPC_D7000_WL] = {
10666 .mixers = { alc262_HP_BPC_WildWest_mixer,
10667 alc262_HP_BPC_WildWest_option_mixer },
10668 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10669 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10670 .dac_nids = alc262_dac_nids,
10671 .hp_nid = 0x03,
10672 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10673 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010674 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010675 .unsol_event = alc262_hp_wildwest_unsol_event,
10676 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010677 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010678 [ALC262_HP_TC_T5735] = {
10679 .mixers = { alc262_hp_t5735_mixer },
10680 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10681 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10682 .dac_nids = alc262_dac_nids,
10683 .hp_nid = 0x03,
10684 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10685 .channel_mode = alc262_modes,
10686 .input_mux = &alc262_capture_source,
10687 .unsol_event = alc262_hp_t5735_unsol_event,
10688 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010689 },
10690 [ALC262_HP_RP5700] = {
10691 .mixers = { alc262_hp_rp5700_mixer },
10692 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10693 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10694 .dac_nids = alc262_dac_nids,
10695 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10696 .channel_mode = alc262_modes,
10697 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010698 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010699 [ALC262_BENQ_ED8] = {
10700 .mixers = { alc262_base_mixer },
10701 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10702 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10703 .dac_nids = alc262_dac_nids,
10704 .hp_nid = 0x03,
10705 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10706 .channel_mode = alc262_modes,
10707 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010708 },
Kailang Yang272a5272007-05-14 11:00:38 +020010709 [ALC262_SONY_ASSAMD] = {
10710 .mixers = { alc262_sony_mixer },
10711 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10712 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10713 .dac_nids = alc262_dac_nids,
10714 .hp_nid = 0x02,
10715 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10716 .channel_mode = alc262_modes,
10717 .input_mux = &alc262_capture_source,
10718 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010719 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010720 },
10721 [ALC262_BENQ_T31] = {
10722 .mixers = { alc262_benq_t31_mixer },
10723 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10724 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10725 .dac_nids = alc262_dac_nids,
10726 .hp_nid = 0x03,
10727 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10728 .channel_mode = alc262_modes,
10729 .input_mux = &alc262_capture_source,
10730 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010731 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010732 },
Tobin Davisf651b502007-10-26 12:40:47 +020010733 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010734 .mixers = { alc262_ultra_mixer },
10735 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010736 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010737 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10738 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010739 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10740 .channel_mode = alc262_modes,
10741 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010742 .adc_nids = alc262_adc_nids, /* ADC0 */
10743 .capsrc_nids = alc262_capsrc_nids,
10744 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010745 .unsol_event = alc262_ultra_unsol_event,
10746 .init_hook = alc262_ultra_automute,
10747 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010748 [ALC262_LENOVO_3000] = {
10749 .mixers = { alc262_lenovo_3000_mixer },
10750 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10751 alc262_lenovo_3000_unsol_verbs },
10752 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10753 .dac_nids = alc262_dac_nids,
10754 .hp_nid = 0x03,
10755 .dig_out_nid = ALC262_DIGOUT_NID,
10756 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10757 .channel_mode = alc262_modes,
10758 .input_mux = &alc262_fujitsu_capture_source,
10759 .unsol_event = alc262_lenovo_3000_unsol_event,
10760 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010761 [ALC262_NEC] = {
10762 .mixers = { alc262_nec_mixer },
10763 .init_verbs = { alc262_nec_verbs },
10764 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10765 .dac_nids = alc262_dac_nids,
10766 .hp_nid = 0x03,
10767 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10768 .channel_mode = alc262_modes,
10769 .input_mux = &alc262_capture_source,
10770 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010771 [ALC262_TOSHIBA_S06] = {
10772 .mixers = { alc262_toshiba_s06_mixer },
10773 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10774 alc262_eapd_verbs },
10775 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10776 .capsrc_nids = alc262_dmic_capsrc_nids,
10777 .dac_nids = alc262_dac_nids,
10778 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10779 .dig_out_nid = ALC262_DIGOUT_NID,
10780 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10781 .channel_mode = alc262_modes,
10782 .input_mux = &alc262_dmic_capture_source,
10783 .unsol_event = alc262_toshiba_s06_unsol_event,
10784 .init_hook = alc262_toshiba_s06_init_hook,
10785 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010786 [ALC262_TOSHIBA_RX1] = {
10787 .mixers = { alc262_toshiba_rx1_mixer },
10788 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10789 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10790 .dac_nids = alc262_dac_nids,
10791 .hp_nid = 0x03,
10792 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10793 .channel_mode = alc262_modes,
10794 .input_mux = &alc262_capture_source,
10795 .unsol_event = alc262_hippo_unsol_event,
10796 .init_hook = alc262_hippo_automute,
10797 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010798};
10799
10800static int patch_alc262(struct hda_codec *codec)
10801{
10802 struct alc_spec *spec;
10803 int board_config;
10804 int err;
10805
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010806 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 if (spec == NULL)
10808 return -ENOMEM;
10809
10810 codec->spec = spec;
10811#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010812 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10813 * under-run
10814 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010815 {
10816 int tmp;
10817 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10818 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10819 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10820 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10821 }
10822#endif
10823
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010824 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10825
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010826 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10827 alc262_models,
10828 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010829
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010830 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10832 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010833 board_config = ALC262_AUTO;
10834 }
10835
10836 if (board_config == ALC262_AUTO) {
10837 /* automatic parse from the BIOS config */
10838 err = alc262_parse_auto_config(codec);
10839 if (err < 0) {
10840 alc_free(codec);
10841 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010842 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010843 printk(KERN_INFO
10844 "hda_codec: Cannot set up configuration "
10845 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010846 board_config = ALC262_BASIC;
10847 }
10848 }
10849
10850 if (board_config != ALC262_AUTO)
10851 setup_preset(spec, &alc262_presets[board_config]);
10852
10853 spec->stream_name_analog = "ALC262 Analog";
10854 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10855 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010856
Kailang Yangdf694da2005-12-05 19:42:22 +010010857 spec->stream_name_digital = "ALC262 Digital";
10858 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10859 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10860
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010861 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010862 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010863 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010864 unsigned int wcap = get_wcaps(codec, 0x07);
10865
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 /* get type */
10867 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010868 if (wcap != AC_WID_AUD_IN) {
10869 spec->adc_nids = alc262_adc_nids_alt;
10870 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010871 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010872 } else {
10873 spec->adc_nids = alc262_adc_nids;
10874 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010875 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010876 }
10877 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010878 if (!spec->cap_mixer)
10879 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010880
Takashi Iwai2134ea42008-01-10 16:53:55 +010010881 spec->vmaster_nid = 0x0c;
10882
Kailang Yangdf694da2005-12-05 19:42:22 +010010883 codec->patch_ops = alc_patch_ops;
10884 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010885 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010886#ifdef CONFIG_SND_HDA_POWER_SAVE
10887 if (!spec->loopback.amplist)
10888 spec->loopback.amplist = alc262_loopbacks;
10889#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010890 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020010891
Kailang Yangdf694da2005-12-05 19:42:22 +010010892 return 0;
10893}
10894
Kailang Yangdf694da2005-12-05 19:42:22 +010010895/*
Kailang Yanga361d842007-06-05 12:30:55 +020010896 * ALC268 channel source setting (2 channel)
10897 */
10898#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10899#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010900
Kailang Yanga361d842007-06-05 12:30:55 +020010901static hda_nid_t alc268_dac_nids[2] = {
10902 /* front, hp */
10903 0x02, 0x03
10904};
10905
10906static hda_nid_t alc268_adc_nids[2] = {
10907 /* ADC0-1 */
10908 0x08, 0x07
10909};
10910
10911static hda_nid_t alc268_adc_nids_alt[1] = {
10912 /* ADC0 */
10913 0x08
10914};
10915
Takashi Iwaie1406342008-02-11 18:32:32 +010010916static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10917
Kailang Yanga361d842007-06-05 12:30:55 +020010918static struct snd_kcontrol_new alc268_base_mixer[] = {
10919 /* output mixer control */
10920 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10921 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10922 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010924 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10925 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10926 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010927 { }
10928};
10929
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010930/* bind Beep switches of both NID 0x0f and 0x10 */
10931static struct hda_bind_ctls alc268_bind_beep_sw = {
10932 .ops = &snd_hda_bind_sw,
10933 .values = {
10934 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10935 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10936 0
10937 },
10938};
10939
10940static struct snd_kcontrol_new alc268_beep_mixer[] = {
10941 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10942 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10943 { }
10944};
10945
Kailang Yangd1a991a2007-08-15 16:21:59 +020010946static struct hda_verb alc268_eapd_verbs[] = {
10947 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10948 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10949 { }
10950};
10951
Takashi Iwaid2738092007-08-16 14:59:45 +020010952/* Toshiba specific */
10953#define alc268_toshiba_automute alc262_hippo_automute
10954
10955static struct hda_verb alc268_toshiba_verbs[] = {
10956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10957 { } /* end */
10958};
10959
Kailang Yang8ef355d2008-08-26 13:10:22 +020010960static struct hda_input_mux alc268_acer_lc_capture_source = {
10961 .num_items = 2,
10962 .items = {
10963 { "i-Mic", 0x6 },
10964 { "E-Mic", 0x0 },
10965 },
10966};
10967
Takashi Iwaid2738092007-08-16 14:59:45 +020010968/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010969/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010970static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10971 .ops = &snd_hda_bind_vol,
10972 .values = {
10973 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10974 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10975 0
10976 },
10977};
10978
Takashi Iwai889c4392007-08-23 18:56:52 +020010979/* mute/unmute internal speaker according to the hp jack and mute state */
10980static void alc268_acer_automute(struct hda_codec *codec, int force)
10981{
10982 struct alc_spec *spec = codec->spec;
10983 unsigned int mute;
10984
10985 if (force || !spec->sense_updated) {
10986 unsigned int present;
10987 present = snd_hda_codec_read(codec, 0x14, 0,
10988 AC_VERB_GET_PIN_SENSE, 0);
10989 spec->jack_present = (present & 0x80000000) != 0;
10990 spec->sense_updated = 1;
10991 }
10992 if (spec->jack_present)
10993 mute = HDA_AMP_MUTE; /* mute internal speaker */
10994 else /* unmute internal speaker if necessary */
10995 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10996 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10997 HDA_AMP_MUTE, mute);
10998}
10999
11000
11001/* bind hp and internal speaker mute (with plug check) */
11002static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11003 struct snd_ctl_elem_value *ucontrol)
11004{
11005 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11006 long *valp = ucontrol->value.integer.value;
11007 int change;
11008
11009 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11010 HDA_AMP_MUTE,
11011 valp[0] ? 0 : HDA_AMP_MUTE);
11012 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11013 HDA_AMP_MUTE,
11014 valp[1] ? 0 : HDA_AMP_MUTE);
11015 if (change)
11016 alc268_acer_automute(codec, 0);
11017 return change;
11018}
Takashi Iwaid2738092007-08-16 14:59:45 +020011019
Kailang Yang8ef355d2008-08-26 13:10:22 +020011020static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11021 /* output mixer control */
11022 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11023 {
11024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11025 .name = "Master Playback Switch",
11026 .info = snd_hda_mixer_amp_switch_info,
11027 .get = snd_hda_mixer_amp_switch_get,
11028 .put = alc268_acer_master_sw_put,
11029 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11030 },
11031 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11032 { }
11033};
11034
Takashi Iwaid2738092007-08-16 14:59:45 +020011035static struct snd_kcontrol_new alc268_acer_mixer[] = {
11036 /* output mixer control */
11037 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11038 {
11039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11040 .name = "Master Playback Switch",
11041 .info = snd_hda_mixer_amp_switch_info,
11042 .get = snd_hda_mixer_amp_switch_get,
11043 .put = alc268_acer_master_sw_put,
11044 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11045 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011046 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11047 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11048 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011049 { }
11050};
11051
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011052static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11053 /* output mixer control */
11054 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11055 {
11056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11057 .name = "Master Playback Switch",
11058 .info = snd_hda_mixer_amp_switch_info,
11059 .get = snd_hda_mixer_amp_switch_get,
11060 .put = alc268_acer_master_sw_put,
11061 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11062 },
11063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11064 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11065 { }
11066};
11067
Kailang Yang8ef355d2008-08-26 13:10:22 +020011068static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11069 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11072 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11073 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11075 { }
11076};
11077
Takashi Iwaid2738092007-08-16 14:59:45 +020011078static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011079 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11080 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011085 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11086 { }
11087};
11088
11089/* unsolicited event for HP jack sensing */
11090static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11091 unsigned int res)
11092{
Takashi Iwai889c4392007-08-23 18:56:52 +020011093 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011094 return;
11095 alc268_toshiba_automute(codec);
11096}
11097
11098static void alc268_acer_unsol_event(struct hda_codec *codec,
11099 unsigned int res)
11100{
Takashi Iwai889c4392007-08-23 18:56:52 +020011101 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011102 return;
11103 alc268_acer_automute(codec, 1);
11104}
11105
Takashi Iwai889c4392007-08-23 18:56:52 +020011106static void alc268_acer_init_hook(struct hda_codec *codec)
11107{
11108 alc268_acer_automute(codec, 1);
11109}
11110
Kailang Yang8ef355d2008-08-26 13:10:22 +020011111/* toggle speaker-output according to the hp-jack state */
11112static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11113{
11114 unsigned int present;
11115 unsigned char bits;
11116
11117 present = snd_hda_codec_read(codec, 0x15, 0,
11118 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11119 bits = present ? AMP_IN_MUTE(0) : 0;
11120 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11121 AMP_IN_MUTE(0), bits);
11122 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11123 AMP_IN_MUTE(0), bits);
11124}
11125
11126
11127static void alc268_acer_mic_automute(struct hda_codec *codec)
11128{
11129 unsigned int present;
11130
11131 present = snd_hda_codec_read(codec, 0x18, 0,
11132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11133 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11134 present ? 0x0 : 0x6);
11135}
11136
11137static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11138 unsigned int res)
11139{
11140 if ((res >> 26) == ALC880_HP_EVENT)
11141 alc268_aspire_one_speaker_automute(codec);
11142 if ((res >> 26) == ALC880_MIC_EVENT)
11143 alc268_acer_mic_automute(codec);
11144}
11145
11146static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11147{
11148 alc268_aspire_one_speaker_automute(codec);
11149 alc268_acer_mic_automute(codec);
11150}
11151
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011152static struct snd_kcontrol_new alc268_dell_mixer[] = {
11153 /* output mixer control */
11154 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11156 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11159 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11160 { }
11161};
11162
11163static struct hda_verb alc268_dell_verbs[] = {
11164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11167 { }
11168};
11169
11170/* mute/unmute internal speaker according to the hp jack and mute state */
11171static void alc268_dell_automute(struct hda_codec *codec)
11172{
11173 unsigned int present;
11174 unsigned int mute;
11175
11176 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11177 if (present & 0x80000000)
11178 mute = HDA_AMP_MUTE;
11179 else
11180 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11181 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11182 HDA_AMP_MUTE, mute);
11183}
11184
11185static void alc268_dell_unsol_event(struct hda_codec *codec,
11186 unsigned int res)
11187{
11188 if ((res >> 26) != ALC880_HP_EVENT)
11189 return;
11190 alc268_dell_automute(codec);
11191}
11192
11193#define alc268_dell_init_hook alc268_dell_automute
11194
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011195static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11197 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11198 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11200 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11201 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11202 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11203 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11204 { }
11205};
11206
11207static struct hda_verb alc267_quanta_il1_verbs[] = {
11208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11210 { }
11211};
11212
11213static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11214{
11215 unsigned int present;
11216
11217 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11218 & AC_PINSENSE_PRESENCE;
11219 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11220 present ? 0 : PIN_OUT);
11221}
11222
11223static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11224{
11225 unsigned int present;
11226
11227 present = snd_hda_codec_read(codec, 0x18, 0,
11228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11229 snd_hda_codec_write(codec, 0x23, 0,
11230 AC_VERB_SET_CONNECT_SEL,
11231 present ? 0x00 : 0x01);
11232}
11233
11234static void alc267_quanta_il1_automute(struct hda_codec *codec)
11235{
11236 alc267_quanta_il1_hp_automute(codec);
11237 alc267_quanta_il1_mic_automute(codec);
11238}
11239
11240static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11241 unsigned int res)
11242{
11243 switch (res >> 26) {
11244 case ALC880_HP_EVENT:
11245 alc267_quanta_il1_hp_automute(codec);
11246 break;
11247 case ALC880_MIC_EVENT:
11248 alc267_quanta_il1_mic_automute(codec);
11249 break;
11250 }
11251}
11252
Kailang Yanga361d842007-06-05 12:30:55 +020011253/*
11254 * generic initialization of ADC, input mixers and output mixers
11255 */
11256static struct hda_verb alc268_base_init_verbs[] = {
11257 /* Unmute DAC0-1 and set vol = 0 */
11258 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11259 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11260 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11261 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11262 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11263 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11264
11265 /*
11266 * Set up output mixers (0x0c - 0x0e)
11267 */
11268 /* set vol=0 to output mixers */
11269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11272 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11273
11274 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11275 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11276
11277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11279 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11280 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11282 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11285
11286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11289 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11292 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011293
11294 /* set PCBEEP vol = 0, mute connections */
11295 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11297 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011298
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011299 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011300
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011301 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11303 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011305
Kailang Yanga361d842007-06-05 12:30:55 +020011306 { }
11307};
11308
11309/*
11310 * generic initialization of ADC, input mixers and output mixers
11311 */
11312static struct hda_verb alc268_volume_init_verbs[] = {
11313 /* set output DAC */
11314 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11315 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11316 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11317 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11318
11319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11320 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11323 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11324
11325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11329 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11330
11331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11334 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11335
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011336 /* set PCBEEP vol = 0, mute connections */
11337 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011340
11341 { }
11342};
11343
Kailang Yanga361d842007-06-05 12:30:55 +020011344static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11345 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11346 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11347 {
11348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11349 /* The multiple "Capture Source" controls confuse alsamixer
11350 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011351 */
11352 /* .name = "Capture Source", */
11353 .name = "Input Source",
11354 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011355 .info = alc_mux_enum_info,
11356 .get = alc_mux_enum_get,
11357 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011358 },
11359 { } /* end */
11360};
11361
11362static struct snd_kcontrol_new alc268_capture_mixer[] = {
11363 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11364 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11365 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11367 {
11368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11369 /* The multiple "Capture Source" controls confuse alsamixer
11370 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011371 */
11372 /* .name = "Capture Source", */
11373 .name = "Input Source",
11374 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011375 .info = alc_mux_enum_info,
11376 .get = alc_mux_enum_get,
11377 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011378 },
11379 { } /* end */
11380};
11381
11382static struct hda_input_mux alc268_capture_source = {
11383 .num_items = 4,
11384 .items = {
11385 { "Mic", 0x0 },
11386 { "Front Mic", 0x1 },
11387 { "Line", 0x2 },
11388 { "CD", 0x3 },
11389 },
11390};
11391
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011392static struct hda_input_mux alc268_acer_capture_source = {
11393 .num_items = 3,
11394 .items = {
11395 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011396 { "Internal Mic", 0x1 },
11397 { "Line", 0x2 },
11398 },
11399};
11400
11401static struct hda_input_mux alc268_acer_dmic_capture_source = {
11402 .num_items = 3,
11403 .items = {
11404 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011405 { "Internal Mic", 0x6 },
11406 { "Line", 0x2 },
11407 },
11408};
11409
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011410#ifdef CONFIG_SND_DEBUG
11411static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011412 /* Volume widgets */
11413 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11415 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11416 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11417 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11418 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11419 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11420 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11421 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11422 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11423 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11424 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11425 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011426 /* The below appears problematic on some hardwares */
11427 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011428 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11429 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11430 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11431 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11432
11433 /* Modes for retasking pin widgets */
11434 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11435 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11436 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11437 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11438
11439 /* Controls for GPIO pins, assuming they are configured as outputs */
11440 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11441 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11442 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11443 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11444
11445 /* Switches to allow the digital SPDIF output pin to be enabled.
11446 * The ALC268 does not have an SPDIF input.
11447 */
11448 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11449
11450 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11451 * this output to turn on an external amplifier.
11452 */
11453 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11454 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11455
11456 { } /* end */
11457};
11458#endif
11459
Kailang Yanga361d842007-06-05 12:30:55 +020011460/* create input playback/capture controls for the given pin */
11461static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11462 const char *ctlname, int idx)
11463{
11464 char name[32];
11465 int err;
11466
11467 sprintf(name, "%s Playback Volume", ctlname);
11468 if (nid == 0x14) {
11469 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11470 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11471 HDA_OUTPUT));
11472 if (err < 0)
11473 return err;
11474 } else if (nid == 0x15) {
11475 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11476 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11477 HDA_OUTPUT));
11478 if (err < 0)
11479 return err;
11480 } else
11481 return -1;
11482 sprintf(name, "%s Playback Switch", ctlname);
11483 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11484 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11485 if (err < 0)
11486 return err;
11487 return 0;
11488}
11489
11490/* add playback controls from the parsed DAC table */
11491static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11492 const struct auto_pin_cfg *cfg)
11493{
11494 hda_nid_t nid;
11495 int err;
11496
11497 spec->multiout.num_dacs = 2; /* only use one dac */
11498 spec->multiout.dac_nids = spec->private_dac_nids;
11499 spec->multiout.dac_nids[0] = 2;
11500 spec->multiout.dac_nids[1] = 3;
11501
11502 nid = cfg->line_out_pins[0];
11503 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011504 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011505
11506 nid = cfg->speaker_pins[0];
11507 if (nid == 0x1d) {
11508 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11509 "Speaker Playback Volume",
11510 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11511 if (err < 0)
11512 return err;
11513 }
11514 nid = cfg->hp_pins[0];
11515 if (nid)
11516 alc268_new_analog_output(spec, nid, "Headphone", 0);
11517
11518 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11519 if (nid == 0x16) {
11520 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11521 "Mono Playback Switch",
11522 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11523 if (err < 0)
11524 return err;
11525 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011526 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011527}
11528
11529/* create playback/capture controls for input pins */
11530static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11531 const struct auto_pin_cfg *cfg)
11532{
11533 struct hda_input_mux *imux = &spec->private_imux;
11534 int i, idx1;
11535
11536 for (i = 0; i < AUTO_PIN_LAST; i++) {
11537 switch(cfg->input_pins[i]) {
11538 case 0x18:
11539 idx1 = 0; /* Mic 1 */
11540 break;
11541 case 0x19:
11542 idx1 = 1; /* Mic 2 */
11543 break;
11544 case 0x1a:
11545 idx1 = 2; /* Line In */
11546 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011547 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011548 idx1 = 3; /* CD */
11549 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011550 case 0x12:
11551 case 0x13:
11552 idx1 = 6; /* digital mics */
11553 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011554 default:
11555 continue;
11556 }
11557 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11558 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011559 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011560 }
11561 return 0;
11562}
11563
11564static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11565{
11566 struct alc_spec *spec = codec->spec;
11567 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11568 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11569 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11570 unsigned int dac_vol1, dac_vol2;
11571
11572 if (speaker_nid) {
11573 snd_hda_codec_write(codec, speaker_nid, 0,
11574 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11575 snd_hda_codec_write(codec, 0x0f, 0,
11576 AC_VERB_SET_AMP_GAIN_MUTE,
11577 AMP_IN_UNMUTE(1));
11578 snd_hda_codec_write(codec, 0x10, 0,
11579 AC_VERB_SET_AMP_GAIN_MUTE,
11580 AMP_IN_UNMUTE(1));
11581 } else {
11582 snd_hda_codec_write(codec, 0x0f, 0,
11583 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11584 snd_hda_codec_write(codec, 0x10, 0,
11585 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11586 }
11587
11588 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011589 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011590 dac_vol2 = AMP_OUT_ZERO;
11591 else if (line_nid == 0x15)
11592 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011593 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011594 dac_vol2 = AMP_OUT_ZERO;
11595 else if (hp_nid == 0x15)
11596 dac_vol1 = AMP_OUT_ZERO;
11597 if (line_nid != 0x16 || hp_nid != 0x16 ||
11598 spec->autocfg.line_out_pins[1] != 0x16 ||
11599 spec->autocfg.line_out_pins[2] != 0x16)
11600 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11601
11602 snd_hda_codec_write(codec, 0x02, 0,
11603 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11604 snd_hda_codec_write(codec, 0x03, 0,
11605 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11606}
11607
11608/* pcm configuration: identiacal with ALC880 */
11609#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11610#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011611#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011612#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11613
11614/*
11615 * BIOS auto configuration
11616 */
11617static int alc268_parse_auto_config(struct hda_codec *codec)
11618{
11619 struct alc_spec *spec = codec->spec;
11620 int err;
11621 static hda_nid_t alc268_ignore[] = { 0 };
11622
11623 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11624 alc268_ignore);
11625 if (err < 0)
11626 return err;
11627 if (!spec->autocfg.line_outs)
11628 return 0; /* can't find valid BIOS pin config */
11629
11630 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11631 if (err < 0)
11632 return err;
11633 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11634 if (err < 0)
11635 return err;
11636
11637 spec->multiout.max_channels = 2;
11638
11639 /* digital only support output */
11640 if (spec->autocfg.dig_out_pin)
11641 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11642
Takashi Iwai603c4012008-07-30 15:01:44 +020011643 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011644 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011645
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011646 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011647 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011648
Takashi Iwaid88897e2008-10-31 15:01:37 +010011649 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011650 spec->num_mux_defs = 1;
11651 spec->input_mux = &spec->private_imux;
11652
Takashi Iwai776e1842007-08-29 15:07:11 +020011653 err = alc_auto_add_mic_boost(codec);
11654 if (err < 0)
11655 return err;
11656
Takashi Iwaie044c392008-10-27 16:56:24 +010011657 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011658 return 1;
11659}
11660
11661#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11662#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11663#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11664
11665/* init callback for auto-configuration model -- overriding the default init */
11666static void alc268_auto_init(struct hda_codec *codec)
11667{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011668 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011669 alc268_auto_init_multi_out(codec);
11670 alc268_auto_init_hp_out(codec);
11671 alc268_auto_init_mono_speaker_out(codec);
11672 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011673 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011674 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011675}
11676
11677/*
11678 * configuration and preset
11679 */
11680static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011681 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011682 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011683 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011684 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011685 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011686 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011687 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011688 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011689#ifdef CONFIG_SND_DEBUG
11690 [ALC268_TEST] = "test",
11691#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011692 [ALC268_AUTO] = "auto",
11693};
11694
11695static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011696 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011697 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011698 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011699 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011700 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011701 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11702 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011703 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011704 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011705 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011706 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011707 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011708 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011709 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011710 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011711 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011712 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011713 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011714 {}
11715};
11716
11717static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011718 [ALC267_QUANTA_IL1] = {
11719 .mixers = { alc267_quanta_il1_mixer },
11720 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11721 alc267_quanta_il1_verbs },
11722 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11723 .dac_nids = alc268_dac_nids,
11724 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11725 .adc_nids = alc268_adc_nids_alt,
11726 .hp_nid = 0x03,
11727 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11728 .channel_mode = alc268_modes,
11729 .input_mux = &alc268_capture_source,
11730 .unsol_event = alc267_quanta_il1_unsol_event,
11731 .init_hook = alc267_quanta_il1_automute,
11732 },
Kailang Yanga361d842007-06-05 12:30:55 +020011733 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011734 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11735 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011736 .init_verbs = { alc268_base_init_verbs },
11737 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11738 .dac_nids = alc268_dac_nids,
11739 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11740 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011741 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011742 .hp_nid = 0x03,
11743 .dig_out_nid = ALC268_DIGOUT_NID,
11744 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11745 .channel_mode = alc268_modes,
11746 .input_mux = &alc268_capture_source,
11747 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011748 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011749 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11750 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011751 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11752 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011753 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11754 .dac_nids = alc268_dac_nids,
11755 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11756 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011757 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011758 .hp_nid = 0x03,
11759 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11760 .channel_mode = alc268_modes,
11761 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011762 .unsol_event = alc268_toshiba_unsol_event,
11763 .init_hook = alc268_toshiba_automute,
11764 },
11765 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011766 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11767 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011768 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11769 alc268_acer_verbs },
11770 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11771 .dac_nids = alc268_dac_nids,
11772 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11773 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011774 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011775 .hp_nid = 0x02,
11776 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11777 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011778 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011779 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011780 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011781 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011782 [ALC268_ACER_DMIC] = {
11783 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11784 alc268_beep_mixer },
11785 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11786 alc268_acer_verbs },
11787 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11788 .dac_nids = alc268_dac_nids,
11789 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11790 .adc_nids = alc268_adc_nids_alt,
11791 .capsrc_nids = alc268_capsrc_nids,
11792 .hp_nid = 0x02,
11793 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11794 .channel_mode = alc268_modes,
11795 .input_mux = &alc268_acer_dmic_capture_source,
11796 .unsol_event = alc268_acer_unsol_event,
11797 .init_hook = alc268_acer_init_hook,
11798 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011799 [ALC268_ACER_ASPIRE_ONE] = {
11800 .mixers = { alc268_acer_aspire_one_mixer,
11801 alc268_capture_alt_mixer },
11802 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11803 alc268_acer_aspire_one_verbs },
11804 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11805 .dac_nids = alc268_dac_nids,
11806 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11807 .adc_nids = alc268_adc_nids_alt,
11808 .capsrc_nids = alc268_capsrc_nids,
11809 .hp_nid = 0x03,
11810 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11811 .channel_mode = alc268_modes,
11812 .input_mux = &alc268_acer_lc_capture_source,
11813 .unsol_event = alc268_acer_lc_unsol_event,
11814 .init_hook = alc268_acer_lc_init_hook,
11815 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011816 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011817 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011818 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11819 alc268_dell_verbs },
11820 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11821 .dac_nids = alc268_dac_nids,
11822 .hp_nid = 0x02,
11823 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11824 .channel_mode = alc268_modes,
11825 .unsol_event = alc268_dell_unsol_event,
11826 .init_hook = alc268_dell_init_hook,
11827 .input_mux = &alc268_capture_source,
11828 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011829 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011830 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11831 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011832 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11833 alc268_toshiba_verbs },
11834 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11835 .dac_nids = alc268_dac_nids,
11836 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11837 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011838 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011839 .hp_nid = 0x03,
11840 .dig_out_nid = ALC268_DIGOUT_NID,
11841 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11842 .channel_mode = alc268_modes,
11843 .input_mux = &alc268_capture_source,
11844 .unsol_event = alc268_toshiba_unsol_event,
11845 .init_hook = alc268_toshiba_automute
11846 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011847#ifdef CONFIG_SND_DEBUG
11848 [ALC268_TEST] = {
11849 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11850 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11851 alc268_volume_init_verbs },
11852 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11853 .dac_nids = alc268_dac_nids,
11854 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11855 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011856 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011857 .hp_nid = 0x03,
11858 .dig_out_nid = ALC268_DIGOUT_NID,
11859 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11860 .channel_mode = alc268_modes,
11861 .input_mux = &alc268_capture_source,
11862 },
11863#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011864};
11865
11866static int patch_alc268(struct hda_codec *codec)
11867{
11868 struct alc_spec *spec;
11869 int board_config;
11870 int err;
11871
11872 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11873 if (spec == NULL)
11874 return -ENOMEM;
11875
11876 codec->spec = spec;
11877
11878 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11879 alc268_models,
11880 alc268_cfg_tbl);
11881
11882 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11883 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11884 "trying auto-probe from BIOS...\n");
11885 board_config = ALC268_AUTO;
11886 }
11887
11888 if (board_config == ALC268_AUTO) {
11889 /* automatic parse from the BIOS config */
11890 err = alc268_parse_auto_config(codec);
11891 if (err < 0) {
11892 alc_free(codec);
11893 return err;
11894 } else if (!err) {
11895 printk(KERN_INFO
11896 "hda_codec: Cannot set up configuration "
11897 "from BIOS. Using base mode...\n");
11898 board_config = ALC268_3ST;
11899 }
11900 }
11901
11902 if (board_config != ALC268_AUTO)
11903 setup_preset(spec, &alc268_presets[board_config]);
11904
Kailang Yang2f893282008-05-27 12:14:47 +020011905 if (codec->vendor_id == 0x10ec0267) {
11906 spec->stream_name_analog = "ALC267 Analog";
11907 spec->stream_name_digital = "ALC267 Digital";
11908 } else {
11909 spec->stream_name_analog = "ALC268 Analog";
11910 spec->stream_name_digital = "ALC268 Digital";
11911 }
11912
Kailang Yanga361d842007-06-05 12:30:55 +020011913 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11914 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011915 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011916
Kailang Yanga361d842007-06-05 12:30:55 +020011917 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11918
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011919 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11920 /* override the amp caps for beep generator */
11921 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11922 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11923 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11924 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11925 (0 << AC_AMPCAP_MUTE_SHIFT));
11926
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011927 if (!spec->adc_nids && spec->input_mux) {
11928 /* check whether NID 0x07 is valid */
11929 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011930 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011931
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011932 /* get type */
11933 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011934 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011935 spec->adc_nids = alc268_adc_nids_alt;
11936 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011937 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011938 } else {
11939 spec->adc_nids = alc268_adc_nids;
11940 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011941 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011942 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011943 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011944 /* set default input source */
11945 for (i = 0; i < spec->num_adc_nids; i++)
11946 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11947 0, AC_VERB_SET_CONNECT_SEL,
11948 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011949 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011950
11951 spec->vmaster_nid = 0x02;
11952
Kailang Yanga361d842007-06-05 12:30:55 +020011953 codec->patch_ops = alc_patch_ops;
11954 if (board_config == ALC268_AUTO)
11955 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011956
Takashi Iwaidaead532008-11-28 12:55:36 +010011957 codec->proc_widget_hook = print_realtek_coef;
11958
Kailang Yanga361d842007-06-05 12:30:55 +020011959 return 0;
11960}
11961
11962/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011963 * ALC269 channel source setting (2 channel)
11964 */
11965#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11966
11967#define alc269_dac_nids alc260_dac_nids
11968
11969static hda_nid_t alc269_adc_nids[1] = {
11970 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011971 0x08,
11972};
11973
Takashi Iwaie01bf502008-08-21 16:25:07 +020011974static hda_nid_t alc269_capsrc_nids[1] = {
11975 0x23,
11976};
11977
11978/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11979 * not a mux!
11980 */
11981
Kailang Yangf53281e2008-07-18 12:36:43 +020011982static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11983 .num_items = 2,
11984 .items = {
11985 { "i-Mic", 0x5 },
11986 { "e-Mic", 0x0 },
11987 },
11988};
11989
11990static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11991 .num_items = 2,
11992 .items = {
11993 { "i-Mic", 0x1 },
11994 { "e-Mic", 0x0 },
11995 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011996};
11997
11998#define alc269_modes alc260_modes
11999#define alc269_capture_source alc880_lg_lw_capture_source
12000
12001static struct snd_kcontrol_new alc269_base_mixer[] = {
12002 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12003 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020012008 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12009 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010012010 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12013 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12015 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12016 { } /* end */
12017};
12018
Kailang Yang60db6b52008-08-26 13:13:00 +020012019static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12020 /* output mixer control */
12021 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12022 {
12023 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12024 .name = "Master Playback Switch",
12025 .info = snd_hda_mixer_amp_switch_info,
12026 .get = snd_hda_mixer_amp_switch_get,
12027 .put = alc268_acer_master_sw_put,
12028 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12029 },
12030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12033 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12034 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12035 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12036 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12037 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12038 { }
12039};
12040
Tony Vroon64154832008-11-06 15:08:49 +000012041static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12042 /* output mixer control */
12043 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12044 {
12045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12046 .name = "Master Playback Switch",
12047 .info = snd_hda_mixer_amp_switch_info,
12048 .get = snd_hda_mixer_amp_switch_get,
12049 .put = alc268_acer_master_sw_put,
12050 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12051 },
12052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12054 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12055 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12056 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12057 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12058 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12059 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12060 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12061 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12062 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12063 { }
12064};
12065
Kailang Yangf53281e2008-07-18 12:36:43 +020012066/* bind volumes of both NID 0x0c and 0x0d */
12067static struct hda_bind_ctls alc269_epc_bind_vol = {
12068 .ops = &snd_hda_bind_vol,
12069 .values = {
12070 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12071 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12072 0
12073 },
12074};
12075
12076static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12077 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12078 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12079 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12080 { } /* end */
12081};
12082
Kailang Yangf6a92242007-12-13 16:52:54 +010012083/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012084static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12085 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12086 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12088 { } /* end */
12089};
12090
12091/* FSC amilo */
12092static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12093 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12095 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012096 { } /* end */
12097};
12098
Takashi Iwai2005af22008-08-20 18:38:26 +020012099/* beep control */
12100static struct snd_kcontrol_new alc269_beep_mixer[] = {
12101 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12102 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12103 { } /* end */
12104};
12105
Kailang Yang60db6b52008-08-26 13:13:00 +020012106static struct hda_verb alc269_quanta_fl1_verbs[] = {
12107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12108 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12112 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12113 { }
12114};
12115
Tony Vroon64154832008-11-06 15:08:49 +000012116static struct hda_verb alc269_lifebook_verbs[] = {
12117 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12119 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12123 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12124 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12125 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12126 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12127 { }
12128};
12129
Kailang Yang60db6b52008-08-26 13:13:00 +020012130/* toggle speaker-output according to the hp-jack state */
12131static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12132{
12133 unsigned int present;
12134 unsigned char bits;
12135
12136 present = snd_hda_codec_read(codec, 0x15, 0,
12137 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12138 bits = present ? AMP_IN_MUTE(0) : 0;
12139 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12140 AMP_IN_MUTE(0), bits);
12141 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12142 AMP_IN_MUTE(0), bits);
12143
12144 snd_hda_codec_write(codec, 0x20, 0,
12145 AC_VERB_SET_COEF_INDEX, 0x0c);
12146 snd_hda_codec_write(codec, 0x20, 0,
12147 AC_VERB_SET_PROC_COEF, 0x680);
12148
12149 snd_hda_codec_write(codec, 0x20, 0,
12150 AC_VERB_SET_COEF_INDEX, 0x0c);
12151 snd_hda_codec_write(codec, 0x20, 0,
12152 AC_VERB_SET_PROC_COEF, 0x480);
12153}
12154
Tony Vroon64154832008-11-06 15:08:49 +000012155/* toggle speaker-output according to the hp-jacks state */
12156static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12157{
12158 unsigned int present;
12159 unsigned char bits;
12160
12161 /* Check laptop headphone socket */
12162 present = snd_hda_codec_read(codec, 0x15, 0,
12163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12164
12165 /* Check port replicator headphone socket */
12166 present |= snd_hda_codec_read(codec, 0x1a, 0,
12167 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12168
12169 bits = present ? AMP_IN_MUTE(0) : 0;
12170 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12171 AMP_IN_MUTE(0), bits);
12172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12173 AMP_IN_MUTE(0), bits);
12174
12175 snd_hda_codec_write(codec, 0x20, 0,
12176 AC_VERB_SET_COEF_INDEX, 0x0c);
12177 snd_hda_codec_write(codec, 0x20, 0,
12178 AC_VERB_SET_PROC_COEF, 0x680);
12179
12180 snd_hda_codec_write(codec, 0x20, 0,
12181 AC_VERB_SET_COEF_INDEX, 0x0c);
12182 snd_hda_codec_write(codec, 0x20, 0,
12183 AC_VERB_SET_PROC_COEF, 0x480);
12184}
12185
Kailang Yang60db6b52008-08-26 13:13:00 +020012186static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12187{
12188 unsigned int present;
12189
12190 present = snd_hda_codec_read(codec, 0x18, 0,
12191 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12192 snd_hda_codec_write(codec, 0x23, 0,
12193 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12194}
12195
Tony Vroon64154832008-11-06 15:08:49 +000012196static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12197{
12198 unsigned int present_laptop;
12199 unsigned int present_dock;
12200
12201 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12202 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12203
12204 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12205 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12206
12207 /* Laptop mic port overrides dock mic port, design decision */
12208 if (present_dock)
12209 snd_hda_codec_write(codec, 0x23, 0,
12210 AC_VERB_SET_CONNECT_SEL, 0x3);
12211 if (present_laptop)
12212 snd_hda_codec_write(codec, 0x23, 0,
12213 AC_VERB_SET_CONNECT_SEL, 0x0);
12214 if (!present_dock && !present_laptop)
12215 snd_hda_codec_write(codec, 0x23, 0,
12216 AC_VERB_SET_CONNECT_SEL, 0x1);
12217}
12218
Kailang Yang60db6b52008-08-26 13:13:00 +020012219static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12220 unsigned int res)
12221{
12222 if ((res >> 26) == ALC880_HP_EVENT)
12223 alc269_quanta_fl1_speaker_automute(codec);
12224 if ((res >> 26) == ALC880_MIC_EVENT)
12225 alc269_quanta_fl1_mic_automute(codec);
12226}
12227
Tony Vroon64154832008-11-06 15:08:49 +000012228static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12229 unsigned int res)
12230{
12231 if ((res >> 26) == ALC880_HP_EVENT)
12232 alc269_lifebook_speaker_automute(codec);
12233 if ((res >> 26) == ALC880_MIC_EVENT)
12234 alc269_lifebook_mic_autoswitch(codec);
12235}
12236
Kailang Yang60db6b52008-08-26 13:13:00 +020012237static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12238{
12239 alc269_quanta_fl1_speaker_automute(codec);
12240 alc269_quanta_fl1_mic_automute(codec);
12241}
12242
Tony Vroon64154832008-11-06 15:08:49 +000012243static void alc269_lifebook_init_hook(struct hda_codec *codec)
12244{
12245 alc269_lifebook_speaker_automute(codec);
12246 alc269_lifebook_mic_autoswitch(codec);
12247}
12248
Kailang Yang60db6b52008-08-26 13:13:00 +020012249static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12251 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12254 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12255 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12256 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12257 {}
12258};
12259
12260static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12262 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12263 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12266 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12267 {}
12268};
12269
12270/* toggle speaker-output according to the hp-jack state */
12271static void alc269_speaker_automute(struct hda_codec *codec)
12272{
12273 unsigned int present;
12274 unsigned char bits;
12275
12276 present = snd_hda_codec_read(codec, 0x15, 0,
12277 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12278 bits = present ? AMP_IN_MUTE(0) : 0;
12279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12280 AMP_IN_MUTE(0), bits);
12281 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12282 AMP_IN_MUTE(0), bits);
12283}
12284
12285static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12286{
12287 unsigned int present;
12288
12289 present = snd_hda_codec_read(codec, 0x18, 0,
12290 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12291 snd_hda_codec_write(codec, 0x23, 0,
12292 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12293}
12294
12295static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12296{
12297 unsigned int present;
12298
12299 present = snd_hda_codec_read(codec, 0x18, 0,
12300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12301 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12302 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12303 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12304 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12305}
12306
12307/* unsolicited event for HP jack sensing */
12308static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12309 unsigned int res)
12310{
12311 if ((res >> 26) == ALC880_HP_EVENT)
12312 alc269_speaker_automute(codec);
12313
12314 if ((res >> 26) == ALC880_MIC_EVENT)
12315 alc269_eeepc_dmic_automute(codec);
12316}
12317
12318static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12319{
12320 alc269_speaker_automute(codec);
12321 alc269_eeepc_dmic_automute(codec);
12322}
12323
12324/* unsolicited event for HP jack sensing */
12325static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12326 unsigned int res)
12327{
12328 if ((res >> 26) == ALC880_HP_EVENT)
12329 alc269_speaker_automute(codec);
12330
12331 if ((res >> 26) == ALC880_MIC_EVENT)
12332 alc269_eeepc_amic_automute(codec);
12333}
12334
12335static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12336{
12337 alc269_speaker_automute(codec);
12338 alc269_eeepc_amic_automute(codec);
12339}
12340
Kailang Yangf6a92242007-12-13 16:52:54 +010012341/*
12342 * generic initialization of ADC, input mixers and output mixers
12343 */
12344static struct hda_verb alc269_init_verbs[] = {
12345 /*
12346 * Unmute ADC0 and set the default input to mic-in
12347 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012349
12350 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12351 * analog-loopback mixer widget
12352 * Note: PASD motherboards uses the Line In 2 as the input for
12353 * front panel mic (mic 2)
12354 */
12355 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12361
12362 /*
12363 * Set up output mixers (0x0c - 0x0e)
12364 */
12365 /* set vol=0 to output mixers */
12366 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12367 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12368
12369 /* set up input amps for analog loopback */
12370 /* Amp Indices: DAC = 0, mixer = 1 */
12371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12377
12378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12380 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12385
12386 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12389 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12392 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12393
12394 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12395 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12396
12397 /* FIXME: use matrix-type input source selection */
12398 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12399 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12404
12405 /* set EAPD */
12406 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12407 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12408 { }
12409};
12410
12411/* add playback controls from the parsed DAC table */
12412static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12413 const struct auto_pin_cfg *cfg)
12414{
12415 hda_nid_t nid;
12416 int err;
12417
12418 spec->multiout.num_dacs = 1; /* only use one dac */
12419 spec->multiout.dac_nids = spec->private_dac_nids;
12420 spec->multiout.dac_nids[0] = 2;
12421
12422 nid = cfg->line_out_pins[0];
12423 if (nid) {
12424 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12425 "Front Playback Volume",
12426 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12427 if (err < 0)
12428 return err;
12429 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12430 "Front Playback Switch",
12431 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12432 if (err < 0)
12433 return err;
12434 }
12435
12436 nid = cfg->speaker_pins[0];
12437 if (nid) {
12438 if (!cfg->line_out_pins[0]) {
12439 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12440 "Speaker Playback Volume",
12441 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12442 HDA_OUTPUT));
12443 if (err < 0)
12444 return err;
12445 }
12446 if (nid == 0x16) {
12447 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12448 "Speaker Playback Switch",
12449 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12450 HDA_OUTPUT));
12451 if (err < 0)
12452 return err;
12453 } else {
12454 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12455 "Speaker Playback Switch",
12456 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12457 HDA_OUTPUT));
12458 if (err < 0)
12459 return err;
12460 }
12461 }
12462 nid = cfg->hp_pins[0];
12463 if (nid) {
12464 /* spec->multiout.hp_nid = 2; */
12465 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12466 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12467 "Headphone Playback Volume",
12468 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12469 HDA_OUTPUT));
12470 if (err < 0)
12471 return err;
12472 }
12473 if (nid == 0x16) {
12474 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12475 "Headphone Playback Switch",
12476 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12477 HDA_OUTPUT));
12478 if (err < 0)
12479 return err;
12480 } else {
12481 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12482 "Headphone Playback Switch",
12483 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12484 HDA_OUTPUT));
12485 if (err < 0)
12486 return err;
12487 }
12488 }
12489 return 0;
12490}
12491
Takashi Iwaiee956e02008-10-31 17:16:31 +010012492static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12493 const struct auto_pin_cfg *cfg)
12494{
12495 int err;
12496
12497 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12498 if (err < 0)
12499 return err;
12500 /* digital-mic input pin is excluded in alc880_auto_create..()
12501 * because it's under 0x18
12502 */
12503 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12504 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12505 struct hda_input_mux *imux = &spec->private_imux;
12506 imux->items[imux->num_items].label = "Int Mic";
12507 imux->items[imux->num_items].index = 0x05;
12508 imux->num_items++;
12509 }
12510 return 0;
12511}
Kailang Yangf6a92242007-12-13 16:52:54 +010012512
12513#ifdef CONFIG_SND_HDA_POWER_SAVE
12514#define alc269_loopbacks alc880_loopbacks
12515#endif
12516
12517/* pcm configuration: identiacal with ALC880 */
12518#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12519#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12520#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12521#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12522
12523/*
12524 * BIOS auto configuration
12525 */
12526static int alc269_parse_auto_config(struct hda_codec *codec)
12527{
12528 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012529 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012530 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12531
12532 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12533 alc269_ignore);
12534 if (err < 0)
12535 return err;
12536
12537 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12538 if (err < 0)
12539 return err;
12540 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12541 if (err < 0)
12542 return err;
12543
12544 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12545
12546 if (spec->autocfg.dig_out_pin)
12547 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12548
Takashi Iwai603c4012008-07-30 15:01:44 +020012549 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012550 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012551
Takashi Iwai2005af22008-08-20 18:38:26 +020012552 /* create a beep mixer control if the pin 0x1d isn't assigned */
12553 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12554 if (spec->autocfg.input_pins[i] == 0x1d)
12555 break;
12556 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012557 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012558
Takashi Iwaid88897e2008-10-31 15:01:37 +010012559 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012560 spec->num_mux_defs = 1;
12561 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012562 /* set default input source */
12563 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12564 0, AC_VERB_SET_CONNECT_SEL,
12565 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012566
12567 err = alc_auto_add_mic_boost(codec);
12568 if (err < 0)
12569 return err;
12570
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012571 if (!spec->cap_mixer)
12572 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012573
Takashi Iwaie044c392008-10-27 16:56:24 +010012574 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012575 return 1;
12576}
12577
12578#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12579#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12580#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12581
12582
12583/* init callback for auto-configuration model -- overriding the default init */
12584static void alc269_auto_init(struct hda_codec *codec)
12585{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012586 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012587 alc269_auto_init_multi_out(codec);
12588 alc269_auto_init_hp_out(codec);
12589 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012590 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012591 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012592}
12593
12594/*
12595 * configuration and preset
12596 */
12597static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012598 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012599 [ALC269_QUANTA_FL1] = "quanta",
12600 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012601 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012602 [ALC269_FUJITSU] = "fujitsu",
12603 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012604};
12605
12606static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012607 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012608 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12609 ALC269_ASUS_EEEPC_P703),
12610 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12611 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012612 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12613 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012614 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012615 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012616 {}
12617};
12618
12619static struct alc_config_preset alc269_presets[] = {
12620 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012621 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012622 .init_verbs = { alc269_init_verbs },
12623 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12624 .dac_nids = alc269_dac_nids,
12625 .hp_nid = 0x03,
12626 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12627 .channel_mode = alc269_modes,
12628 .input_mux = &alc269_capture_source,
12629 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012630 [ALC269_QUANTA_FL1] = {
12631 .mixers = { alc269_quanta_fl1_mixer },
12632 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12633 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12634 .dac_nids = alc269_dac_nids,
12635 .hp_nid = 0x03,
12636 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12637 .channel_mode = alc269_modes,
12638 .input_mux = &alc269_capture_source,
12639 .unsol_event = alc269_quanta_fl1_unsol_event,
12640 .init_hook = alc269_quanta_fl1_init_hook,
12641 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012642 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012643 .mixers = { alc269_eeepc_mixer },
12644 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012645 .init_verbs = { alc269_init_verbs,
12646 alc269_eeepc_amic_init_verbs },
12647 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12648 .dac_nids = alc269_dac_nids,
12649 .hp_nid = 0x03,
12650 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12651 .channel_mode = alc269_modes,
12652 .input_mux = &alc269_eeepc_amic_capture_source,
12653 .unsol_event = alc269_eeepc_amic_unsol_event,
12654 .init_hook = alc269_eeepc_amic_inithook,
12655 },
12656 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012657 .mixers = { alc269_eeepc_mixer },
12658 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012659 .init_verbs = { alc269_init_verbs,
12660 alc269_eeepc_dmic_init_verbs },
12661 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12662 .dac_nids = alc269_dac_nids,
12663 .hp_nid = 0x03,
12664 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12665 .channel_mode = alc269_modes,
12666 .input_mux = &alc269_eeepc_dmic_capture_source,
12667 .unsol_event = alc269_eeepc_dmic_unsol_event,
12668 .init_hook = alc269_eeepc_dmic_inithook,
12669 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012670 [ALC269_FUJITSU] = {
12671 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12672 .cap_mixer = alc269_epc_capture_mixer,
12673 .init_verbs = { alc269_init_verbs,
12674 alc269_eeepc_dmic_init_verbs },
12675 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12676 .dac_nids = alc269_dac_nids,
12677 .hp_nid = 0x03,
12678 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12679 .channel_mode = alc269_modes,
12680 .input_mux = &alc269_eeepc_dmic_capture_source,
12681 .unsol_event = alc269_eeepc_dmic_unsol_event,
12682 .init_hook = alc269_eeepc_dmic_inithook,
12683 },
Tony Vroon64154832008-11-06 15:08:49 +000012684 [ALC269_LIFEBOOK] = {
12685 .mixers = { alc269_lifebook_mixer },
12686 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12687 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12688 .dac_nids = alc269_dac_nids,
12689 .hp_nid = 0x03,
12690 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12691 .channel_mode = alc269_modes,
12692 .input_mux = &alc269_capture_source,
12693 .unsol_event = alc269_lifebook_unsol_event,
12694 .init_hook = alc269_lifebook_init_hook,
12695 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012696};
12697
12698static int patch_alc269(struct hda_codec *codec)
12699{
12700 struct alc_spec *spec;
12701 int board_config;
12702 int err;
12703
12704 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12705 if (spec == NULL)
12706 return -ENOMEM;
12707
12708 codec->spec = spec;
12709
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012710 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12711
Kailang Yangf6a92242007-12-13 16:52:54 +010012712 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12713 alc269_models,
12714 alc269_cfg_tbl);
12715
12716 if (board_config < 0) {
12717 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12718 "trying auto-probe from BIOS...\n");
12719 board_config = ALC269_AUTO;
12720 }
12721
12722 if (board_config == ALC269_AUTO) {
12723 /* automatic parse from the BIOS config */
12724 err = alc269_parse_auto_config(codec);
12725 if (err < 0) {
12726 alc_free(codec);
12727 return err;
12728 } else if (!err) {
12729 printk(KERN_INFO
12730 "hda_codec: Cannot set up configuration "
12731 "from BIOS. Using base mode...\n");
12732 board_config = ALC269_BASIC;
12733 }
12734 }
12735
12736 if (board_config != ALC269_AUTO)
12737 setup_preset(spec, &alc269_presets[board_config]);
12738
12739 spec->stream_name_analog = "ALC269 Analog";
12740 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12741 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12742
12743 spec->stream_name_digital = "ALC269 Digital";
12744 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12745 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12746
12747 spec->adc_nids = alc269_adc_nids;
12748 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012749 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012750 if (!spec->cap_mixer)
12751 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012752
12753 codec->patch_ops = alc_patch_ops;
12754 if (board_config == ALC269_AUTO)
12755 spec->init_hook = alc269_auto_init;
12756#ifdef CONFIG_SND_HDA_POWER_SAVE
12757 if (!spec->loopback.amplist)
12758 spec->loopback.amplist = alc269_loopbacks;
12759#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012760 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012761
12762 return 0;
12763}
12764
12765/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012766 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12767 */
12768
12769/*
12770 * set the path ways for 2 channel output
12771 * need to set the codec line out and mic 1 pin widgets to inputs
12772 */
12773static struct hda_verb alc861_threestack_ch2_init[] = {
12774 /* set pin widget 1Ah (line in) for input */
12775 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012776 /* set pin widget 18h (mic1/2) for input, for mic also enable
12777 * the vref
12778 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012779 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12780
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012781 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12782#if 0
12783 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12784 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12785#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012786 { } /* end */
12787};
12788/*
12789 * 6ch mode
12790 * need to set the codec line out and mic 1 pin widgets to outputs
12791 */
12792static struct hda_verb alc861_threestack_ch6_init[] = {
12793 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12794 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12795 /* set pin widget 18h (mic1) for output (CLFE)*/
12796 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12797
12798 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012799 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012800
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012801 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12802#if 0
12803 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12804 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12805#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012806 { } /* end */
12807};
12808
12809static struct hda_channel_mode alc861_threestack_modes[2] = {
12810 { 2, alc861_threestack_ch2_init },
12811 { 6, alc861_threestack_ch6_init },
12812};
Takashi Iwai22309c32006-08-09 16:57:28 +020012813/* Set mic1 as input and unmute the mixer */
12814static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12815 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12816 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12817 { } /* end */
12818};
12819/* Set mic1 as output and mute mixer */
12820static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12821 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12822 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12823 { } /* end */
12824};
12825
12826static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12827 { 2, alc861_uniwill_m31_ch2_init },
12828 { 4, alc861_uniwill_m31_ch4_init },
12829};
Kailang Yangdf694da2005-12-05 19:42:22 +010012830
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012831/* Set mic1 and line-in as input and unmute the mixer */
12832static struct hda_verb alc861_asus_ch2_init[] = {
12833 /* set pin widget 1Ah (line in) for input */
12834 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012835 /* set pin widget 18h (mic1/2) for input, for mic also enable
12836 * the vref
12837 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012838 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12839
12840 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12841#if 0
12842 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12843 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12844#endif
12845 { } /* end */
12846};
12847/* Set mic1 nad line-in as output and mute mixer */
12848static struct hda_verb alc861_asus_ch6_init[] = {
12849 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12850 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12851 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12852 /* set pin widget 18h (mic1) for output (CLFE)*/
12853 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12854 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12855 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12856 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12857
12858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12859#if 0
12860 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12861 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12862#endif
12863 { } /* end */
12864};
12865
12866static struct hda_channel_mode alc861_asus_modes[2] = {
12867 { 2, alc861_asus_ch2_init },
12868 { 6, alc861_asus_ch6_init },
12869};
12870
Kailang Yangdf694da2005-12-05 19:42:22 +010012871/* patch-ALC861 */
12872
12873static struct snd_kcontrol_new alc861_base_mixer[] = {
12874 /* output mixer control */
12875 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12876 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12877 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12878 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12880
12881 /*Input mixer control */
12882 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12883 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12884 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12885 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12886 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12887 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12889 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12890 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012892
Kailang Yangdf694da2005-12-05 19:42:22 +010012893 { } /* end */
12894};
12895
12896static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12897 /* output mixer control */
12898 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12899 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12900 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12901 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12902 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12903
12904 /* Input mixer control */
12905 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12907 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12908 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12909 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12910 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12912 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12913 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012915
Kailang Yangdf694da2005-12-05 19:42:22 +010012916 {
12917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12918 .name = "Channel Mode",
12919 .info = alc_ch_mode_info,
12920 .get = alc_ch_mode_get,
12921 .put = alc_ch_mode_put,
12922 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12923 },
12924 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012925};
12926
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012927static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012928 /* output mixer control */
12929 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12931 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012932
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012933 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012934};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012935
Takashi Iwai22309c32006-08-09 16:57:28 +020012936static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12937 /* output mixer control */
12938 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12939 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12940 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12941 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12942 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12943
12944 /* Input mixer control */
12945 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12947 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12948 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12949 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12950 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12952 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012955
Takashi Iwai22309c32006-08-09 16:57:28 +020012956 {
12957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12958 .name = "Channel Mode",
12959 .info = alc_ch_mode_info,
12960 .get = alc_ch_mode_get,
12961 .put = alc_ch_mode_put,
12962 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12963 },
12964 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012965};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012966
12967static struct snd_kcontrol_new alc861_asus_mixer[] = {
12968 /* output mixer control */
12969 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12970 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12971 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12972 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12973 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12974
12975 /* Input mixer control */
12976 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12977 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12978 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12979 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12980 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12981 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12983 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12984 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12986
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012987 {
12988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12989 .name = "Channel Mode",
12990 .info = alc_ch_mode_info,
12991 .get = alc_ch_mode_get,
12992 .put = alc_ch_mode_put,
12993 .private_value = ARRAY_SIZE(alc861_asus_modes),
12994 },
12995 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012996};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012997
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012998/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012999static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013000 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13001 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13002 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
13003 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
13004 { }
13005};
13006
Kailang Yangdf694da2005-12-05 19:42:22 +010013007/*
13008 * generic initialization of ADC, input mixers and output mixers
13009 */
13010static struct hda_verb alc861_base_init_verbs[] = {
13011 /*
13012 * Unmute ADC0 and set the default input to mic-in
13013 */
13014 /* port-A for surround (rear panel) */
13015 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13016 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13017 /* port-B for mic-in (rear panel) with vref */
13018 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13019 /* port-C for line-in (rear panel) */
13020 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13021 /* port-D for Front */
13022 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13023 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13024 /* port-E for HP out (front panel) */
13025 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13026 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013027 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013028 /* port-F for mic-in (front panel) with vref */
13029 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13030 /* port-G for CLFE (rear panel) */
13031 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13032 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13033 /* port-H for side (rear panel) */
13034 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13035 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13036 /* CD-in */
13037 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13038 /* route front mic to ADC1*/
13039 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013041
Kailang Yangdf694da2005-12-05 19:42:22 +010013042 /* Unmute DAC0~3 & spdif out*/
13043 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13044 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13045 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13046 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013048
Kailang Yangdf694da2005-12-05 19:42:22 +010013049 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13050 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13051 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13052 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13053 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013054
Kailang Yangdf694da2005-12-05 19:42:22 +010013055 /* Unmute Stereo Mixer 15 */
13056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013060
13061 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13062 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13063 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13064 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13067 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013069 /* hp used DAC 3 (Front) */
13070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13072
13073 { }
13074};
13075
13076static struct hda_verb alc861_threestack_init_verbs[] = {
13077 /*
13078 * Unmute ADC0 and set the default input to mic-in
13079 */
13080 /* port-A for surround (rear panel) */
13081 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13082 /* port-B for mic-in (rear panel) with vref */
13083 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13084 /* port-C for line-in (rear panel) */
13085 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13086 /* port-D for Front */
13087 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13088 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13089 /* port-E for HP out (front panel) */
13090 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13091 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013092 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013093 /* port-F for mic-in (front panel) with vref */
13094 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13095 /* port-G for CLFE (rear panel) */
13096 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13097 /* port-H for side (rear panel) */
13098 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13099 /* CD-in */
13100 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13101 /* route front mic to ADC1*/
13102 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13104 /* Unmute DAC0~3 & spdif out*/
13105 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13106 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13107 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13108 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013110
Kailang Yangdf694da2005-12-05 19:42:22 +010013111 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13112 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13113 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13114 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13115 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013116
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 /* Unmute Stereo Mixer 15 */
13118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013122
13123 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13124 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13125 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13128 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013131 /* hp used DAC 3 (Front) */
13132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13134 { }
13135};
Takashi Iwai22309c32006-08-09 16:57:28 +020013136
13137static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13138 /*
13139 * Unmute ADC0 and set the default input to mic-in
13140 */
13141 /* port-A for surround (rear panel) */
13142 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13143 /* port-B for mic-in (rear panel) with vref */
13144 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13145 /* port-C for line-in (rear panel) */
13146 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13147 /* port-D for Front */
13148 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13149 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13150 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013151 /* this has to be set to VREF80 */
13152 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013153 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013154 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013155 /* port-F for mic-in (front panel) with vref */
13156 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13157 /* port-G for CLFE (rear panel) */
13158 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13159 /* port-H for side (rear panel) */
13160 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13161 /* CD-in */
13162 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13163 /* route front mic to ADC1*/
13164 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13166 /* Unmute DAC0~3 & spdif out*/
13167 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13168 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13169 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13170 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013172
Takashi Iwai22309c32006-08-09 16:57:28 +020013173 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13174 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13175 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13176 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13177 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013178
Takashi Iwai22309c32006-08-09 16:57:28 +020013179 /* Unmute Stereo Mixer 15 */
13180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013184
13185 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13189 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013193 /* hp used DAC 3 (Front) */
13194 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013195 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13196 { }
13197};
13198
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013199static struct hda_verb alc861_asus_init_verbs[] = {
13200 /*
13201 * Unmute ADC0 and set the default input to mic-in
13202 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013203 /* port-A for surround (rear panel)
13204 * according to codec#0 this is the HP jack
13205 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013206 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13207 /* route front PCM to HP */
13208 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13209 /* port-B for mic-in (rear panel) with vref */
13210 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13211 /* port-C for line-in (rear panel) */
13212 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13213 /* port-D for Front */
13214 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13215 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13216 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013217 /* this has to be set to VREF80 */
13218 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013219 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013220 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013221 /* port-F for mic-in (front panel) with vref */
13222 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13223 /* port-G for CLFE (rear panel) */
13224 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13225 /* port-H for side (rear panel) */
13226 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13227 /* CD-in */
13228 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13229 /* route front mic to ADC1*/
13230 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13232 /* Unmute DAC0~3 & spdif out*/
13233 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13235 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13236 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13238 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13239 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13240 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13241 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13242 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013243
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013244 /* Unmute Stereo Mixer 15 */
13245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013249
13250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13252 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13253 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13254 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13256 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013258 /* hp used DAC 3 (Front) */
13259 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13261 { }
13262};
13263
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013264/* additional init verbs for ASUS laptops */
13265static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13266 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13267 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13268 { }
13269};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013270
Kailang Yangdf694da2005-12-05 19:42:22 +010013271/*
13272 * generic initialization of ADC, input mixers and output mixers
13273 */
13274static struct hda_verb alc861_auto_init_verbs[] = {
13275 /*
13276 * Unmute ADC0 and set the default input to mic-in
13277 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013278 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013280
Kailang Yangdf694da2005-12-05 19:42:22 +010013281 /* Unmute DAC0~3 & spdif out*/
13282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13283 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13285 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013287
Kailang Yangdf694da2005-12-05 19:42:22 +010013288 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13289 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13290 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13291 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13292 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013293
Kailang Yangdf694da2005-12-05 19:42:22 +010013294 /* Unmute Stereo Mixer 15 */
13295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13299
13300 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13301 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13302 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13303 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13308
13309 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013313 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13314 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013319
13320 { }
13321};
13322
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013323static struct hda_verb alc861_toshiba_init_verbs[] = {
13324 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013325
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013326 { }
13327};
13328
13329/* toggle speaker-output according to the hp-jack state */
13330static void alc861_toshiba_automute(struct hda_codec *codec)
13331{
13332 unsigned int present;
13333
13334 present = snd_hda_codec_read(codec, 0x0f, 0,
13335 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013336 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13337 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13338 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13339 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013340}
13341
13342static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13343 unsigned int res)
13344{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013345 if ((res >> 26) == ALC880_HP_EVENT)
13346 alc861_toshiba_automute(codec);
13347}
13348
Kailang Yangdf694da2005-12-05 19:42:22 +010013349/* pcm configuration: identiacal with ALC880 */
13350#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13351#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13352#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13353#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13354
13355
13356#define ALC861_DIGOUT_NID 0x07
13357
13358static struct hda_channel_mode alc861_8ch_modes[1] = {
13359 { 8, NULL }
13360};
13361
13362static hda_nid_t alc861_dac_nids[4] = {
13363 /* front, surround, clfe, side */
13364 0x03, 0x06, 0x05, 0x04
13365};
13366
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013367static hda_nid_t alc660_dac_nids[3] = {
13368 /* front, clfe, surround */
13369 0x03, 0x05, 0x06
13370};
13371
Kailang Yangdf694da2005-12-05 19:42:22 +010013372static hda_nid_t alc861_adc_nids[1] = {
13373 /* ADC0-2 */
13374 0x08,
13375};
13376
13377static struct hda_input_mux alc861_capture_source = {
13378 .num_items = 5,
13379 .items = {
13380 { "Mic", 0x0 },
13381 { "Front Mic", 0x3 },
13382 { "Line", 0x1 },
13383 { "CD", 0x4 },
13384 { "Mixer", 0x5 },
13385 },
13386};
13387
13388/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013389static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13390 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013391{
13392 int i;
13393 hda_nid_t nid;
13394
13395 spec->multiout.dac_nids = spec->private_dac_nids;
13396 for (i = 0; i < cfg->line_outs; i++) {
13397 nid = cfg->line_out_pins[i];
13398 if (nid) {
13399 if (i >= ARRAY_SIZE(alc861_dac_nids))
13400 continue;
13401 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13402 }
13403 }
13404 spec->multiout.num_dacs = cfg->line_outs;
13405 return 0;
13406}
13407
13408/* add playback controls from the parsed DAC table */
13409static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13410 const struct auto_pin_cfg *cfg)
13411{
13412 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413 static const char *chname[4] = {
13414 "Front", "Surround", NULL /*CLFE*/, "Side"
13415 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013416 hda_nid_t nid;
13417 int i, idx, err;
13418
13419 for (i = 0; i < cfg->line_outs; i++) {
13420 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013421 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013422 continue;
13423 if (nid == 0x05) {
13424 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013425 err = add_control(spec, ALC_CTL_BIND_MUTE,
13426 "Center Playback Switch",
13427 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13428 HDA_OUTPUT));
13429 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013431 err = add_control(spec, ALC_CTL_BIND_MUTE,
13432 "LFE Playback Switch",
13433 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13434 HDA_OUTPUT));
13435 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013436 return err;
13437 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013438 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13439 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013440 if (nid == alc861_dac_nids[idx])
13441 break;
13442 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013443 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13444 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13445 HDA_OUTPUT));
13446 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013447 return err;
13448 }
13449 }
13450 return 0;
13451}
13452
13453static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13454{
13455 int err;
13456 hda_nid_t nid;
13457
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013458 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013459 return 0;
13460
13461 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13462 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013463 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13464 "Headphone Playback Switch",
13465 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13466 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013467 return err;
13468 spec->multiout.hp_nid = nid;
13469 }
13470 return 0;
13471}
13472
13473/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013474static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13475 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013476{
Kailang Yangdf694da2005-12-05 19:42:22 +010013477 struct hda_input_mux *imux = &spec->private_imux;
13478 int i, err, idx, idx1;
13479
13480 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013481 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013482 case 0x0c:
13483 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013484 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013485 break;
13486 case 0x0f:
13487 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013488 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013489 break;
13490 case 0x0d:
13491 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013492 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013493 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013494 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013495 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013496 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013497 break;
13498 case 0x11:
13499 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013500 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013501 break;
13502 default:
13503 continue;
13504 }
13505
Takashi Iwai4a471b72005-12-07 13:56:29 +010013506 err = new_analog_input(spec, cfg->input_pins[i],
13507 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013508 if (err < 0)
13509 return err;
13510
Takashi Iwai4a471b72005-12-07 13:56:29 +010013511 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013512 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013513 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013514 }
13515 return 0;
13516}
13517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013518static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13519 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013520 int pin_type, int dac_idx)
13521{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013522 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13523 pin_type);
13524 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13525 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013526}
13527
13528static void alc861_auto_init_multi_out(struct hda_codec *codec)
13529{
13530 struct alc_spec *spec = codec->spec;
13531 int i;
13532
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013533 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013534 for (i = 0; i < spec->autocfg.line_outs; i++) {
13535 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013536 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013537 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013538 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013539 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013540 }
13541}
13542
13543static void alc861_auto_init_hp_out(struct hda_codec *codec)
13544{
13545 struct alc_spec *spec = codec->spec;
13546 hda_nid_t pin;
13547
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013548 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013549 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013550 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13551 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013552 pin = spec->autocfg.speaker_pins[0];
13553 if (pin)
13554 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013555}
13556
13557static void alc861_auto_init_analog_input(struct hda_codec *codec)
13558{
13559 struct alc_spec *spec = codec->spec;
13560 int i;
13561
13562 for (i = 0; i < AUTO_PIN_LAST; i++) {
13563 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013564 if (nid >= 0x0c && nid <= 0x11) {
13565 snd_hda_codec_write(codec, nid, 0,
13566 AC_VERB_SET_PIN_WIDGET_CONTROL,
13567 i <= AUTO_PIN_FRONT_MIC ?
13568 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013569 }
13570 }
13571}
13572
13573/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013574/* return 1 if successful, 0 if the proper config is not found,
13575 * or a negative error code
13576 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013577static int alc861_parse_auto_config(struct hda_codec *codec)
13578{
13579 struct alc_spec *spec = codec->spec;
13580 int err;
13581 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13582
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013583 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13584 alc861_ignore);
13585 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013586 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013588 return 0; /* can't find valid BIOS pin config */
13589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013590 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13591 if (err < 0)
13592 return err;
13593 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13594 if (err < 0)
13595 return err;
13596 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13597 if (err < 0)
13598 return err;
13599 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13600 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013601 return err;
13602
13603 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13604
13605 if (spec->autocfg.dig_out_pin)
13606 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13607
Takashi Iwai603c4012008-07-30 15:01:44 +020013608 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013609 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013610
Takashi Iwaid88897e2008-10-31 15:01:37 +010013611 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013612
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013613 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013614 spec->input_mux = &spec->private_imux;
13615
13616 spec->adc_nids = alc861_adc_nids;
13617 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013618 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013619
Takashi Iwaie044c392008-10-27 16:56:24 +010013620 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013621 return 1;
13622}
13623
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013624/* additional initialization for auto-configuration model */
13625static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013626{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013627 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013628 alc861_auto_init_multi_out(codec);
13629 alc861_auto_init_hp_out(codec);
13630 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013631 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013632 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013633}
13634
Takashi Iwaicb53c622007-08-10 17:21:45 +020013635#ifdef CONFIG_SND_HDA_POWER_SAVE
13636static struct hda_amp_list alc861_loopbacks[] = {
13637 { 0x15, HDA_INPUT, 0 },
13638 { 0x15, HDA_INPUT, 1 },
13639 { 0x15, HDA_INPUT, 2 },
13640 { 0x15, HDA_INPUT, 3 },
13641 { } /* end */
13642};
13643#endif
13644
Kailang Yangdf694da2005-12-05 19:42:22 +010013645
13646/*
13647 * configuration and preset
13648 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013649static const char *alc861_models[ALC861_MODEL_LAST] = {
13650 [ALC861_3ST] = "3stack",
13651 [ALC660_3ST] = "3stack-660",
13652 [ALC861_3ST_DIG] = "3stack-dig",
13653 [ALC861_6ST_DIG] = "6stack-dig",
13654 [ALC861_UNIWILL_M31] = "uniwill-m31",
13655 [ALC861_TOSHIBA] = "toshiba",
13656 [ALC861_ASUS] = "asus",
13657 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13658 [ALC861_AUTO] = "auto",
13659};
13660
13661static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013662 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013663 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13664 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13665 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013666 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013667 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013668 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013669 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13670 * Any other models that need this preset?
13671 */
13672 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013673 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13674 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013675 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13676 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13677 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13678 /* FIXME: the below seems conflict */
13679 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13680 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13681 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013682 {}
13683};
13684
13685static struct alc_config_preset alc861_presets[] = {
13686 [ALC861_3ST] = {
13687 .mixers = { alc861_3ST_mixer },
13688 .init_verbs = { alc861_threestack_init_verbs },
13689 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13690 .dac_nids = alc861_dac_nids,
13691 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13692 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013693 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013694 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13695 .adc_nids = alc861_adc_nids,
13696 .input_mux = &alc861_capture_source,
13697 },
13698 [ALC861_3ST_DIG] = {
13699 .mixers = { alc861_base_mixer },
13700 .init_verbs = { alc861_threestack_init_verbs },
13701 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13702 .dac_nids = alc861_dac_nids,
13703 .dig_out_nid = ALC861_DIGOUT_NID,
13704 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13705 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013706 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013707 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13708 .adc_nids = alc861_adc_nids,
13709 .input_mux = &alc861_capture_source,
13710 },
13711 [ALC861_6ST_DIG] = {
13712 .mixers = { alc861_base_mixer },
13713 .init_verbs = { alc861_base_init_verbs },
13714 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13715 .dac_nids = alc861_dac_nids,
13716 .dig_out_nid = ALC861_DIGOUT_NID,
13717 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13718 .channel_mode = alc861_8ch_modes,
13719 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13720 .adc_nids = alc861_adc_nids,
13721 .input_mux = &alc861_capture_source,
13722 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013723 [ALC660_3ST] = {
13724 .mixers = { alc861_3ST_mixer },
13725 .init_verbs = { alc861_threestack_init_verbs },
13726 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13727 .dac_nids = alc660_dac_nids,
13728 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13729 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013730 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013731 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13732 .adc_nids = alc861_adc_nids,
13733 .input_mux = &alc861_capture_source,
13734 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013735 [ALC861_UNIWILL_M31] = {
13736 .mixers = { alc861_uniwill_m31_mixer },
13737 .init_verbs = { alc861_uniwill_m31_init_verbs },
13738 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13739 .dac_nids = alc861_dac_nids,
13740 .dig_out_nid = ALC861_DIGOUT_NID,
13741 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13742 .channel_mode = alc861_uniwill_m31_modes,
13743 .need_dac_fix = 1,
13744 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13745 .adc_nids = alc861_adc_nids,
13746 .input_mux = &alc861_capture_source,
13747 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013748 [ALC861_TOSHIBA] = {
13749 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013750 .init_verbs = { alc861_base_init_verbs,
13751 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013752 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13753 .dac_nids = alc861_dac_nids,
13754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13755 .channel_mode = alc883_3ST_2ch_modes,
13756 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13757 .adc_nids = alc861_adc_nids,
13758 .input_mux = &alc861_capture_source,
13759 .unsol_event = alc861_toshiba_unsol_event,
13760 .init_hook = alc861_toshiba_automute,
13761 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013762 [ALC861_ASUS] = {
13763 .mixers = { alc861_asus_mixer },
13764 .init_verbs = { alc861_asus_init_verbs },
13765 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13766 .dac_nids = alc861_dac_nids,
13767 .dig_out_nid = ALC861_DIGOUT_NID,
13768 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13769 .channel_mode = alc861_asus_modes,
13770 .need_dac_fix = 1,
13771 .hp_nid = 0x06,
13772 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13773 .adc_nids = alc861_adc_nids,
13774 .input_mux = &alc861_capture_source,
13775 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013776 [ALC861_ASUS_LAPTOP] = {
13777 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13778 .init_verbs = { alc861_asus_init_verbs,
13779 alc861_asus_laptop_init_verbs },
13780 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13781 .dac_nids = alc861_dac_nids,
13782 .dig_out_nid = ALC861_DIGOUT_NID,
13783 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13784 .channel_mode = alc883_3ST_2ch_modes,
13785 .need_dac_fix = 1,
13786 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13787 .adc_nids = alc861_adc_nids,
13788 .input_mux = &alc861_capture_source,
13789 },
13790};
Kailang Yangdf694da2005-12-05 19:42:22 +010013791
13792
13793static int patch_alc861(struct hda_codec *codec)
13794{
13795 struct alc_spec *spec;
13796 int board_config;
13797 int err;
13798
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013799 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013800 if (spec == NULL)
13801 return -ENOMEM;
13802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013803 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013804
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013805 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13806 alc861_models,
13807 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013808
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013809 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013810 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13811 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013812 board_config = ALC861_AUTO;
13813 }
13814
13815 if (board_config == ALC861_AUTO) {
13816 /* automatic parse from the BIOS config */
13817 err = alc861_parse_auto_config(codec);
13818 if (err < 0) {
13819 alc_free(codec);
13820 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013821 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013822 printk(KERN_INFO
13823 "hda_codec: Cannot set up configuration "
13824 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013825 board_config = ALC861_3ST_DIG;
13826 }
13827 }
13828
13829 if (board_config != ALC861_AUTO)
13830 setup_preset(spec, &alc861_presets[board_config]);
13831
13832 spec->stream_name_analog = "ALC861 Analog";
13833 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13834 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13835
13836 spec->stream_name_digital = "ALC861 Digital";
13837 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13838 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13839
Takashi Iwai2134ea42008-01-10 16:53:55 +010013840 spec->vmaster_nid = 0x03;
13841
Kailang Yangdf694da2005-12-05 19:42:22 +010013842 codec->patch_ops = alc_patch_ops;
13843 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013844 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013845#ifdef CONFIG_SND_HDA_POWER_SAVE
13846 if (!spec->loopback.amplist)
13847 spec->loopback.amplist = alc861_loopbacks;
13848#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013849 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020013850
Kailang Yangdf694da2005-12-05 19:42:22 +010013851 return 0;
13852}
13853
13854/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013855 * ALC861-VD support
13856 *
13857 * Based on ALC882
13858 *
13859 * In addition, an independent DAC
13860 */
13861#define ALC861VD_DIGOUT_NID 0x06
13862
13863static hda_nid_t alc861vd_dac_nids[4] = {
13864 /* front, surr, clfe, side surr */
13865 0x02, 0x03, 0x04, 0x05
13866};
13867
13868/* dac_nids for ALC660vd are in a different order - according to
13869 * Realtek's driver.
13870 * This should probably tesult in a different mixer for 6stack models
13871 * of ALC660vd codecs, but for now there is only 3stack mixer
13872 * - and it is the same as in 861vd.
13873 * adc_nids in ALC660vd are (is) the same as in 861vd
13874 */
13875static hda_nid_t alc660vd_dac_nids[3] = {
13876 /* front, rear, clfe, rear_surr */
13877 0x02, 0x04, 0x03
13878};
13879
13880static hda_nid_t alc861vd_adc_nids[1] = {
13881 /* ADC0 */
13882 0x09,
13883};
13884
Takashi Iwaie1406342008-02-11 18:32:32 +010013885static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13886
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013887/* input MUX */
13888/* FIXME: should be a matrix-type input source selection */
13889static struct hda_input_mux alc861vd_capture_source = {
13890 .num_items = 4,
13891 .items = {
13892 { "Mic", 0x0 },
13893 { "Front Mic", 0x1 },
13894 { "Line", 0x2 },
13895 { "CD", 0x4 },
13896 },
13897};
13898
Kailang Yang272a5272007-05-14 11:00:38 +020013899static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013900 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013901 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013902 { "Ext Mic", 0x0 },
13903 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013904 },
13905};
13906
Kailang Yangd1a991a2007-08-15 16:21:59 +020013907static struct hda_input_mux alc861vd_hp_capture_source = {
13908 .num_items = 2,
13909 .items = {
13910 { "Front Mic", 0x0 },
13911 { "ATAPI Mic", 0x1 },
13912 },
13913};
13914
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013915/*
13916 * 2ch mode
13917 */
13918static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13919 { 2, NULL }
13920};
13921
13922/*
13923 * 6ch mode
13924 */
13925static struct hda_verb alc861vd_6stack_ch6_init[] = {
13926 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13927 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13928 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13929 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13930 { } /* end */
13931};
13932
13933/*
13934 * 8ch mode
13935 */
13936static struct hda_verb alc861vd_6stack_ch8_init[] = {
13937 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13939 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13940 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13941 { } /* end */
13942};
13943
13944static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13945 { 6, alc861vd_6stack_ch6_init },
13946 { 8, alc861vd_6stack_ch8_init },
13947};
13948
13949static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13950 {
13951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13952 .name = "Channel Mode",
13953 .info = alc_ch_mode_info,
13954 .get = alc_ch_mode_get,
13955 .put = alc_ch_mode_put,
13956 },
13957 { } /* end */
13958};
13959
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013960/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13961 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13962 */
13963static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13964 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13966
13967 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13968 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13969
13970 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13971 HDA_OUTPUT),
13972 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13973 HDA_OUTPUT),
13974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13976
13977 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13978 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13979
13980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13981
13982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13985
13986 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13987 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13988 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13989
13990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13992
13993 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13994 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13995
13996 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13997 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13998
13999 { } /* end */
14000};
14001
14002static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14003 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14005
14006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14007
14008 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14011
14012 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14015
14016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14018
14019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14021
14022 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14023 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14024
14025 { } /* end */
14026};
14027
Kailang Yangbdd148a2007-05-08 15:19:08 +020014028static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14029 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14030 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14031 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14032
14033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14034
14035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14038
14039 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14040 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14041 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14042
14043 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14044 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14045
14046 { } /* end */
14047};
14048
Tobin Davisb419f342008-03-07 11:57:51 +010014049/* Pin assignment: Speaker=0x14, HP = 0x15,
14050 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014051 */
14052static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014053 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14054 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014055 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14056 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014057 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14058 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14059 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14060 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14061 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14062 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14063 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14064 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014065 { } /* end */
14066};
14067
Kailang Yangd1a991a2007-08-15 16:21:59 +020014068/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14069 * Front Mic=0x18, ATAPI Mic = 0x19,
14070 */
14071static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14072 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14073 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14075 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14076 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14078 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14079 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014080
Kailang Yangd1a991a2007-08-15 16:21:59 +020014081 { } /* end */
14082};
14083
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014084/*
14085 * generic initialization of ADC, input mixers and output mixers
14086 */
14087static struct hda_verb alc861vd_volume_init_verbs[] = {
14088 /*
14089 * Unmute ADC0 and set the default input to mic-in
14090 */
14091 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14093
14094 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14095 * the analog-loopback mixer widget
14096 */
14097 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014103
14104 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014109
14110 /*
14111 * Set up output mixers (0x02 - 0x05)
14112 */
14113 /* set vol=0 to output mixers */
14114 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14115 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14117 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14118
14119 /* set up input amps for analog loopback */
14120 /* Amp Indices: DAC = 0, mixer = 1 */
14121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14126 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129
14130 { }
14131};
14132
14133/*
14134 * 3-stack pin configuration:
14135 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14136 */
14137static struct hda_verb alc861vd_3stack_init_verbs[] = {
14138 /*
14139 * Set pin mode and muting
14140 */
14141 /* set front pin widgets 0x14 for output */
14142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14143 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14144 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14145
14146 /* Mic (rear) pin: input vref at 80% */
14147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14149 /* Front Mic pin: input vref at 80% */
14150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14152 /* Line In pin: input */
14153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14155 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14158 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14159 /* CD pin widget for input */
14160 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14161
14162 { }
14163};
14164
14165/*
14166 * 6-stack pin configuration:
14167 */
14168static struct hda_verb alc861vd_6stack_init_verbs[] = {
14169 /*
14170 * Set pin mode and muting
14171 */
14172 /* set front pin widgets 0x14 for output */
14173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14174 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14175 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14176
14177 /* Rear Pin: output 1 (0x0d) */
14178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14181 /* CLFE Pin: output 2 (0x0e) */
14182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14183 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14184 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14185 /* Side Pin: output 3 (0x0f) */
14186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14188 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14189
14190 /* Mic (rear) pin: input vref at 80% */
14191 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14193 /* Front Mic pin: input vref at 80% */
14194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14196 /* Line In pin: input */
14197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14198 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14199 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14202 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14203 /* CD pin widget for input */
14204 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14205
14206 { }
14207};
14208
Kailang Yangbdd148a2007-05-08 15:19:08 +020014209static struct hda_verb alc861vd_eapd_verbs[] = {
14210 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14211 { }
14212};
14213
Kailang Yangf9423e72008-05-27 12:32:25 +020014214static struct hda_verb alc660vd_eapd_verbs[] = {
14215 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14216 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14217 { }
14218};
14219
Kailang Yangbdd148a2007-05-08 15:19:08 +020014220static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14224 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014226 {}
14227};
14228
14229/* toggle speaker-output according to the hp-jack state */
14230static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14231{
14232 unsigned int present;
14233 unsigned char bits;
14234
14235 present = snd_hda_codec_read(codec, 0x1b, 0,
14236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014237 bits = present ? HDA_AMP_MUTE : 0;
14238 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14239 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014240}
14241
14242static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14243{
14244 unsigned int present;
14245 unsigned char bits;
14246
14247 present = snd_hda_codec_read(codec, 0x18, 0,
14248 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014249 bits = present ? HDA_AMP_MUTE : 0;
14250 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14251 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014252}
14253
14254static void alc861vd_lenovo_automute(struct hda_codec *codec)
14255{
14256 alc861vd_lenovo_hp_automute(codec);
14257 alc861vd_lenovo_mic_automute(codec);
14258}
14259
14260static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14261 unsigned int res)
14262{
14263 switch (res >> 26) {
14264 case ALC880_HP_EVENT:
14265 alc861vd_lenovo_hp_automute(codec);
14266 break;
14267 case ALC880_MIC_EVENT:
14268 alc861vd_lenovo_mic_automute(codec);
14269 break;
14270 }
14271}
14272
Kailang Yang272a5272007-05-14 11:00:38 +020014273static struct hda_verb alc861vd_dallas_verbs[] = {
14274 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14275 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14276 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14277 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14278
14279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014287
Kailang Yang272a5272007-05-14 11:00:38 +020014288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14296
14297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14300 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14302 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14303 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14304 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14305
14306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14310
14311 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014312 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14314
14315 { } /* end */
14316};
14317
14318/* toggle speaker-output according to the hp-jack state */
14319static void alc861vd_dallas_automute(struct hda_codec *codec)
14320{
14321 unsigned int present;
14322
14323 present = snd_hda_codec_read(codec, 0x15, 0,
14324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014325 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14326 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014327}
14328
14329static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14330{
14331 if ((res >> 26) == ALC880_HP_EVENT)
14332 alc861vd_dallas_automute(codec);
14333}
14334
Takashi Iwaicb53c622007-08-10 17:21:45 +020014335#ifdef CONFIG_SND_HDA_POWER_SAVE
14336#define alc861vd_loopbacks alc880_loopbacks
14337#endif
14338
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014339/* pcm configuration: identiacal with ALC880 */
14340#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14341#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14342#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14343#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14344
14345/*
14346 * configuration and preset
14347 */
14348static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14349 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014350 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014351 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014352 [ALC861VD_3ST] = "3stack",
14353 [ALC861VD_3ST_DIG] = "3stack-digout",
14354 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014355 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014356 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014357 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014358 [ALC861VD_AUTO] = "auto",
14359};
14360
14361static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014362 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14363 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014364 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014365 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014366 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014367 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014368 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014369 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014370 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014371 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014372 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014373 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014374 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014375 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14376 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014377 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014378 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014379 {}
14380};
14381
14382static struct alc_config_preset alc861vd_presets[] = {
14383 [ALC660VD_3ST] = {
14384 .mixers = { alc861vd_3st_mixer },
14385 .init_verbs = { alc861vd_volume_init_verbs,
14386 alc861vd_3stack_init_verbs },
14387 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14388 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014389 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14390 .channel_mode = alc861vd_3stack_2ch_modes,
14391 .input_mux = &alc861vd_capture_source,
14392 },
Mike Crash6963f842007-06-25 12:12:51 +020014393 [ALC660VD_3ST_DIG] = {
14394 .mixers = { alc861vd_3st_mixer },
14395 .init_verbs = { alc861vd_volume_init_verbs,
14396 alc861vd_3stack_init_verbs },
14397 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14398 .dac_nids = alc660vd_dac_nids,
14399 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014400 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14401 .channel_mode = alc861vd_3stack_2ch_modes,
14402 .input_mux = &alc861vd_capture_source,
14403 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014404 [ALC861VD_3ST] = {
14405 .mixers = { alc861vd_3st_mixer },
14406 .init_verbs = { alc861vd_volume_init_verbs,
14407 alc861vd_3stack_init_verbs },
14408 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14409 .dac_nids = alc861vd_dac_nids,
14410 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14411 .channel_mode = alc861vd_3stack_2ch_modes,
14412 .input_mux = &alc861vd_capture_source,
14413 },
14414 [ALC861VD_3ST_DIG] = {
14415 .mixers = { alc861vd_3st_mixer },
14416 .init_verbs = { alc861vd_volume_init_verbs,
14417 alc861vd_3stack_init_verbs },
14418 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14419 .dac_nids = alc861vd_dac_nids,
14420 .dig_out_nid = ALC861VD_DIGOUT_NID,
14421 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14422 .channel_mode = alc861vd_3stack_2ch_modes,
14423 .input_mux = &alc861vd_capture_source,
14424 },
14425 [ALC861VD_6ST_DIG] = {
14426 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14427 .init_verbs = { alc861vd_volume_init_verbs,
14428 alc861vd_6stack_init_verbs },
14429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14430 .dac_nids = alc861vd_dac_nids,
14431 .dig_out_nid = ALC861VD_DIGOUT_NID,
14432 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14433 .channel_mode = alc861vd_6stack_modes,
14434 .input_mux = &alc861vd_capture_source,
14435 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014436 [ALC861VD_LENOVO] = {
14437 .mixers = { alc861vd_lenovo_mixer },
14438 .init_verbs = { alc861vd_volume_init_verbs,
14439 alc861vd_3stack_init_verbs,
14440 alc861vd_eapd_verbs,
14441 alc861vd_lenovo_unsol_verbs },
14442 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14443 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014444 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14445 .channel_mode = alc861vd_3stack_2ch_modes,
14446 .input_mux = &alc861vd_capture_source,
14447 .unsol_event = alc861vd_lenovo_unsol_event,
14448 .init_hook = alc861vd_lenovo_automute,
14449 },
Kailang Yang272a5272007-05-14 11:00:38 +020014450 [ALC861VD_DALLAS] = {
14451 .mixers = { alc861vd_dallas_mixer },
14452 .init_verbs = { alc861vd_dallas_verbs },
14453 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14454 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014455 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14456 .channel_mode = alc861vd_3stack_2ch_modes,
14457 .input_mux = &alc861vd_dallas_capture_source,
14458 .unsol_event = alc861vd_dallas_unsol_event,
14459 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014460 },
14461 [ALC861VD_HP] = {
14462 .mixers = { alc861vd_hp_mixer },
14463 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14464 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14465 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014466 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014467 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14468 .channel_mode = alc861vd_3stack_2ch_modes,
14469 .input_mux = &alc861vd_hp_capture_source,
14470 .unsol_event = alc861vd_dallas_unsol_event,
14471 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014472 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014473 [ALC660VD_ASUS_V1S] = {
14474 .mixers = { alc861vd_lenovo_mixer },
14475 .init_verbs = { alc861vd_volume_init_verbs,
14476 alc861vd_3stack_init_verbs,
14477 alc861vd_eapd_verbs,
14478 alc861vd_lenovo_unsol_verbs },
14479 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14480 .dac_nids = alc660vd_dac_nids,
14481 .dig_out_nid = ALC861VD_DIGOUT_NID,
14482 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14483 .channel_mode = alc861vd_3stack_2ch_modes,
14484 .input_mux = &alc861vd_capture_source,
14485 .unsol_event = alc861vd_lenovo_unsol_event,
14486 .init_hook = alc861vd_lenovo_automute,
14487 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014488};
14489
14490/*
14491 * BIOS auto configuration
14492 */
14493static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14494 hda_nid_t nid, int pin_type, int dac_idx)
14495{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014496 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014497}
14498
14499static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14500{
14501 struct alc_spec *spec = codec->spec;
14502 int i;
14503
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014504 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014505 for (i = 0; i <= HDA_SIDE; i++) {
14506 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014507 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014508 if (nid)
14509 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014510 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014511 }
14512}
14513
14514
14515static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14516{
14517 struct alc_spec *spec = codec->spec;
14518 hda_nid_t pin;
14519
14520 pin = spec->autocfg.hp_pins[0];
14521 if (pin) /* connect to front and use dac 0 */
14522 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014523 pin = spec->autocfg.speaker_pins[0];
14524 if (pin)
14525 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014526}
14527
14528#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14529#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14530
14531static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14532{
14533 struct alc_spec *spec = codec->spec;
14534 int i;
14535
14536 for (i = 0; i < AUTO_PIN_LAST; i++) {
14537 hda_nid_t nid = spec->autocfg.input_pins[i];
14538 if (alc861vd_is_input_pin(nid)) {
14539 snd_hda_codec_write(codec, nid, 0,
14540 AC_VERB_SET_PIN_WIDGET_CONTROL,
14541 i <= AUTO_PIN_FRONT_MIC ?
14542 PIN_VREF80 : PIN_IN);
14543 if (nid != ALC861VD_PIN_CD_NID)
14544 snd_hda_codec_write(codec, nid, 0,
14545 AC_VERB_SET_AMP_GAIN_MUTE,
14546 AMP_OUT_MUTE);
14547 }
14548 }
14549}
14550
Takashi Iwaif511b012008-08-15 16:46:42 +020014551#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14552
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014553#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14554#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14555
14556/* add playback controls from the parsed DAC table */
14557/* Based on ALC880 version. But ALC861VD has separate,
14558 * different NIDs for mute/unmute switch and volume control */
14559static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14560 const struct auto_pin_cfg *cfg)
14561{
14562 char name[32];
14563 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14564 hda_nid_t nid_v, nid_s;
14565 int i, err;
14566
14567 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014568 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014569 continue;
14570 nid_v = alc861vd_idx_to_mixer_vol(
14571 alc880_dac_to_idx(
14572 spec->multiout.dac_nids[i]));
14573 nid_s = alc861vd_idx_to_mixer_switch(
14574 alc880_dac_to_idx(
14575 spec->multiout.dac_nids[i]));
14576
14577 if (i == 2) {
14578 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014579 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14580 "Center Playback Volume",
14581 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14582 HDA_OUTPUT));
14583 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014584 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14586 "LFE Playback Volume",
14587 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14588 HDA_OUTPUT));
14589 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014591 err = add_control(spec, ALC_CTL_BIND_MUTE,
14592 "Center Playback Switch",
14593 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14594 HDA_INPUT));
14595 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014597 err = add_control(spec, ALC_CTL_BIND_MUTE,
14598 "LFE Playback Switch",
14599 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14600 HDA_INPUT));
14601 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014602 return err;
14603 } else {
14604 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14606 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14607 HDA_OUTPUT));
14608 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014609 return err;
14610 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014611 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014612 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014613 HDA_INPUT));
14614 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014615 return err;
14616 }
14617 }
14618 return 0;
14619}
14620
14621/* add playback controls for speaker and HP outputs */
14622/* Based on ALC880 version. But ALC861VD has separate,
14623 * different NIDs for mute/unmute switch and volume control */
14624static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14625 hda_nid_t pin, const char *pfx)
14626{
14627 hda_nid_t nid_v, nid_s;
14628 int err;
14629 char name[32];
14630
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014631 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014632 return 0;
14633
14634 if (alc880_is_fixed_pin(pin)) {
14635 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14636 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014637 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014638 spec->multiout.hp_nid = nid_v;
14639 else
14640 spec->multiout.extra_out_nid[0] = nid_v;
14641 /* control HP volume/switch on the output mixer amp */
14642 nid_v = alc861vd_idx_to_mixer_vol(
14643 alc880_fixed_pin_idx(pin));
14644 nid_s = alc861vd_idx_to_mixer_switch(
14645 alc880_fixed_pin_idx(pin));
14646
14647 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014648 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14649 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14650 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014651 return err;
14652 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014653 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14654 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14655 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014656 return err;
14657 } else if (alc880_is_multi_pin(pin)) {
14658 /* set manual connection */
14659 /* we have only a switch on HP-out PIN */
14660 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014661 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14662 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14663 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014664 return err;
14665 }
14666 return 0;
14667}
14668
14669/* parse the BIOS configuration and set up the alc_spec
14670 * return 1 if successful, 0 if the proper config is not found,
14671 * or a negative error code
14672 * Based on ALC880 version - had to change it to override
14673 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14674static int alc861vd_parse_auto_config(struct hda_codec *codec)
14675{
14676 struct alc_spec *spec = codec->spec;
14677 int err;
14678 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014680 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14681 alc861vd_ignore);
14682 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014683 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014684 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014685 return 0; /* can't find valid BIOS pin config */
14686
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014687 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14688 if (err < 0)
14689 return err;
14690 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14691 if (err < 0)
14692 return err;
14693 err = alc861vd_auto_create_extra_out(spec,
14694 spec->autocfg.speaker_pins[0],
14695 "Speaker");
14696 if (err < 0)
14697 return err;
14698 err = alc861vd_auto_create_extra_out(spec,
14699 spec->autocfg.hp_pins[0],
14700 "Headphone");
14701 if (err < 0)
14702 return err;
14703 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14704 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014705 return err;
14706
14707 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14708
14709 if (spec->autocfg.dig_out_pin)
14710 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14711
Takashi Iwai603c4012008-07-30 15:01:44 +020014712 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014713 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014714
Takashi Iwaid88897e2008-10-31 15:01:37 +010014715 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014716
14717 spec->num_mux_defs = 1;
14718 spec->input_mux = &spec->private_imux;
14719
Takashi Iwai776e1842007-08-29 15:07:11 +020014720 err = alc_auto_add_mic_boost(codec);
14721 if (err < 0)
14722 return err;
14723
Takashi Iwaie044c392008-10-27 16:56:24 +010014724 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014725 return 1;
14726}
14727
14728/* additional initialization for auto-configuration model */
14729static void alc861vd_auto_init(struct hda_codec *codec)
14730{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014731 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014732 alc861vd_auto_init_multi_out(codec);
14733 alc861vd_auto_init_hp_out(codec);
14734 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014735 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014736 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014737 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014738}
14739
14740static int patch_alc861vd(struct hda_codec *codec)
14741{
14742 struct alc_spec *spec;
14743 int err, board_config;
14744
14745 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14746 if (spec == NULL)
14747 return -ENOMEM;
14748
14749 codec->spec = spec;
14750
14751 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14752 alc861vd_models,
14753 alc861vd_cfg_tbl);
14754
14755 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14756 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14757 "ALC861VD, trying auto-probe from BIOS...\n");
14758 board_config = ALC861VD_AUTO;
14759 }
14760
14761 if (board_config == ALC861VD_AUTO) {
14762 /* automatic parse from the BIOS config */
14763 err = alc861vd_parse_auto_config(codec);
14764 if (err < 0) {
14765 alc_free(codec);
14766 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014767 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014768 printk(KERN_INFO
14769 "hda_codec: Cannot set up configuration "
14770 "from BIOS. Using base mode...\n");
14771 board_config = ALC861VD_3ST;
14772 }
14773 }
14774
14775 if (board_config != ALC861VD_AUTO)
14776 setup_preset(spec, &alc861vd_presets[board_config]);
14777
Kailang Yang2f893282008-05-27 12:14:47 +020014778 if (codec->vendor_id == 0x10ec0660) {
14779 spec->stream_name_analog = "ALC660-VD Analog";
14780 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014781 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014782 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014783 } else {
14784 spec->stream_name_analog = "ALC861VD Analog";
14785 spec->stream_name_digital = "ALC861VD Digital";
14786 }
14787
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014788 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14789 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14790
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14792 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14793
14794 spec->adc_nids = alc861vd_adc_nids;
14795 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014796 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014797 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014798
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014799 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014800
Takashi Iwai2134ea42008-01-10 16:53:55 +010014801 spec->vmaster_nid = 0x02;
14802
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014803 codec->patch_ops = alc_patch_ops;
14804
14805 if (board_config == ALC861VD_AUTO)
14806 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014807#ifdef CONFIG_SND_HDA_POWER_SAVE
14808 if (!spec->loopback.amplist)
14809 spec->loopback.amplist = alc861vd_loopbacks;
14810#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014811 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014812
14813 return 0;
14814}
14815
14816/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014817 * ALC662 support
14818 *
14819 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14820 * configuration. Each pin widget can choose any input DACs and a mixer.
14821 * Each ADC is connected from a mixer of all inputs. This makes possible
14822 * 6-channel independent captures.
14823 *
14824 * In addition, an independent DAC for the multi-playback (not used in this
14825 * driver yet).
14826 */
14827#define ALC662_DIGOUT_NID 0x06
14828#define ALC662_DIGIN_NID 0x0a
14829
14830static hda_nid_t alc662_dac_nids[4] = {
14831 /* front, rear, clfe, rear_surr */
14832 0x02, 0x03, 0x04
14833};
14834
14835static hda_nid_t alc662_adc_nids[1] = {
14836 /* ADC1-2 */
14837 0x09,
14838};
Takashi Iwaie1406342008-02-11 18:32:32 +010014839
Kailang Yang77a261b2008-02-19 11:38:05 +010014840static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014841
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014842/* input MUX */
14843/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014844static struct hda_input_mux alc662_capture_source = {
14845 .num_items = 4,
14846 .items = {
14847 { "Mic", 0x0 },
14848 { "Front Mic", 0x1 },
14849 { "Line", 0x2 },
14850 { "CD", 0x4 },
14851 },
14852};
14853
14854static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14855 .num_items = 2,
14856 .items = {
14857 { "Mic", 0x1 },
14858 { "Line", 0x2 },
14859 },
14860};
Kailang Yang291702f2007-10-16 14:28:03 +020014861
14862static struct hda_input_mux alc662_eeepc_capture_source = {
14863 .num_items = 2,
14864 .items = {
14865 { "i-Mic", 0x1 },
14866 { "e-Mic", 0x0 },
14867 },
14868};
14869
Kailang Yang6dda9f42008-05-27 12:05:31 +020014870static struct hda_input_mux alc663_capture_source = {
14871 .num_items = 3,
14872 .items = {
14873 { "Mic", 0x0 },
14874 { "Front Mic", 0x1 },
14875 { "Line", 0x2 },
14876 },
14877};
14878
14879static struct hda_input_mux alc663_m51va_capture_source = {
14880 .num_items = 2,
14881 .items = {
14882 { "Ext-Mic", 0x0 },
14883 { "D-Mic", 0x9 },
14884 },
14885};
14886
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014887/*
14888 * 2ch mode
14889 */
14890static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14891 { 2, NULL }
14892};
14893
14894/*
14895 * 2ch mode
14896 */
14897static struct hda_verb alc662_3ST_ch2_init[] = {
14898 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14899 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14902 { } /* end */
14903};
14904
14905/*
14906 * 6ch mode
14907 */
14908static struct hda_verb alc662_3ST_ch6_init[] = {
14909 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14910 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14911 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14912 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14913 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14914 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14915 { } /* end */
14916};
14917
14918static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14919 { 2, alc662_3ST_ch2_init },
14920 { 6, alc662_3ST_ch6_init },
14921};
14922
14923/*
14924 * 2ch mode
14925 */
14926static struct hda_verb alc662_sixstack_ch6_init[] = {
14927 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14928 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14929 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14930 { } /* end */
14931};
14932
14933/*
14934 * 6ch mode
14935 */
14936static struct hda_verb alc662_sixstack_ch8_init[] = {
14937 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14938 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14939 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14940 { } /* end */
14941};
14942
14943static struct hda_channel_mode alc662_5stack_modes[2] = {
14944 { 2, alc662_sixstack_ch6_init },
14945 { 6, alc662_sixstack_ch8_init },
14946};
14947
14948/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14949 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14950 */
14951
14952static struct snd_kcontrol_new alc662_base_mixer[] = {
14953 /* output mixer control */
14954 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014955 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014957 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014958 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14959 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014960 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14961 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14963
14964 /*Input mixer control */
14965 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14966 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14967 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14968 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14969 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14970 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014973 { } /* end */
14974};
14975
14976static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014978 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014990 { } /* end */
14991};
14992
14993static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14994 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014995 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014996 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014997 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014998 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14999 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015000 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15001 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15003 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15004 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15009 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013 { } /* end */
15014};
15015
15016static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15017 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15018 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15020 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015026 { } /* end */
15027};
15028
Kailang Yang291702f2007-10-16 14:28:03 +020015029static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015030 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015031
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015032 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15033 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015034
15035 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15036 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15037 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15038
15039 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15040 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15041 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15042 { } /* end */
15043};
15044
Kailang Yang8c427222008-01-10 13:03:59 +010015045static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015046 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15047 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015048 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15049 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15050 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015054 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015055 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15060 { } /* end */
15061};
15062
Kailang Yangf1d4e282008-08-26 14:03:29 +020015063static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15064 .ops = &snd_hda_bind_vol,
15065 .values = {
15066 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15067 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15068 0
15069 },
15070};
15071
15072static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15073 .ops = &snd_hda_bind_sw,
15074 .values = {
15075 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15076 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15077 0
15078 },
15079};
15080
Kailang Yang6dda9f42008-05-27 12:05:31 +020015081static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015082 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15083 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15086 { } /* end */
15087};
15088
15089static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15090 .ops = &snd_hda_bind_sw,
15091 .values = {
15092 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15093 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15094 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15095 0
15096 },
15097};
15098
15099static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15100 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15101 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15104 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15105 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15106
15107 { } /* end */
15108};
15109
15110static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15111 .ops = &snd_hda_bind_sw,
15112 .values = {
15113 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15114 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15115 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15116 0
15117 },
15118};
15119
15120static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15121 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15122 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15125 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15126 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15127 { } /* end */
15128};
15129
15130static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015131 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15132 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15136 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15137 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15138 { } /* end */
15139};
15140
15141static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15142 .ops = &snd_hda_bind_vol,
15143 .values = {
15144 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15145 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15146 0
15147 },
15148};
15149
15150static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15151 .ops = &snd_hda_bind_sw,
15152 .values = {
15153 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15154 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15155 0
15156 },
15157};
15158
15159static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15160 HDA_BIND_VOL("Master Playback Volume",
15161 &alc663_asus_two_bind_master_vol),
15162 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15163 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015167 { } /* end */
15168};
15169
15170static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15171 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15172 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15173 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015177 { } /* end */
15178};
15179
15180static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15181 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15182 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15183 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15184 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15186
15187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15189 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15190 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15191 { } /* end */
15192};
15193
15194static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15195 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15196 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15198
15199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15201 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15202 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15205 { } /* end */
15206};
15207
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015208static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15209 {
15210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15211 .name = "Channel Mode",
15212 .info = alc_ch_mode_info,
15213 .get = alc_ch_mode_get,
15214 .put = alc_ch_mode_put,
15215 },
15216 { } /* end */
15217};
15218
15219static struct hda_verb alc662_init_verbs[] = {
15220 /* ADC: mute amp left and right */
15221 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15222 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15224
Takashi Iwaicb53c622007-08-10 17:21:45 +020015225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015230
Kailang Yangb60dd392007-09-20 12:50:29 +020015231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015237
15238 /* Front Pin: output 0 (0x0c) */
15239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15241
15242 /* Rear Pin: output 1 (0x0d) */
15243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15245
15246 /* CLFE Pin: output 2 (0x0e) */
15247 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15249
15250 /* Mic (rear) pin: input vref at 80% */
15251 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15253 /* Front Mic pin: input vref at 80% */
15254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15256 /* Line In pin: input */
15257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15259 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15262 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15263 /* CD pin widget for input */
15264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15265
15266 /* FIXME: use matrix-type input source selection */
15267 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15268 /* Input mixer */
15269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015273
15274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015278
15279 /* always trun on EAPD */
15280 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15281 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15282
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015283 { }
15284};
15285
15286static struct hda_verb alc662_sue_init_verbs[] = {
15287 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15288 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015289 {}
15290};
15291
15292static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15293 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15294 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15295 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015296};
15297
Kailang Yang8c427222008-01-10 13:03:59 +010015298/* Set Unsolicited Event*/
15299static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15300 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15301 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15302 {}
15303};
15304
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015305/*
15306 * generic initialization of ADC, input mixers and output mixers
15307 */
15308static struct hda_verb alc662_auto_init_verbs[] = {
15309 /*
15310 * Unmute ADC and set the default input to mic-in
15311 */
15312 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15314
15315 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15316 * mixer widget
15317 * Note: PASD motherboards uses the Line In 2 as the input for front
15318 * panel mic (mic 2)
15319 */
15320 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015326
15327 /*
15328 * Set up output mixers (0x0c - 0x0f)
15329 */
15330 /* set vol=0 to output mixers */
15331 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15332 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15333 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15334
15335 /* set up input amps for analog loopback */
15336 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015343
15344
15345 /* FIXME: use matrix-type input source selection */
15346 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15347 /* Input mixer */
15348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015350 { }
15351};
15352
Takashi Iwai24fb9172008-09-02 14:48:20 +020015353/* additional verbs for ALC663 */
15354static struct hda_verb alc663_auto_init_verbs[] = {
15355 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15357 { }
15358};
15359
Kailang Yang6dda9f42008-05-27 12:05:31 +020015360static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015363 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15364 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015365 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015368 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15369 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15370 {}
15371};
15372
Kailang Yangf1d4e282008-08-26 14:03:29 +020015373static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15374 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15375 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15376 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15379 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15380 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15381 {}
15382};
15383
15384static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15386 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15387 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15388 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15391 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15392 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15393 {}
15394};
15395
15396static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15399 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15402 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15404 {}
15405};
15406
15407static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15408 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15409 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15410 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15411 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15417 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15418 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15419 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15420 {}
15421};
15422
15423static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15424 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15434 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15435 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15436 {}
15437};
15438
Kailang Yang6dda9f42008-05-27 12:05:31 +020015439static struct hda_verb alc663_g71v_init_verbs[] = {
15440 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15441 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15442 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15443
15444 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15445 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15446 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15447
15448 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15449 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15450 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15451 {}
15452};
15453
15454static struct hda_verb alc663_g50v_init_verbs[] = {
15455 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15456 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15457 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15458
15459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15460 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15461 {}
15462};
15463
Kailang Yangf1d4e282008-08-26 14:03:29 +020015464static struct hda_verb alc662_ecs_init_verbs[] = {
15465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15467 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15468 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15469 {}
15470};
15471
Kailang Yangf1d4e282008-08-26 14:03:29 +020015472static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15473 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15474 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15475 { } /* end */
15476};
15477
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015478static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15479{
15480 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015481 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015482
15483 present = snd_hda_codec_read(codec, 0x14, 0,
15484 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015485 bits = present ? HDA_AMP_MUTE : 0;
15486 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15487 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015488}
15489
15490static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15491{
15492 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015493 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015494
15495 present = snd_hda_codec_read(codec, 0x1b, 0,
15496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015497 bits = present ? HDA_AMP_MUTE : 0;
15498 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15499 HDA_AMP_MUTE, bits);
15500 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15501 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015502}
15503
15504static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15505 unsigned int res)
15506{
15507 if ((res >> 26) == ALC880_HP_EVENT)
15508 alc662_lenovo_101e_all_automute(codec);
15509 if ((res >> 26) == ALC880_FRONT_EVENT)
15510 alc662_lenovo_101e_ispeaker_automute(codec);
15511}
15512
Kailang Yang291702f2007-10-16 14:28:03 +020015513static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15514{
15515 unsigned int present;
15516
15517 present = snd_hda_codec_read(codec, 0x18, 0,
15518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15519 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15520 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15521 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15522 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15523 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15524 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15525 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15526 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15527}
15528
15529/* unsolicited event for HP jack sensing */
15530static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15531 unsigned int res)
15532{
15533 if ((res >> 26) == ALC880_HP_EVENT)
15534 alc262_hippo1_automute( codec );
15535
15536 if ((res >> 26) == ALC880_MIC_EVENT)
15537 alc662_eeepc_mic_automute(codec);
15538}
15539
15540static void alc662_eeepc_inithook(struct hda_codec *codec)
15541{
15542 alc262_hippo1_automute( codec );
15543 alc662_eeepc_mic_automute(codec);
15544}
15545
Kailang Yang8c427222008-01-10 13:03:59 +010015546static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15547{
15548 unsigned int mute;
15549 unsigned int present;
15550
15551 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15552 present = snd_hda_codec_read(codec, 0x14, 0,
15553 AC_VERB_GET_PIN_SENSE, 0);
15554 present = (present & 0x80000000) != 0;
15555 if (present) {
15556 /* mute internal speaker */
15557 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015558 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015559 } else {
15560 /* unmute internal speaker if necessary */
15561 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15562 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015563 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015564 }
15565}
15566
15567/* unsolicited event for HP jack sensing */
15568static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15569 unsigned int res)
15570{
15571 if ((res >> 26) == ALC880_HP_EVENT)
15572 alc662_eeepc_ep20_automute(codec);
15573}
15574
15575static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15576{
15577 alc662_eeepc_ep20_automute(codec);
15578}
15579
Kailang Yang6dda9f42008-05-27 12:05:31 +020015580static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15581{
15582 unsigned int present;
15583 unsigned char bits;
15584
15585 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015586 AC_VERB_GET_PIN_SENSE, 0)
15587 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015588 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015589 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15590 AMP_IN_MUTE(0), bits);
15591 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15592 AMP_IN_MUTE(0), bits);
15593}
15594
15595static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15596{
15597 unsigned int present;
15598 unsigned char bits;
15599
15600 present = snd_hda_codec_read(codec, 0x21, 0,
15601 AC_VERB_GET_PIN_SENSE, 0)
15602 & AC_PINSENSE_PRESENCE;
15603 bits = present ? HDA_AMP_MUTE : 0;
15604 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15605 AMP_IN_MUTE(0), bits);
15606 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15607 AMP_IN_MUTE(0), bits);
15608 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15609 AMP_IN_MUTE(0), bits);
15610 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15611 AMP_IN_MUTE(0), bits);
15612}
15613
15614static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15615{
15616 unsigned int present;
15617 unsigned char bits;
15618
15619 present = snd_hda_codec_read(codec, 0x15, 0,
15620 AC_VERB_GET_PIN_SENSE, 0)
15621 & AC_PINSENSE_PRESENCE;
15622 bits = present ? HDA_AMP_MUTE : 0;
15623 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15624 AMP_IN_MUTE(0), bits);
15625 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15626 AMP_IN_MUTE(0), bits);
15627 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15628 AMP_IN_MUTE(0), bits);
15629 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15630 AMP_IN_MUTE(0), bits);
15631}
15632
15633static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15634{
15635 unsigned int present;
15636 unsigned char bits;
15637
15638 present = snd_hda_codec_read(codec, 0x1b, 0,
15639 AC_VERB_GET_PIN_SENSE, 0)
15640 & AC_PINSENSE_PRESENCE;
15641 bits = present ? 0 : PIN_OUT;
15642 snd_hda_codec_write(codec, 0x14, 0,
15643 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15644}
15645
15646static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15647{
15648 unsigned int present1, present2;
15649
15650 present1 = snd_hda_codec_read(codec, 0x21, 0,
15651 AC_VERB_GET_PIN_SENSE, 0)
15652 & AC_PINSENSE_PRESENCE;
15653 present2 = snd_hda_codec_read(codec, 0x15, 0,
15654 AC_VERB_GET_PIN_SENSE, 0)
15655 & AC_PINSENSE_PRESENCE;
15656
15657 if (present1 || present2) {
15658 snd_hda_codec_write_cache(codec, 0x14, 0,
15659 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15660 } else {
15661 snd_hda_codec_write_cache(codec, 0x14, 0,
15662 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15663 }
15664}
15665
15666static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15667{
15668 unsigned int present1, present2;
15669
15670 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15671 AC_VERB_GET_PIN_SENSE, 0)
15672 & AC_PINSENSE_PRESENCE;
15673 present2 = snd_hda_codec_read(codec, 0x15, 0,
15674 AC_VERB_GET_PIN_SENSE, 0)
15675 & AC_PINSENSE_PRESENCE;
15676
15677 if (present1 || present2) {
15678 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15679 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15680 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15681 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15682 } else {
15683 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15684 AMP_IN_MUTE(0), 0);
15685 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15686 AMP_IN_MUTE(0), 0);
15687 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015688}
15689
15690static void alc663_m51va_mic_automute(struct hda_codec *codec)
15691{
15692 unsigned int present;
15693
15694 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015695 AC_VERB_GET_PIN_SENSE, 0)
15696 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015697 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015698 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015699 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015700 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015701 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015702 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015703 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015704 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015705}
15706
15707static void alc663_m51va_unsol_event(struct hda_codec *codec,
15708 unsigned int res)
15709{
15710 switch (res >> 26) {
15711 case ALC880_HP_EVENT:
15712 alc663_m51va_speaker_automute(codec);
15713 break;
15714 case ALC880_MIC_EVENT:
15715 alc663_m51va_mic_automute(codec);
15716 break;
15717 }
15718}
15719
15720static void alc663_m51va_inithook(struct hda_codec *codec)
15721{
15722 alc663_m51va_speaker_automute(codec);
15723 alc663_m51va_mic_automute(codec);
15724}
15725
Kailang Yangf1d4e282008-08-26 14:03:29 +020015726/* ***************** Mode1 ******************************/
15727static void alc663_mode1_unsol_event(struct hda_codec *codec,
15728 unsigned int res)
15729{
15730 switch (res >> 26) {
15731 case ALC880_HP_EVENT:
15732 alc663_m51va_speaker_automute(codec);
15733 break;
15734 case ALC880_MIC_EVENT:
15735 alc662_eeepc_mic_automute(codec);
15736 break;
15737 }
15738}
15739
15740static void alc663_mode1_inithook(struct hda_codec *codec)
15741{
15742 alc663_m51va_speaker_automute(codec);
15743 alc662_eeepc_mic_automute(codec);
15744}
15745/* ***************** Mode2 ******************************/
15746static void alc662_mode2_unsol_event(struct hda_codec *codec,
15747 unsigned int res)
15748{
15749 switch (res >> 26) {
15750 case ALC880_HP_EVENT:
15751 alc662_f5z_speaker_automute(codec);
15752 break;
15753 case ALC880_MIC_EVENT:
15754 alc662_eeepc_mic_automute(codec);
15755 break;
15756 }
15757}
15758
15759static void alc662_mode2_inithook(struct hda_codec *codec)
15760{
15761 alc662_f5z_speaker_automute(codec);
15762 alc662_eeepc_mic_automute(codec);
15763}
15764/* ***************** Mode3 ******************************/
15765static void alc663_mode3_unsol_event(struct hda_codec *codec,
15766 unsigned int res)
15767{
15768 switch (res >> 26) {
15769 case ALC880_HP_EVENT:
15770 alc663_two_hp_m1_speaker_automute(codec);
15771 break;
15772 case ALC880_MIC_EVENT:
15773 alc662_eeepc_mic_automute(codec);
15774 break;
15775 }
15776}
15777
15778static void alc663_mode3_inithook(struct hda_codec *codec)
15779{
15780 alc663_two_hp_m1_speaker_automute(codec);
15781 alc662_eeepc_mic_automute(codec);
15782}
15783/* ***************** Mode4 ******************************/
15784static void alc663_mode4_unsol_event(struct hda_codec *codec,
15785 unsigned int res)
15786{
15787 switch (res >> 26) {
15788 case ALC880_HP_EVENT:
15789 alc663_21jd_two_speaker_automute(codec);
15790 break;
15791 case ALC880_MIC_EVENT:
15792 alc662_eeepc_mic_automute(codec);
15793 break;
15794 }
15795}
15796
15797static void alc663_mode4_inithook(struct hda_codec *codec)
15798{
15799 alc663_21jd_two_speaker_automute(codec);
15800 alc662_eeepc_mic_automute(codec);
15801}
15802/* ***************** Mode5 ******************************/
15803static void alc663_mode5_unsol_event(struct hda_codec *codec,
15804 unsigned int res)
15805{
15806 switch (res >> 26) {
15807 case ALC880_HP_EVENT:
15808 alc663_15jd_two_speaker_automute(codec);
15809 break;
15810 case ALC880_MIC_EVENT:
15811 alc662_eeepc_mic_automute(codec);
15812 break;
15813 }
15814}
15815
15816static void alc663_mode5_inithook(struct hda_codec *codec)
15817{
15818 alc663_15jd_two_speaker_automute(codec);
15819 alc662_eeepc_mic_automute(codec);
15820}
15821/* ***************** Mode6 ******************************/
15822static void alc663_mode6_unsol_event(struct hda_codec *codec,
15823 unsigned int res)
15824{
15825 switch (res >> 26) {
15826 case ALC880_HP_EVENT:
15827 alc663_two_hp_m2_speaker_automute(codec);
15828 break;
15829 case ALC880_MIC_EVENT:
15830 alc662_eeepc_mic_automute(codec);
15831 break;
15832 }
15833}
15834
15835static void alc663_mode6_inithook(struct hda_codec *codec)
15836{
15837 alc663_two_hp_m2_speaker_automute(codec);
15838 alc662_eeepc_mic_automute(codec);
15839}
15840
Kailang Yang6dda9f42008-05-27 12:05:31 +020015841static void alc663_g71v_hp_automute(struct hda_codec *codec)
15842{
15843 unsigned int present;
15844 unsigned char bits;
15845
15846 present = snd_hda_codec_read(codec, 0x21, 0,
15847 AC_VERB_GET_PIN_SENSE, 0)
15848 & AC_PINSENSE_PRESENCE;
15849 bits = present ? HDA_AMP_MUTE : 0;
15850 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15851 HDA_AMP_MUTE, bits);
15852 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15853 HDA_AMP_MUTE, bits);
15854}
15855
15856static void alc663_g71v_front_automute(struct hda_codec *codec)
15857{
15858 unsigned int present;
15859 unsigned char bits;
15860
15861 present = snd_hda_codec_read(codec, 0x15, 0,
15862 AC_VERB_GET_PIN_SENSE, 0)
15863 & AC_PINSENSE_PRESENCE;
15864 bits = present ? HDA_AMP_MUTE : 0;
15865 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15866 HDA_AMP_MUTE, bits);
15867}
15868
15869static void alc663_g71v_unsol_event(struct hda_codec *codec,
15870 unsigned int res)
15871{
15872 switch (res >> 26) {
15873 case ALC880_HP_EVENT:
15874 alc663_g71v_hp_automute(codec);
15875 break;
15876 case ALC880_FRONT_EVENT:
15877 alc663_g71v_front_automute(codec);
15878 break;
15879 case ALC880_MIC_EVENT:
15880 alc662_eeepc_mic_automute(codec);
15881 break;
15882 }
15883}
15884
15885static void alc663_g71v_inithook(struct hda_codec *codec)
15886{
15887 alc663_g71v_front_automute(codec);
15888 alc663_g71v_hp_automute(codec);
15889 alc662_eeepc_mic_automute(codec);
15890}
15891
15892static void alc663_g50v_unsol_event(struct hda_codec *codec,
15893 unsigned int res)
15894{
15895 switch (res >> 26) {
15896 case ALC880_HP_EVENT:
15897 alc663_m51va_speaker_automute(codec);
15898 break;
15899 case ALC880_MIC_EVENT:
15900 alc662_eeepc_mic_automute(codec);
15901 break;
15902 }
15903}
15904
15905static void alc663_g50v_inithook(struct hda_codec *codec)
15906{
15907 alc663_m51va_speaker_automute(codec);
15908 alc662_eeepc_mic_automute(codec);
15909}
15910
Kailang Yangf1d4e282008-08-26 14:03:29 +020015911/* bind hp and internal speaker mute (with plug check) */
15912static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15913 struct snd_ctl_elem_value *ucontrol)
15914{
15915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15916 long *valp = ucontrol->value.integer.value;
15917 int change;
15918
15919 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15920 HDA_AMP_MUTE,
15921 valp[0] ? 0 : HDA_AMP_MUTE);
15922 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15923 HDA_AMP_MUTE,
15924 valp[1] ? 0 : HDA_AMP_MUTE);
15925 if (change)
15926 alc262_hippo1_automute(codec);
15927 return change;
15928}
15929
15930static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15931 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15932 {
15933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15934 .name = "Master Playback Switch",
15935 .info = snd_hda_mixer_amp_switch_info,
15936 .get = snd_hda_mixer_amp_switch_get,
15937 .put = alc662_ecs_master_sw_put,
15938 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15939 },
15940
15941 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15942 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15943 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15944
15945 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15946 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15947 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15948 { } /* end */
15949};
15950
Takashi Iwaicb53c622007-08-10 17:21:45 +020015951#ifdef CONFIG_SND_HDA_POWER_SAVE
15952#define alc662_loopbacks alc880_loopbacks
15953#endif
15954
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015955
15956/* pcm configuration: identiacal with ALC880 */
15957#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15958#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15959#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15960#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15961
15962/*
15963 * configuration and preset
15964 */
15965static const char *alc662_models[ALC662_MODEL_LAST] = {
15966 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15967 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15968 [ALC662_3ST_6ch] = "3stack-6ch",
15969 [ALC662_5ST_DIG] = "6stack-dig",
15970 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015971 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015972 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015973 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015974 [ALC663_ASUS_M51VA] = "m51va",
15975 [ALC663_ASUS_G71V] = "g71v",
15976 [ALC663_ASUS_H13] = "h13",
15977 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015978 [ALC663_ASUS_MODE1] = "asus-mode1",
15979 [ALC662_ASUS_MODE2] = "asus-mode2",
15980 [ALC663_ASUS_MODE3] = "asus-mode3",
15981 [ALC663_ASUS_MODE4] = "asus-mode4",
15982 [ALC663_ASUS_MODE5] = "asus-mode5",
15983 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015984 [ALC662_AUTO] = "auto",
15985};
15986
15987static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015988 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015989 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015990 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015991 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015992 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015993 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15994 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15995 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15996 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15997 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15998 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15999 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16000 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16001 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016002 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016003 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16004 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16005 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16006 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16007 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16008 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16009 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16010 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16011 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16012 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16013 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16014 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16015 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16016 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16017 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16018 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16019 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16020 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16021 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16022 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16023 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16024 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016025 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16026 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016027 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016028 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16029 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016030 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16031 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016032 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020016033 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016034 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016035 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
16036 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
16037 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016038 {}
16039};
16040
16041static struct alc_config_preset alc662_presets[] = {
16042 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016043 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044 .init_verbs = { alc662_init_verbs },
16045 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16046 .dac_nids = alc662_dac_nids,
16047 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016048 .dig_in_nid = ALC662_DIGIN_NID,
16049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16050 .channel_mode = alc662_3ST_2ch_modes,
16051 .input_mux = &alc662_capture_source,
16052 },
16053 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016054 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016055 .init_verbs = { alc662_init_verbs },
16056 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16057 .dac_nids = alc662_dac_nids,
16058 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016059 .dig_in_nid = ALC662_DIGIN_NID,
16060 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16061 .channel_mode = alc662_3ST_6ch_modes,
16062 .need_dac_fix = 1,
16063 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016064 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016065 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016066 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016067 .init_verbs = { alc662_init_verbs },
16068 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16069 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016070 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16071 .channel_mode = alc662_3ST_6ch_modes,
16072 .need_dac_fix = 1,
16073 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016074 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016075 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016076 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016077 .init_verbs = { alc662_init_verbs },
16078 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16079 .dac_nids = alc662_dac_nids,
16080 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016081 .dig_in_nid = ALC662_DIGIN_NID,
16082 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16083 .channel_mode = alc662_5stack_modes,
16084 .input_mux = &alc662_capture_source,
16085 },
16086 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016087 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016088 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16089 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16090 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16092 .channel_mode = alc662_3ST_2ch_modes,
16093 .input_mux = &alc662_lenovo_101e_capture_source,
16094 .unsol_event = alc662_lenovo_101e_unsol_event,
16095 .init_hook = alc662_lenovo_101e_all_automute,
16096 },
Kailang Yang291702f2007-10-16 14:28:03 +020016097 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016098 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016099 .init_verbs = { alc662_init_verbs,
16100 alc662_eeepc_sue_init_verbs },
16101 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16102 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016103 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16104 .channel_mode = alc662_3ST_2ch_modes,
16105 .input_mux = &alc662_eeepc_capture_source,
16106 .unsol_event = alc662_eeepc_unsol_event,
16107 .init_hook = alc662_eeepc_inithook,
16108 },
Kailang Yang8c427222008-01-10 13:03:59 +010016109 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016110 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016111 alc662_chmode_mixer },
16112 .init_verbs = { alc662_init_verbs,
16113 alc662_eeepc_ep20_sue_init_verbs },
16114 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16115 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016116 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16117 .channel_mode = alc662_3ST_6ch_modes,
16118 .input_mux = &alc662_lenovo_101e_capture_source,
16119 .unsol_event = alc662_eeepc_ep20_unsol_event,
16120 .init_hook = alc662_eeepc_ep20_inithook,
16121 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016122 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016123 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016124 .init_verbs = { alc662_init_verbs,
16125 alc662_ecs_init_verbs },
16126 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16127 .dac_nids = alc662_dac_nids,
16128 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16129 .channel_mode = alc662_3ST_2ch_modes,
16130 .input_mux = &alc662_eeepc_capture_source,
16131 .unsol_event = alc662_eeepc_unsol_event,
16132 .init_hook = alc662_eeepc_inithook,
16133 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016134 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016135 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016136 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16137 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16138 .dac_nids = alc662_dac_nids,
16139 .dig_out_nid = ALC662_DIGOUT_NID,
16140 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16141 .channel_mode = alc662_3ST_2ch_modes,
16142 .input_mux = &alc663_m51va_capture_source,
16143 .unsol_event = alc663_m51va_unsol_event,
16144 .init_hook = alc663_m51va_inithook,
16145 },
16146 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016147 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016148 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16149 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16150 .dac_nids = alc662_dac_nids,
16151 .dig_out_nid = ALC662_DIGOUT_NID,
16152 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16153 .channel_mode = alc662_3ST_2ch_modes,
16154 .input_mux = &alc662_eeepc_capture_source,
16155 .unsol_event = alc663_g71v_unsol_event,
16156 .init_hook = alc663_g71v_inithook,
16157 },
16158 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016159 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016160 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16161 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16162 .dac_nids = alc662_dac_nids,
16163 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16164 .channel_mode = alc662_3ST_2ch_modes,
16165 .input_mux = &alc663_m51va_capture_source,
16166 .unsol_event = alc663_m51va_unsol_event,
16167 .init_hook = alc663_m51va_inithook,
16168 },
16169 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016170 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016171 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16172 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16173 .dac_nids = alc662_dac_nids,
16174 .dig_out_nid = ALC662_DIGOUT_NID,
16175 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16176 .channel_mode = alc662_3ST_6ch_modes,
16177 .input_mux = &alc663_capture_source,
16178 .unsol_event = alc663_g50v_unsol_event,
16179 .init_hook = alc663_g50v_inithook,
16180 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016181 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016182 .mixers = { alc663_m51va_mixer },
16183 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016184 .init_verbs = { alc662_init_verbs,
16185 alc663_21jd_amic_init_verbs },
16186 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16187 .hp_nid = 0x03,
16188 .dac_nids = alc662_dac_nids,
16189 .dig_out_nid = ALC662_DIGOUT_NID,
16190 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16191 .channel_mode = alc662_3ST_2ch_modes,
16192 .input_mux = &alc662_eeepc_capture_source,
16193 .unsol_event = alc663_mode1_unsol_event,
16194 .init_hook = alc663_mode1_inithook,
16195 },
16196 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016197 .mixers = { alc662_1bjd_mixer },
16198 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016199 .init_verbs = { alc662_init_verbs,
16200 alc662_1bjd_amic_init_verbs },
16201 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16202 .dac_nids = alc662_dac_nids,
16203 .dig_out_nid = ALC662_DIGOUT_NID,
16204 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16205 .channel_mode = alc662_3ST_2ch_modes,
16206 .input_mux = &alc662_eeepc_capture_source,
16207 .unsol_event = alc662_mode2_unsol_event,
16208 .init_hook = alc662_mode2_inithook,
16209 },
16210 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016211 .mixers = { alc663_two_hp_m1_mixer },
16212 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016213 .init_verbs = { alc662_init_verbs,
16214 alc663_two_hp_amic_m1_init_verbs },
16215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16216 .hp_nid = 0x03,
16217 .dac_nids = alc662_dac_nids,
16218 .dig_out_nid = ALC662_DIGOUT_NID,
16219 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16220 .channel_mode = alc662_3ST_2ch_modes,
16221 .input_mux = &alc662_eeepc_capture_source,
16222 .unsol_event = alc663_mode3_unsol_event,
16223 .init_hook = alc663_mode3_inithook,
16224 },
16225 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016226 .mixers = { alc663_asus_21jd_clfe_mixer },
16227 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016228 .init_verbs = { alc662_init_verbs,
16229 alc663_21jd_amic_init_verbs},
16230 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16231 .hp_nid = 0x03,
16232 .dac_nids = alc662_dac_nids,
16233 .dig_out_nid = ALC662_DIGOUT_NID,
16234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16235 .channel_mode = alc662_3ST_2ch_modes,
16236 .input_mux = &alc662_eeepc_capture_source,
16237 .unsol_event = alc663_mode4_unsol_event,
16238 .init_hook = alc663_mode4_inithook,
16239 },
16240 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016241 .mixers = { alc663_asus_15jd_clfe_mixer },
16242 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016243 .init_verbs = { alc662_init_verbs,
16244 alc663_15jd_amic_init_verbs },
16245 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16246 .hp_nid = 0x03,
16247 .dac_nids = alc662_dac_nids,
16248 .dig_out_nid = ALC662_DIGOUT_NID,
16249 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16250 .channel_mode = alc662_3ST_2ch_modes,
16251 .input_mux = &alc662_eeepc_capture_source,
16252 .unsol_event = alc663_mode5_unsol_event,
16253 .init_hook = alc663_mode5_inithook,
16254 },
16255 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016256 .mixers = { alc663_two_hp_m2_mixer },
16257 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016258 .init_verbs = { alc662_init_verbs,
16259 alc663_two_hp_amic_m2_init_verbs },
16260 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16261 .hp_nid = 0x03,
16262 .dac_nids = alc662_dac_nids,
16263 .dig_out_nid = ALC662_DIGOUT_NID,
16264 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16265 .channel_mode = alc662_3ST_2ch_modes,
16266 .input_mux = &alc662_eeepc_capture_source,
16267 .unsol_event = alc663_mode6_unsol_event,
16268 .init_hook = alc663_mode6_inithook,
16269 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016270};
16271
16272
16273/*
16274 * BIOS auto configuration
16275 */
16276
16277/* add playback controls from the parsed DAC table */
16278static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16279 const struct auto_pin_cfg *cfg)
16280{
16281 char name[32];
16282 static const char *chname[4] = {
16283 "Front", "Surround", NULL /*CLFE*/, "Side"
16284 };
16285 hda_nid_t nid;
16286 int i, err;
16287
16288 for (i = 0; i < cfg->line_outs; i++) {
16289 if (!spec->multiout.dac_nids[i])
16290 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016291 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016292 if (i == 2) {
16293 /* Center/LFE */
16294 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16295 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016296 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16297 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016298 if (err < 0)
16299 return err;
16300 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16301 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016302 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16303 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016304 if (err < 0)
16305 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016306 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016307 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016308 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016309 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016310 if (err < 0)
16311 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016312 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016313 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016314 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016315 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 if (err < 0)
16317 return err;
16318 } else {
16319 sprintf(name, "%s Playback Volume", chname[i]);
16320 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016321 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16322 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016323 if (err < 0)
16324 return err;
16325 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016326 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16327 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16328 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329 if (err < 0)
16330 return err;
16331 }
16332 }
16333 return 0;
16334}
16335
16336/* add playback controls for speaker and HP outputs */
16337static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16338 const char *pfx)
16339{
16340 hda_nid_t nid;
16341 int err;
16342 char name[32];
16343
16344 if (!pin)
16345 return 0;
16346
Takashi Iwai24fb9172008-09-02 14:48:20 +020016347 if (pin == 0x17) {
16348 /* ALC663 has a mono output pin on 0x17 */
16349 sprintf(name, "%s Playback Switch", pfx);
16350 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16351 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16352 return err;
16353 }
16354
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016355 if (alc880_is_fixed_pin(pin)) {
16356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16357 /* printk("DAC nid=%x\n",nid); */
16358 /* specify the DAC as the extra output */
16359 if (!spec->multiout.hp_nid)
16360 spec->multiout.hp_nid = nid;
16361 else
16362 spec->multiout.extra_out_nid[0] = nid;
16363 /* control HP volume/switch on the output mixer amp */
16364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16365 sprintf(name, "%s Playback Volume", pfx);
16366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16368 if (err < 0)
16369 return err;
16370 sprintf(name, "%s Playback Switch", pfx);
16371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16373 if (err < 0)
16374 return err;
16375 } else if (alc880_is_multi_pin(pin)) {
16376 /* set manual connection */
16377 /* we have only a switch on HP-out PIN */
16378 sprintf(name, "%s Playback Switch", pfx);
16379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16381 if (err < 0)
16382 return err;
16383 }
16384 return 0;
16385}
16386
16387/* create playback/capture controls for input pins */
16388static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16389 const struct auto_pin_cfg *cfg)
16390{
16391 struct hda_input_mux *imux = &spec->private_imux;
16392 int i, err, idx;
16393
16394 for (i = 0; i < AUTO_PIN_LAST; i++) {
16395 if (alc880_is_input_pin(cfg->input_pins[i])) {
16396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16397 err = new_analog_input(spec, cfg->input_pins[i],
16398 auto_pin_cfg_labels[i],
16399 idx, 0x0b);
16400 if (err < 0)
16401 return err;
16402 imux->items[imux->num_items].label =
16403 auto_pin_cfg_labels[i];
16404 imux->items[imux->num_items].index =
16405 alc880_input_pin_idx(cfg->input_pins[i]);
16406 imux->num_items++;
16407 }
16408 }
16409 return 0;
16410}
16411
16412static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16413 hda_nid_t nid, int pin_type,
16414 int dac_idx)
16415{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016416 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016417 /* need the manual connection? */
16418 if (alc880_is_multi_pin(nid)) {
16419 struct alc_spec *spec = codec->spec;
16420 int idx = alc880_multi_pin_idx(nid);
16421 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16422 AC_VERB_SET_CONNECT_SEL,
16423 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16424 }
16425}
16426
16427static void alc662_auto_init_multi_out(struct hda_codec *codec)
16428{
16429 struct alc_spec *spec = codec->spec;
16430 int i;
16431
Kailang Yang8c427222008-01-10 13:03:59 +010016432 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016433 for (i = 0; i <= HDA_SIDE; i++) {
16434 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016435 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016436 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016437 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016438 i);
16439 }
16440}
16441
16442static void alc662_auto_init_hp_out(struct hda_codec *codec)
16443{
16444 struct alc_spec *spec = codec->spec;
16445 hda_nid_t pin;
16446
16447 pin = spec->autocfg.hp_pins[0];
16448 if (pin) /* connect to front */
16449 /* use dac 0 */
16450 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016451 pin = spec->autocfg.speaker_pins[0];
16452 if (pin)
16453 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016454}
16455
16456#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16457#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16458
16459static void alc662_auto_init_analog_input(struct hda_codec *codec)
16460{
16461 struct alc_spec *spec = codec->spec;
16462 int i;
16463
16464 for (i = 0; i < AUTO_PIN_LAST; i++) {
16465 hda_nid_t nid = spec->autocfg.input_pins[i];
16466 if (alc662_is_input_pin(nid)) {
16467 snd_hda_codec_write(codec, nid, 0,
16468 AC_VERB_SET_PIN_WIDGET_CONTROL,
16469 (i <= AUTO_PIN_FRONT_MIC ?
16470 PIN_VREF80 : PIN_IN));
16471 if (nid != ALC662_PIN_CD_NID)
16472 snd_hda_codec_write(codec, nid, 0,
16473 AC_VERB_SET_AMP_GAIN_MUTE,
16474 AMP_OUT_MUTE);
16475 }
16476 }
16477}
16478
Takashi Iwaif511b012008-08-15 16:46:42 +020016479#define alc662_auto_init_input_src alc882_auto_init_input_src
16480
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016481static int alc662_parse_auto_config(struct hda_codec *codec)
16482{
16483 struct alc_spec *spec = codec->spec;
16484 int err;
16485 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16486
16487 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16488 alc662_ignore);
16489 if (err < 0)
16490 return err;
16491 if (!spec->autocfg.line_outs)
16492 return 0; /* can't find valid BIOS pin config */
16493
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016494 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16495 if (err < 0)
16496 return err;
16497 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16498 if (err < 0)
16499 return err;
16500 err = alc662_auto_create_extra_out(spec,
16501 spec->autocfg.speaker_pins[0],
16502 "Speaker");
16503 if (err < 0)
16504 return err;
16505 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16506 "Headphone");
16507 if (err < 0)
16508 return err;
16509 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16510 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016511 return err;
16512
16513 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16514
16515 if (spec->autocfg.dig_out_pin)
16516 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16517
Takashi Iwai603c4012008-07-30 15:01:44 +020016518 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016519 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016520
16521 spec->num_mux_defs = 1;
16522 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016523
Takashi Iwaid88897e2008-10-31 15:01:37 +010016524 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016525 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016526 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016527
16528 err = alc_auto_add_mic_boost(codec);
16529 if (err < 0)
16530 return err;
16531
Takashi Iwaie044c392008-10-27 16:56:24 +010016532 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016533 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016534}
16535
16536/* additional initialization for auto-configuration model */
16537static void alc662_auto_init(struct hda_codec *codec)
16538{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016539 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016540 alc662_auto_init_multi_out(codec);
16541 alc662_auto_init_hp_out(codec);
16542 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016543 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016544 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016545 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016546}
16547
16548static int patch_alc662(struct hda_codec *codec)
16549{
16550 struct alc_spec *spec;
16551 int err, board_config;
16552
16553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16554 if (!spec)
16555 return -ENOMEM;
16556
16557 codec->spec = spec;
16558
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016559 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16560
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016561 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16562 alc662_models,
16563 alc662_cfg_tbl);
16564 if (board_config < 0) {
16565 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16566 "trying auto-probe from BIOS...\n");
16567 board_config = ALC662_AUTO;
16568 }
16569
16570 if (board_config == ALC662_AUTO) {
16571 /* automatic parse from the BIOS config */
16572 err = alc662_parse_auto_config(codec);
16573 if (err < 0) {
16574 alc_free(codec);
16575 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016576 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 printk(KERN_INFO
16578 "hda_codec: Cannot set up configuration "
16579 "from BIOS. Using base mode...\n");
16580 board_config = ALC662_3ST_2ch_DIG;
16581 }
16582 }
16583
16584 if (board_config != ALC662_AUTO)
16585 setup_preset(spec, &alc662_presets[board_config]);
16586
Kailang Yang6dda9f42008-05-27 12:05:31 +020016587 if (codec->vendor_id == 0x10ec0663) {
16588 spec->stream_name_analog = "ALC663 Analog";
16589 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016590 } else if (codec->vendor_id == 0x10ec0272) {
16591 spec->stream_name_analog = "ALC272 Analog";
16592 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016593 } else {
16594 spec->stream_name_analog = "ALC662 Analog";
16595 spec->stream_name_digital = "ALC662 Digital";
16596 }
16597
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16599 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16600
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016601 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16602 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16603
Takashi Iwaie1406342008-02-11 18:32:32 +010016604 spec->adc_nids = alc662_adc_nids;
16605 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16606 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016607 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016608
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016609 if (!spec->cap_mixer)
16610 set_capture_mixer(spec);
16611
Takashi Iwai2134ea42008-01-10 16:53:55 +010016612 spec->vmaster_nid = 0x02;
16613
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614 codec->patch_ops = alc_patch_ops;
16615 if (board_config == ALC662_AUTO)
16616 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016617#ifdef CONFIG_SND_HDA_POWER_SAVE
16618 if (!spec->loopback.amplist)
16619 spec->loopback.amplist = alc662_loopbacks;
16620#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016621 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016622
16623 return 0;
16624}
16625
16626/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016627 * patch entries
16628 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016629static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016630 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016631 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016632 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016633 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016634 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016635 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016636 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016637 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016638 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16639 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16640 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16642 .patch = patch_alc883 },
16643 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16644 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016645 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016646 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016647 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016648 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016649 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16650 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016651 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016652 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016653 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016654 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016655 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16656 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016657 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016658 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016659 {} /* terminator */
16660};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016661
16662MODULE_ALIAS("snd-hda-codec-id:10ec*");
16663
16664MODULE_LICENSE("GPL");
16665MODULE_DESCRIPTION("Realtek HD-audio codec");
16666
16667static struct hda_codec_preset_list realtek_list = {
16668 .preset = snd_hda_preset_realtek,
16669 .owner = THIS_MODULE,
16670};
16671
16672static int __init patch_realtek_init(void)
16673{
16674 return snd_hda_add_codec_preset(&realtek_list);
16675}
16676
16677static void __exit patch_realtek_exit(void)
16678{
16679 snd_hda_delete_codec_preset(&realtek_list);
16680}
16681
16682module_init(patch_realtek_init)
16683module_exit(patch_realtek_exit)