blob: aa86a1584506931f669699645abed04cfbff287e [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Avdoninbab282b2006-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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 /* capture */
274 unsigned int num_adc_nids;
275 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100276 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200277 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100278 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200281 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 const struct hda_input_mux *input_mux;
283 unsigned int cur_mux[3];
284
285 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100286 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200288 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
290 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100291 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200292
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200293 /* dynamic controls, init_verbs and input_mux */
294 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200295 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200296 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200297 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100298
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100299 /* hooks */
300 void (*init_hook)(struct hda_codec *codec);
301 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
302
Takashi Iwai834be882006-03-01 14:16:17 +0100303 /* for pin sensing */
304 unsigned int sense_updated: 1;
305 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100306 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200307
Takashi Iwai2134ea42008-01-10 16:53:55 +0100308 /* for virtual master */
309 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200310#ifdef CONFIG_SND_HDA_POWER_SAVE
311 struct hda_loopback_check loopback;
312#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200313
314 /* for PLL fix */
315 hda_nid_t pll_nid;
316 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100317
318#ifdef SND_HDA_NEEDS_RESUME
319#define ALC_MAX_PINS 16
320 unsigned int num_pins;
321 hda_nid_t pin_nids[ALC_MAX_PINS];
322 unsigned int pin_cfgs[ALC_MAX_PINS];
323#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100324};
325
326/*
327 * configuration template - to be copied to the spec instance
328 */
329struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330 struct snd_kcontrol_new *mixers[5]; /* should be identical size
331 * with spec
332 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100333 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100334 const struct hda_verb *init_verbs[5];
335 unsigned int num_dacs;
336 hda_nid_t *dac_nids;
337 hda_nid_t dig_out_nid; /* optional */
338 hda_nid_t hp_nid; /* optional */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100342 hda_nid_t dig_in_nid;
343 unsigned int num_channel_mode;
344 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200345 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200346 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100347 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100348 void (*unsol_event)(struct hda_codec *, unsigned int);
349 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200350#ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_amp_list *loopbacks;
352#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353};
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356/*
357 * input MUX handling
358 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
360 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361{
362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
363 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
365 if (mux_idx >= spec->num_mux_defs)
366 mux_idx = 0;
367 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200370static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct alc_spec *spec = codec->spec;
375 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
376
377 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
378 return 0;
379}
380
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200381static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100386 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100388 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100389 hda_nid_t nid = spec->capsrc_nids ?
390 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Takashi Iwaicd896c32008-11-18 12:36:33 +0100392 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
393 imux = &spec->input_mux[mux_idx];
394
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100395 if (spec->is_mix_capture) {
396 /* Matrix-mixer style (e.g. ALC882) */
397 unsigned int *cur_val = &spec->cur_mux[adc_idx];
398 unsigned int i, idx;
399
400 idx = ucontrol->value.enumerated.item[0];
401 if (idx >= imux->num_items)
402 idx = imux->num_items - 1;
403 if (*cur_val == idx)
404 return 0;
405 for (i = 0; i < imux->num_items; i++) {
406 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
407 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
408 imux->items[i].index,
409 HDA_AMP_MUTE, v);
410 }
411 *cur_val = idx;
412 return 1;
413 } else {
414 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100415 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100416 &spec->cur_mux[adc_idx]);
417 }
418}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420/*
421 * channel mode setting
422 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200423static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
424 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425{
426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
427 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100428 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
429 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430}
431
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200432static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100437 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200438 spec->num_channel_mode,
439 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440}
441
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200447 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
448 spec->num_channel_mode,
449 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200450 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200451 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
452 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200457 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100458 * being part of a format specifier. Maximum allowed length of a value is
459 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100460 *
461 * Note: some retasking pin complexes seem to ignore requests for input
462 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
463 * are requested. Therefore order this list so that this behaviour will not
464 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200465 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
466 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200467 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100469 "Mic 50pc bias", "Mic 80pc bias",
470 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471};
472static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100473 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474};
475/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 * in the pin being assumed to be exclusively an input or an output pin. In
477 * addition, "input" pins may or may not process the mic bias option
478 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
479 * accept requests for bias as of chip versions up to March 2006) and/or
480 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200482#define ALC_PIN_DIR_IN 0x00
483#define ALC_PIN_DIR_OUT 0x01
484#define ALC_PIN_DIR_INOUT 0x02
485#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
486#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487
Kailang Yangea1fb292008-08-26 12:58:38 +0200488/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 * For each direction the minimum and maximum values are given.
490 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200491static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 { 0, 2 }, /* ALC_PIN_DIR_IN */
493 { 3, 4 }, /* ALC_PIN_DIR_OUT */
494 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200495 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
496 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497};
498#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
499#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
500#define alc_pin_mode_n_items(_dir) \
501 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
502
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200503static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200505{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 unsigned int item_num = uinfo->value.enumerated.item;
507 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
508
509 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200510 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
512
513 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
514 item_num = alc_pin_mode_min(dir);
515 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516 return 0;
517}
518
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200519static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200526 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
528 AC_VERB_GET_PIN_WIDGET_CONTROL,
529 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 /* Find enumerated value for current pinctl setting */
532 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 return 0;
537}
538
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541{
542 signed int change;
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
546 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_PIN_WIDGET_CONTROL,
549 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200551 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 val = alc_pin_mode_min(dir);
553
554 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100555 if (change) {
556 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200557 snd_hda_codec_write_cache(codec, nid, 0,
558 AC_VERB_SET_PIN_WIDGET_CONTROL,
559 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100560
Kailang Yangea1fb292008-08-26 12:58:38 +0200561 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100562 * for the requested pin mode. Enum values of 2 or less are
563 * input modes.
564 *
565 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200566 * reduces noise slightly (particularly on input) so we'll
567 * do it. However, having both input and output buffers
568 * enabled simultaneously doesn't seem to be problematic if
569 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100570 */
571 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200572 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
573 HDA_AMP_MUTE, HDA_AMP_MUTE);
574 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
575 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100576 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200577 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
578 HDA_AMP_MUTE, HDA_AMP_MUTE);
579 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
580 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 }
582 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200583 return change;
584}
585
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200587 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 .info = alc_pin_mode_info, \
589 .get = alc_pin_mode_get, \
590 .put = alc_pin_mode_put, \
591 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100592
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100593/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
594 * together using a mask with more than one bit set. This control is
595 * currently used only by the ALC260 test model. At this stage they are not
596 * needed for any "production" models.
597 */
598#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200599#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200600
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 hda_nid_t nid = kcontrol->private_value & 0xffff;
606 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
607 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200608 unsigned int val = snd_hda_codec_read(codec, nid, 0,
609 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100610
611 *valp = (val & mask) != 0;
612 return 0;
613}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100616{
617 signed int change;
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
621 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_GPIO_DATA,
624 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100625
626 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
628 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629 gpio_data &= ~mask;
630 else
631 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200632 snd_hda_codec_write_cache(codec, nid, 0,
633 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634
635 return change;
636}
637#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
638 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
639 .info = alc_gpio_data_info, \
640 .get = alc_gpio_data_get, \
641 .put = alc_gpio_data_put, \
642 .private_value = nid | (mask<<16) }
643#endif /* CONFIG_SND_DEBUG */
644
Jonathan Woithe92621f12006-02-28 11:47:47 +0100645/* A switch control to allow the enabling of the digital IO pins on the
646 * ALC260. This is incredibly simplistic; the intention of this control is
647 * to provide something in the test model allowing digital outputs to be
648 * identified if present. If models are found which can utilise these
649 * outputs a more complete mixer control can be devised for those models if
650 * necessary.
651 */
652#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200653#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200654
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 hda_nid_t nid = kcontrol->private_value & 0xffff;
660 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
661 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100663 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100664
665 *valp = (val & mask) != 0;
666 return 0;
667}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200668static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100670{
671 signed int change;
672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
673 hda_nid_t nid = kcontrol->private_value & 0xffff;
674 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
675 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200676 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100677 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100679
680 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200681 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100682 if (val==0)
683 ctrl_data &= ~mask;
684 else
685 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200686 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
687 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100688
689 return change;
690}
691#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
692 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
693 .info = alc_spdif_ctrl_info, \
694 .get = alc_spdif_ctrl_get, \
695 .put = alc_spdif_ctrl_put, \
696 .private_value = nid | (mask<<16) }
697#endif /* CONFIG_SND_DEBUG */
698
Jonathan Woithef8225f62008-01-08 12:16:54 +0100699/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
700 * Again, this is only used in the ALC26x test models to help identify when
701 * the EAPD line must be asserted for features to work.
702 */
703#ifdef CONFIG_SND_DEBUG
704#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
705
706static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
708{
709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
710 hda_nid_t nid = kcontrol->private_value & 0xffff;
711 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
712 long *valp = ucontrol->value.integer.value;
713 unsigned int val = snd_hda_codec_read(codec, nid, 0,
714 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
715
716 *valp = (val & mask) != 0;
717 return 0;
718}
719
720static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
721 struct snd_ctl_elem_value *ucontrol)
722{
723 int change;
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 hda_nid_t nid = kcontrol->private_value & 0xffff;
726 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
727 long val = *ucontrol->value.integer.value;
728 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
729 AC_VERB_GET_EAPD_BTLENABLE,
730 0x00);
731
732 /* Set/unset the masked control bit(s) as needed */
733 change = (!val ? 0 : mask) != (ctrl_data & mask);
734 if (!val)
735 ctrl_data &= ~mask;
736 else
737 ctrl_data |= mask;
738 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
739 ctrl_data);
740
741 return change;
742}
743
744#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
745 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
746 .info = alc_eapd_ctrl_info, \
747 .get = alc_eapd_ctrl_get, \
748 .put = alc_eapd_ctrl_put, \
749 .private_value = nid | (mask<<16) }
750#endif /* CONFIG_SND_DEBUG */
751
Kailang Yangdf694da2005-12-05 19:42:22 +0100752/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100753 */
754static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
755{
756 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
757 return;
758 spec->mixers[spec->num_mixers++] = mix;
759}
760
761static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
762{
763 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
764 return;
765 spec->init_verbs[spec->num_init_verbs++] = verb;
766}
767
Takashi Iwaidaead532008-11-28 12:55:36 +0100768#ifdef CONFIG_PROC_FS
769/*
770 * hook for proc
771 */
772static void print_realtek_coef(struct snd_info_buffer *buffer,
773 struct hda_codec *codec, hda_nid_t nid)
774{
775 int coeff;
776
777 if (nid != 0x20)
778 return;
779 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
780 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
781 coeff = snd_hda_codec_read(codec, nid, 0,
782 AC_VERB_GET_COEF_INDEX, 0);
783 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
784}
785#else
786#define print_realtek_coef NULL
787#endif
788
Takashi Iwaid88897e2008-10-31 15:01:37 +0100789/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100790 * set up from the preset table
791 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200792static void setup_preset(struct alc_spec *spec,
793 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100794{
795 int i;
796
797 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100798 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100799 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200800 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
801 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100802 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200803
Kailang Yangdf694da2005-12-05 19:42:22 +0100804 spec->channel_mode = preset->channel_mode;
805 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200806 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100807
808 spec->multiout.max_channels = spec->channel_mode[0].channels;
809
810 spec->multiout.num_dacs = preset->num_dacs;
811 spec->multiout.dac_nids = preset->dac_nids;
812 spec->multiout.dig_out_nid = preset->dig_out_nid;
813 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200814
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200815 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200816 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200817 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100818 spec->input_mux = preset->input_mux;
819
820 spec->num_adc_nids = preset->num_adc_nids;
821 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100822 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100823 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100824
825 spec->unsol_event = preset->unsol_event;
826 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200827#ifdef CONFIG_SND_HDA_POWER_SAVE
828 spec->loopback.amplist = preset->loopbacks;
829#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100830}
831
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200832/* Enable GPIO mask and set output */
833static struct hda_verb alc_gpio1_init_verbs[] = {
834 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
835 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
836 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
837 { }
838};
839
840static struct hda_verb alc_gpio2_init_verbs[] = {
841 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
842 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
843 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
844 { }
845};
846
Kailang Yangbdd148a2007-05-08 15:19:08 +0200847static struct hda_verb alc_gpio3_init_verbs[] = {
848 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
849 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
850 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
851 { }
852};
853
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200854/*
855 * Fix hardware PLL issue
856 * On some codecs, the analog PLL gating control must be off while
857 * the default value is 1.
858 */
859static void alc_fix_pll(struct hda_codec *codec)
860{
861 struct alc_spec *spec = codec->spec;
862 unsigned int val;
863
864 if (!spec->pll_nid)
865 return;
866 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
867 spec->pll_coef_idx);
868 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
869 AC_VERB_GET_PROC_COEF, 0);
870 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
871 spec->pll_coef_idx);
872 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
873 val & ~(1 << spec->pll_coef_bit));
874}
875
876static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
877 unsigned int coef_idx, unsigned int coef_bit)
878{
879 struct alc_spec *spec = codec->spec;
880 spec->pll_nid = nid;
881 spec->pll_coef_idx = coef_idx;
882 spec->pll_coef_bit = coef_bit;
883 alc_fix_pll(codec);
884}
885
Kailang Yangc9b58002007-10-16 14:30:01 +0200886static void alc_sku_automute(struct hda_codec *codec)
887{
888 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200889 unsigned int present;
890 unsigned int hp_nid = spec->autocfg.hp_pins[0];
891 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
892
893 /* need to execute and sync at first */
894 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
895 present = snd_hda_codec_read(codec, hp_nid, 0,
896 AC_VERB_GET_PIN_SENSE, 0);
897 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100898 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
899 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200900}
901
Takashi Iwai4605b712008-10-31 14:18:24 +0100902#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200903static void alc_mic_automute(struct hda_codec *codec)
904{
905 struct alc_spec *spec = codec->spec;
906 unsigned int present;
907 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
908 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
909 unsigned int mix_nid = spec->capsrc_nids[0];
910 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
911
912 capsrc_idx_mic = mic_nid - 0x18;
913 capsrc_idx_fmic = fmic_nid - 0x18;
914 present = snd_hda_codec_read(codec, mic_nid, 0,
915 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
916 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
917 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
918 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
919 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
920 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
921 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
922}
Takashi Iwai4605b712008-10-31 14:18:24 +0100923#else
924#define alc_mic_automute(codec) /* NOP */
925#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200926
Kailang Yangc9b58002007-10-16 14:30:01 +0200927/* unsolicited event for HP jack sensing */
928static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
929{
930 if (codec->vendor_id == 0x10ec0880)
931 res >>= 28;
932 else
933 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200934 if (res == ALC880_HP_EVENT)
935 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200936
Kailang Yang7fb0d782008-10-15 11:12:35 +0200937 if (res == ALC880_MIC_EVENT)
938 alc_mic_automute(codec);
939}
940
941static void alc_inithook(struct hda_codec *codec)
942{
Kailang Yangc9b58002007-10-16 14:30:01 +0200943 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200944 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200945}
946
Kailang Yangf9423e72008-05-27 12:32:25 +0200947/* additional initialization for ALC888 variants */
948static void alc888_coef_init(struct hda_codec *codec)
949{
950 unsigned int tmp;
951
952 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
953 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
954 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
955 if ((tmp & 0xf0) == 2)
956 /* alc888S-VC */
957 snd_hda_codec_read(codec, 0x20, 0,
958 AC_VERB_SET_PROC_COEF, 0x830);
959 else
960 /* alc888-VB */
961 snd_hda_codec_read(codec, 0x20, 0,
962 AC_VERB_SET_PROC_COEF, 0x3030);
963}
964
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200965/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
966 * 31 ~ 16 : Manufacture ID
967 * 15 ~ 8 : SKU ID
968 * 7 ~ 0 : Assembly ID
969 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
970 */
971static void alc_subsystem_id(struct hda_codec *codec,
972 unsigned int porta, unsigned int porte,
973 unsigned int portd)
974{
Kailang Yangc9b58002007-10-16 14:30:01 +0200975 unsigned int ass, tmp, i;
976 unsigned nid;
977 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200978
Kailang Yangc9b58002007-10-16 14:30:01 +0200979 ass = codec->subsystem_id & 0xffff;
980 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
981 goto do_sku;
982
Kailang Yangea1fb292008-08-26 12:58:38 +0200983 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200984 * 31~30 : port conetcivity
985 * 29~21 : reserve
986 * 20 : PCBEEP input
987 * 19~16 : Check sum (15:1)
988 * 15~1 : Custom
989 * 0 : override
990 */
991 nid = 0x1d;
992 if (codec->vendor_id == 0x10ec0260)
993 nid = 0x17;
994 ass = snd_hda_codec_read(codec, nid, 0,
995 AC_VERB_GET_CONFIG_DEFAULT, 0);
996 if (!(ass & 1) && !(ass & 0x100000))
997 return;
998 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200999 return;
1000
Kailang Yangc9b58002007-10-16 14:30:01 +02001001 /* check sum */
1002 tmp = 0;
1003 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001004 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001005 tmp++;
1006 }
1007 if (((ass >> 16) & 0xf) != tmp)
1008 return;
1009do_sku:
1010 /*
1011 * 0 : override
1012 * 1 : Swap Jack
1013 * 2 : 0 --> Desktop, 1 --> Laptop
1014 * 3~5 : External Amplifier control
1015 * 7~6 : Reserved
1016 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001017 tmp = (ass & 0x38) >> 3; /* external Amp control */
1018 switch (tmp) {
1019 case 1:
1020 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1021 break;
1022 case 3:
1023 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1024 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001025 case 7:
1026 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1027 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001028 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001029 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001030 case 0x10ec0260:
1031 snd_hda_codec_write(codec, 0x0f, 0,
1032 AC_VERB_SET_EAPD_BTLENABLE, 2);
1033 snd_hda_codec_write(codec, 0x10, 0,
1034 AC_VERB_SET_EAPD_BTLENABLE, 2);
1035 break;
1036 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001037 case 0x10ec0267:
1038 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001039 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001040 case 0x10ec0660:
1041 case 0x10ec0662:
1042 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001043 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001044 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001045 snd_hda_codec_write(codec, 0x14, 0,
1046 AC_VERB_SET_EAPD_BTLENABLE, 2);
1047 snd_hda_codec_write(codec, 0x15, 0,
1048 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001050 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001051 switch (codec->vendor_id) {
1052 case 0x10ec0260:
1053 snd_hda_codec_write(codec, 0x1a, 0,
1054 AC_VERB_SET_COEF_INDEX, 7);
1055 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1056 AC_VERB_GET_PROC_COEF, 0);
1057 snd_hda_codec_write(codec, 0x1a, 0,
1058 AC_VERB_SET_COEF_INDEX, 7);
1059 snd_hda_codec_write(codec, 0x1a, 0,
1060 AC_VERB_SET_PROC_COEF,
1061 tmp | 0x2010);
1062 break;
1063 case 0x10ec0262:
1064 case 0x10ec0880:
1065 case 0x10ec0882:
1066 case 0x10ec0883:
1067 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001068 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 snd_hda_codec_write(codec, 0x20, 0,
1070 AC_VERB_SET_COEF_INDEX, 7);
1071 tmp = snd_hda_codec_read(codec, 0x20, 0,
1072 AC_VERB_GET_PROC_COEF, 0);
1073 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001074 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001075 snd_hda_codec_write(codec, 0x20, 0,
1076 AC_VERB_SET_PROC_COEF,
1077 tmp | 0x2010);
1078 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001079 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001080 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001081 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001082 case 0x10ec0267:
1083 case 0x10ec0268:
1084 snd_hda_codec_write(codec, 0x20, 0,
1085 AC_VERB_SET_COEF_INDEX, 7);
1086 tmp = snd_hda_codec_read(codec, 0x20, 0,
1087 AC_VERB_GET_PROC_COEF, 0);
1088 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001089 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001090 snd_hda_codec_write(codec, 0x20, 0,
1091 AC_VERB_SET_PROC_COEF,
1092 tmp | 0x3000);
1093 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001095 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001096 break;
1097 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001098
Kailang Yang8c427222008-01-10 13:03:59 +01001099 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 * when the external headphone out jack is plugged"
1101 */
Kailang Yang8c427222008-01-10 13:03:59 +01001102 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 return;
1104 /*
1105 * 10~8 : Jack location
1106 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1107 * 14~13: Resvered
1108 * 15 : 1 --> enable the function "Mute internal speaker
1109 * when the external headphone out jack is plugged"
1110 */
1111 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001112 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001114 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 else
1116 return;
1117 }
1118
1119 if (!spec->autocfg.hp_pins[0]) {
1120 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1121 if (tmp == 0)
1122 spec->autocfg.hp_pins[0] = porta;
1123 else if (tmp == 1)
1124 spec->autocfg.hp_pins[0] = porte;
1125 else if (tmp == 2)
1126 spec->autocfg.hp_pins[0] = portd;
1127 else
1128 return;
1129 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001130 if (spec->autocfg.hp_pins[0])
1131 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1132 AC_VERB_SET_UNSOLICITED_ENABLE,
1133 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001134
Takashi Iwai4605b712008-10-31 14:18:24 +01001135#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001136 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1137 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1138 snd_hda_codec_write(codec,
1139 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1140 AC_VERB_SET_UNSOLICITED_ENABLE,
1141 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001142#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001143
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001145}
1146
Takashi Iwai41e41f12005-06-08 14:48:49 +02001147/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001148 * Fix-up pin default configurations
1149 */
1150
1151struct alc_pincfg {
1152 hda_nid_t nid;
1153 u32 val;
1154};
1155
1156static void alc_fix_pincfg(struct hda_codec *codec,
1157 const struct snd_pci_quirk *quirk,
1158 const struct alc_pincfg **pinfix)
1159{
1160 const struct alc_pincfg *cfg;
1161
1162 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1163 if (!quirk)
1164 return;
1165
1166 cfg = pinfix[quirk->value];
1167 for (; cfg->nid; cfg++) {
1168 int i;
1169 u32 val = cfg->val;
1170 for (i = 0; i < 4; i++) {
1171 snd_hda_codec_write(codec, cfg->nid, 0,
1172 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1173 val & 0xff);
1174 val >>= 8;
1175 }
1176 }
1177}
1178
1179/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001180 * ALC888
1181 */
1182
1183/*
1184 * 2ch mode
1185 */
1186static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1187/* Mic-in jack as mic in */
1188 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1189 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1190/* Line-in jack as Line in */
1191 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1192 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1193/* Line-Out as Front */
1194 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1195 { } /* end */
1196};
1197
1198/*
1199 * 4ch mode
1200 */
1201static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1202/* Mic-in jack as mic in */
1203 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1204 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1205/* Line-in jack as Surround */
1206 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1207 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1208/* Line-Out as Front */
1209 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1210 { } /* end */
1211};
1212
1213/*
1214 * 6ch mode
1215 */
1216static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1217/* Mic-in jack as CLFE */
1218 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1219 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1220/* Line-in jack as Surround */
1221 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1222 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1223/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1224 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1225 { } /* end */
1226};
1227
1228/*
1229 * 8ch mode
1230 */
1231static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1232/* Mic-in jack as CLFE */
1233 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1234 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1235/* Line-in jack as Surround */
1236 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1237 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1238/* Line-Out as Side */
1239 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1240 { } /* end */
1241};
1242
1243static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1244 { 2, alc888_4ST_ch2_intel_init },
1245 { 4, alc888_4ST_ch4_intel_init },
1246 { 6, alc888_4ST_ch6_intel_init },
1247 { 8, alc888_4ST_ch8_intel_init },
1248};
1249
1250/*
1251 * ALC888 Fujitsu Siemens Amillo xa3530
1252 */
1253
1254static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1255/* Front Mic: set to PIN_IN (empty by default) */
1256 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1257/* Connect Internal HP to Front */
1258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1260 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1261/* Connect Bass HP to Front */
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1265/* Connect Line-Out side jack (SPDIF) to Side */
1266 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1268 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1269/* Connect Mic jack to CLFE */
1270 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1273/* Connect Line-in jack to Surround */
1274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1276 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1277/* Connect HP out jack to Front */
1278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1281/* Enable unsolicited event for HP jack and Line-out jack */
1282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1283 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1284 {}
1285};
1286
1287static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1288{
1289 unsigned int present;
1290 unsigned int bits;
1291 /* Line out presence */
1292 present = snd_hda_codec_read(codec, 0x17, 0,
1293 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1294 /* HP out presence */
1295 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1296 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1297 bits = present ? HDA_AMP_MUTE : 0;
1298 /* Toggle internal speakers muting */
1299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1300 HDA_AMP_MUTE, bits);
1301 /* Toggle internal bass muting */
1302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1303 HDA_AMP_MUTE, bits);
1304}
1305
1306static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1307 unsigned int res)
1308{
1309 if (res >> 26 == ALC880_HP_EVENT)
1310 alc888_fujitsu_xa3530_automute(codec);
1311}
1312
1313
1314/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001315 * ALC888 Acer Aspire 4930G model
1316 */
1317
1318static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1319/* Front Mic: set to PIN_IN (empty by default) */
1320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1321/* Unselect Front Mic by default in input mixer 3 */
1322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001323/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1325/* Connect Internal HP to front */
1326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1329/* Connect HP out to front */
1330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1333 { }
1334};
1335
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001336static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001337 /* Front mic only available on one ADC */
1338 {
1339 .num_items = 4,
1340 .items = {
1341 { "Mic", 0x0 },
1342 { "Line", 0x2 },
1343 { "CD", 0x4 },
1344 { "Front Mic", 0xb },
1345 },
1346 },
1347 {
1348 .num_items = 3,
1349 .items = {
1350 { "Mic", 0x0 },
1351 { "Line", 0x2 },
1352 { "CD", 0x4 },
1353 },
1354 }
1355};
1356
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001357static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1359 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1361 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1363 HDA_OUTPUT),
1364 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1365 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1366 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1367 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1368 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1377 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1378 { } /* end */
1379};
1380
1381static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1382{
1383 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001384 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001385 present = snd_hda_codec_read(codec, 0x15, 0,
1386 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001387 bits = present ? HDA_AMP_MUTE : 0;
1388 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1389 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001390}
1391
1392static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1393 unsigned int res)
1394{
1395 if (res >> 26 == ALC880_HP_EVENT)
1396 alc888_acer_aspire_4930g_automute(codec);
1397}
1398
1399/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001400 * ALC880 3-stack model
1401 *
1402 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001403 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1404 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 */
1406
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407static hda_nid_t alc880_dac_nids[4] = {
1408 /* front, rear, clfe, rear_surr */
1409 0x02, 0x05, 0x04, 0x03
1410};
1411
1412static hda_nid_t alc880_adc_nids[3] = {
1413 /* ADC0-2 */
1414 0x07, 0x08, 0x09,
1415};
1416
1417/* The datasheet says the node 0x07 is connected from inputs,
1418 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001419 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001421static hda_nid_t alc880_adc_nids_alt[2] = {
1422 /* ADC1-2 */
1423 0x08, 0x09,
1424};
1425
1426#define ALC880_DIGOUT_NID 0x06
1427#define ALC880_DIGIN_NID 0x0a
1428
1429static struct hda_input_mux alc880_capture_source = {
1430 .num_items = 4,
1431 .items = {
1432 { "Mic", 0x0 },
1433 { "Front Mic", 0x3 },
1434 { "Line", 0x2 },
1435 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001437};
1438
1439/* channel source setting (2/6 channel selection for 3-stack) */
1440/* 2ch mode */
1441static struct hda_verb alc880_threestack_ch2_init[] = {
1442 /* set line-in to input, mute it */
1443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1445 /* set mic-in to input vref 80%, mute it */
1446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 { } /* end */
1449};
1450
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001451/* 6ch mode */
1452static struct hda_verb alc880_threestack_ch6_init[] = {
1453 /* set line-in to output, unmute it */
1454 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1455 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1456 /* set mic-in to output, unmute it */
1457 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1458 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1459 { } /* end */
1460};
1461
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001462static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001463 { 2, alc880_threestack_ch2_init },
1464 { 6, alc880_threestack_ch6_init },
1465};
1466
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001467static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001468 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001469 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001471 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001472 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1473 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001474 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1475 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1477 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1478 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1479 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1481 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1482 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1484 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1485 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001487 {
1488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1489 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001490 .info = alc_ch_mode_info,
1491 .get = alc_ch_mode_get,
1492 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001493 },
1494 { } /* end */
1495};
1496
1497/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001498static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1499 struct snd_ctl_elem_info *uinfo)
1500{
1501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1502 struct alc_spec *spec = codec->spec;
1503 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001504
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001505 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001506 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1507 HDA_INPUT);
1508 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001509 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001510 return err;
1511}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001513static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1514 unsigned int size, unsigned int __user *tlv)
1515{
1516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1517 struct alc_spec *spec = codec->spec;
1518 int err;
1519
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001520 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001521 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1522 HDA_INPUT);
1523 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001524 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001525 return err;
1526}
1527
1528typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1529 struct snd_ctl_elem_value *ucontrol);
1530
1531static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1532 struct snd_ctl_elem_value *ucontrol,
1533 getput_call_t func)
1534{
1535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1536 struct alc_spec *spec = codec->spec;
1537 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1538 int err;
1539
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001540 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001541 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1542 3, 0, HDA_INPUT);
1543 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001544 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001545 return err;
1546}
1547
1548static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1549 struct snd_ctl_elem_value *ucontrol)
1550{
1551 return alc_cap_getput_caller(kcontrol, ucontrol,
1552 snd_hda_mixer_amp_volume_get);
1553}
1554
1555static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1556 struct snd_ctl_elem_value *ucontrol)
1557{
1558 return alc_cap_getput_caller(kcontrol, ucontrol,
1559 snd_hda_mixer_amp_volume_put);
1560}
1561
1562/* capture mixer elements */
1563#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1564
1565static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1566 struct snd_ctl_elem_value *ucontrol)
1567{
1568 return alc_cap_getput_caller(kcontrol, ucontrol,
1569 snd_hda_mixer_amp_switch_get);
1570}
1571
1572static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_value *ucontrol)
1574{
1575 return alc_cap_getput_caller(kcontrol, ucontrol,
1576 snd_hda_mixer_amp_switch_put);
1577}
1578
1579#define DEFINE_CAPMIX(num) \
1580static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1581 { \
1582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1583 .name = "Capture Switch", \
1584 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1585 .count = num, \
1586 .info = alc_cap_sw_info, \
1587 .get = alc_cap_sw_get, \
1588 .put = alc_cap_sw_put, \
1589 }, \
1590 { \
1591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1592 .name = "Capture Volume", \
1593 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1594 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1595 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1596 .count = num, \
1597 .info = alc_cap_vol_info, \
1598 .get = alc_cap_vol_get, \
1599 .put = alc_cap_vol_put, \
1600 .tlv = { .c = alc_cap_vol_tlv }, \
1601 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001602 { \
1603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1604 /* .name = "Capture Source", */ \
1605 .name = "Input Source", \
1606 .count = num, \
1607 .info = alc_mux_enum_info, \
1608 .get = alc_mux_enum_get, \
1609 .put = alc_mux_enum_put, \
1610 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001611 { } /* end */ \
1612}
1613
1614/* up to three ADCs */
1615DEFINE_CAPMIX(1);
1616DEFINE_CAPMIX(2);
1617DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001618
1619
1620/*
1621 * ALC880 5-stack model
1622 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001623 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1624 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001625 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1626 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1627 */
1628
1629/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001630static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001631 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001632 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 { } /* end */
1634};
1635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001636/* channel source setting (6/8 channel selection for 5-stack) */
1637/* 6ch mode */
1638static struct hda_verb alc880_fivestack_ch6_init[] = {
1639 /* set line-in to input, mute it */
1640 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1641 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001642 { } /* end */
1643};
1644
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001645/* 8ch mode */
1646static struct hda_verb alc880_fivestack_ch8_init[] = {
1647 /* set line-in to output, unmute it */
1648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1650 { } /* end */
1651};
1652
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001653static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 { 6, alc880_fivestack_ch6_init },
1655 { 8, alc880_fivestack_ch8_init },
1656};
1657
1658
1659/*
1660 * ALC880 6-stack model
1661 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001662 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1663 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1665 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1666 */
1667
1668static hda_nid_t alc880_6st_dac_nids[4] = {
1669 /* front, rear, clfe, rear_surr */
1670 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001671};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001672
1673static struct hda_input_mux alc880_6stack_capture_source = {
1674 .num_items = 4,
1675 .items = {
1676 { "Mic", 0x0 },
1677 { "Front Mic", 0x1 },
1678 { "Line", 0x2 },
1679 { "CD", 0x4 },
1680 },
1681};
1682
1683/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001684static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685 { 8, NULL },
1686};
1687
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001688static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001689 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001690 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001692 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1694 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001695 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1696 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001697 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001698 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001699 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1700 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1701 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1702 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1705 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1707 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1708 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001709 {
1710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1711 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001712 .info = alc_ch_mode_info,
1713 .get = alc_ch_mode_get,
1714 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001715 },
1716 { } /* end */
1717};
1718
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001719
1720/*
1721 * ALC880 W810 model
1722 *
1723 * W810 has rear IO for:
1724 * Front (DAC 02)
1725 * Surround (DAC 03)
1726 * Center/LFE (DAC 04)
1727 * Digital out (06)
1728 *
1729 * The system also has a pair of internal speakers, and a headphone jack.
1730 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001731 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732 * There is a variable resistor to control the speaker or headphone
1733 * volume. This is a hardware-only device without a software API.
1734 *
1735 * Plugging headphones in will disable the internal speakers. This is
1736 * implemented in hardware, not via the driver using jack sense. In
1737 * a similar fashion, plugging into the rear socket marked "front" will
1738 * disable both the speakers and headphones.
1739 *
1740 * For input, there's a microphone jack, and an "audio in" jack.
1741 * These may not do anything useful with this driver yet, because I
1742 * haven't setup any initialization verbs for these yet...
1743 */
1744
1745static hda_nid_t alc880_w810_dac_nids[3] = {
1746 /* front, rear/surround, clfe */
1747 0x02, 0x03, 0x04
1748};
1749
1750/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001751static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001752 { 6, NULL }
1753};
1754
1755/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001756static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1766 { } /* end */
1767};
1768
1769
1770/*
1771 * Z710V model
1772 *
1773 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001774 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1775 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776 */
1777
1778static hda_nid_t alc880_z71v_dac_nids[1] = {
1779 0x02
1780};
1781#define ALC880_Z71V_HP_DAC 0x03
1782
1783/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001784static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001785 { 2, NULL }
1786};
1787
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001788static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001791 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001792 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1797 { } /* end */
1798};
1799
1800
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001801/*
1802 * ALC880 F1734 model
1803 *
1804 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1805 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1806 */
1807
1808static hda_nid_t alc880_f1734_dac_nids[1] = {
1809 0x03
1810};
1811#define ALC880_F1734_HP_DAC 0x02
1812
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001813static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001814 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001815 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001816 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1817 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001822 { } /* end */
1823};
1824
Takashi Iwai937b4162008-02-11 14:52:36 +01001825static struct hda_input_mux alc880_f1734_capture_source = {
1826 .num_items = 2,
1827 .items = {
1828 { "Mic", 0x1 },
1829 { "CD", 0x4 },
1830 },
1831};
1832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834/*
1835 * ALC880 ASUS model
1836 *
1837 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1838 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1839 * Mic = 0x18, Line = 0x1a
1840 */
1841
1842#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1843#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1844
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001845static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001846 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001847 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001848 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001849 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001850 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1851 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001852 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1853 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001854 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1855 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1856 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1857 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001860 {
1861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1862 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001863 .info = alc_ch_mode_info,
1864 .get = alc_ch_mode_get,
1865 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001866 },
1867 { } /* end */
1868};
1869
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001870/*
1871 * ALC880 ASUS W1V model
1872 *
1873 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1874 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1875 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1876 */
1877
1878/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001879static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001880 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1881 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001882 { } /* end */
1883};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001885/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001886static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001887 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1888 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1889 { } /* end */
1890};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891
Kailang Yangdf694da2005-12-05 19:42:22 +01001892/* TCL S700 */
1893static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1895 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1898 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1901 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1902 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001903 { } /* end */
1904};
1905
Kailang Yangccc656c2006-10-17 12:32:26 +02001906/* Uniwill */
1907static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001908 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1909 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1911 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001912 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1913 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1914 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1915 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1924 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1925 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1926 {
1927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1928 .name = "Channel Mode",
1929 .info = alc_ch_mode_info,
1930 .get = alc_ch_mode_get,
1931 .put = alc_ch_mode_put,
1932 },
1933 { } /* end */
1934};
1935
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001936static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1937 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1938 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1941 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1942 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1944 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1946 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1947 { } /* end */
1948};
1949
Kailang Yangccc656c2006-10-17 12:32:26 +02001950static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1952 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1954 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1957 { } /* end */
1958};
1959
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001961 * virtual master controls
1962 */
1963
1964/*
1965 * slave controls for virtual master
1966 */
1967static const char *alc_slave_vols[] = {
1968 "Front Playback Volume",
1969 "Surround Playback Volume",
1970 "Center Playback Volume",
1971 "LFE Playback Volume",
1972 "Side Playback Volume",
1973 "Headphone Playback Volume",
1974 "Speaker Playback Volume",
1975 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001976 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001977 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001978 NULL,
1979};
1980
1981static const char *alc_slave_sws[] = {
1982 "Front Playback Switch",
1983 "Surround Playback Switch",
1984 "Center Playback Switch",
1985 "LFE Playback Switch",
1986 "Side Playback Switch",
1987 "Headphone Playback Switch",
1988 "Speaker Playback Switch",
1989 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001990 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001991 NULL,
1992};
1993
1994/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001995 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001997
1998static void alc_free_kctls(struct hda_codec *codec);
1999
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000static int alc_build_controls(struct hda_codec *codec)
2001{
2002 struct alc_spec *spec = codec->spec;
2003 int err;
2004 int i;
2005
2006 for (i = 0; i < spec->num_mixers; i++) {
2007 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2008 if (err < 0)
2009 return err;
2010 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002011 if (spec->cap_mixer) {
2012 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2013 if (err < 0)
2014 return err;
2015 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002017 err = snd_hda_create_spdif_out_ctls(codec,
2018 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019 if (err < 0)
2020 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01002021 err = snd_hda_create_spdif_share_sw(codec,
2022 &spec->multiout);
2023 if (err < 0)
2024 return err;
2025 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026 }
2027 if (spec->dig_in_nid) {
2028 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2029 if (err < 0)
2030 return err;
2031 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002032
2033 /* if we have no master control, let's create it */
2034 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002035 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002036 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002037 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002038 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002039 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002040 if (err < 0)
2041 return err;
2042 }
2043 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2044 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2045 NULL, alc_slave_sws);
2046 if (err < 0)
2047 return err;
2048 }
2049
Takashi Iwai603c4012008-07-30 15:01:44 +02002050 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051 return 0;
2052}
2053
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002054
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055/*
2056 * initialize the codec volumes, etc
2057 */
2058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059/*
2060 * generic initialization of ADC, input mixers and output mixers
2061 */
2062static struct hda_verb alc880_volume_init_verbs[] = {
2063 /*
2064 * Unmute ADC0-2 and set the default input to mic-in
2065 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002066 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002068 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002070 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002072
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2074 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002075 * Note: PASD motherboards uses the Line In 2 as the input for front
2076 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002079 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002087 /*
2088 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 /* set vol=0 to output mixers */
2091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2094 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2095 /* set up input amps for analog loopback */
2096 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002103 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105
2106 { }
2107};
2108
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109/*
2110 * 3-stack pin configuration:
2111 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2112 */
2113static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2114 /*
2115 * preset connection lists of input pins
2116 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2117 */
2118 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2119 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2120 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2121
2122 /*
2123 * Set pin mode and muting
2124 */
2125 /* set front pin widgets 0x14 for output */
2126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2128 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2131 /* Mic2 (as headphone out) for HP output */
2132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2134 /* Line In pin widget for input */
2135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2137 /* Line2 (as front mic) pin widget for input and vref at 80% */
2138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2140 /* CD pin widget for input */
2141 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2142
2143 { }
2144};
2145
2146/*
2147 * 5-stack pin configuration:
2148 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2149 * line-in/side = 0x1a, f-mic = 0x1b
2150 */
2151static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2152 /*
2153 * preset connection lists of input pins
2154 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2155 */
2156 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2157 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2158
2159 /*
2160 * Set pin mode and muting
2161 */
2162 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2165 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2166 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002167 /* unmute pins for output (no gain on this amp) */
2168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2169 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2170 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2172
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002174 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2176 /* Mic2 (as headphone out) for HP output */
2177 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002178 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 /* Line In pin widget for input */
2180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2182 /* Line2 (as front mic) pin widget for input and vref at 80% */
2183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2185 /* CD pin widget for input */
2186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187
2188 { }
2189};
2190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002191/*
2192 * W810 pin configuration:
2193 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2194 */
2195static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 /* hphone/speaker input selector: front DAC */
2197 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2198
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2205
2206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 { }
2210};
2211
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212/*
2213 * Z71V pin configuration:
2214 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2215 */
2216static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002221
Takashi Iwai16ded522005-06-10 19:58:24 +02002222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002226
2227 { }
2228};
2229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002230/*
2231 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002232 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2233 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002234 */
2235static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2236 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2237
Takashi Iwai16ded522005-06-10 19:58:24 +02002238 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2246
Takashi Iwai16ded522005-06-10 19:58:24 +02002247 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257 { }
2258};
Takashi Iwai16ded522005-06-10 19:58:24 +02002259
Kailang Yangccc656c2006-10-17 12:32:26 +02002260/*
2261 * Uniwill pin configuration:
2262 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2263 * line = 0x1a
2264 */
2265static struct hda_verb alc880_uniwill_init_verbs[] = {
2266 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2267
2268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2282
2283 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2284 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2285 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2289 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2290 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2291 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2292
2293 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2294 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2295
2296 { }
2297};
2298
2299/*
2300* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002301* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002302 */
2303static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2304 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2305
2306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2318
2319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2323 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2324 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2325
2326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2327 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2328
2329 { }
2330};
2331
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002332static struct hda_verb alc880_beep_init_verbs[] = {
2333 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2334 { }
2335};
2336
Kailang Yangccc656c2006-10-17 12:32:26 +02002337/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002338static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002339{
2340 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002341 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002342
2343 present = snd_hda_codec_read(codec, 0x14, 0,
2344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002345 bits = present ? HDA_AMP_MUTE : 0;
2346 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2347 HDA_AMP_MUTE, bits);
2348 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2349 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002350}
2351
2352/* auto-toggle front mic */
2353static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2354{
2355 unsigned int present;
2356 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002357
2358 present = snd_hda_codec_read(codec, 0x18, 0,
2359 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002360 bits = present ? HDA_AMP_MUTE : 0;
2361 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002362}
2363
2364static void alc880_uniwill_automute(struct hda_codec *codec)
2365{
2366 alc880_uniwill_hp_automute(codec);
2367 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002368}
2369
2370static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2371 unsigned int res)
2372{
2373 /* Looks like the unsol event is incompatible with the standard
2374 * definition. 4bit tag is placed at 28 bit!
2375 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002376 switch (res >> 28) {
2377 case ALC880_HP_EVENT:
2378 alc880_uniwill_hp_automute(codec);
2379 break;
2380 case ALC880_MIC_EVENT:
2381 alc880_uniwill_mic_automute(codec);
2382 break;
2383 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002384}
2385
2386static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2387{
2388 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002389 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002390
2391 present = snd_hda_codec_read(codec, 0x14, 0,
2392 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002393 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002394 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002395}
2396
2397static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2398{
2399 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002400
Kailang Yangccc656c2006-10-17 12:32:26 +02002401 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002402 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2403 present &= HDA_AMP_VOLMASK;
2404 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2405 HDA_AMP_VOLMASK, present);
2406 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2407 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002408}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002409
Kailang Yangccc656c2006-10-17 12:32:26 +02002410static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2411 unsigned int res)
2412{
2413 /* Looks like the unsol event is incompatible with the standard
2414 * definition. 4bit tag is placed at 28 bit!
2415 */
2416 if ((res >> 28) == ALC880_HP_EVENT)
2417 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002418 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002419 alc880_uniwill_p53_dcvol_automute(codec);
2420}
2421
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002422/*
2423 * F1734 pin configuration:
2424 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2425 */
2426static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002427 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2429 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2430 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2431 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2432
2433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2437
2438 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002440 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002441 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2442 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2443 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2446 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002447
Takashi Iwai937b4162008-02-11 14:52:36 +01002448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2449 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2450
Takashi Iwai16ded522005-06-10 19:58:24 +02002451 { }
2452};
2453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454/*
2455 * ASUS pin configuration:
2456 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2457 */
2458static struct hda_verb alc880_pin_asus_init_verbs[] = {
2459 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2460 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2461 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2463
2464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472
2473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002483 { }
2484};
2485
2486/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002487#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2488#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489
Kailang Yangdf694da2005-12-05 19:42:22 +01002490/* Clevo m520g init */
2491static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2492 /* headphone output */
2493 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2494 /* line-out */
2495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 /* Line-in */
2498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 /* CD */
2501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2502 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 /* Mic1 (rear panel) */
2504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506 /* Mic2 (front panel) */
2507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2509 /* headphone */
2510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2512 /* change to EAPD mode */
2513 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2514 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2515
2516 { }
2517};
2518
2519static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002520 /* change to EAPD mode */
2521 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2522 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2523
Kailang Yangdf694da2005-12-05 19:42:22 +01002524 /* Headphone output */
2525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2526 /* Front output*/
2527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2528 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2529
2530 /* Line In pin widget for input */
2531 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2532 /* CD pin widget for input */
2533 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2534 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2536
2537 /* change to EAPD mode */
2538 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2539 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2540
2541 { }
2542};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543
2544/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002545 * LG m1 express dual
2546 *
2547 * Pin assignment:
2548 * Rear Line-In/Out (blue): 0x14
2549 * Build-in Mic-In: 0x15
2550 * Speaker-out: 0x17
2551 * HP-Out (green): 0x1b
2552 * Mic-In/Out (red): 0x19
2553 * SPDIF-Out: 0x1e
2554 */
2555
2556/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2557static hda_nid_t alc880_lg_dac_nids[3] = {
2558 0x05, 0x02, 0x03
2559};
2560
2561/* seems analog CD is not working */
2562static struct hda_input_mux alc880_lg_capture_source = {
2563 .num_items = 3,
2564 .items = {
2565 { "Mic", 0x1 },
2566 { "Line", 0x5 },
2567 { "Internal Mic", 0x6 },
2568 },
2569};
2570
2571/* 2,4,6 channel modes */
2572static struct hda_verb alc880_lg_ch2_init[] = {
2573 /* set line-in and mic-in to input */
2574 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2575 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2576 { }
2577};
2578
2579static struct hda_verb alc880_lg_ch4_init[] = {
2580 /* set line-in to out and mic-in to input */
2581 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2582 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2583 { }
2584};
2585
2586static struct hda_verb alc880_lg_ch6_init[] = {
2587 /* set line-in and mic-in to output */
2588 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2589 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2590 { }
2591};
2592
2593static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2594 { 2, alc880_lg_ch2_init },
2595 { 4, alc880_lg_ch4_init },
2596 { 6, alc880_lg_ch6_init },
2597};
2598
2599static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2601 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2603 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2612 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2613 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2614 {
2615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2616 .name = "Channel Mode",
2617 .info = alc_ch_mode_info,
2618 .get = alc_ch_mode_get,
2619 .put = alc_ch_mode_put,
2620 },
2621 { } /* end */
2622};
2623
2624static struct hda_verb alc880_lg_init_verbs[] = {
2625 /* set capture source to mic-in */
2626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2628 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2629 /* mute all amp mixer inputs */
2630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002633 /* line-in to input */
2634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636 /* built-in mic */
2637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2639 /* speaker-out */
2640 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2641 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2642 /* mic-in to input */
2643 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2646 /* HP-out */
2647 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650 /* jack sense */
2651 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2652 { }
2653};
2654
2655/* toggle speaker-output according to the hp-jack state */
2656static void alc880_lg_automute(struct hda_codec *codec)
2657{
2658 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002659 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002660
2661 present = snd_hda_codec_read(codec, 0x1b, 0,
2662 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002663 bits = present ? HDA_AMP_MUTE : 0;
2664 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2665 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002666}
2667
2668static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2669{
2670 /* Looks like the unsol event is incompatible with the standard
2671 * definition. 4bit tag is placed at 28 bit!
2672 */
2673 if ((res >> 28) == 0x01)
2674 alc880_lg_automute(codec);
2675}
2676
2677/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002678 * LG LW20
2679 *
2680 * Pin assignment:
2681 * Speaker-out: 0x14
2682 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002683 * Built-in Mic-In: 0x19
2684 * Line-In: 0x1b
2685 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002686 * SPDIF-Out: 0x1e
2687 */
2688
Takashi Iwaid6815182006-03-23 16:06:23 +01002689static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002690 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002691 .items = {
2692 { "Mic", 0x0 },
2693 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002694 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002695 },
2696};
2697
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002698#define alc880_lg_lw_modes alc880_threestack_modes
2699
Takashi Iwaid6815182006-03-23 16:06:23 +01002700static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2702 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2703 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2704 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2705 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2706 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2707 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2708 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2709 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2710 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2714 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002715 {
2716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2717 .name = "Channel Mode",
2718 .info = alc_ch_mode_info,
2719 .get = alc_ch_mode_get,
2720 .put = alc_ch_mode_put,
2721 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002722 { } /* end */
2723};
2724
2725static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002726 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2727 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2728 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2729
Takashi Iwaid6815182006-03-23 16:06:23 +01002730 /* set capture source to mic-in */
2731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002735 /* speaker-out */
2736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2738 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2740 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741 /* mic-in to input */
2742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2744 /* built-in mic */
2745 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 /* jack sense */
2748 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2749 { }
2750};
2751
2752/* toggle speaker-output according to the hp-jack state */
2753static void alc880_lg_lw_automute(struct hda_codec *codec)
2754{
2755 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002756 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002757
2758 present = snd_hda_codec_read(codec, 0x1b, 0,
2759 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002760 bits = present ? HDA_AMP_MUTE : 0;
2761 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2762 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002763}
2764
2765static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2766{
2767 /* Looks like the unsol event is incompatible with the standard
2768 * definition. 4bit tag is placed at 28 bit!
2769 */
2770 if ((res >> 28) == 0x01)
2771 alc880_lg_lw_automute(codec);
2772}
2773
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002774static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2775 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2776 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2779 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2780 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2781 { } /* end */
2782};
2783
2784static struct hda_input_mux alc880_medion_rim_capture_source = {
2785 .num_items = 2,
2786 .items = {
2787 { "Mic", 0x0 },
2788 { "Internal Mic", 0x1 },
2789 },
2790};
2791
2792static struct hda_verb alc880_medion_rim_init_verbs[] = {
2793 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2794
2795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2797
2798 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2799 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2801 /* Mic2 (as headphone out) for HP output */
2802 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2803 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2804 /* Internal Speaker */
2805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2807
2808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2809 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2810
2811 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2812 { }
2813};
2814
2815/* toggle speaker-output according to the hp-jack state */
2816static void alc880_medion_rim_automute(struct hda_codec *codec)
2817{
2818 unsigned int present;
2819 unsigned char bits;
2820
2821 present = snd_hda_codec_read(codec, 0x14, 0,
2822 AC_VERB_GET_PIN_SENSE, 0)
2823 & AC_PINSENSE_PRESENCE;
2824 bits = present ? HDA_AMP_MUTE : 0;
2825 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2826 HDA_AMP_MUTE, bits);
2827 if (present)
2828 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2829 else
2830 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2831}
2832
2833static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2834 unsigned int res)
2835{
2836 /* Looks like the unsol event is incompatible with the standard
2837 * definition. 4bit tag is placed at 28 bit!
2838 */
2839 if ((res >> 28) == ALC880_HP_EVENT)
2840 alc880_medion_rim_automute(codec);
2841}
2842
Takashi Iwaicb53c622007-08-10 17:21:45 +02002843#ifdef CONFIG_SND_HDA_POWER_SAVE
2844static struct hda_amp_list alc880_loopbacks[] = {
2845 { 0x0b, HDA_INPUT, 0 },
2846 { 0x0b, HDA_INPUT, 1 },
2847 { 0x0b, HDA_INPUT, 2 },
2848 { 0x0b, HDA_INPUT, 3 },
2849 { 0x0b, HDA_INPUT, 4 },
2850 { } /* end */
2851};
2852
2853static struct hda_amp_list alc880_lg_loopbacks[] = {
2854 { 0x0b, HDA_INPUT, 1 },
2855 { 0x0b, HDA_INPUT, 6 },
2856 { 0x0b, HDA_INPUT, 7 },
2857 { } /* end */
2858};
2859#endif
2860
Takashi Iwaid6815182006-03-23 16:06:23 +01002861/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002862 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002864
Linus Torvalds1da177e2005-04-16 15:20:36 -07002865static int alc_init(struct hda_codec *codec)
2866{
2867 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 unsigned int i;
2869
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002870 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002871 if (codec->vendor_id == 0x10ec0888)
2872 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002873
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002874 for (i = 0; i < spec->num_init_verbs; i++)
2875 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002876
2877 if (spec->init_hook)
2878 spec->init_hook(codec);
2879
Linus Torvalds1da177e2005-04-16 15:20:36 -07002880 return 0;
2881}
2882
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002883static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2884{
2885 struct alc_spec *spec = codec->spec;
2886
2887 if (spec->unsol_event)
2888 spec->unsol_event(codec, res);
2889}
2890
Takashi Iwaicb53c622007-08-10 17:21:45 +02002891#ifdef CONFIG_SND_HDA_POWER_SAVE
2892static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2893{
2894 struct alc_spec *spec = codec->spec;
2895 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2896}
2897#endif
2898
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899/*
2900 * Analog playback callbacks
2901 */
2902static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2903 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002904 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905{
2906 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002907 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2908 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909}
2910
2911static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2912 struct hda_codec *codec,
2913 unsigned int stream_tag,
2914 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002915 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916{
2917 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002918 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2919 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920}
2921
2922static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2923 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002924 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925{
2926 struct alc_spec *spec = codec->spec;
2927 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2928}
2929
2930/*
2931 * Digital out
2932 */
2933static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2934 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002935 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936{
2937 struct alc_spec *spec = codec->spec;
2938 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2939}
2940
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002941static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2942 struct hda_codec *codec,
2943 unsigned int stream_tag,
2944 unsigned int format,
2945 struct snd_pcm_substream *substream)
2946{
2947 struct alc_spec *spec = codec->spec;
2948 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2949 stream_tag, format, substream);
2950}
2951
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2953 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002954 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955{
2956 struct alc_spec *spec = codec->spec;
2957 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2958}
2959
2960/*
2961 * Analog capture
2962 */
Takashi Iwai63300792008-01-24 15:31:36 +01002963static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964 struct hda_codec *codec,
2965 unsigned int stream_tag,
2966 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002967 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968{
2969 struct alc_spec *spec = codec->spec;
2970
Takashi Iwai63300792008-01-24 15:31:36 +01002971 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 stream_tag, 0, format);
2973 return 0;
2974}
2975
Takashi Iwai63300792008-01-24 15:31:36 +01002976static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002977 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002978 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979{
2980 struct alc_spec *spec = codec->spec;
2981
Takashi Iwai888afa12008-03-18 09:57:50 +01002982 snd_hda_codec_cleanup_stream(codec,
2983 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002984 return 0;
2985}
2986
2987
2988/*
2989 */
2990static struct hda_pcm_stream alc880_pcm_analog_playback = {
2991 .substreams = 1,
2992 .channels_min = 2,
2993 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995 .ops = {
2996 .open = alc880_playback_pcm_open,
2997 .prepare = alc880_playback_pcm_prepare,
2998 .cleanup = alc880_playback_pcm_cleanup
2999 },
3000};
3001
3002static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003003 .substreams = 1,
3004 .channels_min = 2,
3005 .channels_max = 2,
3006 /* NID is set in alc_build_pcms */
3007};
3008
3009static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3010 .substreams = 1,
3011 .channels_min = 2,
3012 .channels_max = 2,
3013 /* NID is set in alc_build_pcms */
3014};
3015
3016static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3017 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018 .channels_min = 2,
3019 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003020 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003021 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003022 .prepare = alc880_alt_capture_pcm_prepare,
3023 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024 },
3025};
3026
3027static struct hda_pcm_stream alc880_pcm_digital_playback = {
3028 .substreams = 1,
3029 .channels_min = 2,
3030 .channels_max = 2,
3031 /* NID is set in alc_build_pcms */
3032 .ops = {
3033 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003034 .close = alc880_dig_playback_pcm_close,
3035 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036 },
3037};
3038
3039static struct hda_pcm_stream alc880_pcm_digital_capture = {
3040 .substreams = 1,
3041 .channels_min = 2,
3042 .channels_max = 2,
3043 /* NID is set in alc_build_pcms */
3044};
3045
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003046/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003047static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003048 .substreams = 0,
3049 .channels_min = 0,
3050 .channels_max = 0,
3051};
3052
Linus Torvalds1da177e2005-04-16 15:20:36 -07003053static int alc_build_pcms(struct hda_codec *codec)
3054{
3055 struct alc_spec *spec = codec->spec;
3056 struct hda_pcm *info = spec->pcm_rec;
3057 int i;
3058
3059 codec->num_pcms = 1;
3060 codec->pcm_info = info;
3061
3062 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003063 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003064 if (snd_BUG_ON(!spec->multiout.dac_nids))
3065 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003066 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3067 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3068 }
3069 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003070 if (snd_BUG_ON(!spec->adc_nids))
3071 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003072 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3073 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3074 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075
Takashi Iwai4a471b72005-12-07 13:56:29 +01003076 if (spec->channel_mode) {
3077 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3078 for (i = 0; i < spec->num_channel_mode; i++) {
3079 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3080 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3081 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082 }
3083 }
3084
Takashi Iwaie08a0072006-09-07 17:52:14 +02003085 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003087 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003088 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003089 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01003090 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003091 if (spec->multiout.dig_out_nid &&
3092 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3094 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3095 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003096 if (spec->dig_in_nid &&
3097 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003098 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3099 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3100 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003101 /* FIXME: do we need this for all Realtek codec models? */
3102 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103 }
3104
Takashi Iwaie08a0072006-09-07 17:52:14 +02003105 /* If the use of more than one ADC is requested for the current
3106 * model, configure a second analog capture-only PCM.
3107 */
3108 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003109 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3110 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003111 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003112 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003113 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003114 if (spec->alt_dac_nid) {
3115 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3116 *spec->stream_analog_alt_playback;
3117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3118 spec->alt_dac_nid;
3119 } else {
3120 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3121 alc_pcm_null_stream;
3122 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3123 }
3124 if (spec->num_adc_nids > 1) {
3125 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3126 *spec->stream_analog_alt_capture;
3127 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3128 spec->adc_nids[1];
3129 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3130 spec->num_adc_nids - 1;
3131 } else {
3132 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3133 alc_pcm_null_stream;
3134 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003135 }
3136 }
3137
Linus Torvalds1da177e2005-04-16 15:20:36 -07003138 return 0;
3139}
3140
Takashi Iwai603c4012008-07-30 15:01:44 +02003141static void alc_free_kctls(struct hda_codec *codec)
3142{
3143 struct alc_spec *spec = codec->spec;
3144
3145 if (spec->kctls.list) {
3146 struct snd_kcontrol_new *kctl = spec->kctls.list;
3147 int i;
3148 for (i = 0; i < spec->kctls.used; i++)
3149 kfree(kctl[i].name);
3150 }
3151 snd_array_free(&spec->kctls);
3152}
3153
Linus Torvalds1da177e2005-04-16 15:20:36 -07003154static void alc_free(struct hda_codec *codec)
3155{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003157
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003158 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 return;
3160
Takashi Iwai603c4012008-07-30 15:01:44 +02003161 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003162 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02003163 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164}
3165
Takashi Iwaie044c392008-10-27 16:56:24 +01003166#ifdef SND_HDA_NEEDS_RESUME
3167static void store_pin_configs(struct hda_codec *codec)
3168{
3169 struct alc_spec *spec = codec->spec;
3170 hda_nid_t nid, end_nid;
3171
3172 end_nid = codec->start_nid + codec->num_nodes;
3173 for (nid = codec->start_nid; nid < end_nid; nid++) {
3174 unsigned int wid_caps = get_wcaps(codec, nid);
3175 unsigned int wid_type =
3176 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3177 if (wid_type != AC_WID_PIN)
3178 continue;
3179 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3180 break;
3181 spec->pin_nids[spec->num_pins] = nid;
3182 spec->pin_cfgs[spec->num_pins] =
3183 snd_hda_codec_read(codec, nid, 0,
3184 AC_VERB_GET_CONFIG_DEFAULT, 0);
3185 spec->num_pins++;
3186 }
3187}
3188
3189static void resume_pin_configs(struct hda_codec *codec)
3190{
3191 struct alc_spec *spec = codec->spec;
3192 int i;
3193
3194 for (i = 0; i < spec->num_pins; i++) {
3195 hda_nid_t pin_nid = spec->pin_nids[i];
3196 unsigned int pin_config = spec->pin_cfgs[i];
3197 snd_hda_codec_write(codec, pin_nid, 0,
3198 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3199 pin_config & 0x000000ff);
3200 snd_hda_codec_write(codec, pin_nid, 0,
3201 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3202 (pin_config & 0x0000ff00) >> 8);
3203 snd_hda_codec_write(codec, pin_nid, 0,
3204 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3205 (pin_config & 0x00ff0000) >> 16);
3206 snd_hda_codec_write(codec, pin_nid, 0,
3207 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3208 pin_config >> 24);
3209 }
3210}
3211
3212static int alc_resume(struct hda_codec *codec)
3213{
3214 resume_pin_configs(codec);
3215 codec->patch_ops.init(codec);
3216 snd_hda_codec_resume_amp(codec);
3217 snd_hda_codec_resume_cache(codec);
3218 return 0;
3219}
3220#else
3221#define store_pin_configs(codec)
3222#endif
3223
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224/*
3225 */
3226static struct hda_codec_ops alc_patch_ops = {
3227 .build_controls = alc_build_controls,
3228 .build_pcms = alc_build_pcms,
3229 .init = alc_init,
3230 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003231 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003232#ifdef SND_HDA_NEEDS_RESUME
3233 .resume = alc_resume,
3234#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003235#ifdef CONFIG_SND_HDA_POWER_SAVE
3236 .check_power_status = alc_check_power_status,
3237#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003238};
3239
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003240
3241/*
3242 * Test configuration for debugging
3243 *
3244 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3245 * enum controls.
3246 */
3247#ifdef CONFIG_SND_DEBUG
3248static hda_nid_t alc880_test_dac_nids[4] = {
3249 0x02, 0x03, 0x04, 0x05
3250};
3251
3252static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003253 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003254 .items = {
3255 { "In-1", 0x0 },
3256 { "In-2", 0x1 },
3257 { "In-3", 0x2 },
3258 { "In-4", 0x3 },
3259 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003260 { "Front", 0x5 },
3261 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003262 },
3263};
3264
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003265static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003266 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003267 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003268 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003269 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003270};
3271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003272static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3273 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003274{
3275 static char *texts[] = {
3276 "N/A", "Line Out", "HP Out",
3277 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3278 };
3279 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3280 uinfo->count = 1;
3281 uinfo->value.enumerated.items = 8;
3282 if (uinfo->value.enumerated.item >= 8)
3283 uinfo->value.enumerated.item = 7;
3284 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3285 return 0;
3286}
3287
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003288static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3289 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003290{
3291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3292 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3293 unsigned int pin_ctl, item = 0;
3294
3295 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3296 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3297 if (pin_ctl & AC_PINCTL_OUT_EN) {
3298 if (pin_ctl & AC_PINCTL_HP_EN)
3299 item = 2;
3300 else
3301 item = 1;
3302 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3303 switch (pin_ctl & AC_PINCTL_VREFEN) {
3304 case AC_PINCTL_VREF_HIZ: item = 3; break;
3305 case AC_PINCTL_VREF_50: item = 4; break;
3306 case AC_PINCTL_VREF_GRD: item = 5; break;
3307 case AC_PINCTL_VREF_80: item = 6; break;
3308 case AC_PINCTL_VREF_100: item = 7; break;
3309 }
3310 }
3311 ucontrol->value.enumerated.item[0] = item;
3312 return 0;
3313}
3314
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003315static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3316 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003317{
3318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3319 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3320 static unsigned int ctls[] = {
3321 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3322 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3323 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3324 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3325 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3327 };
3328 unsigned int old_ctl, new_ctl;
3329
3330 old_ctl = snd_hda_codec_read(codec, nid, 0,
3331 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3332 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3333 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003334 int val;
3335 snd_hda_codec_write_cache(codec, nid, 0,
3336 AC_VERB_SET_PIN_WIDGET_CONTROL,
3337 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003338 val = ucontrol->value.enumerated.item[0] >= 3 ?
3339 HDA_AMP_MUTE : 0;
3340 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3341 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342 return 1;
3343 }
3344 return 0;
3345}
3346
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003347static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3348 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003349{
3350 static char *texts[] = {
3351 "Front", "Surround", "CLFE", "Side"
3352 };
3353 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3354 uinfo->count = 1;
3355 uinfo->value.enumerated.items = 4;
3356 if (uinfo->value.enumerated.item >= 4)
3357 uinfo->value.enumerated.item = 3;
3358 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3359 return 0;
3360}
3361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003362static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3363 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003364{
3365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3366 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3367 unsigned int sel;
3368
3369 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3370 ucontrol->value.enumerated.item[0] = sel & 3;
3371 return 0;
3372}
3373
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003374static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3375 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003376{
3377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3379 unsigned int sel;
3380
3381 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3382 if (ucontrol->value.enumerated.item[0] != sel) {
3383 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003384 snd_hda_codec_write_cache(codec, nid, 0,
3385 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003386 return 1;
3387 }
3388 return 0;
3389}
3390
3391#define PIN_CTL_TEST(xname,nid) { \
3392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3393 .name = xname, \
3394 .info = alc_test_pin_ctl_info, \
3395 .get = alc_test_pin_ctl_get, \
3396 .put = alc_test_pin_ctl_put, \
3397 .private_value = nid \
3398 }
3399
3400#define PIN_SRC_TEST(xname,nid) { \
3401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3402 .name = xname, \
3403 .info = alc_test_pin_src_info, \
3404 .get = alc_test_pin_src_get, \
3405 .put = alc_test_pin_src_put, \
3406 .private_value = nid \
3407 }
3408
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003409static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003410 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3412 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3413 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003414 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3416 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3417 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003418 PIN_CTL_TEST("Front Pin Mode", 0x14),
3419 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3420 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3421 PIN_CTL_TEST("Side Pin Mode", 0x17),
3422 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3423 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3424 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3425 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3426 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3427 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3428 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3429 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3430 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3431 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3432 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3433 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3434 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3435 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3436 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3437 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003440 {
3441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3442 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003443 .info = alc_ch_mode_info,
3444 .get = alc_ch_mode_get,
3445 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003446 },
3447 { } /* end */
3448};
3449
3450static struct hda_verb alc880_test_init_verbs[] = {
3451 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003460 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003465 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3469 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003470 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3473 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003475 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003481 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003486 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 /* Analog input/passthru */
3494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003499 { }
3500};
3501#endif
3502
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503/*
3504 */
3505
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003506static const char *alc880_models[ALC880_MODEL_LAST] = {
3507 [ALC880_3ST] = "3stack",
3508 [ALC880_TCL_S700] = "tcl",
3509 [ALC880_3ST_DIG] = "3stack-digout",
3510 [ALC880_CLEVO] = "clevo",
3511 [ALC880_5ST] = "5stack",
3512 [ALC880_5ST_DIG] = "5stack-digout",
3513 [ALC880_W810] = "w810",
3514 [ALC880_Z71V] = "z71v",
3515 [ALC880_6ST] = "6stack",
3516 [ALC880_6ST_DIG] = "6stack-digout",
3517 [ALC880_ASUS] = "asus",
3518 [ALC880_ASUS_W1V] = "asus-w1v",
3519 [ALC880_ASUS_DIG] = "asus-dig",
3520 [ALC880_ASUS_DIG2] = "asus-dig2",
3521 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003522 [ALC880_UNIWILL_P53] = "uniwill-p53",
3523 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003524 [ALC880_F1734] = "F1734",
3525 [ALC880_LG] = "lg",
3526 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003527 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003528#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003529 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003530#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003531 [ALC880_AUTO] = "auto",
3532};
3533
3534static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003535 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003536 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3537 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3538 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3539 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3540 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3541 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3542 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3543 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003544 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3545 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003546 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3547 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3548 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3549 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3550 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3551 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3552 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3553 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3554 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3555 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003556 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003557 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3558 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3559 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003560 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003561 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003562 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3563 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003564 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3565 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003566 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3567 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3568 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3569 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003570 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3571 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003572 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003573 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003574 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003575 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003576 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3577 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003578 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003579 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003580 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003581 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003583 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003584 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003585 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003586 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003587 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3588 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003589 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003590 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3591 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3592 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3593 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003594 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3595 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003596 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003597 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003598 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3599 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003600 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3601 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3602 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003603 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3604 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3605 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003606 {}
3607};
3608
Takashi Iwai16ded522005-06-10 19:58:24 +02003609/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003610 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003611 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003612static struct alc_config_preset alc880_presets[] = {
3613 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003614 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003615 .init_verbs = { alc880_volume_init_verbs,
3616 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003617 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003618 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003619 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3620 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003621 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003622 .input_mux = &alc880_capture_source,
3623 },
3624 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003626 .init_verbs = { alc880_volume_init_verbs,
3627 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003628 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003629 .dac_nids = alc880_dac_nids,
3630 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003631 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3632 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003633 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003634 .input_mux = &alc880_capture_source,
3635 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003636 [ALC880_TCL_S700] = {
3637 .mixers = { alc880_tcl_s700_mixer },
3638 .init_verbs = { alc880_volume_init_verbs,
3639 alc880_pin_tcl_S700_init_verbs,
3640 alc880_gpio2_init_verbs },
3641 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3642 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003643 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3644 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003645 .hp_nid = 0x03,
3646 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3647 .channel_mode = alc880_2_jack_modes,
3648 .input_mux = &alc880_capture_source,
3649 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003650 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003651 .mixers = { alc880_three_stack_mixer,
3652 alc880_five_stack_mixer},
3653 .init_verbs = { alc880_volume_init_verbs,
3654 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003655 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3656 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003657 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3658 .channel_mode = alc880_fivestack_modes,
3659 .input_mux = &alc880_capture_source,
3660 },
3661 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003662 .mixers = { alc880_three_stack_mixer,
3663 alc880_five_stack_mixer },
3664 .init_verbs = { alc880_volume_init_verbs,
3665 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003666 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3667 .dac_nids = alc880_dac_nids,
3668 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003669 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3670 .channel_mode = alc880_fivestack_modes,
3671 .input_mux = &alc880_capture_source,
3672 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003673 [ALC880_6ST] = {
3674 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003675 .init_verbs = { alc880_volume_init_verbs,
3676 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003677 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3678 .dac_nids = alc880_6st_dac_nids,
3679 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3680 .channel_mode = alc880_sixstack_modes,
3681 .input_mux = &alc880_6stack_capture_source,
3682 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003683 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003684 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003685 .init_verbs = { alc880_volume_init_verbs,
3686 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3688 .dac_nids = alc880_6st_dac_nids,
3689 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3691 .channel_mode = alc880_sixstack_modes,
3692 .input_mux = &alc880_6stack_capture_source,
3693 },
3694 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003695 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003696 .init_verbs = { alc880_volume_init_verbs,
3697 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003698 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3700 .dac_nids = alc880_w810_dac_nids,
3701 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3703 .channel_mode = alc880_w810_modes,
3704 .input_mux = &alc880_capture_source,
3705 },
3706 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003708 .init_verbs = { alc880_volume_init_verbs,
3709 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3711 .dac_nids = alc880_z71v_dac_nids,
3712 .dig_out_nid = ALC880_DIGOUT_NID,
3713 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3715 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003716 .input_mux = &alc880_capture_source,
3717 },
3718 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003719 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003720 .init_verbs = { alc880_volume_init_verbs,
3721 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003722 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3723 .dac_nids = alc880_f1734_dac_nids,
3724 .hp_nid = 0x02,
3725 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3726 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003727 .input_mux = &alc880_f1734_capture_source,
3728 .unsol_event = alc880_uniwill_p53_unsol_event,
3729 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003730 },
3731 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003733 .init_verbs = { alc880_volume_init_verbs,
3734 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003735 alc880_gpio1_init_verbs },
3736 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3737 .dac_nids = alc880_asus_dac_nids,
3738 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3739 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003740 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003741 .input_mux = &alc880_capture_source,
3742 },
3743 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003745 .init_verbs = { alc880_volume_init_verbs,
3746 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003747 alc880_gpio1_init_verbs },
3748 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3749 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003750 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3752 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003753 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003754 .input_mux = &alc880_capture_source,
3755 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003756 [ALC880_ASUS_DIG2] = {
3757 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003758 .init_verbs = { alc880_volume_init_verbs,
3759 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003760 alc880_gpio2_init_verbs }, /* use GPIO2 */
3761 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3762 .dac_nids = alc880_asus_dac_nids,
3763 .dig_out_nid = ALC880_DIGOUT_NID,
3764 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3765 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003766 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003767 .input_mux = &alc880_capture_source,
3768 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003769 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003770 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003771 .init_verbs = { alc880_volume_init_verbs,
3772 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 alc880_gpio1_init_verbs },
3774 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3775 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003776 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3778 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003779 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003780 .input_mux = &alc880_capture_source,
3781 },
3782 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003783 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003784 .init_verbs = { alc880_volume_init_verbs,
3785 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003786 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3787 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003788 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003789 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3790 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003791 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003792 .input_mux = &alc880_capture_source,
3793 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003794 [ALC880_UNIWILL] = {
3795 .mixers = { alc880_uniwill_mixer },
3796 .init_verbs = { alc880_volume_init_verbs,
3797 alc880_uniwill_init_verbs },
3798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3799 .dac_nids = alc880_asus_dac_nids,
3800 .dig_out_nid = ALC880_DIGOUT_NID,
3801 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3802 .channel_mode = alc880_threestack_modes,
3803 .need_dac_fix = 1,
3804 .input_mux = &alc880_capture_source,
3805 .unsol_event = alc880_uniwill_unsol_event,
3806 .init_hook = alc880_uniwill_automute,
3807 },
3808 [ALC880_UNIWILL_P53] = {
3809 .mixers = { alc880_uniwill_p53_mixer },
3810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_uniwill_p53_init_verbs },
3812 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3813 .dac_nids = alc880_asus_dac_nids,
3814 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003815 .channel_mode = alc880_threestack_modes,
3816 .input_mux = &alc880_capture_source,
3817 .unsol_event = alc880_uniwill_p53_unsol_event,
3818 .init_hook = alc880_uniwill_p53_hp_automute,
3819 },
3820 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003821 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003822 alc880_pcbeep_mixer, },
3823 .init_verbs = { alc880_volume_init_verbs,
3824 alc880_uniwill_p53_init_verbs,
3825 alc880_beep_init_verbs },
3826 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3827 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003828 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003829 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3830 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003831 .input_mux = &alc880_capture_source,
3832 .unsol_event = alc880_uniwill_p53_unsol_event,
3833 .init_hook = alc880_uniwill_p53_hp_automute,
3834 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003835 [ALC880_CLEVO] = {
3836 .mixers = { alc880_three_stack_mixer },
3837 .init_verbs = { alc880_volume_init_verbs,
3838 alc880_pin_clevo_init_verbs },
3839 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3840 .dac_nids = alc880_dac_nids,
3841 .hp_nid = 0x03,
3842 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3843 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003844 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003845 .input_mux = &alc880_capture_source,
3846 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003847 [ALC880_LG] = {
3848 .mixers = { alc880_lg_mixer },
3849 .init_verbs = { alc880_volume_init_verbs,
3850 alc880_lg_init_verbs },
3851 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3852 .dac_nids = alc880_lg_dac_nids,
3853 .dig_out_nid = ALC880_DIGOUT_NID,
3854 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3855 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003856 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003857 .input_mux = &alc880_lg_capture_source,
3858 .unsol_event = alc880_lg_unsol_event,
3859 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003860#ifdef CONFIG_SND_HDA_POWER_SAVE
3861 .loopbacks = alc880_lg_loopbacks,
3862#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003863 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003864 [ALC880_LG_LW] = {
3865 .mixers = { alc880_lg_lw_mixer },
3866 .init_verbs = { alc880_volume_init_verbs,
3867 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003868 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003869 .dac_nids = alc880_dac_nids,
3870 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003871 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3872 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003873 .input_mux = &alc880_lg_lw_capture_source,
3874 .unsol_event = alc880_lg_lw_unsol_event,
3875 .init_hook = alc880_lg_lw_automute,
3876 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003877 [ALC880_MEDION_RIM] = {
3878 .mixers = { alc880_medion_rim_mixer },
3879 .init_verbs = { alc880_volume_init_verbs,
3880 alc880_medion_rim_init_verbs,
3881 alc_gpio2_init_verbs },
3882 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3883 .dac_nids = alc880_dac_nids,
3884 .dig_out_nid = ALC880_DIGOUT_NID,
3885 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3886 .channel_mode = alc880_2_jack_modes,
3887 .input_mux = &alc880_medion_rim_capture_source,
3888 .unsol_event = alc880_medion_rim_unsol_event,
3889 .init_hook = alc880_medion_rim_automute,
3890 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003891#ifdef CONFIG_SND_DEBUG
3892 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003893 .mixers = { alc880_test_mixer },
3894 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003895 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3896 .dac_nids = alc880_test_dac_nids,
3897 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003898 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3899 .channel_mode = alc880_test_modes,
3900 .input_mux = &alc880_test_capture_source,
3901 },
3902#endif
3903};
3904
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003905/*
3906 * Automatic parse of I/O pins from the BIOS configuration
3907 */
3908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003909enum {
3910 ALC_CTL_WIDGET_VOL,
3911 ALC_CTL_WIDGET_MUTE,
3912 ALC_CTL_BIND_MUTE,
3913};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003914static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003915 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3916 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003917 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918};
3919
3920/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003921static int add_control(struct alc_spec *spec, int type, const char *name,
3922 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003923{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003924 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925
Takashi Iwai603c4012008-07-30 15:01:44 +02003926 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3927 knew = snd_array_new(&spec->kctls);
3928 if (!knew)
3929 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003930 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003931 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003932 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003933 return -ENOMEM;
3934 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 return 0;
3936}
3937
3938#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3939#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3940#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3941#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3942#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3943#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3944#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3945#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3946#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3947#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3948#define ALC880_PIN_CD_NID 0x1c
3949
3950/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003951static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3952 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003953{
3954 hda_nid_t nid;
3955 int assigned[4];
3956 int i, j;
3957
3958 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003959 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003960
3961 /* check the pins hardwired to audio widget */
3962 for (i = 0; i < cfg->line_outs; i++) {
3963 nid = cfg->line_out_pins[i];
3964 if (alc880_is_fixed_pin(nid)) {
3965 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003966 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003967 assigned[idx] = 1;
3968 }
3969 }
3970 /* left pins can be connect to any audio widget */
3971 for (i = 0; i < cfg->line_outs; i++) {
3972 nid = cfg->line_out_pins[i];
3973 if (alc880_is_fixed_pin(nid))
3974 continue;
3975 /* search for an empty channel */
3976 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003977 if (!assigned[j]) {
3978 spec->multiout.dac_nids[i] =
3979 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980 assigned[j] = 1;
3981 break;
3982 }
3983 }
3984 }
3985 spec->multiout.num_dacs = cfg->line_outs;
3986 return 0;
3987}
3988
3989/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003990static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3991 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003992{
3993 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003994 static const char *chname[4] = {
3995 "Front", "Surround", NULL /*CLFE*/, "Side"
3996 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003997 hda_nid_t nid;
3998 int i, err;
3999
4000 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004001 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 continue;
4003 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4004 if (i == 2) {
4005 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004006 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4007 "Center Playback Volume",
4008 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4009 HDA_OUTPUT));
4010 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004012 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4013 "LFE Playback Volume",
4014 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4015 HDA_OUTPUT));
4016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004018 err = add_control(spec, ALC_CTL_BIND_MUTE,
4019 "Center Playback Switch",
4020 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4021 HDA_INPUT));
4022 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004024 err = add_control(spec, ALC_CTL_BIND_MUTE,
4025 "LFE Playback Switch",
4026 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4027 HDA_INPUT));
4028 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029 return err;
4030 } else {
4031 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004032 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4033 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4034 HDA_OUTPUT));
4035 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004036 return err;
4037 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004038 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4039 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4040 HDA_INPUT));
4041 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004042 return err;
4043 }
4044 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004045 return 0;
4046}
4047
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004048/* add playback controls for speaker and HP outputs */
4049static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4050 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004051{
4052 hda_nid_t nid;
4053 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004054 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004056 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057 return 0;
4058
4059 if (alc880_is_fixed_pin(pin)) {
4060 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004061 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004064 else
4065 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004066 /* control HP volume/switch on the output mixer amp */
4067 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004068 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004069 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4070 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4071 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004072 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004073 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4075 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4076 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 return err;
4078 } else if (alc880_is_multi_pin(pin)) {
4079 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004081 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004082 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4083 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4084 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 return err;
4086 }
4087 return 0;
4088}
4089
4090/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004091static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4092 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004093 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004094{
4095 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004096 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097
4098 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004099 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4100 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4101 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 return err;
4103 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004104 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4105 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4106 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 return err;
4108 return 0;
4109}
4110
4111/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004112static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4113 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01004116 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117
4118 for (i = 0; i < AUTO_PIN_LAST; i++) {
4119 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004120 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004121 err = new_analog_input(spec, cfg->input_pins[i],
4122 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004123 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004124 if (err < 0)
4125 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 imux->items[imux->num_items].label =
4127 auto_pin_cfg_labels[i];
4128 imux->items[imux->num_items].index =
4129 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130 imux->num_items++;
4131 }
4132 }
4133 return 0;
4134}
4135
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004136static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4137 unsigned int pin_type)
4138{
4139 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4140 pin_type);
4141 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004142 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4143 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004144}
4145
Kailang Yangdf694da2005-12-05 19:42:22 +01004146static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4147 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 int dac_idx)
4149{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004150 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151 /* need the manual connection? */
4152 if (alc880_is_multi_pin(nid)) {
4153 struct alc_spec *spec = codec->spec;
4154 int idx = alc880_multi_pin_idx(nid);
4155 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4156 AC_VERB_SET_CONNECT_SEL,
4157 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4158 }
4159}
4160
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004161static int get_pin_type(int line_out_type)
4162{
4163 if (line_out_type == AUTO_PIN_HP_OUT)
4164 return PIN_HP;
4165 else
4166 return PIN_OUT;
4167}
4168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169static void alc880_auto_init_multi_out(struct hda_codec *codec)
4170{
4171 struct alc_spec *spec = codec->spec;
4172 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004173
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004174 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 for (i = 0; i < spec->autocfg.line_outs; i++) {
4176 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004177 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4178 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 }
4180}
4181
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004182static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183{
4184 struct alc_spec *spec = codec->spec;
4185 hda_nid_t pin;
4186
Takashi Iwai82bc9552006-03-21 11:24:42 +01004187 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004188 if (pin) /* connect to front */
4189 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004190 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004191 if (pin) /* connect to front */
4192 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4193}
4194
4195static void alc880_auto_init_analog_input(struct hda_codec *codec)
4196{
4197 struct alc_spec *spec = codec->spec;
4198 int i;
4199
4200 for (i = 0; i < AUTO_PIN_LAST; i++) {
4201 hda_nid_t nid = spec->autocfg.input_pins[i];
4202 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004203 snd_hda_codec_write(codec, nid, 0,
4204 AC_VERB_SET_PIN_WIDGET_CONTROL,
4205 i <= AUTO_PIN_FRONT_MIC ?
4206 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 snd_hda_codec_write(codec, nid, 0,
4209 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210 AMP_OUT_MUTE);
4211 }
4212 }
4213}
4214
4215/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004216/* return 1 if successful, 0 if the proper config is not found,
4217 * or a negative error code
4218 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004219static int alc880_parse_auto_config(struct hda_codec *codec)
4220{
4221 struct alc_spec *spec = codec->spec;
4222 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004223 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004224
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004225 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4226 alc880_ignore);
4227 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004229 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004232 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4233 if (err < 0)
4234 return err;
4235 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4236 if (err < 0)
4237 return err;
4238 err = alc880_auto_create_extra_out(spec,
4239 spec->autocfg.speaker_pins[0],
4240 "Speaker");
4241 if (err < 0)
4242 return err;
4243 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4244 "Headphone");
4245 if (err < 0)
4246 return err;
4247 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4248 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249 return err;
4250
4251 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4252
4253 if (spec->autocfg.dig_out_pin)
4254 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4255 if (spec->autocfg.dig_in_pin)
4256 spec->dig_in_nid = ALC880_DIGIN_NID;
4257
Takashi Iwai603c4012008-07-30 15:01:44 +02004258 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004259 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260
Takashi Iwaid88897e2008-10-31 15:01:37 +01004261 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004263 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264 spec->input_mux = &spec->private_imux;
4265
Takashi Iwaie044c392008-10-27 16:56:24 +01004266 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 return 1;
4268}
4269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004270/* additional initialization for auto-configuration model */
4271static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004272{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004273 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004275 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004277 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004278 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279}
4280
4281/*
4282 * OK, here we have finally the patch for ALC880
4283 */
4284
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004285static void set_capture_mixer(struct alc_spec *spec)
4286{
4287 static struct snd_kcontrol_new *caps[3] = {
4288 alc_capture_mixer1,
4289 alc_capture_mixer2,
4290 alc_capture_mixer3,
4291 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004292 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004293 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4294}
4295
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296static int patch_alc880(struct hda_codec *codec)
4297{
4298 struct alc_spec *spec;
4299 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004300 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004302 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303 if (spec == NULL)
4304 return -ENOMEM;
4305
4306 codec->spec = spec;
4307
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004308 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4309 alc880_models,
4310 alc880_cfg_tbl);
4311 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004312 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4313 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004315 }
4316
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317 if (board_config == ALC880_AUTO) {
4318 /* automatic parse from the BIOS config */
4319 err = alc880_parse_auto_config(codec);
4320 if (err < 0) {
4321 alc_free(codec);
4322 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004324 printk(KERN_INFO
4325 "hda_codec: Cannot set up configuration "
4326 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327 board_config = ALC880_3ST;
4328 }
4329 }
4330
Kailang Yangdf694da2005-12-05 19:42:22 +01004331 if (board_config != ALC880_AUTO)
4332 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333
4334 spec->stream_name_analog = "ALC880 Analog";
4335 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4336 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004337 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004338
4339 spec->stream_name_digital = "ALC880 Digital";
4340 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4341 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4342
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004343 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004345 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004346 /* get type */
4347 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 if (wcap != AC_WID_AUD_IN) {
4349 spec->adc_nids = alc880_adc_nids_alt;
4350 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004351 } else {
4352 spec->adc_nids = alc880_adc_nids;
4353 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004354 }
4355 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004356 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004357
Takashi Iwai2134ea42008-01-10 16:53:55 +01004358 spec->vmaster_nid = 0x0c;
4359
Linus Torvalds1da177e2005-04-16 15:20:36 -07004360 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004362 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004363#ifdef CONFIG_SND_HDA_POWER_SAVE
4364 if (!spec->loopback.amplist)
4365 spec->loopback.amplist = alc880_loopbacks;
4366#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004367 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004368
4369 return 0;
4370}
4371
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372
Linus Torvalds1da177e2005-04-16 15:20:36 -07004373/*
4374 * ALC260 support
4375 */
4376
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377static hda_nid_t alc260_dac_nids[1] = {
4378 /* front */
4379 0x02,
4380};
4381
4382static hda_nid_t alc260_adc_nids[1] = {
4383 /* ADC0 */
4384 0x04,
4385};
4386
Kailang Yangdf694da2005-12-05 19:42:22 +01004387static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 /* ADC1 */
4389 0x05,
4390};
4391
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004392/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4393 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4394 */
4395static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004396 /* ADC0, ADC1 */
4397 0x04, 0x05
4398};
4399
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400#define ALC260_DIGOUT_NID 0x03
4401#define ALC260_DIGIN_NID 0x06
4402
4403static struct hda_input_mux alc260_capture_source = {
4404 .num_items = 4,
4405 .items = {
4406 { "Mic", 0x0 },
4407 { "Front Mic", 0x1 },
4408 { "Line", 0x2 },
4409 { "CD", 0x4 },
4410 },
4411};
4412
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004413/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004414 * headphone jack and the internal CD lines since these are the only pins at
4415 * which audio can appear. For flexibility, also allow the option of
4416 * recording the mixer output on the second ADC (ADC0 doesn't have a
4417 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004418 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004419static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4420 {
4421 .num_items = 3,
4422 .items = {
4423 { "Mic/Line", 0x0 },
4424 { "CD", 0x4 },
4425 { "Headphone", 0x2 },
4426 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004427 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004428 {
4429 .num_items = 4,
4430 .items = {
4431 { "Mic/Line", 0x0 },
4432 { "CD", 0x4 },
4433 { "Headphone", 0x2 },
4434 { "Mixer", 0x5 },
4435 },
4436 },
4437
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004438};
4439
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004440/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4441 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004442 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004443static struct hda_input_mux alc260_acer_capture_sources[2] = {
4444 {
4445 .num_items = 4,
4446 .items = {
4447 { "Mic", 0x0 },
4448 { "Line", 0x2 },
4449 { "CD", 0x4 },
4450 { "Headphone", 0x5 },
4451 },
4452 },
4453 {
4454 .num_items = 5,
4455 .items = {
4456 { "Mic", 0x0 },
4457 { "Line", 0x2 },
4458 { "CD", 0x4 },
4459 { "Headphone", 0x6 },
4460 { "Mixer", 0x5 },
4461 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004462 },
4463};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464/*
4465 * This is just place-holder, so there's something for alc_build_pcms to look
4466 * at when it calculates the maximum number of channels. ALC260 has no mixer
4467 * element which allows changing the channel mode, so the verb list is
4468 * never used.
4469 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004470static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004471 { 2, NULL },
4472};
4473
Kailang Yangdf694da2005-12-05 19:42:22 +01004474
4475/* Mixer combinations
4476 *
4477 * basic: base_output + input + pc_beep + capture
4478 * HP: base_output + input + capture_alt
4479 * HP_3013: hp_3013 + input + capture
4480 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004481 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004482 */
4483
4484static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004485 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004486 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004487 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4488 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4489 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4490 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4491 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004492};
Kailang Yangdf694da2005-12-05 19:42:22 +01004493
4494static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004495 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4496 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4497 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4498 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4499 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4500 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4501 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4502 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004503 { } /* end */
4504};
4505
Kailang Yangdf694da2005-12-05 19:42:22 +01004506static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4507 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4508 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4509 { } /* end */
4510};
4511
Takashi Iwaibec15c32008-01-28 18:16:30 +01004512/* update HP, line and mono out pins according to the master switch */
4513static void alc260_hp_master_update(struct hda_codec *codec,
4514 hda_nid_t hp, hda_nid_t line,
4515 hda_nid_t mono)
4516{
4517 struct alc_spec *spec = codec->spec;
4518 unsigned int val = spec->master_sw ? PIN_HP : 0;
4519 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004520 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004521 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004522 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004523 val);
4524 /* mono (speaker) depending on the HP jack sense */
4525 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004526 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004527 val);
4528}
4529
4530static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4531 struct snd_ctl_elem_value *ucontrol)
4532{
4533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4534 struct alc_spec *spec = codec->spec;
4535 *ucontrol->value.integer.value = spec->master_sw;
4536 return 0;
4537}
4538
4539static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4540 struct snd_ctl_elem_value *ucontrol)
4541{
4542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4543 struct alc_spec *spec = codec->spec;
4544 int val = !!*ucontrol->value.integer.value;
4545 hda_nid_t hp, line, mono;
4546
4547 if (val == spec->master_sw)
4548 return 0;
4549 spec->master_sw = val;
4550 hp = (kcontrol->private_value >> 16) & 0xff;
4551 line = (kcontrol->private_value >> 8) & 0xff;
4552 mono = kcontrol->private_value & 0xff;
4553 alc260_hp_master_update(codec, hp, line, mono);
4554 return 1;
4555}
4556
4557static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4558 {
4559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4560 .name = "Master Playback Switch",
4561 .info = snd_ctl_boolean_mono_info,
4562 .get = alc260_hp_master_sw_get,
4563 .put = alc260_hp_master_sw_put,
4564 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4565 },
4566 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4567 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4568 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4569 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4570 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4571 HDA_OUTPUT),
4572 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4573 { } /* end */
4574};
4575
4576static struct hda_verb alc260_hp_unsol_verbs[] = {
4577 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4578 {},
4579};
4580
4581static void alc260_hp_automute(struct hda_codec *codec)
4582{
4583 struct alc_spec *spec = codec->spec;
4584 unsigned int present;
4585
4586 present = snd_hda_codec_read(codec, 0x10, 0,
4587 AC_VERB_GET_PIN_SENSE, 0);
4588 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4589 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4590}
4591
4592static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4593{
4594 if ((res >> 26) == ALC880_HP_EVENT)
4595 alc260_hp_automute(codec);
4596}
4597
Kailang Yangdf694da2005-12-05 19:42:22 +01004598static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004599 {
4600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4601 .name = "Master Playback Switch",
4602 .info = snd_ctl_boolean_mono_info,
4603 .get = alc260_hp_master_sw_get,
4604 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004605 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004606 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004607 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4608 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4609 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4610 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4611 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004613 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4614 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004615 { } /* end */
4616};
4617
Kailang Yang3f878302008-08-26 13:02:23 +02004618static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4619 .ops = &snd_hda_bind_vol,
4620 .values = {
4621 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4622 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4623 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4624 0
4625 },
4626};
4627
4628static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4629 .ops = &snd_hda_bind_sw,
4630 .values = {
4631 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4632 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4633 0
4634 },
4635};
4636
4637static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4638 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4639 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4640 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4642 { } /* end */
4643};
4644
Takashi Iwaibec15c32008-01-28 18:16:30 +01004645static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4646 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4647 {},
4648};
4649
4650static void alc260_hp_3013_automute(struct hda_codec *codec)
4651{
4652 struct alc_spec *spec = codec->spec;
4653 unsigned int present;
4654
4655 present = snd_hda_codec_read(codec, 0x15, 0,
4656 AC_VERB_GET_PIN_SENSE, 0);
4657 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004658 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004659}
4660
4661static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4662 unsigned int res)
4663{
4664 if ((res >> 26) == ALC880_HP_EVENT)
4665 alc260_hp_3013_automute(codec);
4666}
4667
Kailang Yang3f878302008-08-26 13:02:23 +02004668static void alc260_hp_3012_automute(struct hda_codec *codec)
4669{
4670 unsigned int present, bits;
4671
4672 present = snd_hda_codec_read(codec, 0x10, 0,
4673 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4674
4675 bits = present ? 0 : PIN_OUT;
4676 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4677 bits);
4678 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4679 bits);
4680 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4681 bits);
4682}
4683
4684static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4685 unsigned int res)
4686{
4687 if ((res >> 26) == ALC880_HP_EVENT)
4688 alc260_hp_3012_automute(codec);
4689}
4690
4691/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004692 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4693 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004694static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004696 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004697 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004698 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4699 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4700 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4701 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004702 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004703 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4704 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004705 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4706 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004707 { } /* end */
4708};
4709
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004710/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4711 * versions of the ALC260 don't act on requests to enable mic bias from NID
4712 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4713 * datasheet doesn't mention this restriction. At this stage it's not clear
4714 * whether this behaviour is intentional or is a hardware bug in chip
4715 * revisions available in early 2006. Therefore for now allow the
4716 * "Headphone Jack Mode" control to span all choices, but if it turns out
4717 * that the lack of mic bias for this NID is intentional we could change the
4718 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4719 *
4720 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4721 * don't appear to make the mic bias available from the "line" jack, even
4722 * though the NID used for this jack (0x14) can supply it. The theory is
4723 * that perhaps Acer have included blocking capacitors between the ALC260
4724 * and the output jack. If this turns out to be the case for all such
4725 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4726 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004727 *
4728 * The C20x Tablet series have a mono internal speaker which is controlled
4729 * via the chip's Mono sum widget and pin complex, so include the necessary
4730 * controls for such models. On models without a "mono speaker" the control
4731 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004732 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004733static struct snd_kcontrol_new alc260_acer_mixer[] = {
4734 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4735 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004736 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004737 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004738 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004739 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004740 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004741 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4742 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4744 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4745 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4746 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4747 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4748 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4749 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4750 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4751 { } /* end */
4752};
4753
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004754/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4755 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4756 */
4757static struct snd_kcontrol_new alc260_will_mixer[] = {
4758 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4759 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4761 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4762 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4763 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4764 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4765 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4766 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4767 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4768 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4769 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4770 { } /* end */
4771};
4772
4773/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4774 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4775 */
4776static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4777 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4778 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4780 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4781 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4782 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4783 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4784 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4785 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4786 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4787 { } /* end */
4788};
4789
Kailang Yangdf694da2005-12-05 19:42:22 +01004790/*
4791 * initialization verbs
4792 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004793static struct hda_verb alc260_init_verbs[] = {
4794 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004796 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004798 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004799 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004801 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004804 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004805 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004806 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004807 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004809 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004811 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4812 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004813 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 /* set connection select to line in (default select for this ADC) */
4815 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 /* mute capture amp left and right */
4817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4818 /* set connection select to line in (default select for this ADC) */
4819 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004820 /* set vol=0 Line-Out mixer amp left and right */
4821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4822 /* unmute pin widget amp left and right (no gain on this amp) */
4823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4824 /* set vol=0 HP mixer amp left and right */
4825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4826 /* unmute pin widget amp left and right (no gain on this amp) */
4827 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4828 /* set vol=0 Mono mixer amp left and right */
4829 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4830 /* unmute pin widget amp left and right (no gain on this amp) */
4831 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4832 /* unmute LINE-2 out pin */
4833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004834 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4835 * Line In 2 = 0x03
4836 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004837 /* mute analog inputs */
4838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004844 /* mute Front out path */
4845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4847 /* mute Headphone out path */
4848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4850 /* mute Mono out path */
4851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004853 { }
4854};
4855
Takashi Iwai474167d2006-05-17 17:17:43 +02004856#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004857static struct hda_verb alc260_hp_init_verbs[] = {
4858 /* Headphone and output */
4859 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4860 /* mono output */
4861 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4862 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4864 /* Mic2 (front panel) pin widget for input and vref at 80% */
4865 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4866 /* Line In pin widget for input */
4867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4868 /* Line-2 pin widget for output */
4869 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4870 /* CD pin widget for input */
4871 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4872 /* unmute amp left and right */
4873 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4874 /* set connection select to line in (default select for this ADC) */
4875 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4876 /* unmute Line-Out mixer amp left and right (volume = 0) */
4877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4878 /* mute pin widget amp left and right (no gain on this amp) */
4879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4880 /* unmute HP mixer amp left and right (volume = 0) */
4881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4882 /* mute pin widget amp left and right (no gain on this amp) */
4883 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004884 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4885 * Line In 2 = 0x03
4886 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004887 /* mute analog inputs */
4888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004893 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4894 /* Unmute Front out path */
4895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4897 /* Unmute Headphone out path */
4898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4900 /* Unmute Mono out path */
4901 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4902 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4903 { }
4904};
Takashi Iwai474167d2006-05-17 17:17:43 +02004905#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004906
4907static struct hda_verb alc260_hp_3013_init_verbs[] = {
4908 /* Line out and output */
4909 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4910 /* mono output */
4911 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4912 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4914 /* Mic2 (front panel) pin widget for input and vref at 80% */
4915 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4916 /* Line In pin widget for input */
4917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4918 /* Headphone pin widget for output */
4919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4920 /* CD pin widget for input */
4921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4922 /* unmute amp left and right */
4923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4924 /* set connection select to line in (default select for this ADC) */
4925 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4926 /* unmute Line-Out mixer amp left and right (volume = 0) */
4927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4928 /* mute pin widget amp left and right (no gain on this amp) */
4929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4930 /* unmute HP mixer amp left and right (volume = 0) */
4931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4932 /* mute pin widget amp left and right (no gain on this amp) */
4933 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004934 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4935 * Line In 2 = 0x03
4936 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004937 /* mute analog inputs */
4938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004943 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4944 /* Unmute Front out path */
4945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4946 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4947 /* Unmute Headphone out path */
4948 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4950 /* Unmute Mono out path */
4951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4953 { }
4954};
4955
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004956/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004957 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4958 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004959 */
4960static struct hda_verb alc260_fujitsu_init_verbs[] = {
4961 /* Disable all GPIOs */
4962 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4963 /* Internal speaker is connected to headphone pin */
4964 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4965 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004967 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4968 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4969 /* Ensure all other unused pins are disabled and muted. */
4970 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004972 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004973 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004974 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004975 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004978
Jonathan Woithef7ace402006-02-28 11:46:14 +01004979 /* Disable digital (SPDIF) pins */
4980 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4981 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004982
Kailang Yangea1fb292008-08-26 12:58:38 +02004983 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004984 * when acting as an output.
4985 */
4986 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4987
4988 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004998
Jonathan Woithef7ace402006-02-28 11:46:14 +01004999 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5000 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5001 /* Unmute Line1 pin widget output buffer since it starts as an output.
5002 * If the pin mode is changed by the user the pin mode control will
5003 * take care of enabling the pin's input/output buffers as needed.
5004 * Therefore there's no need to enable the input buffer at this
5005 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005006 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005008 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005009 * mixer ctrl)
5010 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005011 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005012
Jonathan Woithef7ace402006-02-28 11:46:14 +01005013 /* Mute capture amp left and right */
5014 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005015 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005016 * in (on mic1 pin)
5017 */
5018 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005019
Jonathan Woithef7ace402006-02-28 11:46:14 +01005020 /* Do the same for the second ADC: mute capture input amp and
5021 * set ADC connection to line in (on mic1 pin)
5022 */
5023 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5024 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005025
Jonathan Woithef7ace402006-02-28 11:46:14 +01005026 /* Mute all inputs to mixer widget (even unconnected ones) */
5027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005035
5036 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005037};
5038
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005039/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5040 * similar laptops (adapted from Fujitsu init verbs).
5041 */
5042static struct hda_verb alc260_acer_init_verbs[] = {
5043 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5044 * the headphone jack. Turn this on and rely on the standard mute
5045 * methods whenever the user wants to turn these outputs off.
5046 */
5047 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5048 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5049 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5050 /* Internal speaker/Headphone jack is connected to Line-out pin */
5051 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5052 /* Internal microphone/Mic jack is connected to Mic1 pin */
5053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5054 /* Line In jack is connected to Line1 pin */
5055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005056 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5057 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005058 /* Ensure all other unused pins are disabled and muted. */
5059 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5060 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005061 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5062 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5065 /* Disable digital (SPDIF) pins */
5066 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5067 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5068
Kailang Yangea1fb292008-08-26 12:58:38 +02005069 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005070 * bus when acting as outputs.
5071 */
5072 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5073 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5074
5075 /* Start with output sum widgets muted and their output gains at min */
5076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5077 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5080 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5082 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5083 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5084 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5085
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086 /* Unmute Line-out pin widget amp left and right
5087 * (no equiv mixer ctrl)
5088 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005090 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5091 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005092 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5093 * inputs. If the pin mode is changed by the user the pin mode control
5094 * will take care of enabling the pin's input/output buffers as needed.
5095 * Therefore there's no need to enable the input buffer at this
5096 * stage.
5097 */
5098 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5100
5101 /* Mute capture amp left and right */
5102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5103 /* Set ADC connection select to match default mixer setting - mic
5104 * (on mic1 pin)
5105 */
5106 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5107
5108 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005109 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005110 */
5111 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005112 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005113
5114 /* Mute all inputs to mixer widget (even unconnected ones) */
5115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5123
5124 { }
5125};
5126
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005127static struct hda_verb alc260_will_verbs[] = {
5128 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5129 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5130 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5131 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5132 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5133 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5134 {}
5135};
5136
5137static struct hda_verb alc260_replacer_672v_verbs[] = {
5138 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5139 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5140 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5141
5142 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5143 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5144 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5145
5146 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5147 {}
5148};
5149
5150/* toggle speaker-output according to the hp-jack state */
5151static void alc260_replacer_672v_automute(struct hda_codec *codec)
5152{
5153 unsigned int present;
5154
5155 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5156 present = snd_hda_codec_read(codec, 0x0f, 0,
5157 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5158 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005159 snd_hda_codec_write_cache(codec, 0x01, 0,
5160 AC_VERB_SET_GPIO_DATA, 1);
5161 snd_hda_codec_write_cache(codec, 0x0f, 0,
5162 AC_VERB_SET_PIN_WIDGET_CONTROL,
5163 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005164 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005165 snd_hda_codec_write_cache(codec, 0x01, 0,
5166 AC_VERB_SET_GPIO_DATA, 0);
5167 snd_hda_codec_write_cache(codec, 0x0f, 0,
5168 AC_VERB_SET_PIN_WIDGET_CONTROL,
5169 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005170 }
5171}
5172
5173static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5174 unsigned int res)
5175{
5176 if ((res >> 26) == ALC880_HP_EVENT)
5177 alc260_replacer_672v_automute(codec);
5178}
5179
Kailang Yang3f878302008-08-26 13:02:23 +02005180static struct hda_verb alc260_hp_dc7600_verbs[] = {
5181 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5182 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5183 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5184 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5185 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5187 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5188 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5189 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5190 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5191 {}
5192};
5193
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005194/* Test configuration for debugging, modelled after the ALC880 test
5195 * configuration.
5196 */
5197#ifdef CONFIG_SND_DEBUG
5198static hda_nid_t alc260_test_dac_nids[1] = {
5199 0x02,
5200};
5201static hda_nid_t alc260_test_adc_nids[2] = {
5202 0x04, 0x05,
5203};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005204/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005205 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005206 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005207 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005208static struct hda_input_mux alc260_test_capture_sources[2] = {
5209 {
5210 .num_items = 7,
5211 .items = {
5212 { "MIC1 pin", 0x0 },
5213 { "MIC2 pin", 0x1 },
5214 { "LINE1 pin", 0x2 },
5215 { "LINE2 pin", 0x3 },
5216 { "CD pin", 0x4 },
5217 { "LINE-OUT pin", 0x5 },
5218 { "HP-OUT pin", 0x6 },
5219 },
5220 },
5221 {
5222 .num_items = 8,
5223 .items = {
5224 { "MIC1 pin", 0x0 },
5225 { "MIC2 pin", 0x1 },
5226 { "LINE1 pin", 0x2 },
5227 { "LINE2 pin", 0x3 },
5228 { "CD pin", 0x4 },
5229 { "Mixer", 0x5 },
5230 { "LINE-OUT pin", 0x6 },
5231 { "HP-OUT pin", 0x7 },
5232 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005233 },
5234};
5235static struct snd_kcontrol_new alc260_test_mixer[] = {
5236 /* Output driver widgets */
5237 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5238 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5239 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5240 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5241 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5242 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5243
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005244 /* Modes for retasking pin widgets
5245 * Note: the ALC260 doesn't seem to act on requests to enable mic
5246 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5247 * mention this restriction. At this stage it's not clear whether
5248 * this behaviour is intentional or is a hardware bug in chip
5249 * revisions available at least up until early 2006. Therefore for
5250 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5251 * choices, but if it turns out that the lack of mic bias for these
5252 * NIDs is intentional we could change their modes from
5253 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5254 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005255 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5256 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5257 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5258 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5259 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5260 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5261
5262 /* Loopback mixer controls */
5263 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5264 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5265 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5266 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5267 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5268 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5269 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5270 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5271 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5272 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5273 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5274 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5275 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5276 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5277 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5278 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005279
5280 /* Controls for GPIO pins, assuming they are configured as outputs */
5281 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5282 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5283 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5284 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5285
Jonathan Woithe92621f12006-02-28 11:47:47 +01005286 /* Switches to allow the digital IO pins to be enabled. The datasheet
5287 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005288 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005289 */
5290 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5291 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5292
Jonathan Woithef8225f62008-01-08 12:16:54 +01005293 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5294 * this output to turn on an external amplifier.
5295 */
5296 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5297 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5298
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005299 { } /* end */
5300};
5301static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005302 /* Enable all GPIOs as outputs with an initial value of 0 */
5303 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5304 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5305 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5306
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005307 /* Enable retasking pins as output, initially without power amp */
5308 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5309 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5312 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5314
Jonathan Woithe92621f12006-02-28 11:47:47 +01005315 /* Disable digital (SPDIF) pins initially, but users can enable
5316 * them via a mixer switch. In the case of SPDIF-out, this initverb
5317 * payload also sets the generation to 0, output to be in "consumer"
5318 * PCM format, copyright asserted, no pre-emphasis and no validity
5319 * control.
5320 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005321 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5322 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5323
Kailang Yangea1fb292008-08-26 12:58:38 +02005324 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005325 * OUT1 sum bus when acting as an output.
5326 */
5327 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5328 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5329 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5330 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5331
5332 /* Start with output sum widgets muted and their output gains at min */
5333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5339 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005343 /* Unmute retasking pin widget output buffers since the default
5344 * state appears to be output. As the pin mode is changed by the
5345 * user the pin mode control will take care of enabling the pin's
5346 * input/output buffers as needed.
5347 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005348 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5352 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5353 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5354 /* Also unmute the mono-out pin widget */
5355 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5356
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005357 /* Mute capture amp left and right */
5358 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005359 /* Set ADC connection select to match default mixer setting (mic1
5360 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005361 */
5362 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5363
5364 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005365 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005366 */
5367 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5368 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5369
5370 /* Mute all inputs to mixer widget (even unconnected ones) */
5371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5379
5380 { }
5381};
5382#endif
5383
Takashi Iwai63300792008-01-24 15:31:36 +01005384#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5385#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005386
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005387#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5388#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5389
Kailang Yangdf694da2005-12-05 19:42:22 +01005390/*
5391 * for BIOS auto-configuration
5392 */
5393
5394static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005395 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005396{
5397 hda_nid_t nid_vol;
5398 unsigned long vol_val, sw_val;
5399 char name[32];
5400 int err;
5401
5402 if (nid >= 0x0f && nid < 0x11) {
5403 nid_vol = nid - 0x7;
5404 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5405 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5406 } else if (nid == 0x11) {
5407 nid_vol = nid - 0x7;
5408 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5409 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5410 } else if (nid >= 0x12 && nid <= 0x15) {
5411 nid_vol = 0x08;
5412 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5413 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5414 } else
5415 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005416
Takashi Iwai863b4512008-10-21 17:01:47 +02005417 if (!(*vol_bits & (1 << nid_vol))) {
5418 /* first control for the volume widget */
5419 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5420 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5421 if (err < 0)
5422 return err;
5423 *vol_bits |= (1 << nid_vol);
5424 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005425 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005426 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5427 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005428 return err;
5429 return 1;
5430}
5431
5432/* add playback controls from the parsed DAC table */
5433static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5434 const struct auto_pin_cfg *cfg)
5435{
5436 hda_nid_t nid;
5437 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005438 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005439
5440 spec->multiout.num_dacs = 1;
5441 spec->multiout.dac_nids = spec->private_dac_nids;
5442 spec->multiout.dac_nids[0] = 0x02;
5443
5444 nid = cfg->line_out_pins[0];
5445 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005446 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005447 if (err < 0)
5448 return err;
5449 }
5450
Takashi Iwai82bc9552006-03-21 11:24:42 +01005451 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005452 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005453 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005454 if (err < 0)
5455 return err;
5456 }
5457
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005458 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005459 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005460 err = alc260_add_playback_controls(spec, nid, "Headphone",
5461 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005462 if (err < 0)
5463 return err;
5464 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005465 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005466}
5467
5468/* create playback/capture controls for input pins */
5469static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5470 const struct auto_pin_cfg *cfg)
5471{
Kailang Yangdf694da2005-12-05 19:42:22 +01005472 struct hda_input_mux *imux = &spec->private_imux;
5473 int i, err, idx;
5474
5475 for (i = 0; i < AUTO_PIN_LAST; i++) {
5476 if (cfg->input_pins[i] >= 0x12) {
5477 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005478 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005479 auto_pin_cfg_labels[i], idx,
5480 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005481 if (err < 0)
5482 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005483 imux->items[imux->num_items].label =
5484 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005485 imux->items[imux->num_items].index = idx;
5486 imux->num_items++;
5487 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005488 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005490 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005491 auto_pin_cfg_labels[i], idx,
5492 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005493 if (err < 0)
5494 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005495 imux->items[imux->num_items].label =
5496 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005497 imux->items[imux->num_items].index = idx;
5498 imux->num_items++;
5499 }
5500 }
5501 return 0;
5502}
5503
5504static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5505 hda_nid_t nid, int pin_type,
5506 int sel_idx)
5507{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005508 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005509 /* need the manual connection? */
5510 if (nid >= 0x12) {
5511 int idx = nid - 0x12;
5512 snd_hda_codec_write(codec, idx + 0x0b, 0,
5513 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005514 }
5515}
5516
5517static void alc260_auto_init_multi_out(struct hda_codec *codec)
5518{
5519 struct alc_spec *spec = codec->spec;
5520 hda_nid_t nid;
5521
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005522 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005523 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005524 if (nid) {
5525 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5526 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5527 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005528
Takashi Iwai82bc9552006-03-21 11:24:42 +01005529 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005530 if (nid)
5531 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5532
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005533 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005535 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005536}
Kailang Yangdf694da2005-12-05 19:42:22 +01005537
5538#define ALC260_PIN_CD_NID 0x16
5539static void alc260_auto_init_analog_input(struct hda_codec *codec)
5540{
5541 struct alc_spec *spec = codec->spec;
5542 int i;
5543
5544 for (i = 0; i < AUTO_PIN_LAST; i++) {
5545 hda_nid_t nid = spec->autocfg.input_pins[i];
5546 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005547 snd_hda_codec_write(codec, nid, 0,
5548 AC_VERB_SET_PIN_WIDGET_CONTROL,
5549 i <= AUTO_PIN_FRONT_MIC ?
5550 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005551 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005552 snd_hda_codec_write(codec, nid, 0,
5553 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005554 AMP_OUT_MUTE);
5555 }
5556 }
5557}
5558
5559/*
5560 * generic initialization of ADC, input mixers and output mixers
5561 */
5562static struct hda_verb alc260_volume_init_verbs[] = {
5563 /*
5564 * Unmute ADC0-1 and set the default input to mic-in
5565 */
5566 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5567 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5568 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5569 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005570
Kailang Yangdf694da2005-12-05 19:42:22 +01005571 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5572 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005573 * Note: PASD motherboards uses the Line In 2 as the input for
5574 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 */
5576 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005577 /* mute analog inputs */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005583
5584 /*
5585 * Set up output mixers (0x08 - 0x0a)
5586 */
5587 /* set vol=0 to output mixers */
5588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5589 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5590 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 /* set up input amps for analog loopback */
5592 /* Amp Indices: DAC = 0, mixer = 1 */
5593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5597 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5598 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005599
Kailang Yangdf694da2005-12-05 19:42:22 +01005600 { }
5601};
5602
5603static int alc260_parse_auto_config(struct hda_codec *codec)
5604{
5605 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 int err;
5607 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5608
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005609 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5610 alc260_ignore);
5611 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005612 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005613 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5614 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005615 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005616 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005617 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005618 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5619 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005620 return err;
5621
5622 spec->multiout.max_channels = 2;
5623
5624 if (spec->autocfg.dig_out_pin)
5625 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005626 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005627 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005628
Takashi Iwaid88897e2008-10-31 15:01:37 +01005629 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005630
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005631 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005632 spec->input_mux = &spec->private_imux;
5633
Takashi Iwaie044c392008-10-27 16:56:24 +01005634 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005635 return 1;
5636}
5637
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005638/* additional initialization for auto-configuration model */
5639static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005640{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005641 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 alc260_auto_init_multi_out(codec);
5643 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005644 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005645 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005646}
5647
Takashi Iwaicb53c622007-08-10 17:21:45 +02005648#ifdef CONFIG_SND_HDA_POWER_SAVE
5649static struct hda_amp_list alc260_loopbacks[] = {
5650 { 0x07, HDA_INPUT, 0 },
5651 { 0x07, HDA_INPUT, 1 },
5652 { 0x07, HDA_INPUT, 2 },
5653 { 0x07, HDA_INPUT, 3 },
5654 { 0x07, HDA_INPUT, 4 },
5655 { } /* end */
5656};
5657#endif
5658
Kailang Yangdf694da2005-12-05 19:42:22 +01005659/*
5660 * ALC260 configurations
5661 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005662static const char *alc260_models[ALC260_MODEL_LAST] = {
5663 [ALC260_BASIC] = "basic",
5664 [ALC260_HP] = "hp",
5665 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005666 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005667 [ALC260_FUJITSU_S702X] = "fujitsu",
5668 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005669 [ALC260_WILL] = "will",
5670 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005671#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005672 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005673#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005674 [ALC260_AUTO] = "auto",
5675};
5676
5677static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005678 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005679 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005680 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005681 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005682 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005683 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005684 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005685 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5686 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5687 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5688 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5689 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5690 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5691 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5692 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5693 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005694 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005695 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005696 {}
5697};
5698
Kailang Yangdf694da2005-12-05 19:42:22 +01005699static struct alc_config_preset alc260_presets[] = {
5700 [ALC260_BASIC] = {
5701 .mixers = { alc260_base_output_mixer,
5702 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005703 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 .init_verbs = { alc260_init_verbs },
5705 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5706 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005707 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 .adc_nids = alc260_adc_nids,
5709 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5710 .channel_mode = alc260_modes,
5711 .input_mux = &alc260_capture_source,
5712 },
5713 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005714 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005715 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005716 .init_verbs = { alc260_init_verbs,
5717 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005718 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5719 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005720 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5721 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5723 .channel_mode = alc260_modes,
5724 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005725 .unsol_event = alc260_hp_unsol_event,
5726 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005727 },
Kailang Yang3f878302008-08-26 13:02:23 +02005728 [ALC260_HP_DC7600] = {
5729 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005730 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005731 .init_verbs = { alc260_init_verbs,
5732 alc260_hp_dc7600_verbs },
5733 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5734 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005735 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5736 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005737 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5738 .channel_mode = alc260_modes,
5739 .input_mux = &alc260_capture_source,
5740 .unsol_event = alc260_hp_3012_unsol_event,
5741 .init_hook = alc260_hp_3012_automute,
5742 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005743 [ALC260_HP_3013] = {
5744 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005745 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005746 .init_verbs = { alc260_hp_3013_init_verbs,
5747 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005748 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5749 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005750 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5751 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005752 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5753 .channel_mode = alc260_modes,
5754 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005755 .unsol_event = alc260_hp_3013_unsol_event,
5756 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005757 },
5758 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005759 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005760 .init_verbs = { alc260_fujitsu_init_verbs },
5761 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5762 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005763 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5764 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005765 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5766 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005767 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5768 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005769 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005770 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005771 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005772 .init_verbs = { alc260_acer_init_verbs },
5773 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5774 .dac_nids = alc260_dac_nids,
5775 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5776 .adc_nids = alc260_dual_adc_nids,
5777 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5778 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005779 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5780 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005781 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005782 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005783 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005784 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5785 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5786 .dac_nids = alc260_dac_nids,
5787 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5788 .adc_nids = alc260_adc_nids,
5789 .dig_out_nid = ALC260_DIGOUT_NID,
5790 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5791 .channel_mode = alc260_modes,
5792 .input_mux = &alc260_capture_source,
5793 },
5794 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005795 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005796 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5797 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5798 .dac_nids = alc260_dac_nids,
5799 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5800 .adc_nids = alc260_adc_nids,
5801 .dig_out_nid = ALC260_DIGOUT_NID,
5802 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5803 .channel_mode = alc260_modes,
5804 .input_mux = &alc260_capture_source,
5805 .unsol_event = alc260_replacer_672v_unsol_event,
5806 .init_hook = alc260_replacer_672v_automute,
5807 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005808#ifdef CONFIG_SND_DEBUG
5809 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005810 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005811 .init_verbs = { alc260_test_init_verbs },
5812 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5813 .dac_nids = alc260_test_dac_nids,
5814 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5815 .adc_nids = alc260_test_adc_nids,
5816 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5817 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5819 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005820 },
5821#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005822};
5823
Linus Torvalds1da177e2005-04-16 15:20:36 -07005824static int patch_alc260(struct hda_codec *codec)
5825{
5826 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005827 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005828
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005829 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005830 if (spec == NULL)
5831 return -ENOMEM;
5832
5833 codec->spec = spec;
5834
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005835 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5836 alc260_models,
5837 alc260_cfg_tbl);
5838 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005839 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5840 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005841 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005842 }
5843
Kailang Yangdf694da2005-12-05 19:42:22 +01005844 if (board_config == ALC260_AUTO) {
5845 /* automatic parse from the BIOS config */
5846 err = alc260_parse_auto_config(codec);
5847 if (err < 0) {
5848 alc_free(codec);
5849 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005850 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005851 printk(KERN_INFO
5852 "hda_codec: Cannot set up configuration "
5853 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 board_config = ALC260_BASIC;
5855 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005856 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005857
Kailang Yangdf694da2005-12-05 19:42:22 +01005858 if (board_config != ALC260_AUTO)
5859 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005860
5861 spec->stream_name_analog = "ALC260 Analog";
5862 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5863 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5864
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005865 spec->stream_name_digital = "ALC260 Digital";
5866 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5867 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5868
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005869 if (!spec->adc_nids && spec->input_mux) {
5870 /* check whether NID 0x04 is valid */
5871 unsigned int wcap = get_wcaps(codec, 0x04);
5872 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5873 /* get type */
5874 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5875 spec->adc_nids = alc260_adc_nids_alt;
5876 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5877 } else {
5878 spec->adc_nids = alc260_adc_nids;
5879 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5880 }
5881 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005882 set_capture_mixer(spec);
5883
Takashi Iwai2134ea42008-01-10 16:53:55 +01005884 spec->vmaster_nid = 0x08;
5885
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005887 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005888 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005889#ifdef CONFIG_SND_HDA_POWER_SAVE
5890 if (!spec->loopback.amplist)
5891 spec->loopback.amplist = alc260_loopbacks;
5892#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005893 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005894
5895 return 0;
5896}
5897
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005898
Linus Torvalds1da177e2005-04-16 15:20:36 -07005899/*
5900 * ALC882 support
5901 *
5902 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5903 * configuration. Each pin widget can choose any input DACs and a mixer.
5904 * Each ADC is connected from a mixer of all inputs. This makes possible
5905 * 6-channel independent captures.
5906 *
5907 * In addition, an independent DAC for the multi-playback (not used in this
5908 * driver yet).
5909 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005910#define ALC882_DIGOUT_NID 0x06
5911#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005912
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005913static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005914 { 8, NULL }
5915};
5916
5917static hda_nid_t alc882_dac_nids[4] = {
5918 /* front, rear, clfe, rear_surr */
5919 0x02, 0x03, 0x04, 0x05
5920};
5921
Kailang Yangdf694da2005-12-05 19:42:22 +01005922/* identical with ALC880 */
5923#define alc882_adc_nids alc880_adc_nids
5924#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005925
Takashi Iwaie1406342008-02-11 18:32:32 +01005926static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5927static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5928
Linus Torvalds1da177e2005-04-16 15:20:36 -07005929/* input MUX */
5930/* FIXME: should be a matrix-type input source selection */
5931
5932static struct hda_input_mux alc882_capture_source = {
5933 .num_items = 4,
5934 .items = {
5935 { "Mic", 0x0 },
5936 { "Front Mic", 0x1 },
5937 { "Line", 0x2 },
5938 { "CD", 0x4 },
5939 },
5940};
Kailang Yangdf694da2005-12-05 19:42:22 +01005941/*
Kailang Yang272a5272007-05-14 11:00:38 +02005942 * 2ch mode
5943 */
5944static struct hda_verb alc882_3ST_ch2_init[] = {
5945 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5946 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5947 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5948 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5949 { } /* end */
5950};
5951
5952/*
5953 * 6ch mode
5954 */
5955static struct hda_verb alc882_3ST_ch6_init[] = {
5956 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5957 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5958 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5959 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5960 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5961 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5962 { } /* end */
5963};
5964
5965static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5966 { 2, alc882_3ST_ch2_init },
5967 { 6, alc882_3ST_ch6_init },
5968};
5969
5970/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 * 6ch mode
5972 */
5973static struct hda_verb alc882_sixstack_ch6_init[] = {
5974 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5975 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5976 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5977 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5978 { } /* end */
5979};
5980
5981/*
5982 * 8ch mode
5983 */
5984static struct hda_verb alc882_sixstack_ch8_init[] = {
5985 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5986 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5987 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5989 { } /* end */
5990};
5991
5992static struct hda_channel_mode alc882_sixstack_modes[2] = {
5993 { 6, alc882_sixstack_ch6_init },
5994 { 8, alc882_sixstack_ch8_init },
5995};
5996
Takashi Iwai87350ad2007-08-16 18:19:38 +02005997/*
5998 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5999 */
6000
6001/*
6002 * 2ch mode
6003 */
6004static struct hda_verb alc885_mbp_ch2_init[] = {
6005 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6006 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6007 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6008 { } /* end */
6009};
6010
6011/*
6012 * 6ch mode
6013 */
6014static struct hda_verb alc885_mbp_ch6_init[] = {
6015 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6016 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6017 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6018 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6019 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6020 { } /* end */
6021};
6022
6023static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6024 { 2, alc885_mbp_ch2_init },
6025 { 6, alc885_mbp_ch6_init },
6026};
6027
6028
Linus Torvalds1da177e2005-04-16 15:20:36 -07006029/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6030 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6031 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006032static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006035 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006036 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006041 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006042 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6051 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006052 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6054 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6055 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006056 { } /* end */
6057};
6058
Takashi Iwai87350ad2007-08-16 18:19:38 +02006059static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006060 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6061 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6062 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6063 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6065 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6067 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006068 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6070 { } /* end */
6071};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006072static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6075 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6076 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6084 { } /* end */
6085};
6086
Kailang Yang272a5272007-05-14 11:00:38 +02006087static struct snd_kcontrol_new alc882_targa_mixer[] = {
6088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006098 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6099 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006100 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006101 { } /* end */
6102};
6103
6104/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6105 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6106 */
6107static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6111 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6116 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6117 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006120 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006121 { } /* end */
6122};
6123
Takashi Iwai914759b2007-09-06 14:52:04 +02006124static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6126 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6128 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6129 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6131 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6136 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6137 { } /* end */
6138};
6139
Kailang Yangdf694da2005-12-05 19:42:22 +01006140static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6141 {
6142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6143 .name = "Channel Mode",
6144 .info = alc_ch_mode_info,
6145 .get = alc_ch_mode_get,
6146 .put = alc_ch_mode_put,
6147 },
6148 { } /* end */
6149};
6150
Linus Torvalds1da177e2005-04-16 15:20:36 -07006151static struct hda_verb alc882_init_verbs[] = {
6152 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006156 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006157 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6159 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6162 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6163 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006164 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6166 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6167 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006169 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006172 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006173 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006176 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006177 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006178 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006180 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006181 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006182 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006183 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006185 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6188 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6191 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006192 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006193 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6194 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6197 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006199 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006200
6201 /* FIXME: use matrix-type input source selection */
6202 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6203 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006208 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006213 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6218 /* ADC1: mute amp left and right */
6219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006220 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006221 /* ADC2: mute amp left and right */
6222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006223 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006224 /* ADC3: mute amp left and right */
6225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006226 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006227
6228 { }
6229};
6230
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006231static struct hda_verb alc882_eapd_verbs[] = {
6232 /* change to EAPD mode */
6233 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006234 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006235 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006236};
6237
Tobin Davis9102cd12006-12-15 10:02:12 +01006238/* Mac Pro test */
6239static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6245 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6246 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6247 { } /* end */
6248};
6249
6250static struct hda_verb alc882_macpro_init_verbs[] = {
6251 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6255 /* Front Pin: output 0 (0x0c) */
6256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6259 /* Front Mic pin: input vref at 80% */
6260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6262 /* Speaker: output */
6263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6265 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6266 /* Headphone output (output 0 - 0x0c) */
6267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6270
6271 /* FIXME: use matrix-type input source selection */
6272 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6273 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6278 /* Input mixer2 */
6279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6283 /* Input mixer3 */
6284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6288 /* ADC1: mute amp left and right */
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6291 /* ADC2: mute amp left and right */
6292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6294 /* ADC3: mute amp left and right */
6295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6296 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6297
6298 { }
6299};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006300
Takashi Iwai87350ad2007-08-16 18:19:38 +02006301/* Macbook Pro rev3 */
6302static struct hda_verb alc885_mbp3_init_verbs[] = {
6303 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6307 /* Rear mixer */
6308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6311 /* Front Pin: output 0 (0x0c) */
6312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6314 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6315 /* HP Pin: output 0 (0x0d) */
6316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6318 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6320 /* Mic (rear) pin: input vref at 80% */
6321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6323 /* Front Mic pin: input vref at 80% */
6324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6326 /* Line In pin: use output 1 when in LineOut mode */
6327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6330
6331 /* FIXME: use matrix-type input source selection */
6332 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6333 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6338 /* Input mixer2 */
6339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6343 /* Input mixer3 */
6344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6348 /* ADC1: mute amp left and right */
6349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6350 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6351 /* ADC2: mute amp left and right */
6352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6353 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 /* ADC3: mute amp left and right */
6355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6356 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6357
6358 { }
6359};
6360
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006361/* iMac 24 mixer. */
6362static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6363 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6364 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6365 { } /* end */
6366};
6367
6368/* iMac 24 init verbs. */
6369static struct hda_verb alc885_imac24_init_verbs[] = {
6370 /* Internal speakers: output 0 (0x0c) */
6371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6373 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6374 /* Internal speakers: output 0 (0x0c) */
6375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6377 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6378 /* Headphone: output 0 (0x0c) */
6379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6380 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6381 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6382 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6383 /* Front Mic: input vref at 80% */
6384 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6386 { }
6387};
6388
6389/* Toggle speaker-output according to the hp-jack state */
6390static void alc885_imac24_automute(struct hda_codec *codec)
6391{
6392 unsigned int present;
6393
6394 present = snd_hda_codec_read(codec, 0x14, 0,
6395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006396 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6397 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6398 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6399 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006400}
6401
6402/* Processes unsolicited events. */
6403static void alc885_imac24_unsol_event(struct hda_codec *codec,
6404 unsigned int res)
6405{
6406 /* Headphone insertion or removal. */
6407 if ((res >> 26) == ALC880_HP_EVENT)
6408 alc885_imac24_automute(codec);
6409}
6410
Takashi Iwai87350ad2007-08-16 18:19:38 +02006411static void alc885_mbp3_automute(struct hda_codec *codec)
6412{
6413 unsigned int present;
6414
6415 present = snd_hda_codec_read(codec, 0x15, 0,
6416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6418 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6419 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6420 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6421
6422}
6423static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6424 unsigned int res)
6425{
6426 /* Headphone insertion or removal. */
6427 if ((res >> 26) == ALC880_HP_EVENT)
6428 alc885_mbp3_automute(codec);
6429}
6430
6431
Kailang Yang272a5272007-05-14 11:00:38 +02006432static struct hda_verb alc882_targa_verbs[] = {
6433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6435
6436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6437 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006438
Kailang Yang272a5272007-05-14 11:00:38 +02006439 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6440 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6441 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6442
6443 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6444 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6445 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6446 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6447 { } /* end */
6448};
6449
6450/* toggle speaker-output according to the hp-jack state */
6451static void alc882_targa_automute(struct hda_codec *codec)
6452{
6453 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006454
Kailang Yang272a5272007-05-14 11:00:38 +02006455 present = snd_hda_codec_read(codec, 0x14, 0,
6456 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006457 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006459 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6460 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006461}
6462
6463static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6464{
6465 /* Looks like the unsol event is incompatible with the standard
6466 * definition. 4bit tag is placed at 26 bit!
6467 */
6468 if (((res >> 26) == ALC880_HP_EVENT)) {
6469 alc882_targa_automute(codec);
6470 }
6471}
6472
6473static struct hda_verb alc882_asus_a7j_verbs[] = {
6474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6476
6477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006480
Kailang Yang272a5272007-05-14 11:00:38 +02006481 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6483 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6484
6485 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6486 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6487 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6488 { } /* end */
6489};
6490
Takashi Iwai914759b2007-09-06 14:52:04 +02006491static struct hda_verb alc882_asus_a7m_verbs[] = {
6492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6494
6495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006498
Takashi Iwai914759b2007-09-06 14:52:04 +02006499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6500 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6501 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6502
6503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6506 { } /* end */
6507};
6508
Tobin Davis9102cd12006-12-15 10:02:12 +01006509static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6510{
6511 unsigned int gpiostate, gpiomask, gpiodir;
6512
6513 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6514 AC_VERB_GET_GPIO_DATA, 0);
6515
6516 if (!muted)
6517 gpiostate |= (1 << pin);
6518 else
6519 gpiostate &= ~(1 << pin);
6520
6521 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6522 AC_VERB_GET_GPIO_MASK, 0);
6523 gpiomask |= (1 << pin);
6524
6525 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6526 AC_VERB_GET_GPIO_DIRECTION, 0);
6527 gpiodir |= (1 << pin);
6528
6529
6530 snd_hda_codec_write(codec, codec->afg, 0,
6531 AC_VERB_SET_GPIO_MASK, gpiomask);
6532 snd_hda_codec_write(codec, codec->afg, 0,
6533 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6534
6535 msleep(1);
6536
6537 snd_hda_codec_write(codec, codec->afg, 0,
6538 AC_VERB_SET_GPIO_DATA, gpiostate);
6539}
6540
Takashi Iwai7debbe52007-08-16 15:01:03 +02006541/* set up GPIO at initialization */
6542static void alc885_macpro_init_hook(struct hda_codec *codec)
6543{
6544 alc882_gpio_mute(codec, 0, 0);
6545 alc882_gpio_mute(codec, 1, 0);
6546}
6547
6548/* set up GPIO and update auto-muting at initialization */
6549static void alc885_imac24_init_hook(struct hda_codec *codec)
6550{
6551 alc885_macpro_init_hook(codec);
6552 alc885_imac24_automute(codec);
6553}
6554
Kailang Yangdf694da2005-12-05 19:42:22 +01006555/*
6556 * generic initialization of ADC, input mixers and output mixers
6557 */
6558static struct hda_verb alc882_auto_init_verbs[] = {
6559 /*
6560 * Unmute ADC0-2 and set the default input to mic-in
6561 */
6562 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6564 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6566 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6568
Takashi Iwaicb53c622007-08-10 17:21:45 +02006569 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006570 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006571 * Note: PASD motherboards uses the Line In 2 as the input for
6572 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 */
6574 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006580
6581 /*
6582 * Set up output mixers (0x0c - 0x0f)
6583 */
6584 /* set vol=0 to output mixers */
6585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6588 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6589 /* set up input amps for analog loopback */
6590 /* Amp Indices: DAC = 0, mixer = 1 */
6591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6593 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6597 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6599 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6600 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6601
6602 /* FIXME: use matrix-type input source selection */
6603 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6604 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6609 /* Input mixer2 */
6610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6614 /* Input mixer3 */
6615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6619
6620 { }
6621};
6622
Takashi Iwaicb53c622007-08-10 17:21:45 +02006623#ifdef CONFIG_SND_HDA_POWER_SAVE
6624#define alc882_loopbacks alc880_loopbacks
6625#endif
6626
Kailang Yangdf694da2005-12-05 19:42:22 +01006627/* pcm configuration: identiacal with ALC880 */
6628#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6629#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6630#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6631#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6632
6633/*
6634 * configuration and preset
6635 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006636static const char *alc882_models[ALC882_MODEL_LAST] = {
6637 [ALC882_3ST_DIG] = "3stack-dig",
6638 [ALC882_6ST_DIG] = "6stack-dig",
6639 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006640 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006641 [ALC882_TARGA] = "targa",
6642 [ALC882_ASUS_A7J] = "asus-a7j",
6643 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006644 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006645 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006646 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006647 [ALC882_AUTO] = "auto",
6648};
6649
6650static struct snd_pci_quirk alc882_cfg_tbl[] = {
6651 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006652 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006653 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006654 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006655 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006656 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006657 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006658 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006659 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006660 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6661 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6662 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006663 {}
6664};
6665
6666static struct alc_config_preset alc882_presets[] = {
6667 [ALC882_3ST_DIG] = {
6668 .mixers = { alc882_base_mixer },
6669 .init_verbs = { alc882_init_verbs },
6670 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6671 .dac_nids = alc882_dac_nids,
6672 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006673 .dig_in_nid = ALC882_DIGIN_NID,
6674 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6675 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006676 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 .input_mux = &alc882_capture_source,
6678 },
6679 [ALC882_6ST_DIG] = {
6680 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6681 .init_verbs = { alc882_init_verbs },
6682 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6683 .dac_nids = alc882_dac_nids,
6684 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006685 .dig_in_nid = ALC882_DIGIN_NID,
6686 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6687 .channel_mode = alc882_sixstack_modes,
6688 .input_mux = &alc882_capture_source,
6689 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006690 [ALC882_ARIMA] = {
6691 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6692 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6693 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6694 .dac_nids = alc882_dac_nids,
6695 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6696 .channel_mode = alc882_sixstack_modes,
6697 .input_mux = &alc882_capture_source,
6698 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006699 [ALC882_W2JC] = {
6700 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6701 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6702 alc880_gpio1_init_verbs },
6703 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6704 .dac_nids = alc882_dac_nids,
6705 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6706 .channel_mode = alc880_threestack_modes,
6707 .need_dac_fix = 1,
6708 .input_mux = &alc882_capture_source,
6709 .dig_out_nid = ALC882_DIGOUT_NID,
6710 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006711 [ALC885_MBP3] = {
6712 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6713 .init_verbs = { alc885_mbp3_init_verbs,
6714 alc880_gpio1_init_verbs },
6715 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6716 .dac_nids = alc882_dac_nids,
6717 .channel_mode = alc885_mbp_6ch_modes,
6718 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6719 .input_mux = &alc882_capture_source,
6720 .dig_out_nid = ALC882_DIGOUT_NID,
6721 .dig_in_nid = ALC882_DIGIN_NID,
6722 .unsol_event = alc885_mbp3_unsol_event,
6723 .init_hook = alc885_mbp3_automute,
6724 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006725 [ALC885_MACPRO] = {
6726 .mixers = { alc882_macpro_mixer },
6727 .init_verbs = { alc882_macpro_init_verbs },
6728 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6729 .dac_nids = alc882_dac_nids,
6730 .dig_out_nid = ALC882_DIGOUT_NID,
6731 .dig_in_nid = ALC882_DIGIN_NID,
6732 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6733 .channel_mode = alc882_ch_modes,
6734 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006735 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006736 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006737 [ALC885_IMAC24] = {
6738 .mixers = { alc885_imac24_mixer },
6739 .init_verbs = { alc885_imac24_init_verbs },
6740 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6741 .dac_nids = alc882_dac_nids,
6742 .dig_out_nid = ALC882_DIGOUT_NID,
6743 .dig_in_nid = ALC882_DIGIN_NID,
6744 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6745 .channel_mode = alc882_ch_modes,
6746 .input_mux = &alc882_capture_source,
6747 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006748 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006749 },
Kailang Yang272a5272007-05-14 11:00:38 +02006750 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006751 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006752 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6753 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6754 .dac_nids = alc882_dac_nids,
6755 .dig_out_nid = ALC882_DIGOUT_NID,
6756 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6757 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006758 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006759 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6760 .channel_mode = alc882_3ST_6ch_modes,
6761 .need_dac_fix = 1,
6762 .input_mux = &alc882_capture_source,
6763 .unsol_event = alc882_targa_unsol_event,
6764 .init_hook = alc882_targa_automute,
6765 },
6766 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006767 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006768 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6769 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6770 .dac_nids = alc882_dac_nids,
6771 .dig_out_nid = ALC882_DIGOUT_NID,
6772 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6773 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006774 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006775 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6776 .channel_mode = alc882_3ST_6ch_modes,
6777 .need_dac_fix = 1,
6778 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006779 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006780 [ALC882_ASUS_A7M] = {
6781 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6782 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6783 alc880_gpio1_init_verbs,
6784 alc882_asus_a7m_verbs },
6785 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6786 .dac_nids = alc882_dac_nids,
6787 .dig_out_nid = ALC882_DIGOUT_NID,
6788 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6789 .channel_mode = alc880_threestack_modes,
6790 .need_dac_fix = 1,
6791 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006792 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006793};
6794
6795
6796/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006797 * Pin config fixes
6798 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006799enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006800 PINFIX_ABIT_AW9D_MAX
6801};
6802
6803static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6804 { 0x15, 0x01080104 }, /* side */
6805 { 0x16, 0x01011012 }, /* rear */
6806 { 0x17, 0x01016011 }, /* clfe */
6807 { }
6808};
6809
6810static const struct alc_pincfg *alc882_pin_fixes[] = {
6811 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6812};
6813
6814static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6815 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6816 {}
6817};
6818
6819/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 * BIOS auto configuration
6821 */
6822static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6823 hda_nid_t nid, int pin_type,
6824 int dac_idx)
6825{
6826 /* set as output */
6827 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006828 int idx;
6829
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006830 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006831 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6832 idx = 4;
6833 else
6834 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006835 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6836
6837}
6838
6839static void alc882_auto_init_multi_out(struct hda_codec *codec)
6840{
6841 struct alc_spec *spec = codec->spec;
6842 int i;
6843
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006844 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006845 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006846 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006847 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006848 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006849 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006850 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006851 }
6852}
6853
6854static void alc882_auto_init_hp_out(struct hda_codec *codec)
6855{
6856 struct alc_spec *spec = codec->spec;
6857 hda_nid_t pin;
6858
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006859 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006860 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006861 /* use dac 0 */
6862 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006863 pin = spec->autocfg.speaker_pins[0];
6864 if (pin)
6865 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006866}
6867
6868#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6869#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6870
6871static void alc882_auto_init_analog_input(struct hda_codec *codec)
6872{
6873 struct alc_spec *spec = codec->spec;
6874 int i;
6875
6876 for (i = 0; i < AUTO_PIN_LAST; i++) {
6877 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006878 unsigned int vref;
6879 if (!nid)
6880 continue;
6881 vref = PIN_IN;
6882 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006883 unsigned int pincap;
6884 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6885 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006886 AC_PINCAP_VREF_80)
6887 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006889 snd_hda_codec_write(codec, nid, 0,
6890 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6891 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6892 snd_hda_codec_write(codec, nid, 0,
6893 AC_VERB_SET_AMP_GAIN_MUTE,
6894 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006895 }
6896}
6897
Takashi Iwaif511b012008-08-15 16:46:42 +02006898static void alc882_auto_init_input_src(struct hda_codec *codec)
6899{
6900 struct alc_spec *spec = codec->spec;
6901 const struct hda_input_mux *imux = spec->input_mux;
6902 int c;
6903
6904 for (c = 0; c < spec->num_adc_nids; c++) {
6905 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6906 hda_nid_t nid = spec->capsrc_nids[c];
6907 int conns, mute, idx, item;
6908
6909 conns = snd_hda_get_connections(codec, nid, conn_list,
6910 ARRAY_SIZE(conn_list));
6911 if (conns < 0)
6912 continue;
6913 for (idx = 0; idx < conns; idx++) {
6914 /* if the current connection is the selected one,
6915 * unmute it as default - otherwise mute it
6916 */
6917 mute = AMP_IN_MUTE(idx);
6918 for (item = 0; item < imux->num_items; item++) {
6919 if (imux->items[item].index == idx) {
6920 if (spec->cur_mux[c] == item)
6921 mute = AMP_IN_UNMUTE(idx);
6922 break;
6923 }
6924 }
6925 snd_hda_codec_write(codec, nid, 0,
6926 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6927 }
6928 }
6929}
6930
Takashi Iwai776e1842007-08-29 15:07:11 +02006931/* add mic boosts if needed */
6932static int alc_auto_add_mic_boost(struct hda_codec *codec)
6933{
6934 struct alc_spec *spec = codec->spec;
6935 int err;
6936 hda_nid_t nid;
6937
6938 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006939 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006940 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6941 "Mic Boost",
6942 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6943 if (err < 0)
6944 return err;
6945 }
6946 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006947 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006948 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6949 "Front Mic Boost",
6950 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6951 if (err < 0)
6952 return err;
6953 }
6954 return 0;
6955}
6956
Kailang Yangdf694da2005-12-05 19:42:22 +01006957/* almost identical with ALC880 parser... */
6958static int alc882_parse_auto_config(struct hda_codec *codec)
6959{
6960 struct alc_spec *spec = codec->spec;
6961 int err = alc880_parse_auto_config(codec);
6962
6963 if (err < 0)
6964 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006965 else if (!err)
6966 return 0; /* no config found */
6967
6968 err = alc_auto_add_mic_boost(codec);
6969 if (err < 0)
6970 return err;
6971
6972 /* hack - override the init verbs */
6973 spec->init_verbs[0] = alc882_auto_init_verbs;
6974
6975 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006976}
6977
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006978/* additional initialization for auto-configuration model */
6979static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006980{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006981 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006982 alc882_auto_init_multi_out(codec);
6983 alc882_auto_init_hp_out(codec);
6984 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006985 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006986 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006987 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006988}
6989
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006990static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6991
Linus Torvalds1da177e2005-04-16 15:20:36 -07006992static int patch_alc882(struct hda_codec *codec)
6993{
6994 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006995 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006996
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006997 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006998 if (spec == NULL)
6999 return -ENOMEM;
7000
Linus Torvalds1da177e2005-04-16 15:20:36 -07007001 codec->spec = spec;
7002
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007003 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7004 alc882_models,
7005 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007006
Kailang Yangdf694da2005-12-05 19:42:22 +01007007 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007008 /* Pick up systems that don't supply PCI SSID */
7009 switch (codec->subsystem_id) {
7010 case 0x106b0c00: /* Mac Pro */
7011 board_config = ALC885_MACPRO;
7012 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007013 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007014 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007015 board_config = ALC885_IMAC24;
7016 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007017 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007018 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007019 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007020 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007021 board_config = ALC885_MBP3;
7022 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007023 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007024 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007025 if (codec->revision_id == 0x100101 ||
7026 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007027 alc_free(codec);
7028 return patch_alc883(codec);
7029 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007030 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7031 "trying auto-probe from BIOS...\n");
7032 board_config = ALC882_AUTO;
7033 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007034 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007035
Takashi Iwaif95474e2007-07-10 00:47:43 +02007036 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7037
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 if (board_config == ALC882_AUTO) {
7039 /* automatic parse from the BIOS config */
7040 err = alc882_parse_auto_config(codec);
7041 if (err < 0) {
7042 alc_free(codec);
7043 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007044 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007045 printk(KERN_INFO
7046 "hda_codec: Cannot set up configuration "
7047 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 board_config = ALC882_3ST_DIG;
7049 }
7050 }
7051
7052 if (board_config != ALC882_AUTO)
7053 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007054
Kailang Yang2f893282008-05-27 12:14:47 +02007055 if (codec->vendor_id == 0x10ec0885) {
7056 spec->stream_name_analog = "ALC885 Analog";
7057 spec->stream_name_digital = "ALC885 Digital";
7058 } else {
7059 spec->stream_name_analog = "ALC882 Analog";
7060 spec->stream_name_digital = "ALC882 Digital";
7061 }
7062
Kailang Yangdf694da2005-12-05 19:42:22 +01007063 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7064 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007065 /* FIXME: setup DAC5 */
7066 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7067 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007068
Kailang Yangdf694da2005-12-05 19:42:22 +01007069 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7070 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007071
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007072 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007073 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007074 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007075 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007076 /* get type */
7077 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007078 if (wcap != AC_WID_AUD_IN) {
7079 spec->adc_nids = alc882_adc_nids_alt;
7080 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007081 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 } else {
7083 spec->adc_nids = alc882_adc_nids;
7084 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007085 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 }
7087 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007088 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007089
Takashi Iwai2134ea42008-01-10 16:53:55 +01007090 spec->vmaster_nid = 0x0c;
7091
Linus Torvalds1da177e2005-04-16 15:20:36 -07007092 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007093 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007094 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007095#ifdef CONFIG_SND_HDA_POWER_SAVE
7096 if (!spec->loopback.amplist)
7097 spec->loopback.amplist = alc882_loopbacks;
7098#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007099 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007100
7101 return 0;
7102}
7103
7104/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007105 * ALC883 support
7106 *
7107 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7108 * configuration. Each pin widget can choose any input DACs and a mixer.
7109 * Each ADC is connected from a mixer of all inputs. This makes possible
7110 * 6-channel independent captures.
7111 *
7112 * In addition, an independent DAC for the multi-playback (not used in this
7113 * driver yet).
7114 */
7115#define ALC883_DIGOUT_NID 0x06
7116#define ALC883_DIGIN_NID 0x0a
7117
Wu Fengguang3ab90932008-11-17 09:51:09 +01007118#define ALC1200_DIGOUT_NID 0x10
7119
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007120static hda_nid_t alc883_dac_nids[4] = {
7121 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007122 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007123};
7124
7125static hda_nid_t alc883_adc_nids[2] = {
7126 /* ADC1-2 */
7127 0x08, 0x09,
7128};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007129
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007130static hda_nid_t alc883_adc_nids_alt[1] = {
7131 /* ADC1 */
7132 0x08,
7133};
7134
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007135static hda_nid_t alc883_adc_nids_rev[2] = {
7136 /* ADC2-1 */
7137 0x09, 0x08
7138};
7139
Takashi Iwaie1406342008-02-11 18:32:32 +01007140static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7141
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007142static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7143
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007144/* input MUX */
7145/* FIXME: should be a matrix-type input source selection */
7146
7147static struct hda_input_mux alc883_capture_source = {
7148 .num_items = 4,
7149 .items = {
7150 { "Mic", 0x0 },
7151 { "Front Mic", 0x1 },
7152 { "Line", 0x2 },
7153 { "CD", 0x4 },
7154 },
7155};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007156
Jiang zhe17bba1b2008-06-04 12:11:07 +02007157static struct hda_input_mux alc883_3stack_6ch_intel = {
7158 .num_items = 4,
7159 .items = {
7160 { "Mic", 0x1 },
7161 { "Front Mic", 0x0 },
7162 { "Line", 0x2 },
7163 { "CD", 0x4 },
7164 },
7165};
7166
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007167static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7168 .num_items = 2,
7169 .items = {
7170 { "Mic", 0x1 },
7171 { "Line", 0x2 },
7172 },
7173};
7174
Kailang Yang272a5272007-05-14 11:00:38 +02007175static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7176 .num_items = 4,
7177 .items = {
7178 { "Mic", 0x0 },
7179 { "iMic", 0x1 },
7180 { "Line", 0x2 },
7181 { "CD", 0x4 },
7182 },
7183};
7184
Jiang zhefb97dc62008-03-06 11:07:11 +01007185static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7186 .num_items = 2,
7187 .items = {
7188 { "Mic", 0x0 },
7189 { "Int Mic", 0x1 },
7190 },
7191};
7192
Kailang Yange2757d52008-08-26 13:17:46 +02007193static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7194 .num_items = 3,
7195 .items = {
7196 { "Mic", 0x0 },
7197 { "Front Mic", 0x1 },
7198 { "Line", 0x4 },
7199 },
7200};
7201
7202static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7203 .num_items = 2,
7204 .items = {
7205 { "Mic", 0x0 },
7206 { "Line", 0x2 },
7207 },
7208};
7209
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007210/*
7211 * 2ch mode
7212 */
7213static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7214 { 2, NULL }
7215};
7216
7217/*
7218 * 2ch mode
7219 */
7220static struct hda_verb alc883_3ST_ch2_init[] = {
7221 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7222 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7223 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7224 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7225 { } /* end */
7226};
7227
7228/*
Tobin Davisb2011312007-09-17 12:45:11 +02007229 * 4ch mode
7230 */
7231static struct hda_verb alc883_3ST_ch4_init[] = {
7232 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7233 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7234 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7235 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7236 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7237 { } /* end */
7238};
7239
7240/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007241 * 6ch mode
7242 */
7243static struct hda_verb alc883_3ST_ch6_init[] = {
7244 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7245 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7246 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7247 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7248 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7249 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7250 { } /* end */
7251};
7252
Tobin Davisb2011312007-09-17 12:45:11 +02007253static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007254 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007255 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007256 { 6, alc883_3ST_ch6_init },
7257};
7258
7259/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007260 * 2ch mode
7261 */
7262static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7263 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7264 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7265 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7266 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7267 { } /* end */
7268};
7269
7270/*
7271 * 4ch mode
7272 */
7273static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7274 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7275 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7276 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7277 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7278 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7279 { } /* end */
7280};
7281
7282/*
7283 * 6ch mode
7284 */
7285static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7286 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7287 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7288 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7289 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7290 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7291 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7292 { } /* end */
7293};
7294
7295static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7296 { 2, alc883_3ST_ch2_intel_init },
7297 { 4, alc883_3ST_ch4_intel_init },
7298 { 6, alc883_3ST_ch6_intel_init },
7299};
7300
7301/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007302 * 6ch mode
7303 */
7304static struct hda_verb alc883_sixstack_ch6_init[] = {
7305 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7306 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7307 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7308 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7309 { } /* end */
7310};
7311
7312/*
7313 * 8ch mode
7314 */
7315static struct hda_verb alc883_sixstack_ch8_init[] = {
7316 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7317 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7318 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7319 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7320 { } /* end */
7321};
7322
7323static struct hda_channel_mode alc883_sixstack_modes[2] = {
7324 { 6, alc883_sixstack_ch6_init },
7325 { 8, alc883_sixstack_ch8_init },
7326};
7327
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007328static struct hda_verb alc883_medion_eapd_verbs[] = {
7329 /* eanable EAPD on medion laptop */
7330 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7331 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7332 { }
7333};
7334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007335/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7336 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7337 */
7338
7339static struct snd_kcontrol_new alc883_base_mixer[] = {
7340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7341 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7343 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7348 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7349 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007359 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7361 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7362 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007363 { } /* end */
7364};
7365
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007366static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7368 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7369 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7370 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7371 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7372 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7375 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7378 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7379 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007380 { } /* end */
7381};
7382
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007383static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007384 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7385 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7386 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7387 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7391 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7392 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7393 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007394 { } /* end */
7395};
7396
Jiang zhefb97dc62008-03-06 11:07:11 +01007397static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7398 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7399 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7400 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7401 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7405 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7406 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7407 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007408 { } /* end */
7409};
7410
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007411static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7415 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7416 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7417 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7418 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007423 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7425 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7426 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007427 { } /* end */
7428};
7429
7430static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7433 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7434 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7435 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7436 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7437 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7438 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7450 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7451 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007452 { } /* end */
7453};
7454
Jiang zhe17bba1b2008-06-04 12:11:07 +02007455static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7456 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7457 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7458 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7459 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7460 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7461 HDA_OUTPUT),
7462 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7463 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7464 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7465 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7467 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7471 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7473 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7476 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7477 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007478 { } /* end */
7479};
7480
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007481static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007482 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007483 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007484 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007485 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007486 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7487 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007488 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7489 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7491 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7492 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7493 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7494 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007496 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7498 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007499 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7501 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7502 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007503 { } /* end */
7504};
7505
Kailang Yangccc656c2006-10-17 12:32:26 +02007506static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7507 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7509 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7510 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7511 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7512 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7513 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7514 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7515 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007521 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007523 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007524};
Kailang Yangccc656c2006-10-17 12:32:26 +02007525
7526static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7529 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7531 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007535 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7537 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007538 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007539};
Kailang Yangccc656c2006-10-17 12:32:26 +02007540
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007541static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7542 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007544 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7545 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007550 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007551};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007552
Kailang Yang272a5272007-05-14 11:00:38 +02007553static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7554 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7555 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7557 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7558 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7561 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7562 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007563 { } /* end */
7564};
7565
7566static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7569 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7570 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7571 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007576 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007577};
Kailang Yang272a5272007-05-14 11:00:38 +02007578
Tobin Davis2880a862007-08-07 11:50:26 +02007579static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007583 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7584 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7586 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007588 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007589};
Tobin Davis2880a862007-08-07 11:50:26 +02007590
Kailang Yange2757d52008-08-26 13:17:46 +02007591static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7592 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7593 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7594 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7595 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7596 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7597 0x0d, 1, 0x0, HDA_OUTPUT),
7598 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7599 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7600 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7601 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7602 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7604 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7610 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007615 { } /* end */
7616};
7617
7618static struct hda_bind_ctls alc883_bind_cap_vol = {
7619 .ops = &snd_hda_bind_vol,
7620 .values = {
7621 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7622 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7623 0
7624 },
7625};
7626
7627static struct hda_bind_ctls alc883_bind_cap_switch = {
7628 .ops = &snd_hda_bind_sw,
7629 .values = {
7630 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7631 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7632 0
7633 },
7634};
7635
7636static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007645 { } /* end */
7646};
7647
7648static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007649 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7650 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7651 {
7652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7653 /* .name = "Capture Source", */
7654 .name = "Input Source",
7655 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007656 .info = alc_mux_enum_info,
7657 .get = alc_mux_enum_get,
7658 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007659 },
7660 { } /* end */
7661};
7662
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007663static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7664 {
7665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7666 .name = "Channel Mode",
7667 .info = alc_ch_mode_info,
7668 .get = alc_ch_mode_get,
7669 .put = alc_ch_mode_put,
7670 },
7671 { } /* end */
7672};
7673
7674static struct hda_verb alc883_init_verbs[] = {
7675 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007677 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7678 /* ADC2: mute amp left and right */
7679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7680 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7681 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7685 /* Rear mixer */
7686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7689 /* CLFE mixer */
7690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7692 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7693 /* Side mixer */
7694 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7695 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7696 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7697
Takashi Iwaicb53c622007-08-10 17:21:45 +02007698 /* mute analog input loopbacks */
7699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007704
7705 /* Front Pin: output 0 (0x0c) */
7706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7707 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7708 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7709 /* Rear Pin: output 1 (0x0d) */
7710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7712 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7713 /* CLFE Pin: output 2 (0x0e) */
7714 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7716 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7717 /* Side Pin: output 3 (0x0f) */
7718 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7719 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7720 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7721 /* Mic (rear) pin: input vref at 80% */
7722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7724 /* Front Mic pin: input vref at 80% */
7725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7727 /* Line In pin: input */
7728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7730 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7734 /* CD pin widget for input */
7735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7736
7737 /* FIXME: use matrix-type input source selection */
7738 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7739 /* Input mixer2 */
7740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7742 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7743 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007744 /* Input mixer3 */
7745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007749 { }
7750};
7751
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007752/* toggle speaker-output according to the hp-jack state */
7753static void alc883_mitac_hp_automute(struct hda_codec *codec)
7754{
7755 unsigned int present;
7756
7757 present = snd_hda_codec_read(codec, 0x15, 0,
7758 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7759 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7760 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7761 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7762 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7763}
7764
7765/* auto-toggle front mic */
7766/*
7767static void alc883_mitac_mic_automute(struct hda_codec *codec)
7768{
7769 unsigned int present;
7770 unsigned char bits;
7771
7772 present = snd_hda_codec_read(codec, 0x18, 0,
7773 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7774 bits = present ? HDA_AMP_MUTE : 0;
7775 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7776}
7777*/
7778
7779static void alc883_mitac_automute(struct hda_codec *codec)
7780{
7781 alc883_mitac_hp_automute(codec);
7782 /* alc883_mitac_mic_automute(codec); */
7783}
7784
7785static void alc883_mitac_unsol_event(struct hda_codec *codec,
7786 unsigned int res)
7787{
7788 switch (res >> 26) {
7789 case ALC880_HP_EVENT:
7790 alc883_mitac_hp_automute(codec);
7791 break;
7792 case ALC880_MIC_EVENT:
7793 /* alc883_mitac_mic_automute(codec); */
7794 break;
7795 }
7796}
7797
7798static struct hda_verb alc883_mitac_verbs[] = {
7799 /* HP */
7800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7802 /* Subwoofer */
7803 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7804 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7805
7806 /* enable unsolicited event */
7807 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7808 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7809
7810 { } /* end */
7811};
7812
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007813static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007814 /* HP */
7815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7817 /* Int speaker */
7818 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7820
7821 /* enable unsolicited event */
7822 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007823 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007824
7825 { } /* end */
7826};
7827
Jiang zhefb97dc62008-03-06 11:07:11 +01007828static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7829 /* HP */
7830 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7832 /* Subwoofer */
7833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7835
7836 /* enable unsolicited event */
7837 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7838
7839 { } /* end */
7840};
7841
Kailang Yangccc656c2006-10-17 12:32:26 +02007842static struct hda_verb alc883_tagra_verbs[] = {
7843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7845
7846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7847 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007848
Kailang Yangccc656c2006-10-17 12:32:26 +02007849 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7850 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7851 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7852
7853 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007854 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7855 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7856 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007857
7858 { } /* end */
7859};
7860
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007861static struct hda_verb alc883_lenovo_101e_verbs[] = {
7862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7863 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7864 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7865 { } /* end */
7866};
7867
Kailang Yang272a5272007-05-14 11:00:38 +02007868static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7871 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7873 { } /* end */
7874};
7875
7876static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7878 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7881 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7882 { } /* end */
7883};
7884
Kailang Yang189609a2007-08-20 11:31:23 +02007885static struct hda_verb alc883_haier_w66_verbs[] = {
7886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7888
7889 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7890
7891 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7893 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7895 { } /* end */
7896};
7897
Kailang Yange2757d52008-08-26 13:17:46 +02007898static struct hda_verb alc888_lenovo_sky_verbs[] = {
7899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7904 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7905 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7906 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7907 { } /* end */
7908};
7909
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007910static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007911 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007912 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7913 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007914 { }
7915};
7916
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007917static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7919 { }
7920};
7921
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007922static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007923 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7924 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7925 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7926 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7927 { }
7928};
7929
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007930static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007931 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7932 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7933 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7934 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7935 { }
7936};
7937
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007938static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7939 { 2, alc888_3st_hp_2ch_init },
7940 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007941};
7942
Kailang Yang272a5272007-05-14 11:00:38 +02007943/* toggle front-jack and RCA according to the hp-jack state */
7944static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7945{
7946 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007947
Kailang Yang272a5272007-05-14 11:00:38 +02007948 present = snd_hda_codec_read(codec, 0x1b, 0,
7949 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007950 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7952 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007954}
7955
7956/* toggle RCA according to the front-jack state */
7957static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7958{
7959 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007960
Kailang Yang272a5272007-05-14 11:00:38 +02007961 present = snd_hda_codec_read(codec, 0x14, 0,
7962 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007963 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7964 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007965}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007966
Kailang Yang272a5272007-05-14 11:00:38 +02007967static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7968 unsigned int res)
7969{
7970 if ((res >> 26) == ALC880_HP_EVENT)
7971 alc888_lenovo_ms7195_front_automute(codec);
7972 if ((res >> 26) == ALC880_FRONT_EVENT)
7973 alc888_lenovo_ms7195_rca_automute(codec);
7974}
7975
7976static struct hda_verb alc883_medion_md2_verbs[] = {
7977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7979
7980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7981
7982 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7983 { } /* end */
7984};
7985
7986/* toggle speaker-output according to the hp-jack state */
7987static void alc883_medion_md2_automute(struct hda_codec *codec)
7988{
7989 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007990
Kailang Yang272a5272007-05-14 11:00:38 +02007991 present = snd_hda_codec_read(codec, 0x14, 0,
7992 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007993 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7994 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007995}
7996
7997static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7998 unsigned int res)
7999{
8000 if ((res >> 26) == ALC880_HP_EVENT)
8001 alc883_medion_md2_automute(codec);
8002}
8003
Kailang Yangccc656c2006-10-17 12:32:26 +02008004/* toggle speaker-output according to the hp-jack state */
8005static void alc883_tagra_automute(struct hda_codec *codec)
8006{
8007 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008008 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008009
8010 present = snd_hda_codec_read(codec, 0x14, 0,
8011 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008012 bits = present ? HDA_AMP_MUTE : 0;
8013 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8014 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008015 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8016 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008017}
8018
8019static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8020{
8021 if ((res >> 26) == ALC880_HP_EVENT)
8022 alc883_tagra_automute(codec);
8023}
8024
Jiang zhe368c7a92008-03-04 11:20:33 +01008025/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008026static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008027{
8028 unsigned int present;
8029 unsigned char bits;
8030
8031 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8032 & AC_PINSENSE_PRESENCE;
8033 bits = present ? HDA_AMP_MUTE : 0;
8034 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8035 HDA_AMP_MUTE, bits);
8036}
8037
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008038static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8039{
8040 unsigned int present;
8041
8042 present = snd_hda_codec_read(codec, 0x18, 0,
8043 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8044 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8045 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8046}
8047
8048static void alc883_clevo_m720_automute(struct hda_codec *codec)
8049{
8050 alc883_clevo_m720_hp_automute(codec);
8051 alc883_clevo_m720_mic_automute(codec);
8052}
8053
8054static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008055 unsigned int res)
8056{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008057 switch (res >> 26) {
8058 case ALC880_HP_EVENT:
8059 alc883_clevo_m720_hp_automute(codec);
8060 break;
8061 case ALC880_MIC_EVENT:
8062 alc883_clevo_m720_mic_automute(codec);
8063 break;
8064 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008065}
8066
Jiang zhefb97dc62008-03-06 11:07:11 +01008067/* toggle speaker-output according to the hp-jack state */
8068static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8069{
8070 unsigned int present;
8071 unsigned char bits;
8072
8073 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8074 & AC_PINSENSE_PRESENCE;
8075 bits = present ? HDA_AMP_MUTE : 0;
8076 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8077 HDA_AMP_MUTE, bits);
8078}
8079
8080static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8081 unsigned int res)
8082{
8083 if ((res >> 26) == ALC880_HP_EVENT)
8084 alc883_2ch_fujitsu_pi2515_automute(codec);
8085}
8086
Kailang Yang189609a2007-08-20 11:31:23 +02008087static void alc883_haier_w66_automute(struct hda_codec *codec)
8088{
8089 unsigned int present;
8090 unsigned char bits;
8091
8092 present = snd_hda_codec_read(codec, 0x1b, 0,
8093 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8094 bits = present ? 0x80 : 0;
8095 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8096 0x80, bits);
8097}
8098
8099static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8100 unsigned int res)
8101{
8102 if ((res >> 26) == ALC880_HP_EVENT)
8103 alc883_haier_w66_automute(codec);
8104}
8105
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008106static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8107{
8108 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008109 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008110
8111 present = snd_hda_codec_read(codec, 0x14, 0,
8112 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008113 bits = present ? HDA_AMP_MUTE : 0;
8114 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8115 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008116}
8117
8118static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8119{
8120 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008121 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008122
8123 present = snd_hda_codec_read(codec, 0x1b, 0,
8124 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008125 bits = present ? HDA_AMP_MUTE : 0;
8126 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8127 HDA_AMP_MUTE, bits);
8128 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8129 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008130}
8131
8132static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8133 unsigned int res)
8134{
8135 if ((res >> 26) == ALC880_HP_EVENT)
8136 alc883_lenovo_101e_all_automute(codec);
8137 if ((res >> 26) == ALC880_FRONT_EVENT)
8138 alc883_lenovo_101e_ispeaker_automute(codec);
8139}
8140
Takashi Iwai676a9b52007-08-16 15:23:35 +02008141/* toggle speaker-output according to the hp-jack state */
8142static void alc883_acer_aspire_automute(struct hda_codec *codec)
8143{
8144 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008145
Takashi Iwai676a9b52007-08-16 15:23:35 +02008146 present = snd_hda_codec_read(codec, 0x14, 0,
8147 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8148 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8149 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8150 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8152}
8153
8154static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8155 unsigned int res)
8156{
8157 if ((res >> 26) == ALC880_HP_EVENT)
8158 alc883_acer_aspire_automute(codec);
8159}
8160
Kailang Yangd1a991a2007-08-15 16:21:59 +02008161static struct hda_verb alc883_acer_eapd_verbs[] = {
8162 /* HP Pin: output 0 (0x0c) */
8163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8165 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8166 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8168 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008170 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8171 /* eanable EAPD on medion laptop */
8172 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8173 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008174 /* enable unsolicited event */
8175 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008176 { }
8177};
8178
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008179static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8180{
8181 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008182
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008183 present = snd_hda_codec_read(codec, 0x1b, 0,
8184 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8185 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8186 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8187 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8188 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8189 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8190 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8191 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8192 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8193}
8194
8195static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8196 unsigned int res)
8197{
8198 switch (res >> 26) {
8199 case ALC880_HP_EVENT:
8200 printk("hp_event\n");
8201 alc888_6st_dell_front_automute(codec);
8202 break;
8203 }
8204}
8205
Kailang Yange2757d52008-08-26 13:17:46 +02008206static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8207{
8208 unsigned int mute;
8209 unsigned int present;
8210
8211 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8212 present = snd_hda_codec_read(codec, 0x1b, 0,
8213 AC_VERB_GET_PIN_SENSE, 0);
8214 present = (present & 0x80000000) != 0;
8215 if (present) {
8216 /* mute internal speaker */
8217 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8218 HDA_AMP_MUTE, HDA_AMP_MUTE);
8219 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8220 HDA_AMP_MUTE, HDA_AMP_MUTE);
8221 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8222 HDA_AMP_MUTE, HDA_AMP_MUTE);
8223 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8224 HDA_AMP_MUTE, HDA_AMP_MUTE);
8225 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8226 HDA_AMP_MUTE, HDA_AMP_MUTE);
8227 } else {
8228 /* unmute internal speaker if necessary */
8229 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8230 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8231 HDA_AMP_MUTE, mute);
8232 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8233 HDA_AMP_MUTE, mute);
8234 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8235 HDA_AMP_MUTE, mute);
8236 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8237 HDA_AMP_MUTE, mute);
8238 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8239 HDA_AMP_MUTE, mute);
8240 }
8241}
8242
8243static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8244 unsigned int res)
8245{
8246 if ((res >> 26) == ALC880_HP_EVENT)
8247 alc888_lenovo_sky_front_automute(codec);
8248}
8249
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008250/*
8251 * generic initialization of ADC, input mixers and output mixers
8252 */
8253static struct hda_verb alc883_auto_init_verbs[] = {
8254 /*
8255 * Unmute ADC0-2 and set the default input to mic-in
8256 */
8257 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8258 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8259 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8261
Takashi Iwaicb53c622007-08-10 17:21:45 +02008262 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008263 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008264 * Note: PASD motherboards uses the Line In 2 as the input for
8265 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008266 */
8267 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008273
8274 /*
8275 * Set up output mixers (0x0c - 0x0f)
8276 */
8277 /* set vol=0 to output mixers */
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8282 /* set up input amps for analog loopback */
8283 /* Amp Indices: DAC = 0, mixer = 1 */
8284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8292 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8293 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8294
8295 /* FIXME: use matrix-type input source selection */
8296 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8297 /* Input mixer1 */
8298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008301 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8303 /* Input mixer2 */
8304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008307 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008309
8310 { }
8311};
8312
Kailang Yange2757d52008-08-26 13:17:46 +02008313static struct hda_verb alc888_asus_m90v_verbs[] = {
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8317 /* enable unsolicited event */
8318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8320 { } /* end */
8321};
8322
8323static void alc883_nb_mic_automute(struct hda_codec *codec)
8324{
8325 unsigned int present;
8326
8327 present = snd_hda_codec_read(codec, 0x18, 0,
8328 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8329 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8330 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8331 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8332 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8333}
8334
8335static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8336{
8337 unsigned int present;
8338 unsigned char bits;
8339
8340 present = snd_hda_codec_read(codec, 0x1b, 0,
8341 AC_VERB_GET_PIN_SENSE, 0)
8342 & AC_PINSENSE_PRESENCE;
8343 bits = present ? 0 : PIN_OUT;
8344 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8345 bits);
8346 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8347 bits);
8348 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8349 bits);
8350}
8351
8352static void alc883_mode2_unsol_event(struct hda_codec *codec,
8353 unsigned int res)
8354{
8355 switch (res >> 26) {
8356 case ALC880_HP_EVENT:
8357 alc883_M90V_speaker_automute(codec);
8358 break;
8359 case ALC880_MIC_EVENT:
8360 alc883_nb_mic_automute(codec);
8361 break;
8362 }
8363}
8364
8365static void alc883_mode2_inithook(struct hda_codec *codec)
8366{
8367 alc883_M90V_speaker_automute(codec);
8368 alc883_nb_mic_automute(codec);
8369}
8370
8371static struct hda_verb alc888_asus_eee1601_verbs[] = {
8372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8377 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8378 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8379 /* enable unsolicited event */
8380 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8381 { } /* end */
8382};
8383
8384static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8385{
8386 unsigned int present;
8387 unsigned char bits;
8388
8389 present = snd_hda_codec_read(codec, 0x14, 0,
8390 AC_VERB_GET_PIN_SENSE, 0)
8391 & AC_PINSENSE_PRESENCE;
8392 bits = present ? 0 : PIN_OUT;
8393 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8394 bits);
8395}
8396
8397static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8398 unsigned int res)
8399{
8400 switch (res >> 26) {
8401 case ALC880_HP_EVENT:
8402 alc883_eee1601_speaker_automute(codec);
8403 break;
8404 }
8405}
8406
8407static void alc883_eee1601_inithook(struct hda_codec *codec)
8408{
8409 alc883_eee1601_speaker_automute(codec);
8410}
8411
Takashi Iwaicb53c622007-08-10 17:21:45 +02008412#ifdef CONFIG_SND_HDA_POWER_SAVE
8413#define alc883_loopbacks alc880_loopbacks
8414#endif
8415
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008416/* pcm configuration: identiacal with ALC880 */
8417#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8418#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008419#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008420#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8421#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8422
8423/*
8424 * configuration and preset
8425 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008426static const char *alc883_models[ALC883_MODEL_LAST] = {
8427 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8428 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8429 [ALC883_3ST_6ch] = "3stack-6ch",
8430 [ALC883_6ST_DIG] = "6stack-dig",
8431 [ALC883_TARGA_DIG] = "targa-dig",
8432 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008433 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008434 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008435 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008436 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008437 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008438 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008439 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008440 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8441 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008442 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008443 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008444 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008445 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008446 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008447 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008448 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008449 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008450 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008451 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008452 [ALC883_AUTO] = "auto",
8453};
8454
8455static struct snd_pci_quirk alc883_cfg_tbl[] = {
8456 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008457 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008458 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008459 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8460 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008461 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008462 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8463 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008464 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8465 ALC888_ACER_ASPIRE_4930G),
8466 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8467 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008468 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008469 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008470 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008471 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8472 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008473 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008474 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008475 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008476 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008477 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008478 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008479 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008480 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008481 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8482 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008483 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008484 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008485 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008486 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8487 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8488 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008489 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008490 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008491 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008492 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8493 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8494 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8495 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8496 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8497 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8498 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8499 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8500 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008501 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8502 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008503 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008504 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008505 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008506 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008507 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008508 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008509 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008510 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8511 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008512 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008513 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008514 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008515 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008516 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8517 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008518 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008519 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008520 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8521 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008522 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008523 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008524 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008525 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008526 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008527 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8528 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008529 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008530 {}
8531};
8532
8533static struct alc_config_preset alc883_presets[] = {
8534 [ALC883_3ST_2ch_DIG] = {
8535 .mixers = { alc883_3ST_2ch_mixer },
8536 .init_verbs = { alc883_init_verbs },
8537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8538 .dac_nids = alc883_dac_nids,
8539 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008540 .dig_in_nid = ALC883_DIGIN_NID,
8541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8542 .channel_mode = alc883_3ST_2ch_modes,
8543 .input_mux = &alc883_capture_source,
8544 },
8545 [ALC883_3ST_6ch_DIG] = {
8546 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8547 .init_verbs = { alc883_init_verbs },
8548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8549 .dac_nids = alc883_dac_nids,
8550 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008551 .dig_in_nid = ALC883_DIGIN_NID,
8552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8553 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008554 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008555 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008556 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008557 [ALC883_3ST_6ch] = {
8558 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8559 .init_verbs = { alc883_init_verbs },
8560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8561 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8563 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008564 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008565 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008566 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008567 [ALC883_3ST_6ch_INTEL] = {
8568 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8569 .init_verbs = { alc883_init_verbs },
8570 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8571 .dac_nids = alc883_dac_nids,
8572 .dig_out_nid = ALC883_DIGOUT_NID,
8573 .dig_in_nid = ALC883_DIGIN_NID,
8574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8575 .channel_mode = alc883_3ST_6ch_intel_modes,
8576 .need_dac_fix = 1,
8577 .input_mux = &alc883_3stack_6ch_intel,
8578 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008579 [ALC883_6ST_DIG] = {
8580 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8581 .init_verbs = { alc883_init_verbs },
8582 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8583 .dac_nids = alc883_dac_nids,
8584 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008585 .dig_in_nid = ALC883_DIGIN_NID,
8586 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8587 .channel_mode = alc883_sixstack_modes,
8588 .input_mux = &alc883_capture_source,
8589 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008590 [ALC883_TARGA_DIG] = {
8591 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8592 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8594 .dac_nids = alc883_dac_nids,
8595 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8597 .channel_mode = alc883_3ST_6ch_modes,
8598 .need_dac_fix = 1,
8599 .input_mux = &alc883_capture_source,
8600 .unsol_event = alc883_tagra_unsol_event,
8601 .init_hook = alc883_tagra_automute,
8602 },
8603 [ALC883_TARGA_2ch_DIG] = {
8604 .mixers = { alc883_tagra_2ch_mixer},
8605 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8607 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008608 .adc_nids = alc883_adc_nids_alt,
8609 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008610 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008611 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8612 .channel_mode = alc883_3ST_2ch_modes,
8613 .input_mux = &alc883_capture_source,
8614 .unsol_event = alc883_tagra_unsol_event,
8615 .init_hook = alc883_tagra_automute,
8616 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008617 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008618 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008619 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8620 * and the headphone jack. Turn this on and rely on the
8621 * standard mute methods whenever the user wants to turn
8622 * these outputs off.
8623 */
8624 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8625 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8626 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008627 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8628 .channel_mode = alc883_3ST_2ch_modes,
8629 .input_mux = &alc883_capture_source,
8630 },
Tobin Davis2880a862007-08-07 11:50:26 +02008631 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008632 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008633 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008634 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8635 .dac_nids = alc883_dac_nids,
8636 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008637 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8638 .channel_mode = alc883_3ST_2ch_modes,
8639 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008640 .unsol_event = alc883_acer_aspire_unsol_event,
8641 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008642 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008643 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008644 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008645 alc883_chmode_mixer },
8646 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8647 alc888_acer_aspire_4930g_verbs },
8648 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8649 .dac_nids = alc883_dac_nids,
8650 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8651 .adc_nids = alc883_adc_nids_rev,
8652 .capsrc_nids = alc883_capsrc_nids_rev,
8653 .dig_out_nid = ALC883_DIGOUT_NID,
8654 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8655 .channel_mode = alc883_3ST_6ch_modes,
8656 .need_dac_fix = 1,
8657 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008658 ARRAY_SIZE(alc888_2_capture_sources),
8659 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008660 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8661 .init_hook = alc888_acer_aspire_4930g_automute,
8662 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008663 [ALC883_MEDION] = {
8664 .mixers = { alc883_fivestack_mixer,
8665 alc883_chmode_mixer },
8666 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008667 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8669 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008670 .adc_nids = alc883_adc_nids_alt,
8671 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008672 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8673 .channel_mode = alc883_sixstack_modes,
8674 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008675 },
Kailang Yang272a5272007-05-14 11:00:38 +02008676 [ALC883_MEDION_MD2] = {
8677 .mixers = { alc883_medion_md2_mixer},
8678 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8679 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8680 .dac_nids = alc883_dac_nids,
8681 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008682 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8683 .channel_mode = alc883_3ST_2ch_modes,
8684 .input_mux = &alc883_capture_source,
8685 .unsol_event = alc883_medion_md2_unsol_event,
8686 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008687 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008688 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008689 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008690 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8692 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008693 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8694 .channel_mode = alc883_3ST_2ch_modes,
8695 .input_mux = &alc883_capture_source,
8696 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008697 [ALC883_CLEVO_M720] = {
8698 .mixers = { alc883_clevo_m720_mixer },
8699 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8701 .dac_nids = alc883_dac_nids,
8702 .dig_out_nid = ALC883_DIGOUT_NID,
8703 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8704 .channel_mode = alc883_3ST_2ch_modes,
8705 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008706 .unsol_event = alc883_clevo_m720_unsol_event,
8707 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008708 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008709 [ALC883_LENOVO_101E_2ch] = {
8710 .mixers = { alc883_lenovo_101e_2ch_mixer},
8711 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8712 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8713 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008714 .adc_nids = alc883_adc_nids_alt,
8715 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8717 .channel_mode = alc883_3ST_2ch_modes,
8718 .input_mux = &alc883_lenovo_101e_capture_source,
8719 .unsol_event = alc883_lenovo_101e_unsol_event,
8720 .init_hook = alc883_lenovo_101e_all_automute,
8721 },
Kailang Yang272a5272007-05-14 11:00:38 +02008722 [ALC883_LENOVO_NB0763] = {
8723 .mixers = { alc883_lenovo_nb0763_mixer },
8724 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8725 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8726 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008727 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8728 .channel_mode = alc883_3ST_2ch_modes,
8729 .need_dac_fix = 1,
8730 .input_mux = &alc883_lenovo_nb0763_capture_source,
8731 .unsol_event = alc883_medion_md2_unsol_event,
8732 .init_hook = alc883_medion_md2_automute,
8733 },
8734 [ALC888_LENOVO_MS7195_DIG] = {
8735 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8736 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8737 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8738 .dac_nids = alc883_dac_nids,
8739 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8741 .channel_mode = alc883_3ST_6ch_modes,
8742 .need_dac_fix = 1,
8743 .input_mux = &alc883_capture_source,
8744 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8745 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008746 },
8747 [ALC883_HAIER_W66] = {
8748 .mixers = { alc883_tagra_2ch_mixer},
8749 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8750 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8751 .dac_nids = alc883_dac_nids,
8752 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008753 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8754 .channel_mode = alc883_3ST_2ch_modes,
8755 .input_mux = &alc883_capture_source,
8756 .unsol_event = alc883_haier_w66_unsol_event,
8757 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008758 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008759 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008760 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008761 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8763 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008764 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8765 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008766 .need_dac_fix = 1,
8767 .input_mux = &alc883_capture_source,
8768 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008769 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008770 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008771 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8772 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8773 .dac_nids = alc883_dac_nids,
8774 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008775 .dig_in_nid = ALC883_DIGIN_NID,
8776 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8777 .channel_mode = alc883_sixstack_modes,
8778 .input_mux = &alc883_capture_source,
8779 .unsol_event = alc888_6st_dell_unsol_event,
8780 .init_hook = alc888_6st_dell_front_automute,
8781 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008782 [ALC883_MITAC] = {
8783 .mixers = { alc883_mitac_mixer },
8784 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8786 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8788 .channel_mode = alc883_3ST_2ch_modes,
8789 .input_mux = &alc883_capture_source,
8790 .unsol_event = alc883_mitac_unsol_event,
8791 .init_hook = alc883_mitac_automute,
8792 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008793 [ALC883_FUJITSU_PI2515] = {
8794 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8795 .init_verbs = { alc883_init_verbs,
8796 alc883_2ch_fujitsu_pi2515_verbs},
8797 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8798 .dac_nids = alc883_dac_nids,
8799 .dig_out_nid = ALC883_DIGOUT_NID,
8800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8801 .channel_mode = alc883_3ST_2ch_modes,
8802 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8803 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8804 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8805 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008806 [ALC888_FUJITSU_XA3530] = {
8807 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8808 .init_verbs = { alc883_init_verbs,
8809 alc888_fujitsu_xa3530_verbs },
8810 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8811 .dac_nids = alc883_dac_nids,
8812 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8813 .adc_nids = alc883_adc_nids_rev,
8814 .capsrc_nids = alc883_capsrc_nids_rev,
8815 .dig_out_nid = ALC883_DIGOUT_NID,
8816 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8817 .channel_mode = alc888_4ST_8ch_intel_modes,
8818 .num_mux_defs =
8819 ARRAY_SIZE(alc888_2_capture_sources),
8820 .input_mux = alc888_2_capture_sources,
8821 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8822 .init_hook = alc888_fujitsu_xa3530_automute,
8823 },
Kailang Yange2757d52008-08-26 13:17:46 +02008824 [ALC888_LENOVO_SKY] = {
8825 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8826 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8827 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8828 .dac_nids = alc883_dac_nids,
8829 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008830 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8831 .channel_mode = alc883_sixstack_modes,
8832 .need_dac_fix = 1,
8833 .input_mux = &alc883_lenovo_sky_capture_source,
8834 .unsol_event = alc883_lenovo_sky_unsol_event,
8835 .init_hook = alc888_lenovo_sky_front_automute,
8836 },
8837 [ALC888_ASUS_M90V] = {
8838 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8839 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8840 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8841 .dac_nids = alc883_dac_nids,
8842 .dig_out_nid = ALC883_DIGOUT_NID,
8843 .dig_in_nid = ALC883_DIGIN_NID,
8844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8845 .channel_mode = alc883_3ST_6ch_modes,
8846 .need_dac_fix = 1,
8847 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8848 .unsol_event = alc883_mode2_unsol_event,
8849 .init_hook = alc883_mode2_inithook,
8850 },
8851 [ALC888_ASUS_EEE1601] = {
8852 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008853 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008854 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8855 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8856 .dac_nids = alc883_dac_nids,
8857 .dig_out_nid = ALC883_DIGOUT_NID,
8858 .dig_in_nid = ALC883_DIGIN_NID,
8859 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8860 .channel_mode = alc883_3ST_2ch_modes,
8861 .need_dac_fix = 1,
8862 .input_mux = &alc883_asus_eee1601_capture_source,
8863 .unsol_event = alc883_eee1601_unsol_event,
8864 .init_hook = alc883_eee1601_inithook,
8865 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008866 [ALC1200_ASUS_P5Q] = {
8867 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8868 .init_verbs = { alc883_init_verbs },
8869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8870 .dac_nids = alc883_dac_nids,
8871 .dig_out_nid = ALC1200_DIGOUT_NID,
8872 .dig_in_nid = ALC883_DIGIN_NID,
8873 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8874 .channel_mode = alc883_sixstack_modes,
8875 .input_mux = &alc883_capture_source,
8876 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008877};
8878
8879
8880/*
8881 * BIOS auto configuration
8882 */
8883static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8884 hda_nid_t nid, int pin_type,
8885 int dac_idx)
8886{
8887 /* set as output */
8888 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008889 int idx;
8890
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008891 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8893 idx = 4;
8894 else
8895 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008896 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8897
8898}
8899
8900static void alc883_auto_init_multi_out(struct hda_codec *codec)
8901{
8902 struct alc_spec *spec = codec->spec;
8903 int i;
8904
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008905 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008906 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008907 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008908 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008909 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008910 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008911 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008912 }
8913}
8914
8915static void alc883_auto_init_hp_out(struct hda_codec *codec)
8916{
8917 struct alc_spec *spec = codec->spec;
8918 hda_nid_t pin;
8919
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008920 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008921 if (pin) /* connect to front */
8922 /* use dac 0 */
8923 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008924 pin = spec->autocfg.speaker_pins[0];
8925 if (pin)
8926 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008927}
8928
8929#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8930#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8931
8932static void alc883_auto_init_analog_input(struct hda_codec *codec)
8933{
8934 struct alc_spec *spec = codec->spec;
8935 int i;
8936
8937 for (i = 0; i < AUTO_PIN_LAST; i++) {
8938 hda_nid_t nid = spec->autocfg.input_pins[i];
8939 if (alc883_is_input_pin(nid)) {
8940 snd_hda_codec_write(codec, nid, 0,
8941 AC_VERB_SET_PIN_WIDGET_CONTROL,
8942 (i <= AUTO_PIN_FRONT_MIC ?
8943 PIN_VREF80 : PIN_IN));
8944 if (nid != ALC883_PIN_CD_NID)
8945 snd_hda_codec_write(codec, nid, 0,
8946 AC_VERB_SET_AMP_GAIN_MUTE,
8947 AMP_OUT_MUTE);
8948 }
8949 }
8950}
8951
Takashi Iwaif511b012008-08-15 16:46:42 +02008952#define alc883_auto_init_input_src alc882_auto_init_input_src
8953
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008954/* almost identical with ALC880 parser... */
8955static int alc883_parse_auto_config(struct hda_codec *codec)
8956{
8957 struct alc_spec *spec = codec->spec;
8958 int err = alc880_parse_auto_config(codec);
8959
8960 if (err < 0)
8961 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008962 else if (!err)
8963 return 0; /* no config found */
8964
8965 err = alc_auto_add_mic_boost(codec);
8966 if (err < 0)
8967 return err;
8968
8969 /* hack - override the init verbs */
8970 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008971
8972 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008973}
8974
8975/* additional initialization for auto-configuration model */
8976static void alc883_auto_init(struct hda_codec *codec)
8977{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008978 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008979 alc883_auto_init_multi_out(codec);
8980 alc883_auto_init_hp_out(codec);
8981 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008982 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008983 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008984 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008985}
8986
8987static int patch_alc883(struct hda_codec *codec)
8988{
8989 struct alc_spec *spec;
8990 int err, board_config;
8991
8992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8993 if (spec == NULL)
8994 return -ENOMEM;
8995
8996 codec->spec = spec;
8997
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008998 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8999
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009000 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9001 alc883_models,
9002 alc883_cfg_tbl);
9003 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009004 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9005 "trying auto-probe from BIOS...\n");
9006 board_config = ALC883_AUTO;
9007 }
9008
9009 if (board_config == ALC883_AUTO) {
9010 /* automatic parse from the BIOS config */
9011 err = alc883_parse_auto_config(codec);
9012 if (err < 0) {
9013 alc_free(codec);
9014 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009015 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009016 printk(KERN_INFO
9017 "hda_codec: Cannot set up configuration "
9018 "from BIOS. Using base mode...\n");
9019 board_config = ALC883_3ST_2ch_DIG;
9020 }
9021 }
9022
9023 if (board_config != ALC883_AUTO)
9024 setup_preset(spec, &alc883_presets[board_config]);
9025
Kailang Yang2f893282008-05-27 12:14:47 +02009026 switch (codec->vendor_id) {
9027 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009028 if (codec->revision_id == 0x100101) {
9029 spec->stream_name_analog = "ALC1200 Analog";
9030 spec->stream_name_digital = "ALC1200 Digital";
9031 } else {
9032 spec->stream_name_analog = "ALC888 Analog";
9033 spec->stream_name_digital = "ALC888 Digital";
9034 }
Kailang Yang2f893282008-05-27 12:14:47 +02009035 break;
9036 case 0x10ec0889:
9037 spec->stream_name_analog = "ALC889 Analog";
9038 spec->stream_name_digital = "ALC889 Digital";
9039 break;
9040 default:
9041 spec->stream_name_analog = "ALC883 Analog";
9042 spec->stream_name_digital = "ALC883 Digital";
9043 break;
9044 }
9045
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009046 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9047 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009048 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009049
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009050 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9051 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9052
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009053 if (!spec->num_adc_nids) {
9054 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9055 spec->adc_nids = alc883_adc_nids;
9056 }
9057 if (!spec->capsrc_nids)
9058 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009059 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009060 if (!spec->cap_mixer)
9061 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009062
Takashi Iwai2134ea42008-01-10 16:53:55 +01009063 spec->vmaster_nid = 0x0c;
9064
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009065 codec->patch_ops = alc_patch_ops;
9066 if (board_config == ALC883_AUTO)
9067 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009068
Takashi Iwaicb53c622007-08-10 17:21:45 +02009069#ifdef CONFIG_SND_HDA_POWER_SAVE
9070 if (!spec->loopback.amplist)
9071 spec->loopback.amplist = alc883_loopbacks;
9072#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009073 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009074
9075 return 0;
9076}
9077
9078/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009079 * ALC262 support
9080 */
9081
9082#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9083#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9084
9085#define alc262_dac_nids alc260_dac_nids
9086#define alc262_adc_nids alc882_adc_nids
9087#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009088#define alc262_capsrc_nids alc882_capsrc_nids
9089#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009090
9091#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009092#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009093
Kailang Yang4e555fe2008-08-26 13:05:55 +02009094static hda_nid_t alc262_dmic_adc_nids[1] = {
9095 /* ADC0 */
9096 0x09
9097};
9098
9099static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9100
Kailang Yangdf694da2005-12-05 19:42:22 +01009101static struct snd_kcontrol_new alc262_base_mixer[] = {
9102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9103 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009113 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009114 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009115 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01009116 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9118 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9119 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009120 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009121};
9122
Kailang Yangccc656c2006-10-17 12:32:26 +02009123static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9125 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009135 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009136 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009137 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02009138 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9140 { } /* end */
9141};
9142
Takashi Iwaice875f02008-01-28 18:17:43 +01009143/* update HP, line and mono-out pins according to the master switch */
9144static void alc262_hp_master_update(struct hda_codec *codec)
9145{
9146 struct alc_spec *spec = codec->spec;
9147 int val = spec->master_sw;
9148
9149 /* HP & line-out */
9150 snd_hda_codec_write_cache(codec, 0x1b, 0,
9151 AC_VERB_SET_PIN_WIDGET_CONTROL,
9152 val ? PIN_HP : 0);
9153 snd_hda_codec_write_cache(codec, 0x15, 0,
9154 AC_VERB_SET_PIN_WIDGET_CONTROL,
9155 val ? PIN_HP : 0);
9156 /* mono (speaker) depending on the HP jack sense */
9157 val = val && !spec->jack_present;
9158 snd_hda_codec_write_cache(codec, 0x16, 0,
9159 AC_VERB_SET_PIN_WIDGET_CONTROL,
9160 val ? PIN_OUT : 0);
9161}
9162
9163static void alc262_hp_bpc_automute(struct hda_codec *codec)
9164{
9165 struct alc_spec *spec = codec->spec;
9166 unsigned int presence;
9167 presence = snd_hda_codec_read(codec, 0x1b, 0,
9168 AC_VERB_GET_PIN_SENSE, 0);
9169 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9170 alc262_hp_master_update(codec);
9171}
9172
9173static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9174{
9175 if ((res >> 26) != ALC880_HP_EVENT)
9176 return;
9177 alc262_hp_bpc_automute(codec);
9178}
9179
9180static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9181{
9182 struct alc_spec *spec = codec->spec;
9183 unsigned int presence;
9184 presence = snd_hda_codec_read(codec, 0x15, 0,
9185 AC_VERB_GET_PIN_SENSE, 0);
9186 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9187 alc262_hp_master_update(codec);
9188}
9189
9190static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9191 unsigned int res)
9192{
9193 if ((res >> 26) != ALC880_HP_EVENT)
9194 return;
9195 alc262_hp_wildwest_automute(codec);
9196}
9197
9198static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9199 struct snd_ctl_elem_value *ucontrol)
9200{
9201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9202 struct alc_spec *spec = codec->spec;
9203 *ucontrol->value.integer.value = spec->master_sw;
9204 return 0;
9205}
9206
9207static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9208 struct snd_ctl_elem_value *ucontrol)
9209{
9210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9211 struct alc_spec *spec = codec->spec;
9212 int val = !!*ucontrol->value.integer.value;
9213
9214 if (val == spec->master_sw)
9215 return 0;
9216 spec->master_sw = val;
9217 alc262_hp_master_update(codec);
9218 return 1;
9219}
9220
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009221static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009222 {
9223 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9224 .name = "Master Playback Switch",
9225 .info = snd_ctl_boolean_mono_info,
9226 .get = alc262_hp_master_sw_get,
9227 .put = alc262_hp_master_sw_put,
9228 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9230 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009232 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9233 HDA_OUTPUT),
9234 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9235 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009238 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009239 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9240 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009241 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9244 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9245 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9246 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9247 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9248 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9249 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9250 { } /* end */
9251};
9252
Kailang Yangcd7509a2007-01-26 18:33:17 +01009253static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009254 {
9255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9256 .name = "Master Playback Switch",
9257 .info = snd_ctl_boolean_mono_info,
9258 .get = alc262_hp_master_sw_get,
9259 .put = alc262_hp_master_sw_put,
9260 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9262 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009265 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9266 HDA_OUTPUT),
9267 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9268 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009269 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9270 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009271 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9276 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9277 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9278 { } /* end */
9279};
9280
9281static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9282 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9283 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009284 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009285 { } /* end */
9286};
9287
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009288/* mute/unmute internal speaker according to the hp jack and mute state */
9289static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9290{
9291 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009292
9293 if (force || !spec->sense_updated) {
9294 unsigned int present;
9295 present = snd_hda_codec_read(codec, 0x15, 0,
9296 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009297 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009298 spec->sense_updated = 1;
9299 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009300 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9301 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009302}
9303
9304static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9305 unsigned int res)
9306{
9307 if ((res >> 26) != ALC880_HP_EVENT)
9308 return;
9309 alc262_hp_t5735_automute(codec, 1);
9310}
9311
9312static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9313{
9314 alc262_hp_t5735_automute(codec, 1);
9315}
9316
9317static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9319 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009320 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9321 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9324 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9325 { } /* end */
9326};
9327
9328static struct hda_verb alc262_hp_t5735_verbs[] = {
9329 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9331
9332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9333 { }
9334};
9335
Kailang Yang8c427222008-01-10 13:03:59 +01009336static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009337 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009339 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9340 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009341 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9342 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9343 { } /* end */
9344};
9345
9346static struct hda_verb alc262_hp_rp5700_verbs[] = {
9347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9348 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9349 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9350 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9352 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9357 {}
9358};
9359
9360static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9361 .num_items = 1,
9362 .items = {
9363 { "Line", 0x1 },
9364 },
9365};
9366
Takashi Iwai0724ea22007-08-23 00:31:43 +02009367/* bind hp and internal speaker mute (with plug check) */
9368static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9369 struct snd_ctl_elem_value *ucontrol)
9370{
9371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9372 long *valp = ucontrol->value.integer.value;
9373 int change;
9374
9375 /* change hp mute */
9376 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9377 HDA_AMP_MUTE,
9378 valp[0] ? 0 : HDA_AMP_MUTE);
9379 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9380 HDA_AMP_MUTE,
9381 valp[1] ? 0 : HDA_AMP_MUTE);
9382 if (change) {
9383 /* change speaker according to HP jack state */
9384 struct alc_spec *spec = codec->spec;
9385 unsigned int mute;
9386 if (spec->jack_present)
9387 mute = HDA_AMP_MUTE;
9388 else
9389 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9390 HDA_OUTPUT, 0);
9391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9392 HDA_AMP_MUTE, mute);
9393 }
9394 return change;
9395}
Takashi Iwai5b319542007-07-26 11:49:22 +02009396
Kailang Yang272a5272007-05-14 11:00:38 +02009397static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009398 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9399 {
9400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9401 .name = "Master Playback Switch",
9402 .info = snd_hda_mixer_amp_switch_info,
9403 .get = snd_hda_mixer_amp_switch_get,
9404 .put = alc262_sony_master_sw_put,
9405 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9406 },
Kailang Yang272a5272007-05-14 11:00:38 +02009407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9409 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9410 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9411 { } /* end */
9412};
9413
Kailang Yang83c34212007-07-05 11:43:05 +02009414static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9416 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9420 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9421 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9422 { } /* end */
9423};
Kailang Yang272a5272007-05-14 11:00:38 +02009424
Kailang Yangdf694da2005-12-05 19:42:22 +01009425#define alc262_capture_mixer alc882_capture_mixer
9426#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9427
9428/*
9429 * generic initialization of ADC, input mixers and output mixers
9430 */
9431static struct hda_verb alc262_init_verbs[] = {
9432 /*
9433 * Unmute ADC0-2 and set the default input to mic-in
9434 */
9435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9437 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9439 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9441
Takashi Iwaicb53c622007-08-10 17:21:45 +02009442 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009443 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009444 * Note: PASD motherboards uses the Line In 2 as the input for
9445 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009446 */
9447 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009453
9454 /*
9455 * Set up output mixers (0x0c - 0x0e)
9456 */
9457 /* set vol=0 to output mixers */
9458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9461 /* set up input amps for analog loopback */
9462 /* Amp Indices: DAC = 0, mixer = 1 */
9463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9469
9470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9476
9477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009482
Kailang Yangdf694da2005-12-05 19:42:22 +01009483 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009485
Kailang Yangdf694da2005-12-05 19:42:22 +01009486 /* FIXME: use matrix-type input source selection */
9487 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9488 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9489 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9490 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9493 /* Input mixer2 */
9494 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9495 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9498 /* Input mixer3 */
9499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9500 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9501 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009503
9504 { }
9505};
9506
Kailang Yang4e555fe2008-08-26 13:05:55 +02009507static struct hda_verb alc262_eapd_verbs[] = {
9508 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9509 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9510 { }
9511};
9512
Kailang Yangccc656c2006-10-17 12:32:26 +02009513static struct hda_verb alc262_hippo_unsol_verbs[] = {
9514 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9516 {}
9517};
9518
9519static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9521 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9522 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9523
9524 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9526 {}
9527};
9528
Kailang Yang272a5272007-05-14 11:00:38 +02009529static struct hda_verb alc262_sony_unsol_verbs[] = {
9530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9533
9534 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009536 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009537};
9538
Kailang Yang4e555fe2008-08-26 13:05:55 +02009539static struct hda_input_mux alc262_dmic_capture_source = {
9540 .num_items = 2,
9541 .items = {
9542 { "Int DMic", 0x9 },
9543 { "Mic", 0x0 },
9544 },
9545};
9546
9547static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9549 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009553 { } /* end */
9554};
9555
9556static struct hda_verb alc262_toshiba_s06_verbs[] = {
9557 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9561 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9565 {}
9566};
9567
9568static void alc262_dmic_automute(struct hda_codec *codec)
9569{
9570 unsigned int present;
9571
9572 present = snd_hda_codec_read(codec, 0x18, 0,
9573 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9574 snd_hda_codec_write(codec, 0x22, 0,
9575 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9576}
9577
9578/* toggle speaker-output according to the hp-jack state */
9579static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9580{
9581 unsigned int present;
9582 unsigned char bits;
9583
9584 present = snd_hda_codec_read(codec, 0x15, 0,
9585 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9586 bits = present ? 0 : PIN_OUT;
9587 snd_hda_codec_write(codec, 0x14, 0,
9588 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9589}
9590
9591
9592
9593/* unsolicited event for HP jack sensing */
9594static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9595 unsigned int res)
9596{
9597 if ((res >> 26) == ALC880_HP_EVENT)
9598 alc262_toshiba_s06_speaker_automute(codec);
9599 if ((res >> 26) == ALC880_MIC_EVENT)
9600 alc262_dmic_automute(codec);
9601
9602}
9603
9604static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9605{
9606 alc262_toshiba_s06_speaker_automute(codec);
9607 alc262_dmic_automute(codec);
9608}
9609
Kailang Yangccc656c2006-10-17 12:32:26 +02009610/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009611static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009612{
9613 struct alc_spec *spec = codec->spec;
9614 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009615 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009616
Takashi Iwai5b319542007-07-26 11:49:22 +02009617 /* need to execute and sync at first */
9618 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9619 present = snd_hda_codec_read(codec, 0x15, 0,
9620 AC_VERB_GET_PIN_SENSE, 0);
9621 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009622 if (spec->jack_present) {
9623 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009624 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9625 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009626 } else {
9627 /* unmute internal speaker if necessary */
9628 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009629 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9630 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009631 }
9632}
9633
9634/* unsolicited event for HP jack sensing */
9635static void alc262_hippo_unsol_event(struct hda_codec *codec,
9636 unsigned int res)
9637{
9638 if ((res >> 26) != ALC880_HP_EVENT)
9639 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009640 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009641}
9642
Takashi Iwai5b319542007-07-26 11:49:22 +02009643static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009644{
Kailang Yangccc656c2006-10-17 12:32:26 +02009645 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009646 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009647
Takashi Iwai5b319542007-07-26 11:49:22 +02009648 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9649 present = snd_hda_codec_read(codec, 0x1b, 0,
9650 AC_VERB_GET_PIN_SENSE, 0);
9651 present = (present & 0x80000000) != 0;
9652 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009653 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009654 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9655 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009656 } else {
9657 /* unmute internal speaker if necessary */
9658 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009659 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9660 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009661 }
9662}
9663
9664/* unsolicited event for HP jack sensing */
9665static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9666 unsigned int res)
9667{
9668 if ((res >> 26) != ALC880_HP_EVENT)
9669 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009670 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009671}
9672
Takashi Iwai834be882006-03-01 14:16:17 +01009673/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009674 * nec model
9675 * 0x15 = headphone
9676 * 0x16 = internal speaker
9677 * 0x18 = external mic
9678 */
9679
9680static struct snd_kcontrol_new alc262_nec_mixer[] = {
9681 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9682 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9683
9684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9687
9688 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9690 { } /* end */
9691};
9692
9693static struct hda_verb alc262_nec_verbs[] = {
9694 /* Unmute Speaker */
9695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9696
9697 /* Headphone */
9698 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9700
9701 /* External mic to headphone */
9702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9703 /* External mic to speaker */
9704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9705 {}
9706};
9707
9708/*
Takashi Iwai834be882006-03-01 14:16:17 +01009709 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009710 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9711 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009712 */
9713
9714#define ALC_HP_EVENT 0x37
9715
9716static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009721 {}
9722};
9723
Jiang zhe0e31daf2008-03-20 12:12:39 +01009724static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9725 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9727 {}
9728};
9729
Takashi Iwai834be882006-03-01 14:16:17 +01009730static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009731 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009732 .items = {
9733 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009734 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009735 { "CD", 0x4 },
9736 },
9737};
9738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739static struct hda_input_mux alc262_HP_capture_source = {
9740 .num_items = 5,
9741 .items = {
9742 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009743 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009744 { "Line", 0x2 },
9745 { "CD", 0x4 },
9746 { "AUX IN", 0x6 },
9747 },
9748};
9749
zhejiangaccbe492007-08-31 12:36:05 +02009750static struct hda_input_mux alc262_HP_D7000_capture_source = {
9751 .num_items = 4,
9752 .items = {
9753 { "Mic", 0x0 },
9754 { "Front Mic", 0x2 },
9755 { "Line", 0x1 },
9756 { "CD", 0x4 },
9757 },
9758};
9759
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009760/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009761static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9762{
9763 struct alc_spec *spec = codec->spec;
9764 unsigned int mute;
9765
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009766 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009767 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009768 /* need to execute and sync at first */
9769 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009770 /* check laptop HP jack */
9771 present = snd_hda_codec_read(codec, 0x14, 0,
9772 AC_VERB_GET_PIN_SENSE, 0);
9773 /* need to execute and sync at first */
9774 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9775 /* check docking HP jack */
9776 present |= snd_hda_codec_read(codec, 0x1b, 0,
9777 AC_VERB_GET_PIN_SENSE, 0);
9778 if (present & AC_PINSENSE_PRESENCE)
9779 spec->jack_present = 1;
9780 else
9781 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009782 spec->sense_updated = 1;
9783 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009784 /* unmute internal speaker only if both HPs are unplugged and
9785 * master switch is on
9786 */
9787 if (spec->jack_present)
9788 mute = HDA_AMP_MUTE;
9789 else
Takashi Iwai834be882006-03-01 14:16:17 +01009790 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009791 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9792 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009793}
9794
9795/* unsolicited event for HP jack sensing */
9796static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9797 unsigned int res)
9798{
9799 if ((res >> 26) != ALC_HP_EVENT)
9800 return;
9801 alc262_fujitsu_automute(codec, 1);
9802}
9803
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009804static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9805{
9806 alc262_fujitsu_automute(codec, 1);
9807}
9808
Takashi Iwai834be882006-03-01 14:16:17 +01009809/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009810static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9811 .ops = &snd_hda_bind_vol,
9812 .values = {
9813 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9814 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9815 0
9816 },
9817};
Takashi Iwai834be882006-03-01 14:16:17 +01009818
Jiang zhe0e31daf2008-03-20 12:12:39 +01009819/* mute/unmute internal speaker according to the hp jack and mute state */
9820static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9821{
9822 struct alc_spec *spec = codec->spec;
9823 unsigned int mute;
9824
9825 if (force || !spec->sense_updated) {
9826 unsigned int present_int_hp;
9827 /* need to execute and sync at first */
9828 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9829 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9830 AC_VERB_GET_PIN_SENSE, 0);
9831 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9832 spec->sense_updated = 1;
9833 }
9834 if (spec->jack_present) {
9835 /* mute internal speaker */
9836 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9837 HDA_AMP_MUTE, HDA_AMP_MUTE);
9838 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9839 HDA_AMP_MUTE, HDA_AMP_MUTE);
9840 } else {
9841 /* unmute internal speaker if necessary */
9842 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9843 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9844 HDA_AMP_MUTE, mute);
9845 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9846 HDA_AMP_MUTE, mute);
9847 }
9848}
9849
9850/* unsolicited event for HP jack sensing */
9851static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9852 unsigned int res)
9853{
9854 if ((res >> 26) != ALC_HP_EVENT)
9855 return;
9856 alc262_lenovo_3000_automute(codec, 1);
9857}
9858
Takashi Iwai834be882006-03-01 14:16:17 +01009859/* bind hp and internal speaker mute (with plug check) */
9860static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9861 struct snd_ctl_elem_value *ucontrol)
9862{
9863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9864 long *valp = ucontrol->value.integer.value;
9865 int change;
9866
Tony Vroon5d9fab22008-03-14 17:09:18 +01009867 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9868 HDA_AMP_MUTE,
9869 valp ? 0 : HDA_AMP_MUTE);
9870 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9871 HDA_AMP_MUTE,
9872 valp ? 0 : HDA_AMP_MUTE);
9873
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009874 if (change)
9875 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009876 return change;
9877}
9878
9879static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009880 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009881 {
9882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9883 .name = "Master Playback Switch",
9884 .info = snd_hda_mixer_amp_switch_info,
9885 .get = snd_hda_mixer_amp_switch_get,
9886 .put = alc262_fujitsu_master_sw_put,
9887 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9888 },
9889 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9890 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009891 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9892 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009896 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9897 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9898 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009899 { } /* end */
9900};
9901
Jiang zhe0e31daf2008-03-20 12:12:39 +01009902/* bind hp and internal speaker mute (with plug check) */
9903static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9904 struct snd_ctl_elem_value *ucontrol)
9905{
9906 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9907 long *valp = ucontrol->value.integer.value;
9908 int change;
9909
9910 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9911 HDA_AMP_MUTE,
9912 valp ? 0 : HDA_AMP_MUTE);
9913
9914 if (change)
9915 alc262_lenovo_3000_automute(codec, 0);
9916 return change;
9917}
9918
9919static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9920 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9921 {
9922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9923 .name = "Master Playback Switch",
9924 .info = snd_hda_mixer_amp_switch_info,
9925 .get = snd_hda_mixer_amp_switch_get,
9926 .put = alc262_lenovo_3000_master_sw_put,
9927 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9928 },
9929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9931 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9934 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9935 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9936 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9937 { } /* end */
9938};
9939
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009940static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9941 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9942 {
9943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9944 .name = "Master Playback Switch",
9945 .info = snd_hda_mixer_amp_switch_info,
9946 .get = snd_hda_mixer_amp_switch_get,
9947 .put = alc262_sony_master_sw_put,
9948 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9949 },
9950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9956 { } /* end */
9957};
9958
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009959/* additional init verbs for Benq laptops */
9960static struct hda_verb alc262_EAPD_verbs[] = {
9961 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9962 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9963 {}
9964};
9965
Kailang Yang83c34212007-07-05 11:43:05 +02009966static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9969
9970 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9971 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9972 {}
9973};
9974
Tobin Davisf651b502007-10-26 12:40:47 +02009975/* Samsung Q1 Ultra Vista model setup */
9976static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009977 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9978 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9981 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009982 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009983 { } /* end */
9984};
9985
9986static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009987 /* output mixer */
9988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9991 /* speaker */
9992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9993 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9995 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9996 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10002 /* internal mic */
10003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10005 /* ADC, choose mic */
10006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10007 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10008 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10009 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010016 {}
10017};
10018
Tobin Davisf651b502007-10-26 12:40:47 +020010019/* mute/unmute internal speaker according to the hp jack and mute state */
10020static void alc262_ultra_automute(struct hda_codec *codec)
10021{
10022 struct alc_spec *spec = codec->spec;
10023 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010024
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010025 mute = 0;
10026 /* auto-mute only when HP is used as HP */
10027 if (!spec->cur_mux[0]) {
10028 unsigned int present;
10029 /* need to execute and sync at first */
10030 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10031 present = snd_hda_codec_read(codec, 0x15, 0,
10032 AC_VERB_GET_PIN_SENSE, 0);
10033 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10034 if (spec->jack_present)
10035 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010036 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010037 /* mute/unmute internal speaker */
10038 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10039 HDA_AMP_MUTE, mute);
10040 /* mute/unmute HP */
10041 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10042 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010043}
10044
10045/* unsolicited event for HP jack sensing */
10046static void alc262_ultra_unsol_event(struct hda_codec *codec,
10047 unsigned int res)
10048{
10049 if ((res >> 26) != ALC880_HP_EVENT)
10050 return;
10051 alc262_ultra_automute(codec);
10052}
10053
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010054static struct hda_input_mux alc262_ultra_capture_source = {
10055 .num_items = 2,
10056 .items = {
10057 { "Mic", 0x1 },
10058 { "Headphone", 0x7 },
10059 },
10060};
10061
10062static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10063 struct snd_ctl_elem_value *ucontrol)
10064{
10065 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10066 struct alc_spec *spec = codec->spec;
10067 int ret;
10068
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010069 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010070 if (!ret)
10071 return 0;
10072 /* reprogram the HP pin as mic or HP according to the input source */
10073 snd_hda_codec_write_cache(codec, 0x15, 0,
10074 AC_VERB_SET_PIN_WIDGET_CONTROL,
10075 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10076 alc262_ultra_automute(codec); /* mute/unmute HP */
10077 return ret;
10078}
10079
10080static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10081 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10082 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10083 {
10084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10085 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010086 .info = alc_mux_enum_info,
10087 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010088 .put = alc262_ultra_mux_enum_put,
10089 },
10090 { } /* end */
10091};
10092
Kailang Yangdf694da2005-12-05 19:42:22 +010010093/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010094static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10095 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010096{
10097 hda_nid_t nid;
10098 int err;
10099
10100 spec->multiout.num_dacs = 1; /* only use one dac */
10101 spec->multiout.dac_nids = spec->private_dac_nids;
10102 spec->multiout.dac_nids[0] = 2;
10103
10104 nid = cfg->line_out_pins[0];
10105 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010106 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10107 "Front Playback Volume",
10108 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10109 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010110 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010111 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10112 "Front Playback Switch",
10113 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10114 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010115 return err;
10116 }
10117
Takashi Iwai82bc9552006-03-21 11:24:42 +010010118 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010119 if (nid) {
10120 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010121 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10122 "Speaker Playback Volume",
10123 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10124 HDA_OUTPUT));
10125 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010126 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010127 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10128 "Speaker Playback Switch",
10129 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10130 HDA_OUTPUT));
10131 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010132 return err;
10133 } else {
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, 3, 0,
10137 HDA_OUTPUT));
10138 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010139 return err;
10140 }
10141 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010142 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010143 if (nid) {
10144 /* spec->multiout.hp_nid = 2; */
10145 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010146 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10147 "Headphone Playback Volume",
10148 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10149 HDA_OUTPUT));
10150 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010151 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010152 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10153 "Headphone Playback Switch",
10154 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10155 HDA_OUTPUT));
10156 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010157 return err;
10158 } else {
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, 3, 0,
10162 HDA_OUTPUT));
10163 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010164 return err;
10165 }
10166 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010167 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010168}
10169
10170/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010171#define alc262_auto_create_analog_input_ctls \
10172 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010173
10174/*
10175 * generic initialization of ADC, input mixers and output mixers
10176 */
10177static struct hda_verb alc262_volume_init_verbs[] = {
10178 /*
10179 * Unmute ADC0-2 and set the default input to mic-in
10180 */
10181 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10183 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10185 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10187
Takashi Iwaicb53c622007-08-10 17:21:45 +020010188 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010189 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010190 * Note: PASD motherboards uses the Line In 2 as the input for
10191 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010192 */
10193 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10196 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010199
10200 /*
10201 * Set up output mixers (0x0c - 0x0f)
10202 */
10203 /* set vol=0 to output mixers */
10204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010207
Kailang Yangdf694da2005-12-05 19:42:22 +010010208 /* set up input amps for analog loopback */
10209 /* Amp Indices: DAC = 0, mixer = 1 */
10210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10213 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10214 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10216
10217 /* FIXME: use matrix-type input source selection */
10218 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10219 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10224 /* Input mixer2 */
10225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10229 /* Input mixer3 */
10230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10233 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10234
10235 { }
10236};
10237
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010238static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10239 /*
10240 * Unmute ADC0-2 and set the default input to mic-in
10241 */
10242 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10244 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10246 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10248
Takashi Iwaicb53c622007-08-10 17:21:45 +020010249 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010250 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010251 * Note: PASD motherboards uses the Line In 2 as the input for
10252 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010253 */
10254 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010262
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010263 /*
10264 * Set up output mixers (0x0c - 0x0e)
10265 */
10266 /* set vol=0 to output mixers */
10267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10270
10271 /* set up input amps for analog loopback */
10272 /* Amp Indices: DAC = 0, mixer = 1 */
10273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10279
Takashi Iwaice875f02008-01-28 18:17:43 +010010280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10282 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10283
10284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10286
10287 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10289
10290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10292 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10294 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10295
10296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10300 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10301 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10302
10303
10304 /* FIXME: use matrix-type input source selection */
10305 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10306 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10311 /* Input mixer2 */
10312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10316 /* Input mixer3 */
10317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10321
Takashi Iwaice875f02008-01-28 18:17:43 +010010322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10323
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010324 { }
10325};
10326
Kailang Yangcd7509a2007-01-26 18:33:17 +010010327static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10328 /*
10329 * Unmute ADC0-2 and set the default input to mic-in
10330 */
10331 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10333 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10337
Takashi Iwaicb53c622007-08-10 17:21:45 +020010338 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010339 * mixer widget
10340 * Note: PASD motherboards uses the Line In 2 as the input for front
10341 * panel mic (mic 2)
10342 */
10343 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010352 /*
10353 * Set up output mixers (0x0c - 0x0e)
10354 */
10355 /* set vol=0 to output mixers */
10356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10359
10360 /* set up input amps for analog loopback */
10361 /* Amp Indices: DAC = 0, mixer = 1 */
10362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10368
10369
10370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10371 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10373 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10377
10378 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10379 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10380
10381 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10383
10384 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10387 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10388 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10389 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10390
10391 /* FIXME: use matrix-type input source selection */
10392 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10393 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10399 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10401 /* Input mixer2 */
10402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10407 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10409 /* Input mixer3 */
10410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10415 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10417
Takashi Iwaice875f02008-01-28 18:17:43 +010010418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10419
Kailang Yangcd7509a2007-01-26 18:33:17 +010010420 { }
10421};
10422
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010423static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10424
10425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10427 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10428
10429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10433
10434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10435 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10437 {}
10438};
10439
10440
Takashi Iwaicb53c622007-08-10 17:21:45 +020010441#ifdef CONFIG_SND_HDA_POWER_SAVE
10442#define alc262_loopbacks alc880_loopbacks
10443#endif
10444
Kailang Yangdf694da2005-12-05 19:42:22 +010010445/* pcm configuration: identiacal with ALC880 */
10446#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10447#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10448#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10449#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10450
10451/*
10452 * BIOS auto configuration
10453 */
10454static int alc262_parse_auto_config(struct hda_codec *codec)
10455{
10456 struct alc_spec *spec = codec->spec;
10457 int err;
10458 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10459
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010460 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10461 alc262_ignore);
10462 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010463 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010464 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010465 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010466 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10467 if (err < 0)
10468 return err;
10469 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10470 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010471 return err;
10472
10473 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10474
10475 if (spec->autocfg.dig_out_pin)
10476 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10477 if (spec->autocfg.dig_in_pin)
10478 spec->dig_in_nid = ALC262_DIGIN_NID;
10479
Takashi Iwai603c4012008-07-30 15:01:44 +020010480 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010481 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010482
Takashi Iwaid88897e2008-10-31 15:01:37 +010010483 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010484 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 spec->input_mux = &spec->private_imux;
10486
Takashi Iwai776e1842007-08-29 15:07:11 +020010487 err = alc_auto_add_mic_boost(codec);
10488 if (err < 0)
10489 return err;
10490
Takashi Iwaie044c392008-10-27 16:56:24 +010010491 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010492 return 1;
10493}
10494
10495#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10496#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10497#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010498#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010499
10500
10501/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010502static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010503{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010504 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010505 alc262_auto_init_multi_out(codec);
10506 alc262_auto_init_hp_out(codec);
10507 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010508 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010509 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010510 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010511}
10512
10513/*
10514 * configuration and preset
10515 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010516static const char *alc262_models[ALC262_MODEL_LAST] = {
10517 [ALC262_BASIC] = "basic",
10518 [ALC262_HIPPO] = "hippo",
10519 [ALC262_HIPPO_1] = "hippo_1",
10520 [ALC262_FUJITSU] = "fujitsu",
10521 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010522 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010523 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010524 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010525 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010526 [ALC262_BENQ_T31] = "benq-t31",
10527 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010528 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010529 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010530 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010531 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010532 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010533 [ALC262_AUTO] = "auto",
10534};
10535
10536static struct snd_pci_quirk alc262_cfg_tbl[] = {
10537 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010538 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010539 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010540 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010541 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10542 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010543 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010544 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010545 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010546 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010547 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010548 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010549 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010550 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010551 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010552 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010553 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010554 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010555 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10556 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10557 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010558 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10559 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010560 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010561 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010562 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010563 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10564 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10565 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010566 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10567 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010568 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010569 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010570 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010571 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010572 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010573 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010574 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010575 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010576 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010577 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010578 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010579 {}
10580};
10581
10582static struct alc_config_preset alc262_presets[] = {
10583 [ALC262_BASIC] = {
10584 .mixers = { alc262_base_mixer },
10585 .init_verbs = { alc262_init_verbs },
10586 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10587 .dac_nids = alc262_dac_nids,
10588 .hp_nid = 0x03,
10589 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10590 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010591 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010592 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010593 [ALC262_HIPPO] = {
10594 .mixers = { alc262_base_mixer },
10595 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10596 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10597 .dac_nids = alc262_dac_nids,
10598 .hp_nid = 0x03,
10599 .dig_out_nid = ALC262_DIGOUT_NID,
10600 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10601 .channel_mode = alc262_modes,
10602 .input_mux = &alc262_capture_source,
10603 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010604 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010605 },
10606 [ALC262_HIPPO_1] = {
10607 .mixers = { alc262_hippo1_mixer },
10608 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10609 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10610 .dac_nids = alc262_dac_nids,
10611 .hp_nid = 0x02,
10612 .dig_out_nid = ALC262_DIGOUT_NID,
10613 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10614 .channel_mode = alc262_modes,
10615 .input_mux = &alc262_capture_source,
10616 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010617 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010618 },
Takashi Iwai834be882006-03-01 14:16:17 +010010619 [ALC262_FUJITSU] = {
10620 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010621 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10622 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010623 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10624 .dac_nids = alc262_dac_nids,
10625 .hp_nid = 0x03,
10626 .dig_out_nid = ALC262_DIGOUT_NID,
10627 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10628 .channel_mode = alc262_modes,
10629 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010630 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010631 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010632 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010633 [ALC262_HP_BPC] = {
10634 .mixers = { alc262_HP_BPC_mixer },
10635 .init_verbs = { alc262_HP_BPC_init_verbs },
10636 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10637 .dac_nids = alc262_dac_nids,
10638 .hp_nid = 0x03,
10639 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10640 .channel_mode = alc262_modes,
10641 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010642 .unsol_event = alc262_hp_bpc_unsol_event,
10643 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010644 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010645 [ALC262_HP_BPC_D7000_WF] = {
10646 .mixers = { alc262_HP_BPC_WildWest_mixer },
10647 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10648 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10649 .dac_nids = alc262_dac_nids,
10650 .hp_nid = 0x03,
10651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10652 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010653 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010654 .unsol_event = alc262_hp_wildwest_unsol_event,
10655 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010656 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010657 [ALC262_HP_BPC_D7000_WL] = {
10658 .mixers = { alc262_HP_BPC_WildWest_mixer,
10659 alc262_HP_BPC_WildWest_option_mixer },
10660 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10661 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10662 .dac_nids = alc262_dac_nids,
10663 .hp_nid = 0x03,
10664 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10665 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010666 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010667 .unsol_event = alc262_hp_wildwest_unsol_event,
10668 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010669 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010670 [ALC262_HP_TC_T5735] = {
10671 .mixers = { alc262_hp_t5735_mixer },
10672 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10673 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10674 .dac_nids = alc262_dac_nids,
10675 .hp_nid = 0x03,
10676 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10677 .channel_mode = alc262_modes,
10678 .input_mux = &alc262_capture_source,
10679 .unsol_event = alc262_hp_t5735_unsol_event,
10680 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010681 },
10682 [ALC262_HP_RP5700] = {
10683 .mixers = { alc262_hp_rp5700_mixer },
10684 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10685 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10686 .dac_nids = alc262_dac_nids,
10687 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10688 .channel_mode = alc262_modes,
10689 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010690 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010691 [ALC262_BENQ_ED8] = {
10692 .mixers = { alc262_base_mixer },
10693 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10694 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10695 .dac_nids = alc262_dac_nids,
10696 .hp_nid = 0x03,
10697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10698 .channel_mode = alc262_modes,
10699 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010700 },
Kailang Yang272a5272007-05-14 11:00:38 +020010701 [ALC262_SONY_ASSAMD] = {
10702 .mixers = { alc262_sony_mixer },
10703 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10705 .dac_nids = alc262_dac_nids,
10706 .hp_nid = 0x02,
10707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10708 .channel_mode = alc262_modes,
10709 .input_mux = &alc262_capture_source,
10710 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010711 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010712 },
10713 [ALC262_BENQ_T31] = {
10714 .mixers = { alc262_benq_t31_mixer },
10715 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10717 .dac_nids = alc262_dac_nids,
10718 .hp_nid = 0x03,
10719 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10720 .channel_mode = alc262_modes,
10721 .input_mux = &alc262_capture_source,
10722 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010723 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010724 },
Tobin Davisf651b502007-10-26 12:40:47 +020010725 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010726 .mixers = { alc262_ultra_mixer },
10727 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010728 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010729 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10730 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010731 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10732 .channel_mode = alc262_modes,
10733 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010734 .adc_nids = alc262_adc_nids, /* ADC0 */
10735 .capsrc_nids = alc262_capsrc_nids,
10736 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010737 .unsol_event = alc262_ultra_unsol_event,
10738 .init_hook = alc262_ultra_automute,
10739 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010740 [ALC262_LENOVO_3000] = {
10741 .mixers = { alc262_lenovo_3000_mixer },
10742 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10743 alc262_lenovo_3000_unsol_verbs },
10744 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10745 .dac_nids = alc262_dac_nids,
10746 .hp_nid = 0x03,
10747 .dig_out_nid = ALC262_DIGOUT_NID,
10748 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10749 .channel_mode = alc262_modes,
10750 .input_mux = &alc262_fujitsu_capture_source,
10751 .unsol_event = alc262_lenovo_3000_unsol_event,
10752 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010753 [ALC262_NEC] = {
10754 .mixers = { alc262_nec_mixer },
10755 .init_verbs = { alc262_nec_verbs },
10756 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10757 .dac_nids = alc262_dac_nids,
10758 .hp_nid = 0x03,
10759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10760 .channel_mode = alc262_modes,
10761 .input_mux = &alc262_capture_source,
10762 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010763 [ALC262_TOSHIBA_S06] = {
10764 .mixers = { alc262_toshiba_s06_mixer },
10765 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10766 alc262_eapd_verbs },
10767 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10768 .capsrc_nids = alc262_dmic_capsrc_nids,
10769 .dac_nids = alc262_dac_nids,
10770 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10771 .dig_out_nid = ALC262_DIGOUT_NID,
10772 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10773 .channel_mode = alc262_modes,
10774 .input_mux = &alc262_dmic_capture_source,
10775 .unsol_event = alc262_toshiba_s06_unsol_event,
10776 .init_hook = alc262_toshiba_s06_init_hook,
10777 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010778 [ALC262_TOSHIBA_RX1] = {
10779 .mixers = { alc262_toshiba_rx1_mixer },
10780 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10782 .dac_nids = alc262_dac_nids,
10783 .hp_nid = 0x03,
10784 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10785 .channel_mode = alc262_modes,
10786 .input_mux = &alc262_capture_source,
10787 .unsol_event = alc262_hippo_unsol_event,
10788 .init_hook = alc262_hippo_automute,
10789 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010790};
10791
10792static int patch_alc262(struct hda_codec *codec)
10793{
10794 struct alc_spec *spec;
10795 int board_config;
10796 int err;
10797
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010798 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010799 if (spec == NULL)
10800 return -ENOMEM;
10801
10802 codec->spec = spec;
10803#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010804 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10805 * under-run
10806 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 {
10808 int tmp;
10809 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10810 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10811 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10812 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10813 }
10814#endif
10815
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010816 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10817
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010818 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10819 alc262_models,
10820 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010821
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010822 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010823 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10824 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010825 board_config = ALC262_AUTO;
10826 }
10827
10828 if (board_config == ALC262_AUTO) {
10829 /* automatic parse from the BIOS config */
10830 err = alc262_parse_auto_config(codec);
10831 if (err < 0) {
10832 alc_free(codec);
10833 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010834 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010835 printk(KERN_INFO
10836 "hda_codec: Cannot set up configuration "
10837 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010838 board_config = ALC262_BASIC;
10839 }
10840 }
10841
10842 if (board_config != ALC262_AUTO)
10843 setup_preset(spec, &alc262_presets[board_config]);
10844
10845 spec->stream_name_analog = "ALC262 Analog";
10846 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10847 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010848
Kailang Yangdf694da2005-12-05 19:42:22 +010010849 spec->stream_name_digital = "ALC262 Digital";
10850 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10851 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10852
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010853 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010854 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010855 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010856 unsigned int wcap = get_wcaps(codec, 0x07);
10857
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010858 /* get type */
10859 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010860 if (wcap != AC_WID_AUD_IN) {
10861 spec->adc_nids = alc262_adc_nids_alt;
10862 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010863 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010864 } else {
10865 spec->adc_nids = alc262_adc_nids;
10866 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010867 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010868 }
10869 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010870 if (!spec->cap_mixer)
10871 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010872
Takashi Iwai2134ea42008-01-10 16:53:55 +010010873 spec->vmaster_nid = 0x0c;
10874
Kailang Yangdf694da2005-12-05 19:42:22 +010010875 codec->patch_ops = alc_patch_ops;
10876 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010877 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010878#ifdef CONFIG_SND_HDA_POWER_SAVE
10879 if (!spec->loopback.amplist)
10880 spec->loopback.amplist = alc262_loopbacks;
10881#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010882 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020010883
Kailang Yangdf694da2005-12-05 19:42:22 +010010884 return 0;
10885}
10886
Kailang Yangdf694da2005-12-05 19:42:22 +010010887/*
Kailang Yanga361d842007-06-05 12:30:55 +020010888 * ALC268 channel source setting (2 channel)
10889 */
10890#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10891#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010892
Kailang Yanga361d842007-06-05 12:30:55 +020010893static hda_nid_t alc268_dac_nids[2] = {
10894 /* front, hp */
10895 0x02, 0x03
10896};
10897
10898static hda_nid_t alc268_adc_nids[2] = {
10899 /* ADC0-1 */
10900 0x08, 0x07
10901};
10902
10903static hda_nid_t alc268_adc_nids_alt[1] = {
10904 /* ADC0 */
10905 0x08
10906};
10907
Takashi Iwaie1406342008-02-11 18:32:32 +010010908static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10909
Kailang Yanga361d842007-06-05 12:30:55 +020010910static struct snd_kcontrol_new alc268_base_mixer[] = {
10911 /* output mixer control */
10912 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10913 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10917 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10918 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010919 { }
10920};
10921
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010922/* bind Beep switches of both NID 0x0f and 0x10 */
10923static struct hda_bind_ctls alc268_bind_beep_sw = {
10924 .ops = &snd_hda_bind_sw,
10925 .values = {
10926 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10927 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10928 0
10929 },
10930};
10931
10932static struct snd_kcontrol_new alc268_beep_mixer[] = {
10933 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10934 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10935 { }
10936};
10937
Kailang Yangd1a991a2007-08-15 16:21:59 +020010938static struct hda_verb alc268_eapd_verbs[] = {
10939 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10940 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10941 { }
10942};
10943
Takashi Iwaid2738092007-08-16 14:59:45 +020010944/* Toshiba specific */
10945#define alc268_toshiba_automute alc262_hippo_automute
10946
10947static struct hda_verb alc268_toshiba_verbs[] = {
10948 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10949 { } /* end */
10950};
10951
Kailang Yang8ef355d2008-08-26 13:10:22 +020010952static struct hda_input_mux alc268_acer_lc_capture_source = {
10953 .num_items = 2,
10954 .items = {
10955 { "i-Mic", 0x6 },
10956 { "E-Mic", 0x0 },
10957 },
10958};
10959
Takashi Iwaid2738092007-08-16 14:59:45 +020010960/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010961/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010962static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10963 .ops = &snd_hda_bind_vol,
10964 .values = {
10965 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10966 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10967 0
10968 },
10969};
10970
Takashi Iwai889c4392007-08-23 18:56:52 +020010971/* mute/unmute internal speaker according to the hp jack and mute state */
10972static void alc268_acer_automute(struct hda_codec *codec, int force)
10973{
10974 struct alc_spec *spec = codec->spec;
10975 unsigned int mute;
10976
10977 if (force || !spec->sense_updated) {
10978 unsigned int present;
10979 present = snd_hda_codec_read(codec, 0x14, 0,
10980 AC_VERB_GET_PIN_SENSE, 0);
10981 spec->jack_present = (present & 0x80000000) != 0;
10982 spec->sense_updated = 1;
10983 }
10984 if (spec->jack_present)
10985 mute = HDA_AMP_MUTE; /* mute internal speaker */
10986 else /* unmute internal speaker if necessary */
10987 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10988 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10989 HDA_AMP_MUTE, mute);
10990}
10991
10992
10993/* bind hp and internal speaker mute (with plug check) */
10994static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10995 struct snd_ctl_elem_value *ucontrol)
10996{
10997 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10998 long *valp = ucontrol->value.integer.value;
10999 int change;
11000
11001 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11002 HDA_AMP_MUTE,
11003 valp[0] ? 0 : HDA_AMP_MUTE);
11004 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11005 HDA_AMP_MUTE,
11006 valp[1] ? 0 : HDA_AMP_MUTE);
11007 if (change)
11008 alc268_acer_automute(codec, 0);
11009 return change;
11010}
Takashi Iwaid2738092007-08-16 14:59:45 +020011011
Kailang Yang8ef355d2008-08-26 13:10:22 +020011012static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11013 /* output mixer control */
11014 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11015 {
11016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11017 .name = "Master Playback Switch",
11018 .info = snd_hda_mixer_amp_switch_info,
11019 .get = snd_hda_mixer_amp_switch_get,
11020 .put = alc268_acer_master_sw_put,
11021 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11022 },
11023 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11024 { }
11025};
11026
Takashi Iwaid2738092007-08-16 14:59:45 +020011027static struct snd_kcontrol_new alc268_acer_mixer[] = {
11028 /* output mixer control */
11029 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11030 {
11031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11032 .name = "Master Playback Switch",
11033 .info = snd_hda_mixer_amp_switch_info,
11034 .get = snd_hda_mixer_amp_switch_get,
11035 .put = alc268_acer_master_sw_put,
11036 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11037 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11039 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11040 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011041 { }
11042};
11043
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011044static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11045 /* output mixer control */
11046 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11047 {
11048 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11049 .name = "Master Playback Switch",
11050 .info = snd_hda_mixer_amp_switch_info,
11051 .get = snd_hda_mixer_amp_switch_get,
11052 .put = alc268_acer_master_sw_put,
11053 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11054 },
11055 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11056 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11057 { }
11058};
11059
Kailang Yang8ef355d2008-08-26 13:10:22 +020011060static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11061 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11063 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11064 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11065 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11067 { }
11068};
11069
Takashi Iwaid2738092007-08-16 14:59:45 +020011070static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11072 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011075 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011077 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11078 { }
11079};
11080
11081/* unsolicited event for HP jack sensing */
11082static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11083 unsigned int res)
11084{
Takashi Iwai889c4392007-08-23 18:56:52 +020011085 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011086 return;
11087 alc268_toshiba_automute(codec);
11088}
11089
11090static void alc268_acer_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_acer_automute(codec, 1);
11096}
11097
Takashi Iwai889c4392007-08-23 18:56:52 +020011098static void alc268_acer_init_hook(struct hda_codec *codec)
11099{
11100 alc268_acer_automute(codec, 1);
11101}
11102
Kailang Yang8ef355d2008-08-26 13:10:22 +020011103/* toggle speaker-output according to the hp-jack state */
11104static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11105{
11106 unsigned int present;
11107 unsigned char bits;
11108
11109 present = snd_hda_codec_read(codec, 0x15, 0,
11110 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11111 bits = present ? AMP_IN_MUTE(0) : 0;
11112 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11113 AMP_IN_MUTE(0), bits);
11114 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11115 AMP_IN_MUTE(0), bits);
11116}
11117
11118
11119static void alc268_acer_mic_automute(struct hda_codec *codec)
11120{
11121 unsigned int present;
11122
11123 present = snd_hda_codec_read(codec, 0x18, 0,
11124 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11125 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11126 present ? 0x0 : 0x6);
11127}
11128
11129static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11130 unsigned int res)
11131{
11132 if ((res >> 26) == ALC880_HP_EVENT)
11133 alc268_aspire_one_speaker_automute(codec);
11134 if ((res >> 26) == ALC880_MIC_EVENT)
11135 alc268_acer_mic_automute(codec);
11136}
11137
11138static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11139{
11140 alc268_aspire_one_speaker_automute(codec);
11141 alc268_acer_mic_automute(codec);
11142}
11143
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011144static struct snd_kcontrol_new alc268_dell_mixer[] = {
11145 /* output mixer control */
11146 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11147 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11148 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11150 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11151 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11152 { }
11153};
11154
11155static struct hda_verb alc268_dell_verbs[] = {
11156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11159 { }
11160};
11161
11162/* mute/unmute internal speaker according to the hp jack and mute state */
11163static void alc268_dell_automute(struct hda_codec *codec)
11164{
11165 unsigned int present;
11166 unsigned int mute;
11167
11168 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11169 if (present & 0x80000000)
11170 mute = HDA_AMP_MUTE;
11171 else
11172 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11173 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11174 HDA_AMP_MUTE, mute);
11175}
11176
11177static void alc268_dell_unsol_event(struct hda_codec *codec,
11178 unsigned int res)
11179{
11180 if ((res >> 26) != ALC880_HP_EVENT)
11181 return;
11182 alc268_dell_automute(codec);
11183}
11184
11185#define alc268_dell_init_hook alc268_dell_automute
11186
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011187static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11189 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11190 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11192 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11193 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11194 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11195 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11196 { }
11197};
11198
11199static struct hda_verb alc267_quanta_il1_verbs[] = {
11200 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11202 { }
11203};
11204
11205static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11206{
11207 unsigned int present;
11208
11209 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11210 & AC_PINSENSE_PRESENCE;
11211 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11212 present ? 0 : PIN_OUT);
11213}
11214
11215static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11216{
11217 unsigned int present;
11218
11219 present = snd_hda_codec_read(codec, 0x18, 0,
11220 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11221 snd_hda_codec_write(codec, 0x23, 0,
11222 AC_VERB_SET_CONNECT_SEL,
11223 present ? 0x00 : 0x01);
11224}
11225
11226static void alc267_quanta_il1_automute(struct hda_codec *codec)
11227{
11228 alc267_quanta_il1_hp_automute(codec);
11229 alc267_quanta_il1_mic_automute(codec);
11230}
11231
11232static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11233 unsigned int res)
11234{
11235 switch (res >> 26) {
11236 case ALC880_HP_EVENT:
11237 alc267_quanta_il1_hp_automute(codec);
11238 break;
11239 case ALC880_MIC_EVENT:
11240 alc267_quanta_il1_mic_automute(codec);
11241 break;
11242 }
11243}
11244
Kailang Yanga361d842007-06-05 12:30:55 +020011245/*
11246 * generic initialization of ADC, input mixers and output mixers
11247 */
11248static struct hda_verb alc268_base_init_verbs[] = {
11249 /* Unmute DAC0-1 and set vol = 0 */
11250 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11251 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11254 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11256
11257 /*
11258 * Set up output mixers (0x0c - 0x0e)
11259 */
11260 /* set vol=0 to output mixers */
11261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11264 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11265
11266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11267 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11268
11269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11272 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11273 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11276 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11277
11278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11280 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11281 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11282 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11284 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011285
11286 /* set PCBEEP vol = 0, mute connections */
11287 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11289 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011290
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011291 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011292
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011293 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11295 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011297
Kailang Yanga361d842007-06-05 12:30:55 +020011298 { }
11299};
11300
11301/*
11302 * generic initialization of ADC, input mixers and output mixers
11303 */
11304static struct hda_verb alc268_volume_init_verbs[] = {
11305 /* set output DAC */
11306 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11310
11311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11312 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11314 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11315 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11316
11317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11322
11323 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11324 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11326 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11327
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011328 /* set PCBEEP vol = 0, mute connections */
11329 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11331 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011332
11333 { }
11334};
11335
Kailang Yanga361d842007-06-05 12:30:55 +020011336static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11337 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11338 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11339 {
11340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11341 /* The multiple "Capture Source" controls confuse alsamixer
11342 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011343 */
11344 /* .name = "Capture Source", */
11345 .name = "Input Source",
11346 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011347 .info = alc_mux_enum_info,
11348 .get = alc_mux_enum_get,
11349 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011350 },
11351 { } /* end */
11352};
11353
11354static struct snd_kcontrol_new alc268_capture_mixer[] = {
11355 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11356 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11357 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11358 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11359 {
11360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11361 /* The multiple "Capture Source" controls confuse alsamixer
11362 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011363 */
11364 /* .name = "Capture Source", */
11365 .name = "Input Source",
11366 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011367 .info = alc_mux_enum_info,
11368 .get = alc_mux_enum_get,
11369 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011370 },
11371 { } /* end */
11372};
11373
11374static struct hda_input_mux alc268_capture_source = {
11375 .num_items = 4,
11376 .items = {
11377 { "Mic", 0x0 },
11378 { "Front Mic", 0x1 },
11379 { "Line", 0x2 },
11380 { "CD", 0x3 },
11381 },
11382};
11383
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011384static struct hda_input_mux alc268_acer_capture_source = {
11385 .num_items = 3,
11386 .items = {
11387 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011388 { "Internal Mic", 0x1 },
11389 { "Line", 0x2 },
11390 },
11391};
11392
11393static struct hda_input_mux alc268_acer_dmic_capture_source = {
11394 .num_items = 3,
11395 .items = {
11396 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011397 { "Internal Mic", 0x6 },
11398 { "Line", 0x2 },
11399 },
11400};
11401
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011402#ifdef CONFIG_SND_DEBUG
11403static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011404 /* Volume widgets */
11405 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11406 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11407 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11408 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11409 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11410 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11411 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11412 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11413 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11414 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11415 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11416 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11417 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011418 /* The below appears problematic on some hardwares */
11419 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011420 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11421 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11422 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11423 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11424
11425 /* Modes for retasking pin widgets */
11426 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11427 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11428 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11429 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11430
11431 /* Controls for GPIO pins, assuming they are configured as outputs */
11432 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11433 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11434 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11435 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11436
11437 /* Switches to allow the digital SPDIF output pin to be enabled.
11438 * The ALC268 does not have an SPDIF input.
11439 */
11440 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11441
11442 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11443 * this output to turn on an external amplifier.
11444 */
11445 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11446 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11447
11448 { } /* end */
11449};
11450#endif
11451
Kailang Yanga361d842007-06-05 12:30:55 +020011452/* create input playback/capture controls for the given pin */
11453static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11454 const char *ctlname, int idx)
11455{
11456 char name[32];
11457 int err;
11458
11459 sprintf(name, "%s Playback Volume", ctlname);
11460 if (nid == 0x14) {
11461 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11462 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11463 HDA_OUTPUT));
11464 if (err < 0)
11465 return err;
11466 } else if (nid == 0x15) {
11467 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11468 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11469 HDA_OUTPUT));
11470 if (err < 0)
11471 return err;
11472 } else
11473 return -1;
11474 sprintf(name, "%s Playback Switch", ctlname);
11475 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11476 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11477 if (err < 0)
11478 return err;
11479 return 0;
11480}
11481
11482/* add playback controls from the parsed DAC table */
11483static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11484 const struct auto_pin_cfg *cfg)
11485{
11486 hda_nid_t nid;
11487 int err;
11488
11489 spec->multiout.num_dacs = 2; /* only use one dac */
11490 spec->multiout.dac_nids = spec->private_dac_nids;
11491 spec->multiout.dac_nids[0] = 2;
11492 spec->multiout.dac_nids[1] = 3;
11493
11494 nid = cfg->line_out_pins[0];
11495 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011496 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011497
11498 nid = cfg->speaker_pins[0];
11499 if (nid == 0x1d) {
11500 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11501 "Speaker Playback Volume",
11502 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11503 if (err < 0)
11504 return err;
11505 }
11506 nid = cfg->hp_pins[0];
11507 if (nid)
11508 alc268_new_analog_output(spec, nid, "Headphone", 0);
11509
11510 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11511 if (nid == 0x16) {
11512 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11513 "Mono Playback Switch",
11514 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11515 if (err < 0)
11516 return err;
11517 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011518 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011519}
11520
11521/* create playback/capture controls for input pins */
11522static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11523 const struct auto_pin_cfg *cfg)
11524{
11525 struct hda_input_mux *imux = &spec->private_imux;
11526 int i, idx1;
11527
11528 for (i = 0; i < AUTO_PIN_LAST; i++) {
11529 switch(cfg->input_pins[i]) {
11530 case 0x18:
11531 idx1 = 0; /* Mic 1 */
11532 break;
11533 case 0x19:
11534 idx1 = 1; /* Mic 2 */
11535 break;
11536 case 0x1a:
11537 idx1 = 2; /* Line In */
11538 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011539 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011540 idx1 = 3; /* CD */
11541 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011542 case 0x12:
11543 case 0x13:
11544 idx1 = 6; /* digital mics */
11545 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011546 default:
11547 continue;
11548 }
11549 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11550 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011551 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011552 }
11553 return 0;
11554}
11555
11556static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11557{
11558 struct alc_spec *spec = codec->spec;
11559 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11560 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11561 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11562 unsigned int dac_vol1, dac_vol2;
11563
11564 if (speaker_nid) {
11565 snd_hda_codec_write(codec, speaker_nid, 0,
11566 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11567 snd_hda_codec_write(codec, 0x0f, 0,
11568 AC_VERB_SET_AMP_GAIN_MUTE,
11569 AMP_IN_UNMUTE(1));
11570 snd_hda_codec_write(codec, 0x10, 0,
11571 AC_VERB_SET_AMP_GAIN_MUTE,
11572 AMP_IN_UNMUTE(1));
11573 } else {
11574 snd_hda_codec_write(codec, 0x0f, 0,
11575 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11576 snd_hda_codec_write(codec, 0x10, 0,
11577 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11578 }
11579
11580 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011581 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011582 dac_vol2 = AMP_OUT_ZERO;
11583 else if (line_nid == 0x15)
11584 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011585 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011586 dac_vol2 = AMP_OUT_ZERO;
11587 else if (hp_nid == 0x15)
11588 dac_vol1 = AMP_OUT_ZERO;
11589 if (line_nid != 0x16 || hp_nid != 0x16 ||
11590 spec->autocfg.line_out_pins[1] != 0x16 ||
11591 spec->autocfg.line_out_pins[2] != 0x16)
11592 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11593
11594 snd_hda_codec_write(codec, 0x02, 0,
11595 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11596 snd_hda_codec_write(codec, 0x03, 0,
11597 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11598}
11599
11600/* pcm configuration: identiacal with ALC880 */
11601#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11602#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011603#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011604#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11605
11606/*
11607 * BIOS auto configuration
11608 */
11609static int alc268_parse_auto_config(struct hda_codec *codec)
11610{
11611 struct alc_spec *spec = codec->spec;
11612 int err;
11613 static hda_nid_t alc268_ignore[] = { 0 };
11614
11615 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11616 alc268_ignore);
11617 if (err < 0)
11618 return err;
11619 if (!spec->autocfg.line_outs)
11620 return 0; /* can't find valid BIOS pin config */
11621
11622 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11623 if (err < 0)
11624 return err;
11625 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11626 if (err < 0)
11627 return err;
11628
11629 spec->multiout.max_channels = 2;
11630
11631 /* digital only support output */
11632 if (spec->autocfg.dig_out_pin)
11633 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11634
Takashi Iwai603c4012008-07-30 15:01:44 +020011635 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011636 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011637
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011638 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011639 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011640
Takashi Iwaid88897e2008-10-31 15:01:37 +010011641 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011642 spec->num_mux_defs = 1;
11643 spec->input_mux = &spec->private_imux;
11644
Takashi Iwai776e1842007-08-29 15:07:11 +020011645 err = alc_auto_add_mic_boost(codec);
11646 if (err < 0)
11647 return err;
11648
Takashi Iwaie044c392008-10-27 16:56:24 +010011649 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011650 return 1;
11651}
11652
11653#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11654#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11655#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11656
11657/* init callback for auto-configuration model -- overriding the default init */
11658static void alc268_auto_init(struct hda_codec *codec)
11659{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011660 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011661 alc268_auto_init_multi_out(codec);
11662 alc268_auto_init_hp_out(codec);
11663 alc268_auto_init_mono_speaker_out(codec);
11664 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011665 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011666 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011667}
11668
11669/*
11670 * configuration and preset
11671 */
11672static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011673 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011674 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011675 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011676 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011677 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011678 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011679 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011680 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011681#ifdef CONFIG_SND_DEBUG
11682 [ALC268_TEST] = "test",
11683#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011684 [ALC268_AUTO] = "auto",
11685};
11686
11687static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011688 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011689 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011690 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011691 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011692 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011693 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11694 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011695 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011696 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011697 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011698 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011699 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011700 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011701 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011702 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011703 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011704 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011705 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011706 {}
11707};
11708
11709static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011710 [ALC267_QUANTA_IL1] = {
11711 .mixers = { alc267_quanta_il1_mixer },
11712 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11713 alc267_quanta_il1_verbs },
11714 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11715 .dac_nids = alc268_dac_nids,
11716 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11717 .adc_nids = alc268_adc_nids_alt,
11718 .hp_nid = 0x03,
11719 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11720 .channel_mode = alc268_modes,
11721 .input_mux = &alc268_capture_source,
11722 .unsol_event = alc267_quanta_il1_unsol_event,
11723 .init_hook = alc267_quanta_il1_automute,
11724 },
Kailang Yanga361d842007-06-05 12:30:55 +020011725 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011726 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11727 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011728 .init_verbs = { alc268_base_init_verbs },
11729 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11730 .dac_nids = alc268_dac_nids,
11731 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11732 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011733 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011734 .hp_nid = 0x03,
11735 .dig_out_nid = ALC268_DIGOUT_NID,
11736 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11737 .channel_mode = alc268_modes,
11738 .input_mux = &alc268_capture_source,
11739 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011740 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011741 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11742 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011743 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11744 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011745 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11746 .dac_nids = alc268_dac_nids,
11747 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11748 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011749 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011750 .hp_nid = 0x03,
11751 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11752 .channel_mode = alc268_modes,
11753 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011754 .unsol_event = alc268_toshiba_unsol_event,
11755 .init_hook = alc268_toshiba_automute,
11756 },
11757 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011758 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11759 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011760 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11761 alc268_acer_verbs },
11762 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11763 .dac_nids = alc268_dac_nids,
11764 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11765 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011766 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011767 .hp_nid = 0x02,
11768 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11769 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011770 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011771 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011772 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011773 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011774 [ALC268_ACER_DMIC] = {
11775 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11776 alc268_beep_mixer },
11777 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11778 alc268_acer_verbs },
11779 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11780 .dac_nids = alc268_dac_nids,
11781 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11782 .adc_nids = alc268_adc_nids_alt,
11783 .capsrc_nids = alc268_capsrc_nids,
11784 .hp_nid = 0x02,
11785 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11786 .channel_mode = alc268_modes,
11787 .input_mux = &alc268_acer_dmic_capture_source,
11788 .unsol_event = alc268_acer_unsol_event,
11789 .init_hook = alc268_acer_init_hook,
11790 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011791 [ALC268_ACER_ASPIRE_ONE] = {
11792 .mixers = { alc268_acer_aspire_one_mixer,
11793 alc268_capture_alt_mixer },
11794 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11795 alc268_acer_aspire_one_verbs },
11796 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11797 .dac_nids = alc268_dac_nids,
11798 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11799 .adc_nids = alc268_adc_nids_alt,
11800 .capsrc_nids = alc268_capsrc_nids,
11801 .hp_nid = 0x03,
11802 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11803 .channel_mode = alc268_modes,
11804 .input_mux = &alc268_acer_lc_capture_source,
11805 .unsol_event = alc268_acer_lc_unsol_event,
11806 .init_hook = alc268_acer_lc_init_hook,
11807 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011808 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011809 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011810 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11811 alc268_dell_verbs },
11812 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11813 .dac_nids = alc268_dac_nids,
11814 .hp_nid = 0x02,
11815 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11816 .channel_mode = alc268_modes,
11817 .unsol_event = alc268_dell_unsol_event,
11818 .init_hook = alc268_dell_init_hook,
11819 .input_mux = &alc268_capture_source,
11820 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011821 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011822 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11823 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011824 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11825 alc268_toshiba_verbs },
11826 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11827 .dac_nids = alc268_dac_nids,
11828 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11829 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011830 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011831 .hp_nid = 0x03,
11832 .dig_out_nid = ALC268_DIGOUT_NID,
11833 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11834 .channel_mode = alc268_modes,
11835 .input_mux = &alc268_capture_source,
11836 .unsol_event = alc268_toshiba_unsol_event,
11837 .init_hook = alc268_toshiba_automute
11838 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011839#ifdef CONFIG_SND_DEBUG
11840 [ALC268_TEST] = {
11841 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11842 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11843 alc268_volume_init_verbs },
11844 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11845 .dac_nids = alc268_dac_nids,
11846 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11847 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011848 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011849 .hp_nid = 0x03,
11850 .dig_out_nid = ALC268_DIGOUT_NID,
11851 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11852 .channel_mode = alc268_modes,
11853 .input_mux = &alc268_capture_source,
11854 },
11855#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011856};
11857
11858static int patch_alc268(struct hda_codec *codec)
11859{
11860 struct alc_spec *spec;
11861 int board_config;
11862 int err;
11863
11864 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11865 if (spec == NULL)
11866 return -ENOMEM;
11867
11868 codec->spec = spec;
11869
11870 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11871 alc268_models,
11872 alc268_cfg_tbl);
11873
11874 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11875 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11876 "trying auto-probe from BIOS...\n");
11877 board_config = ALC268_AUTO;
11878 }
11879
11880 if (board_config == ALC268_AUTO) {
11881 /* automatic parse from the BIOS config */
11882 err = alc268_parse_auto_config(codec);
11883 if (err < 0) {
11884 alc_free(codec);
11885 return err;
11886 } else if (!err) {
11887 printk(KERN_INFO
11888 "hda_codec: Cannot set up configuration "
11889 "from BIOS. Using base mode...\n");
11890 board_config = ALC268_3ST;
11891 }
11892 }
11893
11894 if (board_config != ALC268_AUTO)
11895 setup_preset(spec, &alc268_presets[board_config]);
11896
Kailang Yang2f893282008-05-27 12:14:47 +020011897 if (codec->vendor_id == 0x10ec0267) {
11898 spec->stream_name_analog = "ALC267 Analog";
11899 spec->stream_name_digital = "ALC267 Digital";
11900 } else {
11901 spec->stream_name_analog = "ALC268 Analog";
11902 spec->stream_name_digital = "ALC268 Digital";
11903 }
11904
Kailang Yanga361d842007-06-05 12:30:55 +020011905 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11906 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011907 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011908
Kailang Yanga361d842007-06-05 12:30:55 +020011909 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11910
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011911 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11912 /* override the amp caps for beep generator */
11913 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11914 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11915 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11916 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11917 (0 << AC_AMPCAP_MUTE_SHIFT));
11918
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011919 if (!spec->adc_nids && spec->input_mux) {
11920 /* check whether NID 0x07 is valid */
11921 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011922 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011923
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011924 /* get type */
11925 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011926 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011927 spec->adc_nids = alc268_adc_nids_alt;
11928 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011929 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011930 } else {
11931 spec->adc_nids = alc268_adc_nids;
11932 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011933 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011934 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011935 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011936 /* set default input source */
11937 for (i = 0; i < spec->num_adc_nids; i++)
11938 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11939 0, AC_VERB_SET_CONNECT_SEL,
11940 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011941 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011942
11943 spec->vmaster_nid = 0x02;
11944
Kailang Yanga361d842007-06-05 12:30:55 +020011945 codec->patch_ops = alc_patch_ops;
11946 if (board_config == ALC268_AUTO)
11947 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011948
Takashi Iwaidaead532008-11-28 12:55:36 +010011949 codec->proc_widget_hook = print_realtek_coef;
11950
Kailang Yanga361d842007-06-05 12:30:55 +020011951 return 0;
11952}
11953
11954/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011955 * ALC269 channel source setting (2 channel)
11956 */
11957#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11958
11959#define alc269_dac_nids alc260_dac_nids
11960
11961static hda_nid_t alc269_adc_nids[1] = {
11962 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011963 0x08,
11964};
11965
Takashi Iwaie01bf502008-08-21 16:25:07 +020011966static hda_nid_t alc269_capsrc_nids[1] = {
11967 0x23,
11968};
11969
11970/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11971 * not a mux!
11972 */
11973
Kailang Yangf53281e2008-07-18 12:36:43 +020011974static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11975 .num_items = 2,
11976 .items = {
11977 { "i-Mic", 0x5 },
11978 { "e-Mic", 0x0 },
11979 },
11980};
11981
11982static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11983 .num_items = 2,
11984 .items = {
11985 { "i-Mic", 0x1 },
11986 { "e-Mic", 0x0 },
11987 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011988};
11989
11990#define alc269_modes alc260_modes
11991#define alc269_capture_source alc880_lg_lw_capture_source
11992
11993static struct snd_kcontrol_new alc269_base_mixer[] = {
11994 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11995 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020012000 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12001 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010012002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12003 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12004 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12005 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12007 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12008 { } /* end */
12009};
12010
Kailang Yang60db6b52008-08-26 13:13:00 +020012011static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12012 /* output mixer control */
12013 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12014 {
12015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12016 .name = "Master Playback Switch",
12017 .info = snd_hda_mixer_amp_switch_info,
12018 .get = snd_hda_mixer_amp_switch_get,
12019 .put = alc268_acer_master_sw_put,
12020 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12021 },
12022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12026 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12027 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12028 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12029 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12030 { }
12031};
12032
Tony Vroon64154832008-11-06 15:08:49 +000012033static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12034 /* output mixer control */
12035 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12036 {
12037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12038 .name = "Master Playback Switch",
12039 .info = snd_hda_mixer_amp_switch_info,
12040 .get = snd_hda_mixer_amp_switch_get,
12041 .put = alc268_acer_master_sw_put,
12042 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12043 },
12044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12046 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12048 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12049 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12050 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12051 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12052 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12053 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12054 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12055 { }
12056};
12057
Kailang Yangf53281e2008-07-18 12:36:43 +020012058/* bind volumes of both NID 0x0c and 0x0d */
12059static struct hda_bind_ctls alc269_epc_bind_vol = {
12060 .ops = &snd_hda_bind_vol,
12061 .values = {
12062 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12063 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12064 0
12065 },
12066};
12067
12068static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12069 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12070 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12071 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12072 { } /* end */
12073};
12074
Kailang Yangf6a92242007-12-13 16:52:54 +010012075/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012076static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12077 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12078 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012079 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12080 { } /* end */
12081};
12082
12083/* FSC amilo */
12084static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12085 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12087 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012088 { } /* end */
12089};
12090
Takashi Iwai2005af22008-08-20 18:38:26 +020012091/* beep control */
12092static struct snd_kcontrol_new alc269_beep_mixer[] = {
12093 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12094 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12095 { } /* end */
12096};
12097
Kailang Yang60db6b52008-08-26 13:13:00 +020012098static struct hda_verb alc269_quanta_fl1_verbs[] = {
12099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12100 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12103 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12104 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12105 { }
12106};
12107
Tony Vroon64154832008-11-06 15:08:49 +000012108static struct hda_verb alc269_lifebook_verbs[] = {
12109 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12110 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12111 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12113 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12114 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12116 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12117 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12118 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12119 { }
12120};
12121
Kailang Yang60db6b52008-08-26 13:13:00 +020012122/* toggle speaker-output according to the hp-jack state */
12123static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12124{
12125 unsigned int present;
12126 unsigned char bits;
12127
12128 present = snd_hda_codec_read(codec, 0x15, 0,
12129 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12130 bits = present ? AMP_IN_MUTE(0) : 0;
12131 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12132 AMP_IN_MUTE(0), bits);
12133 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12134 AMP_IN_MUTE(0), bits);
12135
12136 snd_hda_codec_write(codec, 0x20, 0,
12137 AC_VERB_SET_COEF_INDEX, 0x0c);
12138 snd_hda_codec_write(codec, 0x20, 0,
12139 AC_VERB_SET_PROC_COEF, 0x680);
12140
12141 snd_hda_codec_write(codec, 0x20, 0,
12142 AC_VERB_SET_COEF_INDEX, 0x0c);
12143 snd_hda_codec_write(codec, 0x20, 0,
12144 AC_VERB_SET_PROC_COEF, 0x480);
12145}
12146
Tony Vroon64154832008-11-06 15:08:49 +000012147/* toggle speaker-output according to the hp-jacks state */
12148static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12149{
12150 unsigned int present;
12151 unsigned char bits;
12152
12153 /* Check laptop headphone socket */
12154 present = snd_hda_codec_read(codec, 0x15, 0,
12155 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12156
12157 /* Check port replicator headphone socket */
12158 present |= snd_hda_codec_read(codec, 0x1a, 0,
12159 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12160
12161 bits = present ? AMP_IN_MUTE(0) : 0;
12162 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12163 AMP_IN_MUTE(0), bits);
12164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12165 AMP_IN_MUTE(0), bits);
12166
12167 snd_hda_codec_write(codec, 0x20, 0,
12168 AC_VERB_SET_COEF_INDEX, 0x0c);
12169 snd_hda_codec_write(codec, 0x20, 0,
12170 AC_VERB_SET_PROC_COEF, 0x680);
12171
12172 snd_hda_codec_write(codec, 0x20, 0,
12173 AC_VERB_SET_COEF_INDEX, 0x0c);
12174 snd_hda_codec_write(codec, 0x20, 0,
12175 AC_VERB_SET_PROC_COEF, 0x480);
12176}
12177
Kailang Yang60db6b52008-08-26 13:13:00 +020012178static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12179{
12180 unsigned int present;
12181
12182 present = snd_hda_codec_read(codec, 0x18, 0,
12183 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12184 snd_hda_codec_write(codec, 0x23, 0,
12185 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12186}
12187
Tony Vroon64154832008-11-06 15:08:49 +000012188static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12189{
12190 unsigned int present_laptop;
12191 unsigned int present_dock;
12192
12193 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12195
12196 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12197 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12198
12199 /* Laptop mic port overrides dock mic port, design decision */
12200 if (present_dock)
12201 snd_hda_codec_write(codec, 0x23, 0,
12202 AC_VERB_SET_CONNECT_SEL, 0x3);
12203 if (present_laptop)
12204 snd_hda_codec_write(codec, 0x23, 0,
12205 AC_VERB_SET_CONNECT_SEL, 0x0);
12206 if (!present_dock && !present_laptop)
12207 snd_hda_codec_write(codec, 0x23, 0,
12208 AC_VERB_SET_CONNECT_SEL, 0x1);
12209}
12210
Kailang Yang60db6b52008-08-26 13:13:00 +020012211static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12212 unsigned int res)
12213{
12214 if ((res >> 26) == ALC880_HP_EVENT)
12215 alc269_quanta_fl1_speaker_automute(codec);
12216 if ((res >> 26) == ALC880_MIC_EVENT)
12217 alc269_quanta_fl1_mic_automute(codec);
12218}
12219
Tony Vroon64154832008-11-06 15:08:49 +000012220static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12221 unsigned int res)
12222{
12223 if ((res >> 26) == ALC880_HP_EVENT)
12224 alc269_lifebook_speaker_automute(codec);
12225 if ((res >> 26) == ALC880_MIC_EVENT)
12226 alc269_lifebook_mic_autoswitch(codec);
12227}
12228
Kailang Yang60db6b52008-08-26 13:13:00 +020012229static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12230{
12231 alc269_quanta_fl1_speaker_automute(codec);
12232 alc269_quanta_fl1_mic_automute(codec);
12233}
12234
Tony Vroon64154832008-11-06 15:08:49 +000012235static void alc269_lifebook_init_hook(struct hda_codec *codec)
12236{
12237 alc269_lifebook_speaker_automute(codec);
12238 alc269_lifebook_mic_autoswitch(codec);
12239}
12240
Kailang Yang60db6b52008-08-26 13:13:00 +020012241static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12242 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12243 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12244 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12248 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12249 {}
12250};
12251
12252static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12254 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12255 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12257 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12258 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12259 {}
12260};
12261
12262/* toggle speaker-output according to the hp-jack state */
12263static void alc269_speaker_automute(struct hda_codec *codec)
12264{
12265 unsigned int present;
12266 unsigned char bits;
12267
12268 present = snd_hda_codec_read(codec, 0x15, 0,
12269 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12270 bits = present ? AMP_IN_MUTE(0) : 0;
12271 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12272 AMP_IN_MUTE(0), bits);
12273 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12274 AMP_IN_MUTE(0), bits);
12275}
12276
12277static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12278{
12279 unsigned int present;
12280
12281 present = snd_hda_codec_read(codec, 0x18, 0,
12282 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12283 snd_hda_codec_write(codec, 0x23, 0,
12284 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12285}
12286
12287static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12288{
12289 unsigned int present;
12290
12291 present = snd_hda_codec_read(codec, 0x18, 0,
12292 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12293 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12294 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12295 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12296 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12297}
12298
12299/* unsolicited event for HP jack sensing */
12300static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12301 unsigned int res)
12302{
12303 if ((res >> 26) == ALC880_HP_EVENT)
12304 alc269_speaker_automute(codec);
12305
12306 if ((res >> 26) == ALC880_MIC_EVENT)
12307 alc269_eeepc_dmic_automute(codec);
12308}
12309
12310static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12311{
12312 alc269_speaker_automute(codec);
12313 alc269_eeepc_dmic_automute(codec);
12314}
12315
12316/* unsolicited event for HP jack sensing */
12317static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12318 unsigned int res)
12319{
12320 if ((res >> 26) == ALC880_HP_EVENT)
12321 alc269_speaker_automute(codec);
12322
12323 if ((res >> 26) == ALC880_MIC_EVENT)
12324 alc269_eeepc_amic_automute(codec);
12325}
12326
12327static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12328{
12329 alc269_speaker_automute(codec);
12330 alc269_eeepc_amic_automute(codec);
12331}
12332
Kailang Yangf6a92242007-12-13 16:52:54 +010012333/*
12334 * generic initialization of ADC, input mixers and output mixers
12335 */
12336static struct hda_verb alc269_init_verbs[] = {
12337 /*
12338 * Unmute ADC0 and set the default input to mic-in
12339 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012341
12342 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12343 * analog-loopback mixer widget
12344 * Note: PASD motherboards uses the Line In 2 as the input for
12345 * front panel mic (mic 2)
12346 */
12347 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12353
12354 /*
12355 * Set up output mixers (0x0c - 0x0e)
12356 */
12357 /* set vol=0 to output mixers */
12358 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12359 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12360
12361 /* set up input amps for analog loopback */
12362 /* Amp Indices: DAC = 0, mixer = 1 */
12363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12369
12370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12372 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12377
12378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12379 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12380 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12383 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12385
12386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12388
12389 /* FIXME: use matrix-type input source selection */
12390 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12391 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12396
12397 /* set EAPD */
12398 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12399 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12400 { }
12401};
12402
12403/* add playback controls from the parsed DAC table */
12404static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12405 const struct auto_pin_cfg *cfg)
12406{
12407 hda_nid_t nid;
12408 int err;
12409
12410 spec->multiout.num_dacs = 1; /* only use one dac */
12411 spec->multiout.dac_nids = spec->private_dac_nids;
12412 spec->multiout.dac_nids[0] = 2;
12413
12414 nid = cfg->line_out_pins[0];
12415 if (nid) {
12416 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12417 "Front Playback Volume",
12418 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12419 if (err < 0)
12420 return err;
12421 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12422 "Front Playback Switch",
12423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12424 if (err < 0)
12425 return err;
12426 }
12427
12428 nid = cfg->speaker_pins[0];
12429 if (nid) {
12430 if (!cfg->line_out_pins[0]) {
12431 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12432 "Speaker Playback Volume",
12433 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12434 HDA_OUTPUT));
12435 if (err < 0)
12436 return err;
12437 }
12438 if (nid == 0x16) {
12439 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12440 "Speaker Playback Switch",
12441 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12442 HDA_OUTPUT));
12443 if (err < 0)
12444 return err;
12445 } else {
12446 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12447 "Speaker Playback Switch",
12448 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12449 HDA_OUTPUT));
12450 if (err < 0)
12451 return err;
12452 }
12453 }
12454 nid = cfg->hp_pins[0];
12455 if (nid) {
12456 /* spec->multiout.hp_nid = 2; */
12457 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12458 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12459 "Headphone Playback Volume",
12460 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12461 HDA_OUTPUT));
12462 if (err < 0)
12463 return err;
12464 }
12465 if (nid == 0x16) {
12466 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12467 "Headphone Playback Switch",
12468 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12469 HDA_OUTPUT));
12470 if (err < 0)
12471 return err;
12472 } else {
12473 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12474 "Headphone Playback Switch",
12475 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12476 HDA_OUTPUT));
12477 if (err < 0)
12478 return err;
12479 }
12480 }
12481 return 0;
12482}
12483
Takashi Iwaiee956e02008-10-31 17:16:31 +010012484static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12485 const struct auto_pin_cfg *cfg)
12486{
12487 int err;
12488
12489 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12490 if (err < 0)
12491 return err;
12492 /* digital-mic input pin is excluded in alc880_auto_create..()
12493 * because it's under 0x18
12494 */
12495 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12496 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12497 struct hda_input_mux *imux = &spec->private_imux;
12498 imux->items[imux->num_items].label = "Int Mic";
12499 imux->items[imux->num_items].index = 0x05;
12500 imux->num_items++;
12501 }
12502 return 0;
12503}
Kailang Yangf6a92242007-12-13 16:52:54 +010012504
12505#ifdef CONFIG_SND_HDA_POWER_SAVE
12506#define alc269_loopbacks alc880_loopbacks
12507#endif
12508
12509/* pcm configuration: identiacal with ALC880 */
12510#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12511#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12512#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12513#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12514
12515/*
12516 * BIOS auto configuration
12517 */
12518static int alc269_parse_auto_config(struct hda_codec *codec)
12519{
12520 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012521 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012522 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12523
12524 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12525 alc269_ignore);
12526 if (err < 0)
12527 return err;
12528
12529 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12530 if (err < 0)
12531 return err;
12532 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12533 if (err < 0)
12534 return err;
12535
12536 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12537
12538 if (spec->autocfg.dig_out_pin)
12539 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12540
Takashi Iwai603c4012008-07-30 15:01:44 +020012541 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012542 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012543
Takashi Iwai2005af22008-08-20 18:38:26 +020012544 /* create a beep mixer control if the pin 0x1d isn't assigned */
12545 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12546 if (spec->autocfg.input_pins[i] == 0x1d)
12547 break;
12548 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012549 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012550
Takashi Iwaid88897e2008-10-31 15:01:37 +010012551 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012552 spec->num_mux_defs = 1;
12553 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012554 /* set default input source */
12555 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12556 0, AC_VERB_SET_CONNECT_SEL,
12557 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012558
12559 err = alc_auto_add_mic_boost(codec);
12560 if (err < 0)
12561 return err;
12562
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012563 if (!spec->cap_mixer)
12564 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012565
Takashi Iwaie044c392008-10-27 16:56:24 +010012566 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012567 return 1;
12568}
12569
12570#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12571#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12572#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12573
12574
12575/* init callback for auto-configuration model -- overriding the default init */
12576static void alc269_auto_init(struct hda_codec *codec)
12577{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012578 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012579 alc269_auto_init_multi_out(codec);
12580 alc269_auto_init_hp_out(codec);
12581 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012582 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012583 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012584}
12585
12586/*
12587 * configuration and preset
12588 */
12589static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012590 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012591 [ALC269_QUANTA_FL1] = "quanta",
12592 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012593 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012594 [ALC269_FUJITSU] = "fujitsu",
12595 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012596};
12597
12598static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012599 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012600 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12601 ALC269_ASUS_EEEPC_P703),
12602 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12603 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012604 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12605 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012606 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012607 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012608 {}
12609};
12610
12611static struct alc_config_preset alc269_presets[] = {
12612 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012613 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012614 .init_verbs = { alc269_init_verbs },
12615 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12616 .dac_nids = alc269_dac_nids,
12617 .hp_nid = 0x03,
12618 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12619 .channel_mode = alc269_modes,
12620 .input_mux = &alc269_capture_source,
12621 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012622 [ALC269_QUANTA_FL1] = {
12623 .mixers = { alc269_quanta_fl1_mixer },
12624 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12625 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12626 .dac_nids = alc269_dac_nids,
12627 .hp_nid = 0x03,
12628 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12629 .channel_mode = alc269_modes,
12630 .input_mux = &alc269_capture_source,
12631 .unsol_event = alc269_quanta_fl1_unsol_event,
12632 .init_hook = alc269_quanta_fl1_init_hook,
12633 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012634 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012635 .mixers = { alc269_eeepc_mixer },
12636 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012637 .init_verbs = { alc269_init_verbs,
12638 alc269_eeepc_amic_init_verbs },
12639 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12640 .dac_nids = alc269_dac_nids,
12641 .hp_nid = 0x03,
12642 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12643 .channel_mode = alc269_modes,
12644 .input_mux = &alc269_eeepc_amic_capture_source,
12645 .unsol_event = alc269_eeepc_amic_unsol_event,
12646 .init_hook = alc269_eeepc_amic_inithook,
12647 },
12648 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012649 .mixers = { alc269_eeepc_mixer },
12650 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012651 .init_verbs = { alc269_init_verbs,
12652 alc269_eeepc_dmic_init_verbs },
12653 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12654 .dac_nids = alc269_dac_nids,
12655 .hp_nid = 0x03,
12656 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12657 .channel_mode = alc269_modes,
12658 .input_mux = &alc269_eeepc_dmic_capture_source,
12659 .unsol_event = alc269_eeepc_dmic_unsol_event,
12660 .init_hook = alc269_eeepc_dmic_inithook,
12661 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012662 [ALC269_FUJITSU] = {
12663 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12664 .cap_mixer = alc269_epc_capture_mixer,
12665 .init_verbs = { alc269_init_verbs,
12666 alc269_eeepc_dmic_init_verbs },
12667 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12668 .dac_nids = alc269_dac_nids,
12669 .hp_nid = 0x03,
12670 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12671 .channel_mode = alc269_modes,
12672 .input_mux = &alc269_eeepc_dmic_capture_source,
12673 .unsol_event = alc269_eeepc_dmic_unsol_event,
12674 .init_hook = alc269_eeepc_dmic_inithook,
12675 },
Tony Vroon64154832008-11-06 15:08:49 +000012676 [ALC269_LIFEBOOK] = {
12677 .mixers = { alc269_lifebook_mixer },
12678 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12679 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12680 .dac_nids = alc269_dac_nids,
12681 .hp_nid = 0x03,
12682 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12683 .channel_mode = alc269_modes,
12684 .input_mux = &alc269_capture_source,
12685 .unsol_event = alc269_lifebook_unsol_event,
12686 .init_hook = alc269_lifebook_init_hook,
12687 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012688};
12689
12690static int patch_alc269(struct hda_codec *codec)
12691{
12692 struct alc_spec *spec;
12693 int board_config;
12694 int err;
12695
12696 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12697 if (spec == NULL)
12698 return -ENOMEM;
12699
12700 codec->spec = spec;
12701
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012702 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12703
Kailang Yangf6a92242007-12-13 16:52:54 +010012704 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12705 alc269_models,
12706 alc269_cfg_tbl);
12707
12708 if (board_config < 0) {
12709 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12710 "trying auto-probe from BIOS...\n");
12711 board_config = ALC269_AUTO;
12712 }
12713
12714 if (board_config == ALC269_AUTO) {
12715 /* automatic parse from the BIOS config */
12716 err = alc269_parse_auto_config(codec);
12717 if (err < 0) {
12718 alc_free(codec);
12719 return err;
12720 } else if (!err) {
12721 printk(KERN_INFO
12722 "hda_codec: Cannot set up configuration "
12723 "from BIOS. Using base mode...\n");
12724 board_config = ALC269_BASIC;
12725 }
12726 }
12727
12728 if (board_config != ALC269_AUTO)
12729 setup_preset(spec, &alc269_presets[board_config]);
12730
12731 spec->stream_name_analog = "ALC269 Analog";
12732 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12733 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12734
12735 spec->stream_name_digital = "ALC269 Digital";
12736 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12737 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12738
12739 spec->adc_nids = alc269_adc_nids;
12740 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012741 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012742 if (!spec->cap_mixer)
12743 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012744
12745 codec->patch_ops = alc_patch_ops;
12746 if (board_config == ALC269_AUTO)
12747 spec->init_hook = alc269_auto_init;
12748#ifdef CONFIG_SND_HDA_POWER_SAVE
12749 if (!spec->loopback.amplist)
12750 spec->loopback.amplist = alc269_loopbacks;
12751#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012752 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012753
12754 return 0;
12755}
12756
12757/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012758 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12759 */
12760
12761/*
12762 * set the path ways for 2 channel output
12763 * need to set the codec line out and mic 1 pin widgets to inputs
12764 */
12765static struct hda_verb alc861_threestack_ch2_init[] = {
12766 /* set pin widget 1Ah (line in) for input */
12767 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012768 /* set pin widget 18h (mic1/2) for input, for mic also enable
12769 * the vref
12770 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012771 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12772
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012773 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12774#if 0
12775 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12776 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12777#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012778 { } /* end */
12779};
12780/*
12781 * 6ch mode
12782 * need to set the codec line out and mic 1 pin widgets to outputs
12783 */
12784static struct hda_verb alc861_threestack_ch6_init[] = {
12785 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12786 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12787 /* set pin widget 18h (mic1) for output (CLFE)*/
12788 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12789
12790 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012791 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012792
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012793 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12794#if 0
12795 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12796 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12797#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012798 { } /* end */
12799};
12800
12801static struct hda_channel_mode alc861_threestack_modes[2] = {
12802 { 2, alc861_threestack_ch2_init },
12803 { 6, alc861_threestack_ch6_init },
12804};
Takashi Iwai22309c32006-08-09 16:57:28 +020012805/* Set mic1 as input and unmute the mixer */
12806static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12807 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12808 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12809 { } /* end */
12810};
12811/* Set mic1 as output and mute mixer */
12812static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12813 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12814 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12815 { } /* end */
12816};
12817
12818static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12819 { 2, alc861_uniwill_m31_ch2_init },
12820 { 4, alc861_uniwill_m31_ch4_init },
12821};
Kailang Yangdf694da2005-12-05 19:42:22 +010012822
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012823/* Set mic1 and line-in as input and unmute the mixer */
12824static struct hda_verb alc861_asus_ch2_init[] = {
12825 /* set pin widget 1Ah (line in) for input */
12826 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012827 /* set pin widget 18h (mic1/2) for input, for mic also enable
12828 * the vref
12829 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012830 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12831
12832 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12833#if 0
12834 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12835 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12836#endif
12837 { } /* end */
12838};
12839/* Set mic1 nad line-in as output and mute mixer */
12840static struct hda_verb alc861_asus_ch6_init[] = {
12841 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12842 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12843 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12844 /* set pin widget 18h (mic1) for output (CLFE)*/
12845 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12846 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12847 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12848 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12849
12850 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12851#if 0
12852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12853 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12854#endif
12855 { } /* end */
12856};
12857
12858static struct hda_channel_mode alc861_asus_modes[2] = {
12859 { 2, alc861_asus_ch2_init },
12860 { 6, alc861_asus_ch6_init },
12861};
12862
Kailang Yangdf694da2005-12-05 19:42:22 +010012863/* patch-ALC861 */
12864
12865static struct snd_kcontrol_new alc861_base_mixer[] = {
12866 /* output mixer control */
12867 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12868 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12869 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12870 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12871 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12872
12873 /*Input mixer control */
12874 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12875 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12876 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12877 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12878 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12879 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12881 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12882 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012884
Kailang Yangdf694da2005-12-05 19:42:22 +010012885 { } /* end */
12886};
12887
12888static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12889 /* output mixer control */
12890 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12891 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12892 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12893 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12894 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12895
12896 /* Input mixer control */
12897 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12898 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12899 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12900 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12901 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12902 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12904 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012907
Kailang Yangdf694da2005-12-05 19:42:22 +010012908 {
12909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12910 .name = "Channel Mode",
12911 .info = alc_ch_mode_info,
12912 .get = alc_ch_mode_get,
12913 .put = alc_ch_mode_put,
12914 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12915 },
12916 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012917};
12918
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012919static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012920 /* output mixer control */
12921 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12923 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012924
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012925 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012926};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012927
Takashi Iwai22309c32006-08-09 16:57:28 +020012928static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12929 /* output mixer control */
12930 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12931 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12932 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12933 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12934 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12935
12936 /* Input mixer control */
12937 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12938 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12939 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12940 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12941 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12942 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12944 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12945 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012947
Takashi Iwai22309c32006-08-09 16:57:28 +020012948 {
12949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12950 .name = "Channel Mode",
12951 .info = alc_ch_mode_info,
12952 .get = alc_ch_mode_get,
12953 .put = alc_ch_mode_put,
12954 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12955 },
12956 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012957};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012958
12959static struct snd_kcontrol_new alc861_asus_mixer[] = {
12960 /* output mixer control */
12961 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12962 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12963 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12964 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12965 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12966
12967 /* Input mixer control */
12968 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12970 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12971 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12972 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12973 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12975 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12978
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012979 {
12980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12981 .name = "Channel Mode",
12982 .info = alc_ch_mode_info,
12983 .get = alc_ch_mode_get,
12984 .put = alc_ch_mode_put,
12985 .private_value = ARRAY_SIZE(alc861_asus_modes),
12986 },
12987 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012988};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012989
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012990/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012991static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012992 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12993 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12994 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12995 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12996 { }
12997};
12998
Kailang Yangdf694da2005-12-05 19:42:22 +010012999/*
13000 * generic initialization of ADC, input mixers and output mixers
13001 */
13002static struct hda_verb alc861_base_init_verbs[] = {
13003 /*
13004 * Unmute ADC0 and set the default input to mic-in
13005 */
13006 /* port-A for surround (rear panel) */
13007 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13008 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13009 /* port-B for mic-in (rear panel) with vref */
13010 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13011 /* port-C for line-in (rear panel) */
13012 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13013 /* port-D for Front */
13014 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13015 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13016 /* port-E for HP out (front panel) */
13017 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13018 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013019 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013020 /* port-F for mic-in (front panel) with vref */
13021 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13022 /* port-G for CLFE (rear panel) */
13023 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13024 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13025 /* port-H for side (rear panel) */
13026 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13027 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13028 /* CD-in */
13029 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13030 /* route front mic to ADC1*/
13031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013033
Kailang Yangdf694da2005-12-05 19:42:22 +010013034 /* Unmute DAC0~3 & spdif out*/
13035 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13036 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13037 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13038 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013040
Kailang Yangdf694da2005-12-05 19:42:22 +010013041 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13042 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13043 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13044 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13045 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013046
Kailang Yangdf694da2005-12-05 19:42:22 +010013047 /* Unmute Stereo Mixer 15 */
13048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013052
13053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13054 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13058 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13060 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013061 /* hp used DAC 3 (Front) */
13062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13064
13065 { }
13066};
13067
13068static struct hda_verb alc861_threestack_init_verbs[] = {
13069 /*
13070 * Unmute ADC0 and set the default input to mic-in
13071 */
13072 /* port-A for surround (rear panel) */
13073 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13074 /* port-B for mic-in (rear panel) with vref */
13075 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13076 /* port-C for line-in (rear panel) */
13077 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13078 /* port-D for Front */
13079 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13080 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13081 /* port-E for HP out (front panel) */
13082 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13083 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013084 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013085 /* port-F for mic-in (front panel) with vref */
13086 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13087 /* port-G for CLFE (rear panel) */
13088 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13089 /* port-H for side (rear panel) */
13090 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13091 /* CD-in */
13092 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13093 /* route front mic to ADC1*/
13094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13096 /* Unmute DAC0~3 & spdif out*/
13097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13100 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013102
Kailang Yangdf694da2005-12-05 19:42:22 +010013103 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13104 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13105 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13106 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13107 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013108
Kailang Yangdf694da2005-12-05 19:42:22 +010013109 /* Unmute Stereo Mixer 15 */
13110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013114
13115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13117 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13121 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013123 /* hp used DAC 3 (Front) */
13124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13126 { }
13127};
Takashi Iwai22309c32006-08-09 16:57:28 +020013128
13129static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13130 /*
13131 * Unmute ADC0 and set the default input to mic-in
13132 */
13133 /* port-A for surround (rear panel) */
13134 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13135 /* port-B for mic-in (rear panel) with vref */
13136 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13137 /* port-C for line-in (rear panel) */
13138 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13139 /* port-D for Front */
13140 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13141 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13142 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013143 /* this has to be set to VREF80 */
13144 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013145 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013146 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013147 /* port-F for mic-in (front panel) with vref */
13148 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13149 /* port-G for CLFE (rear panel) */
13150 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13151 /* port-H for side (rear panel) */
13152 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13153 /* CD-in */
13154 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13155 /* route front mic to ADC1*/
13156 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13158 /* Unmute DAC0~3 & spdif out*/
13159 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13160 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13161 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13162 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013164
Takashi Iwai22309c32006-08-09 16:57:28 +020013165 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13166 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13167 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13168 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13169 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013170
Takashi Iwai22309c32006-08-09 16:57:28 +020013171 /* Unmute Stereo Mixer 15 */
13172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013176
13177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13178 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13180 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13182 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013185 /* hp used DAC 3 (Front) */
13186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13188 { }
13189};
13190
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013191static struct hda_verb alc861_asus_init_verbs[] = {
13192 /*
13193 * Unmute ADC0 and set the default input to mic-in
13194 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013195 /* port-A for surround (rear panel)
13196 * according to codec#0 this is the HP jack
13197 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013198 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13199 /* route front PCM to HP */
13200 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13201 /* port-B for mic-in (rear panel) with vref */
13202 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13203 /* port-C for line-in (rear panel) */
13204 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13205 /* port-D for Front */
13206 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13207 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13208 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013209 /* this has to be set to VREF80 */
13210 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013211 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013212 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013213 /* port-F for mic-in (front panel) with vref */
13214 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13215 /* port-G for CLFE (rear panel) */
13216 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13217 /* port-H for side (rear panel) */
13218 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13219 /* CD-in */
13220 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13221 /* route front mic to ADC1*/
13222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13224 /* Unmute DAC0~3 & spdif out*/
13225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13227 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13228 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13230 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13231 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13232 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13233 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13234 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013235
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013236 /* Unmute Stereo Mixer 15 */
13237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013241
13242 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13244 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13246 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13247 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13248 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13249 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013250 /* hp used DAC 3 (Front) */
13251 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13253 { }
13254};
13255
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013256/* additional init verbs for ASUS laptops */
13257static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13258 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13259 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13260 { }
13261};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013262
Kailang Yangdf694da2005-12-05 19:42:22 +010013263/*
13264 * generic initialization of ADC, input mixers and output mixers
13265 */
13266static struct hda_verb alc861_auto_init_verbs[] = {
13267 /*
13268 * Unmute ADC0 and set the default input to mic-in
13269 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013270 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013272
Kailang Yangdf694da2005-12-05 19:42:22 +010013273 /* Unmute DAC0~3 & spdif out*/
13274 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13276 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13277 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013279
Kailang Yangdf694da2005-12-05 19:42:22 +010013280 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13281 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13282 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13283 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13284 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013285
Kailang Yangdf694da2005-12-05 19:42:22 +010013286 /* Unmute Stereo Mixer 15 */
13287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13291
13292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13300
13301 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013305 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13306 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013309
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013310 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013311
13312 { }
13313};
13314
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013315static struct hda_verb alc861_toshiba_init_verbs[] = {
13316 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013317
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013318 { }
13319};
13320
13321/* toggle speaker-output according to the hp-jack state */
13322static void alc861_toshiba_automute(struct hda_codec *codec)
13323{
13324 unsigned int present;
13325
13326 present = snd_hda_codec_read(codec, 0x0f, 0,
13327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013328 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13329 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13330 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13331 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013332}
13333
13334static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13335 unsigned int res)
13336{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013337 if ((res >> 26) == ALC880_HP_EVENT)
13338 alc861_toshiba_automute(codec);
13339}
13340
Kailang Yangdf694da2005-12-05 19:42:22 +010013341/* pcm configuration: identiacal with ALC880 */
13342#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13343#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13344#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13345#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13346
13347
13348#define ALC861_DIGOUT_NID 0x07
13349
13350static struct hda_channel_mode alc861_8ch_modes[1] = {
13351 { 8, NULL }
13352};
13353
13354static hda_nid_t alc861_dac_nids[4] = {
13355 /* front, surround, clfe, side */
13356 0x03, 0x06, 0x05, 0x04
13357};
13358
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013359static hda_nid_t alc660_dac_nids[3] = {
13360 /* front, clfe, surround */
13361 0x03, 0x05, 0x06
13362};
13363
Kailang Yangdf694da2005-12-05 19:42:22 +010013364static hda_nid_t alc861_adc_nids[1] = {
13365 /* ADC0-2 */
13366 0x08,
13367};
13368
13369static struct hda_input_mux alc861_capture_source = {
13370 .num_items = 5,
13371 .items = {
13372 { "Mic", 0x0 },
13373 { "Front Mic", 0x3 },
13374 { "Line", 0x1 },
13375 { "CD", 0x4 },
13376 { "Mixer", 0x5 },
13377 },
13378};
13379
13380/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013381static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13382 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013383{
13384 int i;
13385 hda_nid_t nid;
13386
13387 spec->multiout.dac_nids = spec->private_dac_nids;
13388 for (i = 0; i < cfg->line_outs; i++) {
13389 nid = cfg->line_out_pins[i];
13390 if (nid) {
13391 if (i >= ARRAY_SIZE(alc861_dac_nids))
13392 continue;
13393 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13394 }
13395 }
13396 spec->multiout.num_dacs = cfg->line_outs;
13397 return 0;
13398}
13399
13400/* add playback controls from the parsed DAC table */
13401static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13402 const struct auto_pin_cfg *cfg)
13403{
13404 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013405 static const char *chname[4] = {
13406 "Front", "Surround", NULL /*CLFE*/, "Side"
13407 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013408 hda_nid_t nid;
13409 int i, idx, err;
13410
13411 for (i = 0; i < cfg->line_outs; i++) {
13412 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013413 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013414 continue;
13415 if (nid == 0x05) {
13416 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013417 err = add_control(spec, ALC_CTL_BIND_MUTE,
13418 "Center Playback Switch",
13419 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13420 HDA_OUTPUT));
13421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013423 err = add_control(spec, ALC_CTL_BIND_MUTE,
13424 "LFE Playback Switch",
13425 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13426 HDA_OUTPUT));
13427 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013428 return err;
13429 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013430 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13431 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013432 if (nid == alc861_dac_nids[idx])
13433 break;
13434 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013435 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13436 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13437 HDA_OUTPUT));
13438 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013439 return err;
13440 }
13441 }
13442 return 0;
13443}
13444
13445static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13446{
13447 int err;
13448 hda_nid_t nid;
13449
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013450 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013451 return 0;
13452
13453 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13454 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013455 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13456 "Headphone Playback Switch",
13457 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13458 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013459 return err;
13460 spec->multiout.hp_nid = nid;
13461 }
13462 return 0;
13463}
13464
13465/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013466static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13467 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013468{
Kailang Yangdf694da2005-12-05 19:42:22 +010013469 struct hda_input_mux *imux = &spec->private_imux;
13470 int i, err, idx, idx1;
13471
13472 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013473 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013474 case 0x0c:
13475 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013476 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013477 break;
13478 case 0x0f:
13479 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013480 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013481 break;
13482 case 0x0d:
13483 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013484 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013485 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013486 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013487 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013488 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013489 break;
13490 case 0x11:
13491 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013492 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013493 break;
13494 default:
13495 continue;
13496 }
13497
Takashi Iwai4a471b72005-12-07 13:56:29 +010013498 err = new_analog_input(spec, cfg->input_pins[i],
13499 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013500 if (err < 0)
13501 return err;
13502
Takashi Iwai4a471b72005-12-07 13:56:29 +010013503 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013504 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013505 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013506 }
13507 return 0;
13508}
13509
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013510static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13511 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013512 int pin_type, int dac_idx)
13513{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013514 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13515 pin_type);
13516 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13517 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013518}
13519
13520static void alc861_auto_init_multi_out(struct hda_codec *codec)
13521{
13522 struct alc_spec *spec = codec->spec;
13523 int i;
13524
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013525 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013526 for (i = 0; i < spec->autocfg.line_outs; i++) {
13527 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013528 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013529 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013530 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013531 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013532 }
13533}
13534
13535static void alc861_auto_init_hp_out(struct hda_codec *codec)
13536{
13537 struct alc_spec *spec = codec->spec;
13538 hda_nid_t pin;
13539
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013540 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013541 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013542 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13543 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013544 pin = spec->autocfg.speaker_pins[0];
13545 if (pin)
13546 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013547}
13548
13549static void alc861_auto_init_analog_input(struct hda_codec *codec)
13550{
13551 struct alc_spec *spec = codec->spec;
13552 int i;
13553
13554 for (i = 0; i < AUTO_PIN_LAST; i++) {
13555 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013556 if (nid >= 0x0c && nid <= 0x11) {
13557 snd_hda_codec_write(codec, nid, 0,
13558 AC_VERB_SET_PIN_WIDGET_CONTROL,
13559 i <= AUTO_PIN_FRONT_MIC ?
13560 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013561 }
13562 }
13563}
13564
13565/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013566/* return 1 if successful, 0 if the proper config is not found,
13567 * or a negative error code
13568 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013569static int alc861_parse_auto_config(struct hda_codec *codec)
13570{
13571 struct alc_spec *spec = codec->spec;
13572 int err;
13573 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013575 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13576 alc861_ignore);
13577 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013578 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013579 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013580 return 0; /* can't find valid BIOS pin config */
13581
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013582 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13583 if (err < 0)
13584 return err;
13585 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13586 if (err < 0)
13587 return err;
13588 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13589 if (err < 0)
13590 return err;
13591 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13592 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013593 return err;
13594
13595 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13596
13597 if (spec->autocfg.dig_out_pin)
13598 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13599
Takashi Iwai603c4012008-07-30 15:01:44 +020013600 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013601 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013602
Takashi Iwaid88897e2008-10-31 15:01:37 +010013603 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013604
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013605 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013606 spec->input_mux = &spec->private_imux;
13607
13608 spec->adc_nids = alc861_adc_nids;
13609 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013610 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013611
Takashi Iwaie044c392008-10-27 16:56:24 +010013612 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013613 return 1;
13614}
13615
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013616/* additional initialization for auto-configuration model */
13617static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013618{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013619 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013620 alc861_auto_init_multi_out(codec);
13621 alc861_auto_init_hp_out(codec);
13622 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013623 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013624 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013625}
13626
Takashi Iwaicb53c622007-08-10 17:21:45 +020013627#ifdef CONFIG_SND_HDA_POWER_SAVE
13628static struct hda_amp_list alc861_loopbacks[] = {
13629 { 0x15, HDA_INPUT, 0 },
13630 { 0x15, HDA_INPUT, 1 },
13631 { 0x15, HDA_INPUT, 2 },
13632 { 0x15, HDA_INPUT, 3 },
13633 { } /* end */
13634};
13635#endif
13636
Kailang Yangdf694da2005-12-05 19:42:22 +010013637
13638/*
13639 * configuration and preset
13640 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013641static const char *alc861_models[ALC861_MODEL_LAST] = {
13642 [ALC861_3ST] = "3stack",
13643 [ALC660_3ST] = "3stack-660",
13644 [ALC861_3ST_DIG] = "3stack-dig",
13645 [ALC861_6ST_DIG] = "6stack-dig",
13646 [ALC861_UNIWILL_M31] = "uniwill-m31",
13647 [ALC861_TOSHIBA] = "toshiba",
13648 [ALC861_ASUS] = "asus",
13649 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13650 [ALC861_AUTO] = "auto",
13651};
13652
13653static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013654 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013655 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13656 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13657 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013658 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013659 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013660 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013661 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13662 * Any other models that need this preset?
13663 */
13664 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013665 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13666 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013667 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13668 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13669 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13670 /* FIXME: the below seems conflict */
13671 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13672 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13673 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013674 {}
13675};
13676
13677static struct alc_config_preset alc861_presets[] = {
13678 [ALC861_3ST] = {
13679 .mixers = { alc861_3ST_mixer },
13680 .init_verbs = { alc861_threestack_init_verbs },
13681 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13682 .dac_nids = alc861_dac_nids,
13683 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13684 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013685 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013686 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13687 .adc_nids = alc861_adc_nids,
13688 .input_mux = &alc861_capture_source,
13689 },
13690 [ALC861_3ST_DIG] = {
13691 .mixers = { alc861_base_mixer },
13692 .init_verbs = { alc861_threestack_init_verbs },
13693 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13694 .dac_nids = alc861_dac_nids,
13695 .dig_out_nid = ALC861_DIGOUT_NID,
13696 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13697 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013698 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013699 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13700 .adc_nids = alc861_adc_nids,
13701 .input_mux = &alc861_capture_source,
13702 },
13703 [ALC861_6ST_DIG] = {
13704 .mixers = { alc861_base_mixer },
13705 .init_verbs = { alc861_base_init_verbs },
13706 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13707 .dac_nids = alc861_dac_nids,
13708 .dig_out_nid = ALC861_DIGOUT_NID,
13709 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13710 .channel_mode = alc861_8ch_modes,
13711 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13712 .adc_nids = alc861_adc_nids,
13713 .input_mux = &alc861_capture_source,
13714 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013715 [ALC660_3ST] = {
13716 .mixers = { alc861_3ST_mixer },
13717 .init_verbs = { alc861_threestack_init_verbs },
13718 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13719 .dac_nids = alc660_dac_nids,
13720 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13721 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013722 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013723 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13724 .adc_nids = alc861_adc_nids,
13725 .input_mux = &alc861_capture_source,
13726 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013727 [ALC861_UNIWILL_M31] = {
13728 .mixers = { alc861_uniwill_m31_mixer },
13729 .init_verbs = { alc861_uniwill_m31_init_verbs },
13730 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13731 .dac_nids = alc861_dac_nids,
13732 .dig_out_nid = ALC861_DIGOUT_NID,
13733 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13734 .channel_mode = alc861_uniwill_m31_modes,
13735 .need_dac_fix = 1,
13736 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13737 .adc_nids = alc861_adc_nids,
13738 .input_mux = &alc861_capture_source,
13739 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013740 [ALC861_TOSHIBA] = {
13741 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742 .init_verbs = { alc861_base_init_verbs,
13743 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013744 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13745 .dac_nids = alc861_dac_nids,
13746 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13747 .channel_mode = alc883_3ST_2ch_modes,
13748 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13749 .adc_nids = alc861_adc_nids,
13750 .input_mux = &alc861_capture_source,
13751 .unsol_event = alc861_toshiba_unsol_event,
13752 .init_hook = alc861_toshiba_automute,
13753 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013754 [ALC861_ASUS] = {
13755 .mixers = { alc861_asus_mixer },
13756 .init_verbs = { alc861_asus_init_verbs },
13757 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13758 .dac_nids = alc861_dac_nids,
13759 .dig_out_nid = ALC861_DIGOUT_NID,
13760 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13761 .channel_mode = alc861_asus_modes,
13762 .need_dac_fix = 1,
13763 .hp_nid = 0x06,
13764 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13765 .adc_nids = alc861_adc_nids,
13766 .input_mux = &alc861_capture_source,
13767 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013768 [ALC861_ASUS_LAPTOP] = {
13769 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13770 .init_verbs = { alc861_asus_init_verbs,
13771 alc861_asus_laptop_init_verbs },
13772 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13773 .dac_nids = alc861_dac_nids,
13774 .dig_out_nid = ALC861_DIGOUT_NID,
13775 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13776 .channel_mode = alc883_3ST_2ch_modes,
13777 .need_dac_fix = 1,
13778 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13779 .adc_nids = alc861_adc_nids,
13780 .input_mux = &alc861_capture_source,
13781 },
13782};
Kailang Yangdf694da2005-12-05 19:42:22 +010013783
13784
13785static int patch_alc861(struct hda_codec *codec)
13786{
13787 struct alc_spec *spec;
13788 int board_config;
13789 int err;
13790
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013791 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013792 if (spec == NULL)
13793 return -ENOMEM;
13794
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013795 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013796
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013797 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13798 alc861_models,
13799 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013800
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013801 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013802 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13803 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013804 board_config = ALC861_AUTO;
13805 }
13806
13807 if (board_config == ALC861_AUTO) {
13808 /* automatic parse from the BIOS config */
13809 err = alc861_parse_auto_config(codec);
13810 if (err < 0) {
13811 alc_free(codec);
13812 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013813 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013814 printk(KERN_INFO
13815 "hda_codec: Cannot set up configuration "
13816 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 board_config = ALC861_3ST_DIG;
13818 }
13819 }
13820
13821 if (board_config != ALC861_AUTO)
13822 setup_preset(spec, &alc861_presets[board_config]);
13823
13824 spec->stream_name_analog = "ALC861 Analog";
13825 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13826 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13827
13828 spec->stream_name_digital = "ALC861 Digital";
13829 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13830 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13831
Takashi Iwai2134ea42008-01-10 16:53:55 +010013832 spec->vmaster_nid = 0x03;
13833
Kailang Yangdf694da2005-12-05 19:42:22 +010013834 codec->patch_ops = alc_patch_ops;
13835 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013836 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013837#ifdef CONFIG_SND_HDA_POWER_SAVE
13838 if (!spec->loopback.amplist)
13839 spec->loopback.amplist = alc861_loopbacks;
13840#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013841 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020013842
Kailang Yangdf694da2005-12-05 19:42:22 +010013843 return 0;
13844}
13845
13846/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013847 * ALC861-VD support
13848 *
13849 * Based on ALC882
13850 *
13851 * In addition, an independent DAC
13852 */
13853#define ALC861VD_DIGOUT_NID 0x06
13854
13855static hda_nid_t alc861vd_dac_nids[4] = {
13856 /* front, surr, clfe, side surr */
13857 0x02, 0x03, 0x04, 0x05
13858};
13859
13860/* dac_nids for ALC660vd are in a different order - according to
13861 * Realtek's driver.
13862 * This should probably tesult in a different mixer for 6stack models
13863 * of ALC660vd codecs, but for now there is only 3stack mixer
13864 * - and it is the same as in 861vd.
13865 * adc_nids in ALC660vd are (is) the same as in 861vd
13866 */
13867static hda_nid_t alc660vd_dac_nids[3] = {
13868 /* front, rear, clfe, rear_surr */
13869 0x02, 0x04, 0x03
13870};
13871
13872static hda_nid_t alc861vd_adc_nids[1] = {
13873 /* ADC0 */
13874 0x09,
13875};
13876
Takashi Iwaie1406342008-02-11 18:32:32 +010013877static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13878
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013879/* input MUX */
13880/* FIXME: should be a matrix-type input source selection */
13881static struct hda_input_mux alc861vd_capture_source = {
13882 .num_items = 4,
13883 .items = {
13884 { "Mic", 0x0 },
13885 { "Front Mic", 0x1 },
13886 { "Line", 0x2 },
13887 { "CD", 0x4 },
13888 },
13889};
13890
Kailang Yang272a5272007-05-14 11:00:38 +020013891static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013892 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013893 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013894 { "Ext Mic", 0x0 },
13895 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013896 },
13897};
13898
Kailang Yangd1a991a2007-08-15 16:21:59 +020013899static struct hda_input_mux alc861vd_hp_capture_source = {
13900 .num_items = 2,
13901 .items = {
13902 { "Front Mic", 0x0 },
13903 { "ATAPI Mic", 0x1 },
13904 },
13905};
13906
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013907/*
13908 * 2ch mode
13909 */
13910static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13911 { 2, NULL }
13912};
13913
13914/*
13915 * 6ch mode
13916 */
13917static struct hda_verb alc861vd_6stack_ch6_init[] = {
13918 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13919 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13920 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13921 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13922 { } /* end */
13923};
13924
13925/*
13926 * 8ch mode
13927 */
13928static struct hda_verb alc861vd_6stack_ch8_init[] = {
13929 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13930 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13931 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13932 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13933 { } /* end */
13934};
13935
13936static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13937 { 6, alc861vd_6stack_ch6_init },
13938 { 8, alc861vd_6stack_ch8_init },
13939};
13940
13941static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13942 {
13943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13944 .name = "Channel Mode",
13945 .info = alc_ch_mode_info,
13946 .get = alc_ch_mode_get,
13947 .put = alc_ch_mode_put,
13948 },
13949 { } /* end */
13950};
13951
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013952/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13953 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13954 */
13955static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13956 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13957 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13958
13959 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13960 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13961
13962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13963 HDA_OUTPUT),
13964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13965 HDA_OUTPUT),
13966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13968
13969 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13970 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13971
13972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13973
13974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13977
13978 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13981
13982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13984
13985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13987
13988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13990
13991 { } /* end */
13992};
13993
13994static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13995 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13996 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13997
13998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13999
14000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14003
14004 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14007
14008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14010
14011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14013
14014 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14015 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14016
14017 { } /* end */
14018};
14019
Kailang Yangbdd148a2007-05-08 15:19:08 +020014020static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14021 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14022 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14023 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14024
14025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14026
14027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14030
14031 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14032 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14033 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14034
14035 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14036 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14037
14038 { } /* end */
14039};
14040
Tobin Davisb419f342008-03-07 11:57:51 +010014041/* Pin assignment: Speaker=0x14, HP = 0x15,
14042 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014043 */
14044static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14046 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014047 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14048 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014049 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14050 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14051 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14052 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14053 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14054 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14055 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14056 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014057 { } /* end */
14058};
14059
Kailang Yangd1a991a2007-08-15 16:21:59 +020014060/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14061 * Front Mic=0x18, ATAPI Mic = 0x19,
14062 */
14063static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14064 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14065 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14067 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14068 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14069 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14070 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14071 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014072
Kailang Yangd1a991a2007-08-15 16:21:59 +020014073 { } /* end */
14074};
14075
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014076/*
14077 * generic initialization of ADC, input mixers and output mixers
14078 */
14079static struct hda_verb alc861vd_volume_init_verbs[] = {
14080 /*
14081 * Unmute ADC0 and set the default input to mic-in
14082 */
14083 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14084 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14085
14086 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14087 * the analog-loopback mixer widget
14088 */
14089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014095
14096 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014101
14102 /*
14103 * Set up output mixers (0x02 - 0x05)
14104 */
14105 /* set vol=0 to output mixers */
14106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14107 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14108 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14109 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14110
14111 /* set up input amps for analog loopback */
14112 /* Amp Indices: DAC = 0, mixer = 1 */
14113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14119 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14121
14122 { }
14123};
14124
14125/*
14126 * 3-stack pin configuration:
14127 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14128 */
14129static struct hda_verb alc861vd_3stack_init_verbs[] = {
14130 /*
14131 * Set pin mode and muting
14132 */
14133 /* set front pin widgets 0x14 for output */
14134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14136 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14137
14138 /* Mic (rear) pin: input vref at 80% */
14139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14141 /* Front Mic pin: input vref at 80% */
14142 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14143 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14144 /* Line In pin: input */
14145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14147 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14149 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14150 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14151 /* CD pin widget for input */
14152 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14153
14154 { }
14155};
14156
14157/*
14158 * 6-stack pin configuration:
14159 */
14160static struct hda_verb alc861vd_6stack_init_verbs[] = {
14161 /*
14162 * Set pin mode and muting
14163 */
14164 /* set front pin widgets 0x14 for output */
14165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14166 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14167 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14168
14169 /* Rear Pin: output 1 (0x0d) */
14170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14172 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14173 /* CLFE Pin: output 2 (0x0e) */
14174 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14175 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14176 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14177 /* Side Pin: output 3 (0x0f) */
14178 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14180 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14181
14182 /* Mic (rear) pin: input vref at 80% */
14183 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14185 /* Front Mic pin: input vref at 80% */
14186 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14188 /* Line In pin: input */
14189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14191 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14194 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14195 /* CD pin widget for input */
14196 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14197
14198 { }
14199};
14200
Kailang Yangbdd148a2007-05-08 15:19:08 +020014201static struct hda_verb alc861vd_eapd_verbs[] = {
14202 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14203 { }
14204};
14205
Kailang Yangf9423e72008-05-27 12:32:25 +020014206static struct hda_verb alc660vd_eapd_verbs[] = {
14207 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14208 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14209 { }
14210};
14211
Kailang Yangbdd148a2007-05-08 15:19:08 +020014212static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14216 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014217 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014218 {}
14219};
14220
14221/* toggle speaker-output according to the hp-jack state */
14222static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14223{
14224 unsigned int present;
14225 unsigned char bits;
14226
14227 present = snd_hda_codec_read(codec, 0x1b, 0,
14228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014229 bits = present ? HDA_AMP_MUTE : 0;
14230 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14231 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014232}
14233
14234static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14235{
14236 unsigned int present;
14237 unsigned char bits;
14238
14239 present = snd_hda_codec_read(codec, 0x18, 0,
14240 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014241 bits = present ? HDA_AMP_MUTE : 0;
14242 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14243 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014244}
14245
14246static void alc861vd_lenovo_automute(struct hda_codec *codec)
14247{
14248 alc861vd_lenovo_hp_automute(codec);
14249 alc861vd_lenovo_mic_automute(codec);
14250}
14251
14252static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14253 unsigned int res)
14254{
14255 switch (res >> 26) {
14256 case ALC880_HP_EVENT:
14257 alc861vd_lenovo_hp_automute(codec);
14258 break;
14259 case ALC880_MIC_EVENT:
14260 alc861vd_lenovo_mic_automute(codec);
14261 break;
14262 }
14263}
14264
Kailang Yang272a5272007-05-14 11:00:38 +020014265static struct hda_verb alc861vd_dallas_verbs[] = {
14266 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14270
14271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014279
Kailang Yang272a5272007-05-14 11:00:38 +020014280 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14284 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14285 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14286 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14288
14289 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14294 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14295 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14296 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14297
14298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14302
14303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14306
14307 { } /* end */
14308};
14309
14310/* toggle speaker-output according to the hp-jack state */
14311static void alc861vd_dallas_automute(struct hda_codec *codec)
14312{
14313 unsigned int present;
14314
14315 present = snd_hda_codec_read(codec, 0x15, 0,
14316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014317 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14318 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014319}
14320
14321static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14322{
14323 if ((res >> 26) == ALC880_HP_EVENT)
14324 alc861vd_dallas_automute(codec);
14325}
14326
Takashi Iwaicb53c622007-08-10 17:21:45 +020014327#ifdef CONFIG_SND_HDA_POWER_SAVE
14328#define alc861vd_loopbacks alc880_loopbacks
14329#endif
14330
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014331/* pcm configuration: identiacal with ALC880 */
14332#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14333#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14334#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14335#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14336
14337/*
14338 * configuration and preset
14339 */
14340static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14341 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014342 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014343 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014344 [ALC861VD_3ST] = "3stack",
14345 [ALC861VD_3ST_DIG] = "3stack-digout",
14346 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014347 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014348 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014349 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014350 [ALC861VD_AUTO] = "auto",
14351};
14352
14353static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014354 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14355 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014356 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014357 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014358 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014359 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014360 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014361 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014362 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014363 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014364 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014365 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014366 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014367 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14368 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014369 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014370 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014371 {}
14372};
14373
14374static struct alc_config_preset alc861vd_presets[] = {
14375 [ALC660VD_3ST] = {
14376 .mixers = { alc861vd_3st_mixer },
14377 .init_verbs = { alc861vd_volume_init_verbs,
14378 alc861vd_3stack_init_verbs },
14379 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14380 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014381 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14382 .channel_mode = alc861vd_3stack_2ch_modes,
14383 .input_mux = &alc861vd_capture_source,
14384 },
Mike Crash6963f842007-06-25 12:12:51 +020014385 [ALC660VD_3ST_DIG] = {
14386 .mixers = { alc861vd_3st_mixer },
14387 .init_verbs = { alc861vd_volume_init_verbs,
14388 alc861vd_3stack_init_verbs },
14389 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14390 .dac_nids = alc660vd_dac_nids,
14391 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014392 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14393 .channel_mode = alc861vd_3stack_2ch_modes,
14394 .input_mux = &alc861vd_capture_source,
14395 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014396 [ALC861VD_3ST] = {
14397 .mixers = { alc861vd_3st_mixer },
14398 .init_verbs = { alc861vd_volume_init_verbs,
14399 alc861vd_3stack_init_verbs },
14400 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14401 .dac_nids = alc861vd_dac_nids,
14402 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14403 .channel_mode = alc861vd_3stack_2ch_modes,
14404 .input_mux = &alc861vd_capture_source,
14405 },
14406 [ALC861VD_3ST_DIG] = {
14407 .mixers = { alc861vd_3st_mixer },
14408 .init_verbs = { alc861vd_volume_init_verbs,
14409 alc861vd_3stack_init_verbs },
14410 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14411 .dac_nids = alc861vd_dac_nids,
14412 .dig_out_nid = ALC861VD_DIGOUT_NID,
14413 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14414 .channel_mode = alc861vd_3stack_2ch_modes,
14415 .input_mux = &alc861vd_capture_source,
14416 },
14417 [ALC861VD_6ST_DIG] = {
14418 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14419 .init_verbs = { alc861vd_volume_init_verbs,
14420 alc861vd_6stack_init_verbs },
14421 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14422 .dac_nids = alc861vd_dac_nids,
14423 .dig_out_nid = ALC861VD_DIGOUT_NID,
14424 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14425 .channel_mode = alc861vd_6stack_modes,
14426 .input_mux = &alc861vd_capture_source,
14427 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014428 [ALC861VD_LENOVO] = {
14429 .mixers = { alc861vd_lenovo_mixer },
14430 .init_verbs = { alc861vd_volume_init_verbs,
14431 alc861vd_3stack_init_verbs,
14432 alc861vd_eapd_verbs,
14433 alc861vd_lenovo_unsol_verbs },
14434 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14435 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014436 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14437 .channel_mode = alc861vd_3stack_2ch_modes,
14438 .input_mux = &alc861vd_capture_source,
14439 .unsol_event = alc861vd_lenovo_unsol_event,
14440 .init_hook = alc861vd_lenovo_automute,
14441 },
Kailang Yang272a5272007-05-14 11:00:38 +020014442 [ALC861VD_DALLAS] = {
14443 .mixers = { alc861vd_dallas_mixer },
14444 .init_verbs = { alc861vd_dallas_verbs },
14445 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14446 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014447 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14448 .channel_mode = alc861vd_3stack_2ch_modes,
14449 .input_mux = &alc861vd_dallas_capture_source,
14450 .unsol_event = alc861vd_dallas_unsol_event,
14451 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014452 },
14453 [ALC861VD_HP] = {
14454 .mixers = { alc861vd_hp_mixer },
14455 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14456 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14457 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014458 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014459 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14460 .channel_mode = alc861vd_3stack_2ch_modes,
14461 .input_mux = &alc861vd_hp_capture_source,
14462 .unsol_event = alc861vd_dallas_unsol_event,
14463 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014464 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014465 [ALC660VD_ASUS_V1S] = {
14466 .mixers = { alc861vd_lenovo_mixer },
14467 .init_verbs = { alc861vd_volume_init_verbs,
14468 alc861vd_3stack_init_verbs,
14469 alc861vd_eapd_verbs,
14470 alc861vd_lenovo_unsol_verbs },
14471 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14472 .dac_nids = alc660vd_dac_nids,
14473 .dig_out_nid = ALC861VD_DIGOUT_NID,
14474 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14475 .channel_mode = alc861vd_3stack_2ch_modes,
14476 .input_mux = &alc861vd_capture_source,
14477 .unsol_event = alc861vd_lenovo_unsol_event,
14478 .init_hook = alc861vd_lenovo_automute,
14479 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014480};
14481
14482/*
14483 * BIOS auto configuration
14484 */
14485static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14486 hda_nid_t nid, int pin_type, int dac_idx)
14487{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014488 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014489}
14490
14491static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14492{
14493 struct alc_spec *spec = codec->spec;
14494 int i;
14495
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014496 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014497 for (i = 0; i <= HDA_SIDE; i++) {
14498 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014499 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014500 if (nid)
14501 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014502 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014503 }
14504}
14505
14506
14507static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14508{
14509 struct alc_spec *spec = codec->spec;
14510 hda_nid_t pin;
14511
14512 pin = spec->autocfg.hp_pins[0];
14513 if (pin) /* connect to front and use dac 0 */
14514 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014515 pin = spec->autocfg.speaker_pins[0];
14516 if (pin)
14517 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014518}
14519
14520#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14521#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14522
14523static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14524{
14525 struct alc_spec *spec = codec->spec;
14526 int i;
14527
14528 for (i = 0; i < AUTO_PIN_LAST; i++) {
14529 hda_nid_t nid = spec->autocfg.input_pins[i];
14530 if (alc861vd_is_input_pin(nid)) {
14531 snd_hda_codec_write(codec, nid, 0,
14532 AC_VERB_SET_PIN_WIDGET_CONTROL,
14533 i <= AUTO_PIN_FRONT_MIC ?
14534 PIN_VREF80 : PIN_IN);
14535 if (nid != ALC861VD_PIN_CD_NID)
14536 snd_hda_codec_write(codec, nid, 0,
14537 AC_VERB_SET_AMP_GAIN_MUTE,
14538 AMP_OUT_MUTE);
14539 }
14540 }
14541}
14542
Takashi Iwaif511b012008-08-15 16:46:42 +020014543#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14544
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014545#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14546#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14547
14548/* add playback controls from the parsed DAC table */
14549/* Based on ALC880 version. But ALC861VD has separate,
14550 * different NIDs for mute/unmute switch and volume control */
14551static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14552 const struct auto_pin_cfg *cfg)
14553{
14554 char name[32];
14555 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14556 hda_nid_t nid_v, nid_s;
14557 int i, err;
14558
14559 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014560 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014561 continue;
14562 nid_v = alc861vd_idx_to_mixer_vol(
14563 alc880_dac_to_idx(
14564 spec->multiout.dac_nids[i]));
14565 nid_s = alc861vd_idx_to_mixer_switch(
14566 alc880_dac_to_idx(
14567 spec->multiout.dac_nids[i]));
14568
14569 if (i == 2) {
14570 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014571 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14572 "Center Playback Volume",
14573 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14574 HDA_OUTPUT));
14575 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014576 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014577 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14578 "LFE Playback Volume",
14579 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14580 HDA_OUTPUT));
14581 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014582 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014583 err = add_control(spec, ALC_CTL_BIND_MUTE,
14584 "Center Playback Switch",
14585 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14586 HDA_INPUT));
14587 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014588 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014589 err = add_control(spec, ALC_CTL_BIND_MUTE,
14590 "LFE Playback Switch",
14591 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14592 HDA_INPUT));
14593 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014594 return err;
14595 } else {
14596 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014597 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14598 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14599 HDA_OUTPUT));
14600 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014601 return err;
14602 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 HDA_INPUT));
14606 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014607 return err;
14608 }
14609 }
14610 return 0;
14611}
14612
14613/* add playback controls for speaker and HP outputs */
14614/* Based on ALC880 version. But ALC861VD has separate,
14615 * different NIDs for mute/unmute switch and volume control */
14616static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14617 hda_nid_t pin, const char *pfx)
14618{
14619 hda_nid_t nid_v, nid_s;
14620 int err;
14621 char name[32];
14622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014623 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014624 return 0;
14625
14626 if (alc880_is_fixed_pin(pin)) {
14627 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14628 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014629 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014630 spec->multiout.hp_nid = nid_v;
14631 else
14632 spec->multiout.extra_out_nid[0] = nid_v;
14633 /* control HP volume/switch on the output mixer amp */
14634 nid_v = alc861vd_idx_to_mixer_vol(
14635 alc880_fixed_pin_idx(pin));
14636 nid_s = alc861vd_idx_to_mixer_switch(
14637 alc880_fixed_pin_idx(pin));
14638
14639 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014640 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14641 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14642 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014643 return err;
14644 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014645 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14646 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14647 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014648 return err;
14649 } else if (alc880_is_multi_pin(pin)) {
14650 /* set manual connection */
14651 /* we have only a switch on HP-out PIN */
14652 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014653 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14654 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14655 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014656 return err;
14657 }
14658 return 0;
14659}
14660
14661/* parse the BIOS configuration and set up the alc_spec
14662 * return 1 if successful, 0 if the proper config is not found,
14663 * or a negative error code
14664 * Based on ALC880 version - had to change it to override
14665 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14666static int alc861vd_parse_auto_config(struct hda_codec *codec)
14667{
14668 struct alc_spec *spec = codec->spec;
14669 int err;
14670 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14671
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014672 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14673 alc861vd_ignore);
14674 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014675 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014676 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014677 return 0; /* can't find valid BIOS pin config */
14678
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014679 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14680 if (err < 0)
14681 return err;
14682 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14683 if (err < 0)
14684 return err;
14685 err = alc861vd_auto_create_extra_out(spec,
14686 spec->autocfg.speaker_pins[0],
14687 "Speaker");
14688 if (err < 0)
14689 return err;
14690 err = alc861vd_auto_create_extra_out(spec,
14691 spec->autocfg.hp_pins[0],
14692 "Headphone");
14693 if (err < 0)
14694 return err;
14695 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14696 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014697 return err;
14698
14699 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14700
14701 if (spec->autocfg.dig_out_pin)
14702 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14703
Takashi Iwai603c4012008-07-30 15:01:44 +020014704 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014705 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706
Takashi Iwaid88897e2008-10-31 15:01:37 +010014707 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014708
14709 spec->num_mux_defs = 1;
14710 spec->input_mux = &spec->private_imux;
14711
Takashi Iwai776e1842007-08-29 15:07:11 +020014712 err = alc_auto_add_mic_boost(codec);
14713 if (err < 0)
14714 return err;
14715
Takashi Iwaie044c392008-10-27 16:56:24 +010014716 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014717 return 1;
14718}
14719
14720/* additional initialization for auto-configuration model */
14721static void alc861vd_auto_init(struct hda_codec *codec)
14722{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014723 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014724 alc861vd_auto_init_multi_out(codec);
14725 alc861vd_auto_init_hp_out(codec);
14726 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014727 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014728 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014729 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014730}
14731
14732static int patch_alc861vd(struct hda_codec *codec)
14733{
14734 struct alc_spec *spec;
14735 int err, board_config;
14736
14737 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14738 if (spec == NULL)
14739 return -ENOMEM;
14740
14741 codec->spec = spec;
14742
14743 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14744 alc861vd_models,
14745 alc861vd_cfg_tbl);
14746
14747 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14748 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14749 "ALC861VD, trying auto-probe from BIOS...\n");
14750 board_config = ALC861VD_AUTO;
14751 }
14752
14753 if (board_config == ALC861VD_AUTO) {
14754 /* automatic parse from the BIOS config */
14755 err = alc861vd_parse_auto_config(codec);
14756 if (err < 0) {
14757 alc_free(codec);
14758 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014759 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014760 printk(KERN_INFO
14761 "hda_codec: Cannot set up configuration "
14762 "from BIOS. Using base mode...\n");
14763 board_config = ALC861VD_3ST;
14764 }
14765 }
14766
14767 if (board_config != ALC861VD_AUTO)
14768 setup_preset(spec, &alc861vd_presets[board_config]);
14769
Kailang Yang2f893282008-05-27 12:14:47 +020014770 if (codec->vendor_id == 0x10ec0660) {
14771 spec->stream_name_analog = "ALC660-VD Analog";
14772 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014773 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014774 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014775 } else {
14776 spec->stream_name_analog = "ALC861VD Analog";
14777 spec->stream_name_digital = "ALC861VD Digital";
14778 }
14779
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014780 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14781 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14782
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014783 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14784 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14785
14786 spec->adc_nids = alc861vd_adc_nids;
14787 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014788 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014789 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014790
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014791 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014792
Takashi Iwai2134ea42008-01-10 16:53:55 +010014793 spec->vmaster_nid = 0x02;
14794
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014795 codec->patch_ops = alc_patch_ops;
14796
14797 if (board_config == ALC861VD_AUTO)
14798 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014799#ifdef CONFIG_SND_HDA_POWER_SAVE
14800 if (!spec->loopback.amplist)
14801 spec->loopback.amplist = alc861vd_loopbacks;
14802#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014803 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014804
14805 return 0;
14806}
14807
14808/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014809 * ALC662 support
14810 *
14811 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14812 * configuration. Each pin widget can choose any input DACs and a mixer.
14813 * Each ADC is connected from a mixer of all inputs. This makes possible
14814 * 6-channel independent captures.
14815 *
14816 * In addition, an independent DAC for the multi-playback (not used in this
14817 * driver yet).
14818 */
14819#define ALC662_DIGOUT_NID 0x06
14820#define ALC662_DIGIN_NID 0x0a
14821
14822static hda_nid_t alc662_dac_nids[4] = {
14823 /* front, rear, clfe, rear_surr */
14824 0x02, 0x03, 0x04
14825};
14826
14827static hda_nid_t alc662_adc_nids[1] = {
14828 /* ADC1-2 */
14829 0x09,
14830};
Takashi Iwaie1406342008-02-11 18:32:32 +010014831
Kailang Yang77a261b2008-02-19 11:38:05 +010014832static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014833
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014834/* input MUX */
14835/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014836static struct hda_input_mux alc662_capture_source = {
14837 .num_items = 4,
14838 .items = {
14839 { "Mic", 0x0 },
14840 { "Front Mic", 0x1 },
14841 { "Line", 0x2 },
14842 { "CD", 0x4 },
14843 },
14844};
14845
14846static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14847 .num_items = 2,
14848 .items = {
14849 { "Mic", 0x1 },
14850 { "Line", 0x2 },
14851 },
14852};
Kailang Yang291702f2007-10-16 14:28:03 +020014853
14854static struct hda_input_mux alc662_eeepc_capture_source = {
14855 .num_items = 2,
14856 .items = {
14857 { "i-Mic", 0x1 },
14858 { "e-Mic", 0x0 },
14859 },
14860};
14861
Kailang Yang6dda9f42008-05-27 12:05:31 +020014862static struct hda_input_mux alc663_capture_source = {
14863 .num_items = 3,
14864 .items = {
14865 { "Mic", 0x0 },
14866 { "Front Mic", 0x1 },
14867 { "Line", 0x2 },
14868 },
14869};
14870
14871static struct hda_input_mux alc663_m51va_capture_source = {
14872 .num_items = 2,
14873 .items = {
14874 { "Ext-Mic", 0x0 },
14875 { "D-Mic", 0x9 },
14876 },
14877};
14878
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014879/*
14880 * 2ch mode
14881 */
14882static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14883 { 2, NULL }
14884};
14885
14886/*
14887 * 2ch mode
14888 */
14889static struct hda_verb alc662_3ST_ch2_init[] = {
14890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14892 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14893 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14894 { } /* end */
14895};
14896
14897/*
14898 * 6ch mode
14899 */
14900static struct hda_verb alc662_3ST_ch6_init[] = {
14901 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14902 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14903 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14904 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14905 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14906 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14907 { } /* end */
14908};
14909
14910static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14911 { 2, alc662_3ST_ch2_init },
14912 { 6, alc662_3ST_ch6_init },
14913};
14914
14915/*
14916 * 2ch mode
14917 */
14918static struct hda_verb alc662_sixstack_ch6_init[] = {
14919 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14920 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14921 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14922 { } /* end */
14923};
14924
14925/*
14926 * 6ch mode
14927 */
14928static struct hda_verb alc662_sixstack_ch8_init[] = {
14929 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14930 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14931 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14932 { } /* end */
14933};
14934
14935static struct hda_channel_mode alc662_5stack_modes[2] = {
14936 { 2, alc662_sixstack_ch6_init },
14937 { 6, alc662_sixstack_ch8_init },
14938};
14939
14940/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14941 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14942 */
14943
14944static struct snd_kcontrol_new alc662_base_mixer[] = {
14945 /* output mixer control */
14946 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014947 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014949 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014952 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14953 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14955
14956 /*Input mixer control */
14957 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14958 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14959 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14960 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14961 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14962 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14963 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014965 { } /* end */
14966};
14967
14968static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14969 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014970 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14979 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14980 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14981 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014982 { } /* end */
14983};
14984
14985static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14986 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014987 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014988 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014989 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014990 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14991 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014992 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14993 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15003 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15004 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015005 { } /* end */
15006};
15007
15008static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15009 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15010 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015011 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15012 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15014 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15015 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15017 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015018 { } /* end */
15019};
15020
Kailang Yang291702f2007-10-16 14:28:03 +020015021static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015022 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015023
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015024 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15025 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015026
15027 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15028 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15029 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15030
15031 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15032 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15033 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15034 { } /* end */
15035};
15036
Kailang Yang8c427222008-01-10 13:03:59 +010015037static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015038 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15039 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15041 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015046 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015047 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15052 { } /* end */
15053};
15054
Kailang Yangf1d4e282008-08-26 14:03:29 +020015055static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15056 .ops = &snd_hda_bind_vol,
15057 .values = {
15058 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15059 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15060 0
15061 },
15062};
15063
15064static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15065 .ops = &snd_hda_bind_sw,
15066 .values = {
15067 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15068 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15069 0
15070 },
15071};
15072
Kailang Yang6dda9f42008-05-27 12:05:31 +020015073static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015074 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15075 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15078 { } /* end */
15079};
15080
15081static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15082 .ops = &snd_hda_bind_sw,
15083 .values = {
15084 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15085 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15086 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15087 0
15088 },
15089};
15090
15091static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15092 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15093 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15096 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15097 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15098
15099 { } /* end */
15100};
15101
15102static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15103 .ops = &snd_hda_bind_sw,
15104 .values = {
15105 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15106 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15107 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15108 0
15109 },
15110};
15111
15112static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15113 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15114 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15117 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15118 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15119 { } /* end */
15120};
15121
15122static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015123 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15124 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15128 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15129 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15130 { } /* end */
15131};
15132
15133static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15134 .ops = &snd_hda_bind_vol,
15135 .values = {
15136 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15137 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15138 0
15139 },
15140};
15141
15142static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15143 .ops = &snd_hda_bind_sw,
15144 .values = {
15145 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15146 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15147 0
15148 },
15149};
15150
15151static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15152 HDA_BIND_VOL("Master Playback Volume",
15153 &alc663_asus_two_bind_master_vol),
15154 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015159 { } /* end */
15160};
15161
15162static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15163 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15164 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015169 { } /* end */
15170};
15171
15172static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15174 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15175 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15176 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15178
15179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15181 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15182 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15183 { } /* end */
15184};
15185
15186static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15187 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15188 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15190
15191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15193 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15194 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15197 { } /* end */
15198};
15199
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015200static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15201 {
15202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15203 .name = "Channel Mode",
15204 .info = alc_ch_mode_info,
15205 .get = alc_ch_mode_get,
15206 .put = alc_ch_mode_put,
15207 },
15208 { } /* end */
15209};
15210
15211static struct hda_verb alc662_init_verbs[] = {
15212 /* ADC: mute amp left and right */
15213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15214 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15215 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15216
Takashi Iwaicb53c622007-08-10 17:21:45 +020015217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015222
Kailang Yangb60dd392007-09-20 12:50:29 +020015223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015229
15230 /* Front Pin: output 0 (0x0c) */
15231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15233
15234 /* Rear Pin: output 1 (0x0d) */
15235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15237
15238 /* CLFE Pin: output 2 (0x0e) */
15239 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15241
15242 /* Mic (rear) pin: input vref at 80% */
15243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15245 /* Front Mic pin: input vref at 80% */
15246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15248 /* Line In pin: input */
15249 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15250 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15251 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15252 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15253 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15254 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15255 /* CD pin widget for input */
15256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15257
15258 /* FIXME: use matrix-type input source selection */
15259 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15260 /* Input mixer */
15261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015265
15266 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15267 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015270
15271 /* always trun on EAPD */
15272 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15273 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15274
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015275 { }
15276};
15277
15278static struct hda_verb alc662_sue_init_verbs[] = {
15279 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15280 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015281 {}
15282};
15283
15284static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15286 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15287 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015288};
15289
Kailang Yang8c427222008-01-10 13:03:59 +010015290/* Set Unsolicited Event*/
15291static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15293 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15294 {}
15295};
15296
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015297/*
15298 * generic initialization of ADC, input mixers and output mixers
15299 */
15300static struct hda_verb alc662_auto_init_verbs[] = {
15301 /*
15302 * Unmute ADC and set the default input to mic-in
15303 */
15304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15306
15307 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15308 * mixer widget
15309 * Note: PASD motherboards uses the Line In 2 as the input for front
15310 * panel mic (mic 2)
15311 */
15312 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015318
15319 /*
15320 * Set up output mixers (0x0c - 0x0f)
15321 */
15322 /* set vol=0 to output mixers */
15323 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15324 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15326
15327 /* set up input amps for analog loopback */
15328 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015335
15336
15337 /* FIXME: use matrix-type input source selection */
15338 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15339 /* Input mixer */
15340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015342 { }
15343};
15344
Takashi Iwai24fb9172008-09-02 14:48:20 +020015345/* additional verbs for ALC663 */
15346static struct hda_verb alc663_auto_init_verbs[] = {
15347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15349 { }
15350};
15351
Kailang Yang6dda9f42008-05-27 12:05:31 +020015352static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15354 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015355 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15356 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015357 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15362 {}
15363};
15364
Kailang Yangf1d4e282008-08-26 14:03:29 +020015365static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15366 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15367 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15368 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15371 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15372 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15373 {}
15374};
15375
15376static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15377 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15379 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15380 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15383 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15385 {}
15386};
15387
15388static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15394 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15395 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15396 {}
15397};
15398
15399static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15401 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15402 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15403 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15404 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15406 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15409 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15410 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15411 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15412 {}
15413};
15414
15415static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15416 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15418 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15419 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15425 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15426 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15427 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15428 {}
15429};
15430
Kailang Yang6dda9f42008-05-27 12:05:31 +020015431static struct hda_verb alc663_g71v_init_verbs[] = {
15432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15433 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15434 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15435
15436 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15437 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15438 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15439
15440 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15441 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15442 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15443 {}
15444};
15445
15446static struct hda_verb alc663_g50v_init_verbs[] = {
15447 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15448 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15449 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15450
15451 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15452 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15453 {}
15454};
15455
Kailang Yangf1d4e282008-08-26 14:03:29 +020015456static struct hda_verb alc662_ecs_init_verbs[] = {
15457 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15460 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15461 {}
15462};
15463
Kailang Yangf1d4e282008-08-26 14:03:29 +020015464static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15465 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15466 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15467 { } /* end */
15468};
15469
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015470static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15471{
15472 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015473 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015474
15475 present = snd_hda_codec_read(codec, 0x14, 0,
15476 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015477 bits = present ? HDA_AMP_MUTE : 0;
15478 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15479 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015480}
15481
15482static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15483{
15484 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015485 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015486
15487 present = snd_hda_codec_read(codec, 0x1b, 0,
15488 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015489 bits = present ? HDA_AMP_MUTE : 0;
15490 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15491 HDA_AMP_MUTE, bits);
15492 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15493 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015494}
15495
15496static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15497 unsigned int res)
15498{
15499 if ((res >> 26) == ALC880_HP_EVENT)
15500 alc662_lenovo_101e_all_automute(codec);
15501 if ((res >> 26) == ALC880_FRONT_EVENT)
15502 alc662_lenovo_101e_ispeaker_automute(codec);
15503}
15504
Kailang Yang291702f2007-10-16 14:28:03 +020015505static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15506{
15507 unsigned int present;
15508
15509 present = snd_hda_codec_read(codec, 0x18, 0,
15510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15511 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15512 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15513 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15514 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15515 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15516 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15517 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15518 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15519}
15520
15521/* unsolicited event for HP jack sensing */
15522static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15523 unsigned int res)
15524{
15525 if ((res >> 26) == ALC880_HP_EVENT)
15526 alc262_hippo1_automute( codec );
15527
15528 if ((res >> 26) == ALC880_MIC_EVENT)
15529 alc662_eeepc_mic_automute(codec);
15530}
15531
15532static void alc662_eeepc_inithook(struct hda_codec *codec)
15533{
15534 alc262_hippo1_automute( codec );
15535 alc662_eeepc_mic_automute(codec);
15536}
15537
Kailang Yang8c427222008-01-10 13:03:59 +010015538static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15539{
15540 unsigned int mute;
15541 unsigned int present;
15542
15543 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15544 present = snd_hda_codec_read(codec, 0x14, 0,
15545 AC_VERB_GET_PIN_SENSE, 0);
15546 present = (present & 0x80000000) != 0;
15547 if (present) {
15548 /* mute internal speaker */
15549 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015550 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015551 } else {
15552 /* unmute internal speaker if necessary */
15553 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15554 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015555 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015556 }
15557}
15558
15559/* unsolicited event for HP jack sensing */
15560static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15561 unsigned int res)
15562{
15563 if ((res >> 26) == ALC880_HP_EVENT)
15564 alc662_eeepc_ep20_automute(codec);
15565}
15566
15567static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15568{
15569 alc662_eeepc_ep20_automute(codec);
15570}
15571
Kailang Yang6dda9f42008-05-27 12:05:31 +020015572static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15573{
15574 unsigned int present;
15575 unsigned char bits;
15576
15577 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015578 AC_VERB_GET_PIN_SENSE, 0)
15579 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015580 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015581 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15582 AMP_IN_MUTE(0), bits);
15583 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15584 AMP_IN_MUTE(0), bits);
15585}
15586
15587static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15588{
15589 unsigned int present;
15590 unsigned char bits;
15591
15592 present = snd_hda_codec_read(codec, 0x21, 0,
15593 AC_VERB_GET_PIN_SENSE, 0)
15594 & AC_PINSENSE_PRESENCE;
15595 bits = present ? HDA_AMP_MUTE : 0;
15596 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15597 AMP_IN_MUTE(0), bits);
15598 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15599 AMP_IN_MUTE(0), bits);
15600 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15601 AMP_IN_MUTE(0), bits);
15602 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15603 AMP_IN_MUTE(0), bits);
15604}
15605
15606static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15607{
15608 unsigned int present;
15609 unsigned char bits;
15610
15611 present = snd_hda_codec_read(codec, 0x15, 0,
15612 AC_VERB_GET_PIN_SENSE, 0)
15613 & AC_PINSENSE_PRESENCE;
15614 bits = present ? HDA_AMP_MUTE : 0;
15615 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15616 AMP_IN_MUTE(0), bits);
15617 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15618 AMP_IN_MUTE(0), bits);
15619 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15620 AMP_IN_MUTE(0), bits);
15621 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15622 AMP_IN_MUTE(0), bits);
15623}
15624
15625static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15626{
15627 unsigned int present;
15628 unsigned char bits;
15629
15630 present = snd_hda_codec_read(codec, 0x1b, 0,
15631 AC_VERB_GET_PIN_SENSE, 0)
15632 & AC_PINSENSE_PRESENCE;
15633 bits = present ? 0 : PIN_OUT;
15634 snd_hda_codec_write(codec, 0x14, 0,
15635 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15636}
15637
15638static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15639{
15640 unsigned int present1, present2;
15641
15642 present1 = snd_hda_codec_read(codec, 0x21, 0,
15643 AC_VERB_GET_PIN_SENSE, 0)
15644 & AC_PINSENSE_PRESENCE;
15645 present2 = snd_hda_codec_read(codec, 0x15, 0,
15646 AC_VERB_GET_PIN_SENSE, 0)
15647 & AC_PINSENSE_PRESENCE;
15648
15649 if (present1 || present2) {
15650 snd_hda_codec_write_cache(codec, 0x14, 0,
15651 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15652 } else {
15653 snd_hda_codec_write_cache(codec, 0x14, 0,
15654 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15655 }
15656}
15657
15658static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15659{
15660 unsigned int present1, present2;
15661
15662 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15663 AC_VERB_GET_PIN_SENSE, 0)
15664 & AC_PINSENSE_PRESENCE;
15665 present2 = snd_hda_codec_read(codec, 0x15, 0,
15666 AC_VERB_GET_PIN_SENSE, 0)
15667 & AC_PINSENSE_PRESENCE;
15668
15669 if (present1 || present2) {
15670 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15671 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15672 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15673 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15674 } else {
15675 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15676 AMP_IN_MUTE(0), 0);
15677 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15678 AMP_IN_MUTE(0), 0);
15679 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015680}
15681
15682static void alc663_m51va_mic_automute(struct hda_codec *codec)
15683{
15684 unsigned int present;
15685
15686 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015687 AC_VERB_GET_PIN_SENSE, 0)
15688 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015689 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015690 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015691 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015692 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015693 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015694 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015695 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015696 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015697}
15698
15699static void alc663_m51va_unsol_event(struct hda_codec *codec,
15700 unsigned int res)
15701{
15702 switch (res >> 26) {
15703 case ALC880_HP_EVENT:
15704 alc663_m51va_speaker_automute(codec);
15705 break;
15706 case ALC880_MIC_EVENT:
15707 alc663_m51va_mic_automute(codec);
15708 break;
15709 }
15710}
15711
15712static void alc663_m51va_inithook(struct hda_codec *codec)
15713{
15714 alc663_m51va_speaker_automute(codec);
15715 alc663_m51va_mic_automute(codec);
15716}
15717
Kailang Yangf1d4e282008-08-26 14:03:29 +020015718/* ***************** Mode1 ******************************/
15719static void alc663_mode1_unsol_event(struct hda_codec *codec,
15720 unsigned int res)
15721{
15722 switch (res >> 26) {
15723 case ALC880_HP_EVENT:
15724 alc663_m51va_speaker_automute(codec);
15725 break;
15726 case ALC880_MIC_EVENT:
15727 alc662_eeepc_mic_automute(codec);
15728 break;
15729 }
15730}
15731
15732static void alc663_mode1_inithook(struct hda_codec *codec)
15733{
15734 alc663_m51va_speaker_automute(codec);
15735 alc662_eeepc_mic_automute(codec);
15736}
15737/* ***************** Mode2 ******************************/
15738static void alc662_mode2_unsol_event(struct hda_codec *codec,
15739 unsigned int res)
15740{
15741 switch (res >> 26) {
15742 case ALC880_HP_EVENT:
15743 alc662_f5z_speaker_automute(codec);
15744 break;
15745 case ALC880_MIC_EVENT:
15746 alc662_eeepc_mic_automute(codec);
15747 break;
15748 }
15749}
15750
15751static void alc662_mode2_inithook(struct hda_codec *codec)
15752{
15753 alc662_f5z_speaker_automute(codec);
15754 alc662_eeepc_mic_automute(codec);
15755}
15756/* ***************** Mode3 ******************************/
15757static void alc663_mode3_unsol_event(struct hda_codec *codec,
15758 unsigned int res)
15759{
15760 switch (res >> 26) {
15761 case ALC880_HP_EVENT:
15762 alc663_two_hp_m1_speaker_automute(codec);
15763 break;
15764 case ALC880_MIC_EVENT:
15765 alc662_eeepc_mic_automute(codec);
15766 break;
15767 }
15768}
15769
15770static void alc663_mode3_inithook(struct hda_codec *codec)
15771{
15772 alc663_two_hp_m1_speaker_automute(codec);
15773 alc662_eeepc_mic_automute(codec);
15774}
15775/* ***************** Mode4 ******************************/
15776static void alc663_mode4_unsol_event(struct hda_codec *codec,
15777 unsigned int res)
15778{
15779 switch (res >> 26) {
15780 case ALC880_HP_EVENT:
15781 alc663_21jd_two_speaker_automute(codec);
15782 break;
15783 case ALC880_MIC_EVENT:
15784 alc662_eeepc_mic_automute(codec);
15785 break;
15786 }
15787}
15788
15789static void alc663_mode4_inithook(struct hda_codec *codec)
15790{
15791 alc663_21jd_two_speaker_automute(codec);
15792 alc662_eeepc_mic_automute(codec);
15793}
15794/* ***************** Mode5 ******************************/
15795static void alc663_mode5_unsol_event(struct hda_codec *codec,
15796 unsigned int res)
15797{
15798 switch (res >> 26) {
15799 case ALC880_HP_EVENT:
15800 alc663_15jd_two_speaker_automute(codec);
15801 break;
15802 case ALC880_MIC_EVENT:
15803 alc662_eeepc_mic_automute(codec);
15804 break;
15805 }
15806}
15807
15808static void alc663_mode5_inithook(struct hda_codec *codec)
15809{
15810 alc663_15jd_two_speaker_automute(codec);
15811 alc662_eeepc_mic_automute(codec);
15812}
15813/* ***************** Mode6 ******************************/
15814static void alc663_mode6_unsol_event(struct hda_codec *codec,
15815 unsigned int res)
15816{
15817 switch (res >> 26) {
15818 case ALC880_HP_EVENT:
15819 alc663_two_hp_m2_speaker_automute(codec);
15820 break;
15821 case ALC880_MIC_EVENT:
15822 alc662_eeepc_mic_automute(codec);
15823 break;
15824 }
15825}
15826
15827static void alc663_mode6_inithook(struct hda_codec *codec)
15828{
15829 alc663_two_hp_m2_speaker_automute(codec);
15830 alc662_eeepc_mic_automute(codec);
15831}
15832
Kailang Yang6dda9f42008-05-27 12:05:31 +020015833static void alc663_g71v_hp_automute(struct hda_codec *codec)
15834{
15835 unsigned int present;
15836 unsigned char bits;
15837
15838 present = snd_hda_codec_read(codec, 0x21, 0,
15839 AC_VERB_GET_PIN_SENSE, 0)
15840 & AC_PINSENSE_PRESENCE;
15841 bits = present ? HDA_AMP_MUTE : 0;
15842 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15843 HDA_AMP_MUTE, bits);
15844 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15845 HDA_AMP_MUTE, bits);
15846}
15847
15848static void alc663_g71v_front_automute(struct hda_codec *codec)
15849{
15850 unsigned int present;
15851 unsigned char bits;
15852
15853 present = snd_hda_codec_read(codec, 0x15, 0,
15854 AC_VERB_GET_PIN_SENSE, 0)
15855 & AC_PINSENSE_PRESENCE;
15856 bits = present ? HDA_AMP_MUTE : 0;
15857 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15858 HDA_AMP_MUTE, bits);
15859}
15860
15861static void alc663_g71v_unsol_event(struct hda_codec *codec,
15862 unsigned int res)
15863{
15864 switch (res >> 26) {
15865 case ALC880_HP_EVENT:
15866 alc663_g71v_hp_automute(codec);
15867 break;
15868 case ALC880_FRONT_EVENT:
15869 alc663_g71v_front_automute(codec);
15870 break;
15871 case ALC880_MIC_EVENT:
15872 alc662_eeepc_mic_automute(codec);
15873 break;
15874 }
15875}
15876
15877static void alc663_g71v_inithook(struct hda_codec *codec)
15878{
15879 alc663_g71v_front_automute(codec);
15880 alc663_g71v_hp_automute(codec);
15881 alc662_eeepc_mic_automute(codec);
15882}
15883
15884static void alc663_g50v_unsol_event(struct hda_codec *codec,
15885 unsigned int res)
15886{
15887 switch (res >> 26) {
15888 case ALC880_HP_EVENT:
15889 alc663_m51va_speaker_automute(codec);
15890 break;
15891 case ALC880_MIC_EVENT:
15892 alc662_eeepc_mic_automute(codec);
15893 break;
15894 }
15895}
15896
15897static void alc663_g50v_inithook(struct hda_codec *codec)
15898{
15899 alc663_m51va_speaker_automute(codec);
15900 alc662_eeepc_mic_automute(codec);
15901}
15902
Kailang Yangf1d4e282008-08-26 14:03:29 +020015903/* bind hp and internal speaker mute (with plug check) */
15904static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15905 struct snd_ctl_elem_value *ucontrol)
15906{
15907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15908 long *valp = ucontrol->value.integer.value;
15909 int change;
15910
15911 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15912 HDA_AMP_MUTE,
15913 valp[0] ? 0 : HDA_AMP_MUTE);
15914 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15915 HDA_AMP_MUTE,
15916 valp[1] ? 0 : HDA_AMP_MUTE);
15917 if (change)
15918 alc262_hippo1_automute(codec);
15919 return change;
15920}
15921
15922static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15923 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15924 {
15925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15926 .name = "Master Playback Switch",
15927 .info = snd_hda_mixer_amp_switch_info,
15928 .get = snd_hda_mixer_amp_switch_get,
15929 .put = alc662_ecs_master_sw_put,
15930 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15931 },
15932
15933 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15934 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15935 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15936
15937 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15938 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15939 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15940 { } /* end */
15941};
15942
Takashi Iwaicb53c622007-08-10 17:21:45 +020015943#ifdef CONFIG_SND_HDA_POWER_SAVE
15944#define alc662_loopbacks alc880_loopbacks
15945#endif
15946
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015947
15948/* pcm configuration: identiacal with ALC880 */
15949#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15950#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15951#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15952#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15953
15954/*
15955 * configuration and preset
15956 */
15957static const char *alc662_models[ALC662_MODEL_LAST] = {
15958 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15959 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15960 [ALC662_3ST_6ch] = "3stack-6ch",
15961 [ALC662_5ST_DIG] = "6stack-dig",
15962 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015963 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015964 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015965 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015966 [ALC663_ASUS_M51VA] = "m51va",
15967 [ALC663_ASUS_G71V] = "g71v",
15968 [ALC663_ASUS_H13] = "h13",
15969 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015970 [ALC663_ASUS_MODE1] = "asus-mode1",
15971 [ALC662_ASUS_MODE2] = "asus-mode2",
15972 [ALC663_ASUS_MODE3] = "asus-mode3",
15973 [ALC663_ASUS_MODE4] = "asus-mode4",
15974 [ALC663_ASUS_MODE5] = "asus-mode5",
15975 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015976 [ALC662_AUTO] = "auto",
15977};
15978
15979static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015980 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015981 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015982 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015983 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015984 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015985 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15986 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15987 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15988 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15989 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15990 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15991 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15992 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15993 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015994 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015995 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15996 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15997 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15998 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15999 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16000 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16001 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16002 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16003 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16004 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16005 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16006 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16007 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16008 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16009 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16010 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16011 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16012 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16013 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16014 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16015 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16016 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016017 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16018 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016019 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016020 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16021 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016022 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16023 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016024 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020016025 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016026 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016027 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
16028 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
16029 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016030 {}
16031};
16032
16033static struct alc_config_preset alc662_presets[] = {
16034 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016035 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016036 .init_verbs = { alc662_init_verbs },
16037 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16038 .dac_nids = alc662_dac_nids,
16039 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016040 .dig_in_nid = ALC662_DIGIN_NID,
16041 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16042 .channel_mode = alc662_3ST_2ch_modes,
16043 .input_mux = &alc662_capture_source,
16044 },
16045 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016046 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016047 .init_verbs = { alc662_init_verbs },
16048 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16049 .dac_nids = alc662_dac_nids,
16050 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016051 .dig_in_nid = ALC662_DIGIN_NID,
16052 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16053 .channel_mode = alc662_3ST_6ch_modes,
16054 .need_dac_fix = 1,
16055 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016056 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016057 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016058 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016059 .init_verbs = { alc662_init_verbs },
16060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16061 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016062 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16063 .channel_mode = alc662_3ST_6ch_modes,
16064 .need_dac_fix = 1,
16065 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016066 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016067 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016068 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016069 .init_verbs = { alc662_init_verbs },
16070 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16071 .dac_nids = alc662_dac_nids,
16072 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016073 .dig_in_nid = ALC662_DIGIN_NID,
16074 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16075 .channel_mode = alc662_5stack_modes,
16076 .input_mux = &alc662_capture_source,
16077 },
16078 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016079 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016080 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16081 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16082 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16084 .channel_mode = alc662_3ST_2ch_modes,
16085 .input_mux = &alc662_lenovo_101e_capture_source,
16086 .unsol_event = alc662_lenovo_101e_unsol_event,
16087 .init_hook = alc662_lenovo_101e_all_automute,
16088 },
Kailang Yang291702f2007-10-16 14:28:03 +020016089 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016090 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016091 .init_verbs = { alc662_init_verbs,
16092 alc662_eeepc_sue_init_verbs },
16093 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16094 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016095 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16096 .channel_mode = alc662_3ST_2ch_modes,
16097 .input_mux = &alc662_eeepc_capture_source,
16098 .unsol_event = alc662_eeepc_unsol_event,
16099 .init_hook = alc662_eeepc_inithook,
16100 },
Kailang Yang8c427222008-01-10 13:03:59 +010016101 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016102 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016103 alc662_chmode_mixer },
16104 .init_verbs = { alc662_init_verbs,
16105 alc662_eeepc_ep20_sue_init_verbs },
16106 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16107 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016108 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16109 .channel_mode = alc662_3ST_6ch_modes,
16110 .input_mux = &alc662_lenovo_101e_capture_source,
16111 .unsol_event = alc662_eeepc_ep20_unsol_event,
16112 .init_hook = alc662_eeepc_ep20_inithook,
16113 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016114 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016115 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016116 .init_verbs = { alc662_init_verbs,
16117 alc662_ecs_init_verbs },
16118 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16119 .dac_nids = alc662_dac_nids,
16120 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16121 .channel_mode = alc662_3ST_2ch_modes,
16122 .input_mux = &alc662_eeepc_capture_source,
16123 .unsol_event = alc662_eeepc_unsol_event,
16124 .init_hook = alc662_eeepc_inithook,
16125 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016126 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016127 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016128 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16129 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16130 .dac_nids = alc662_dac_nids,
16131 .dig_out_nid = ALC662_DIGOUT_NID,
16132 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16133 .channel_mode = alc662_3ST_2ch_modes,
16134 .input_mux = &alc663_m51va_capture_source,
16135 .unsol_event = alc663_m51va_unsol_event,
16136 .init_hook = alc663_m51va_inithook,
16137 },
16138 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016139 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016140 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16141 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16142 .dac_nids = alc662_dac_nids,
16143 .dig_out_nid = ALC662_DIGOUT_NID,
16144 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16145 .channel_mode = alc662_3ST_2ch_modes,
16146 .input_mux = &alc662_eeepc_capture_source,
16147 .unsol_event = alc663_g71v_unsol_event,
16148 .init_hook = alc663_g71v_inithook,
16149 },
16150 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016151 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016152 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16153 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16154 .dac_nids = alc662_dac_nids,
16155 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16156 .channel_mode = alc662_3ST_2ch_modes,
16157 .input_mux = &alc663_m51va_capture_source,
16158 .unsol_event = alc663_m51va_unsol_event,
16159 .init_hook = alc663_m51va_inithook,
16160 },
16161 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016162 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016163 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16164 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16165 .dac_nids = alc662_dac_nids,
16166 .dig_out_nid = ALC662_DIGOUT_NID,
16167 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16168 .channel_mode = alc662_3ST_6ch_modes,
16169 .input_mux = &alc663_capture_source,
16170 .unsol_event = alc663_g50v_unsol_event,
16171 .init_hook = alc663_g50v_inithook,
16172 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016173 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016174 .mixers = { alc663_m51va_mixer },
16175 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016176 .init_verbs = { alc662_init_verbs,
16177 alc663_21jd_amic_init_verbs },
16178 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16179 .hp_nid = 0x03,
16180 .dac_nids = alc662_dac_nids,
16181 .dig_out_nid = ALC662_DIGOUT_NID,
16182 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16183 .channel_mode = alc662_3ST_2ch_modes,
16184 .input_mux = &alc662_eeepc_capture_source,
16185 .unsol_event = alc663_mode1_unsol_event,
16186 .init_hook = alc663_mode1_inithook,
16187 },
16188 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016189 .mixers = { alc662_1bjd_mixer },
16190 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016191 .init_verbs = { alc662_init_verbs,
16192 alc662_1bjd_amic_init_verbs },
16193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16194 .dac_nids = alc662_dac_nids,
16195 .dig_out_nid = ALC662_DIGOUT_NID,
16196 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16197 .channel_mode = alc662_3ST_2ch_modes,
16198 .input_mux = &alc662_eeepc_capture_source,
16199 .unsol_event = alc662_mode2_unsol_event,
16200 .init_hook = alc662_mode2_inithook,
16201 },
16202 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016203 .mixers = { alc663_two_hp_m1_mixer },
16204 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016205 .init_verbs = { alc662_init_verbs,
16206 alc663_two_hp_amic_m1_init_verbs },
16207 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16208 .hp_nid = 0x03,
16209 .dac_nids = alc662_dac_nids,
16210 .dig_out_nid = ALC662_DIGOUT_NID,
16211 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16212 .channel_mode = alc662_3ST_2ch_modes,
16213 .input_mux = &alc662_eeepc_capture_source,
16214 .unsol_event = alc663_mode3_unsol_event,
16215 .init_hook = alc663_mode3_inithook,
16216 },
16217 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016218 .mixers = { alc663_asus_21jd_clfe_mixer },
16219 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016220 .init_verbs = { alc662_init_verbs,
16221 alc663_21jd_amic_init_verbs},
16222 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16223 .hp_nid = 0x03,
16224 .dac_nids = alc662_dac_nids,
16225 .dig_out_nid = ALC662_DIGOUT_NID,
16226 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16227 .channel_mode = alc662_3ST_2ch_modes,
16228 .input_mux = &alc662_eeepc_capture_source,
16229 .unsol_event = alc663_mode4_unsol_event,
16230 .init_hook = alc663_mode4_inithook,
16231 },
16232 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016233 .mixers = { alc663_asus_15jd_clfe_mixer },
16234 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016235 .init_verbs = { alc662_init_verbs,
16236 alc663_15jd_amic_init_verbs },
16237 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16238 .hp_nid = 0x03,
16239 .dac_nids = alc662_dac_nids,
16240 .dig_out_nid = ALC662_DIGOUT_NID,
16241 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16242 .channel_mode = alc662_3ST_2ch_modes,
16243 .input_mux = &alc662_eeepc_capture_source,
16244 .unsol_event = alc663_mode5_unsol_event,
16245 .init_hook = alc663_mode5_inithook,
16246 },
16247 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016248 .mixers = { alc663_two_hp_m2_mixer },
16249 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016250 .init_verbs = { alc662_init_verbs,
16251 alc663_two_hp_amic_m2_init_verbs },
16252 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16253 .hp_nid = 0x03,
16254 .dac_nids = alc662_dac_nids,
16255 .dig_out_nid = ALC662_DIGOUT_NID,
16256 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16257 .channel_mode = alc662_3ST_2ch_modes,
16258 .input_mux = &alc662_eeepc_capture_source,
16259 .unsol_event = alc663_mode6_unsol_event,
16260 .init_hook = alc663_mode6_inithook,
16261 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016262};
16263
16264
16265/*
16266 * BIOS auto configuration
16267 */
16268
16269/* add playback controls from the parsed DAC table */
16270static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16271 const struct auto_pin_cfg *cfg)
16272{
16273 char name[32];
16274 static const char *chname[4] = {
16275 "Front", "Surround", NULL /*CLFE*/, "Side"
16276 };
16277 hda_nid_t nid;
16278 int i, err;
16279
16280 for (i = 0; i < cfg->line_outs; i++) {
16281 if (!spec->multiout.dac_nids[i])
16282 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016283 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016284 if (i == 2) {
16285 /* Center/LFE */
16286 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16287 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016288 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16289 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016290 if (err < 0)
16291 return err;
16292 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16293 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016294 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16295 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016296 if (err < 0)
16297 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016298 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016299 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016300 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016301 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016302 if (err < 0)
16303 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016304 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016305 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016306 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016307 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016308 if (err < 0)
16309 return err;
16310 } else {
16311 sprintf(name, "%s Playback Volume", chname[i]);
16312 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016313 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16314 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315 if (err < 0)
16316 return err;
16317 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016318 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16319 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16320 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321 if (err < 0)
16322 return err;
16323 }
16324 }
16325 return 0;
16326}
16327
16328/* add playback controls for speaker and HP outputs */
16329static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16330 const char *pfx)
16331{
16332 hda_nid_t nid;
16333 int err;
16334 char name[32];
16335
16336 if (!pin)
16337 return 0;
16338
Takashi Iwai24fb9172008-09-02 14:48:20 +020016339 if (pin == 0x17) {
16340 /* ALC663 has a mono output pin on 0x17 */
16341 sprintf(name, "%s Playback Switch", pfx);
16342 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16343 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16344 return err;
16345 }
16346
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016347 if (alc880_is_fixed_pin(pin)) {
16348 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16349 /* printk("DAC nid=%x\n",nid); */
16350 /* specify the DAC as the extra output */
16351 if (!spec->multiout.hp_nid)
16352 spec->multiout.hp_nid = nid;
16353 else
16354 spec->multiout.extra_out_nid[0] = nid;
16355 /* control HP volume/switch on the output mixer amp */
16356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16357 sprintf(name, "%s Playback Volume", pfx);
16358 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16359 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16360 if (err < 0)
16361 return err;
16362 sprintf(name, "%s Playback Switch", pfx);
16363 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16364 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16365 if (err < 0)
16366 return err;
16367 } else if (alc880_is_multi_pin(pin)) {
16368 /* set manual connection */
16369 /* we have only a switch on HP-out PIN */
16370 sprintf(name, "%s Playback Switch", pfx);
16371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16372 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16373 if (err < 0)
16374 return err;
16375 }
16376 return 0;
16377}
16378
16379/* create playback/capture controls for input pins */
16380static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16381 const struct auto_pin_cfg *cfg)
16382{
16383 struct hda_input_mux *imux = &spec->private_imux;
16384 int i, err, idx;
16385
16386 for (i = 0; i < AUTO_PIN_LAST; i++) {
16387 if (alc880_is_input_pin(cfg->input_pins[i])) {
16388 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16389 err = new_analog_input(spec, cfg->input_pins[i],
16390 auto_pin_cfg_labels[i],
16391 idx, 0x0b);
16392 if (err < 0)
16393 return err;
16394 imux->items[imux->num_items].label =
16395 auto_pin_cfg_labels[i];
16396 imux->items[imux->num_items].index =
16397 alc880_input_pin_idx(cfg->input_pins[i]);
16398 imux->num_items++;
16399 }
16400 }
16401 return 0;
16402}
16403
16404static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16405 hda_nid_t nid, int pin_type,
16406 int dac_idx)
16407{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016408 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016409 /* need the manual connection? */
16410 if (alc880_is_multi_pin(nid)) {
16411 struct alc_spec *spec = codec->spec;
16412 int idx = alc880_multi_pin_idx(nid);
16413 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16414 AC_VERB_SET_CONNECT_SEL,
16415 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16416 }
16417}
16418
16419static void alc662_auto_init_multi_out(struct hda_codec *codec)
16420{
16421 struct alc_spec *spec = codec->spec;
16422 int i;
16423
Kailang Yang8c427222008-01-10 13:03:59 +010016424 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016425 for (i = 0; i <= HDA_SIDE; i++) {
16426 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016427 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016428 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016429 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016430 i);
16431 }
16432}
16433
16434static void alc662_auto_init_hp_out(struct hda_codec *codec)
16435{
16436 struct alc_spec *spec = codec->spec;
16437 hda_nid_t pin;
16438
16439 pin = spec->autocfg.hp_pins[0];
16440 if (pin) /* connect to front */
16441 /* use dac 0 */
16442 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016443 pin = spec->autocfg.speaker_pins[0];
16444 if (pin)
16445 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016446}
16447
16448#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16449#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16450
16451static void alc662_auto_init_analog_input(struct hda_codec *codec)
16452{
16453 struct alc_spec *spec = codec->spec;
16454 int i;
16455
16456 for (i = 0; i < AUTO_PIN_LAST; i++) {
16457 hda_nid_t nid = spec->autocfg.input_pins[i];
16458 if (alc662_is_input_pin(nid)) {
16459 snd_hda_codec_write(codec, nid, 0,
16460 AC_VERB_SET_PIN_WIDGET_CONTROL,
16461 (i <= AUTO_PIN_FRONT_MIC ?
16462 PIN_VREF80 : PIN_IN));
16463 if (nid != ALC662_PIN_CD_NID)
16464 snd_hda_codec_write(codec, nid, 0,
16465 AC_VERB_SET_AMP_GAIN_MUTE,
16466 AMP_OUT_MUTE);
16467 }
16468 }
16469}
16470
Takashi Iwaif511b012008-08-15 16:46:42 +020016471#define alc662_auto_init_input_src alc882_auto_init_input_src
16472
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016473static int alc662_parse_auto_config(struct hda_codec *codec)
16474{
16475 struct alc_spec *spec = codec->spec;
16476 int err;
16477 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16478
16479 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16480 alc662_ignore);
16481 if (err < 0)
16482 return err;
16483 if (!spec->autocfg.line_outs)
16484 return 0; /* can't find valid BIOS pin config */
16485
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016486 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16487 if (err < 0)
16488 return err;
16489 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16490 if (err < 0)
16491 return err;
16492 err = alc662_auto_create_extra_out(spec,
16493 spec->autocfg.speaker_pins[0],
16494 "Speaker");
16495 if (err < 0)
16496 return err;
16497 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16498 "Headphone");
16499 if (err < 0)
16500 return err;
16501 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16502 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016503 return err;
16504
16505 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16506
16507 if (spec->autocfg.dig_out_pin)
16508 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16509
Takashi Iwai603c4012008-07-30 15:01:44 +020016510 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016511 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016512
16513 spec->num_mux_defs = 1;
16514 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016515
Takashi Iwaid88897e2008-10-31 15:01:37 +010016516 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016517 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016518 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016519
16520 err = alc_auto_add_mic_boost(codec);
16521 if (err < 0)
16522 return err;
16523
Takashi Iwaie044c392008-10-27 16:56:24 +010016524 store_pin_configs(codec);
Takashi Iwai8c872862007-06-19 12:11:16 +020016525 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016526}
16527
16528/* additional initialization for auto-configuration model */
16529static void alc662_auto_init(struct hda_codec *codec)
16530{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016531 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016532 alc662_auto_init_multi_out(codec);
16533 alc662_auto_init_hp_out(codec);
16534 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016535 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016536 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016537 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016538}
16539
16540static int patch_alc662(struct hda_codec *codec)
16541{
16542 struct alc_spec *spec;
16543 int err, board_config;
16544
16545 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16546 if (!spec)
16547 return -ENOMEM;
16548
16549 codec->spec = spec;
16550
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016551 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16552
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016553 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16554 alc662_models,
16555 alc662_cfg_tbl);
16556 if (board_config < 0) {
16557 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16558 "trying auto-probe from BIOS...\n");
16559 board_config = ALC662_AUTO;
16560 }
16561
16562 if (board_config == ALC662_AUTO) {
16563 /* automatic parse from the BIOS config */
16564 err = alc662_parse_auto_config(codec);
16565 if (err < 0) {
16566 alc_free(codec);
16567 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020016568 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016569 printk(KERN_INFO
16570 "hda_codec: Cannot set up configuration "
16571 "from BIOS. Using base mode...\n");
16572 board_config = ALC662_3ST_2ch_DIG;
16573 }
16574 }
16575
16576 if (board_config != ALC662_AUTO)
16577 setup_preset(spec, &alc662_presets[board_config]);
16578
Kailang Yang6dda9f42008-05-27 12:05:31 +020016579 if (codec->vendor_id == 0x10ec0663) {
16580 spec->stream_name_analog = "ALC663 Analog";
16581 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016582 } else if (codec->vendor_id == 0x10ec0272) {
16583 spec->stream_name_analog = "ALC272 Analog";
16584 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016585 } else {
16586 spec->stream_name_analog = "ALC662 Analog";
16587 spec->stream_name_digital = "ALC662 Digital";
16588 }
16589
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016590 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16591 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16592
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016593 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16594 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16595
Takashi Iwaie1406342008-02-11 18:32:32 +010016596 spec->adc_nids = alc662_adc_nids;
16597 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16598 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016599 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016601 if (!spec->cap_mixer)
16602 set_capture_mixer(spec);
16603
Takashi Iwai2134ea42008-01-10 16:53:55 +010016604 spec->vmaster_nid = 0x02;
16605
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016606 codec->patch_ops = alc_patch_ops;
16607 if (board_config == ALC662_AUTO)
16608 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016609#ifdef CONFIG_SND_HDA_POWER_SAVE
16610 if (!spec->loopback.amplist)
16611 spec->loopback.amplist = alc662_loopbacks;
16612#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016613 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614
16615 return 0;
16616}
16617
16618/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016619 * patch entries
16620 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016621static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016622 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016623 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016624 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016625 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016626 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016627 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016628 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016629 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016630 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16631 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16632 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016633 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16634 .patch = patch_alc883 },
16635 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16636 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016637 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016638 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016639 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016640 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016641 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16642 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016643 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016644 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016645 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016646 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016647 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16648 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016649 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016650 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016651 {} /* terminator */
16652};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016653
16654MODULE_ALIAS("snd-hda-codec-id:10ec*");
16655
16656MODULE_LICENSE("GPL");
16657MODULE_DESCRIPTION("Realtek HD-audio codec");
16658
16659static struct hda_codec_preset_list realtek_list = {
16660 .preset = snd_hda_preset_realtek,
16661 .owner = THIS_MODULE,
16662};
16663
16664static int __init patch_realtek_init(void)
16665{
16666 return snd_hda_add_codec_preset(&realtek_list);
16667}
16668
16669static void __exit patch_realtek_exit(void)
16670{
16671 snd_hda_delete_codec_preset(&realtek_list);
16672}
16673
16674module_init(patch_realtek_init)
16675module_exit(patch_realtek_exit)